Cardinal
  • Home
  • Template Catalog
  • About
  • Resources
  • Help
    • Getting Started
    • Report a Bug
    • FAQ

Subjects With Adverse Events Leading to Treatment Discontinuation by Organ System and OCMQ (Narrow), Safety Population, Pooled Analysis (or Trial X)

FDA Table 13

table
FDA
safety
adverse events
  • Table Preview
  • Setup
  • Build ARD
  • Build Table

Code
# Load libraries & data -------------------------------------
library(dplyr)
library(cards)
library(gtsummary)

set.seed(1)
adsl <- pharmaverseadam::adsl
adae <- pharmaverseadam::adae

adae <- adae |>
  rename(OCMQ01SC = AEHLTCD) |>
  mutate(
    AESER = sample(c("Y", "N"), size = nrow(adae), replace = TRUE),
    OCMQ01NAM = sample(c("OCMQ1", "OCMQ2", "OCMQ3"), size = nrow(adae), replace = TRUE)
  )

adae$OCMQ01SC[is.na(adae$OCMQ01SC)] <- "NARROW"

# Pre-processing --------------------------------------------
adsl <- adsl |>
  filter(SAFFL == "Y") # safety population

data <- adae |>
  filter(
    # safety population
    SAFFL == "Y",
    # narrow OCMQ
    OCMQ01SC == "NARROW"
  )

sliced_data <- data |>
  count(AEBODSYS, sort = TRUE) |>
  slice_head(n = 3) |> # keep top 3
  pull(AEBODSYS)

data <- data |>
  filter(AEBODSYS %in% sliced_data)
Code
ard <- ard_stack_hierarchical(
  data,
  variables = c(AEBODSYS, OCMQ01NAM),
  by = TRT01A,
  denominator = adsl,
  id = USUBJID
)

ard
{cards} data frame: 117 x 13
   group1 group1_level   group2 group2_level  variable variable_level   context stat_name stat_label  stat fmt_fun warning error
1    <NA>                  <NA>                 TRT01A        Placebo  tabulate         n          n    86       0              
2    <NA>                  <NA>                 TRT01A        Placebo  tabulate         N          N   254       0              
3    <NA>                  <NA>                 TRT01A        Placebo  tabulate         p          % 0.339    <fn>              
4    <NA>                  <NA>                 TRT01A      Xanomeli…  tabulate         n          n    72       0              
5    <NA>                  <NA>                 TRT01A      Xanomeli…  tabulate         N          N   254       0              
6    <NA>                  <NA>                 TRT01A      Xanomeli…  tabulate         p          % 0.283    <fn>              
7    <NA>                  <NA>                 TRT01A      Xanomeli…  tabulate         n          n    96       0              
8    <NA>                  <NA>                 TRT01A      Xanomeli…  tabulate         N          N   254       0              
9    <NA>                  <NA>                 TRT01A      Xanomeli…  tabulate         p          % 0.378    <fn>              
10 TRT01A      Placebo     <NA>               AEBODSYS      GENERAL … hierarch…         n          n    21       0              
11 TRT01A      Placebo     <NA>               AEBODSYS      GENERAL … hierarch…         N          N    86       0              
12 TRT01A      Placebo     <NA>               AEBODSYS      GENERAL … hierarch…         p          % 0.244    <fn>              
13 TRT01A    Xanomeli…     <NA>               AEBODSYS      GENERAL … hierarch…         n          n    36       0              
14 TRT01A    Xanomeli…     <NA>               AEBODSYS      GENERAL … hierarch…         N          N    72       0              
15 TRT01A    Xanomeli…     <NA>               AEBODSYS      GENERAL … hierarch…         p          %   0.5    <fn>              
16 TRT01A    Xanomeli…     <NA>               AEBODSYS      GENERAL … hierarch…         n          n    51       0              
17 TRT01A    Xanomeli…     <NA>               AEBODSYS      GENERAL … hierarch…         N          N    96       0              
18 TRT01A    Xanomeli…     <NA>               AEBODSYS      GENERAL … hierarch…         p          % 0.531    <fn>              
19 TRT01A      Placebo AEBODSYS    GENERAL … OCMQ01NAM          OCMQ1 hierarch…         n          n     8       0              
20 TRT01A      Placebo AEBODSYS    GENERAL … OCMQ01NAM          OCMQ1 hierarch…         N          N    86       0              
21 TRT01A      Placebo AEBODSYS    GENERAL … OCMQ01NAM          OCMQ1 hierarch…         p          % 0.093    <fn>              
22 TRT01A    Xanomeli… AEBODSYS    GENERAL … OCMQ01NAM          OCMQ1 hierarch…         n          n    23       0              
23 TRT01A    Xanomeli… AEBODSYS    GENERAL … OCMQ01NAM          OCMQ1 hierarch…         N          N    72       0              
24 TRT01A    Xanomeli… AEBODSYS    GENERAL … OCMQ01NAM          OCMQ1 hierarch…         p          % 0.319    <fn>              
25 TRT01A    Xanomeli… AEBODSYS    GENERAL … OCMQ01NAM          OCMQ1 hierarch…         n          n    25       0              
26 TRT01A    Xanomeli… AEBODSYS    GENERAL … OCMQ01NAM          OCMQ1 hierarch…         N          N    96       0              
27 TRT01A    Xanomeli… AEBODSYS    GENERAL … OCMQ01NAM          OCMQ1 hierarch…         p          %  0.26    <fn>              
28 TRT01A      Placebo AEBODSYS    GENERAL … OCMQ01NAM          OCMQ2 hierarch…         n          n    11       0              
29 TRT01A      Placebo AEBODSYS    GENERAL … OCMQ01NAM          OCMQ2 hierarch…         N          N    86       0              
30 TRT01A      Placebo AEBODSYS    GENERAL … OCMQ01NAM          OCMQ2 hierarch…         p          % 0.128    <fn>              
31 TRT01A    Xanomeli… AEBODSYS    GENERAL … OCMQ01NAM          OCMQ2 hierarch…         n          n    22       0              
32 TRT01A    Xanomeli… AEBODSYS    GENERAL … OCMQ01NAM          OCMQ2 hierarch…         N          N    72       0              
33 TRT01A    Xanomeli… AEBODSYS    GENERAL … OCMQ01NAM          OCMQ2 hierarch…         p          % 0.306    <fn>              
34 TRT01A    Xanomeli… AEBODSYS    GENERAL … OCMQ01NAM          OCMQ2 hierarch…         n          n    26       0              
35 TRT01A    Xanomeli… AEBODSYS    GENERAL … OCMQ01NAM          OCMQ2 hierarch…         N          N    96       0              
36 TRT01A    Xanomeli… AEBODSYS    GENERAL … OCMQ01NAM          OCMQ2 hierarch…         p          % 0.271    <fn>              
37 TRT01A      Placebo AEBODSYS    GENERAL … OCMQ01NAM          OCMQ3 hierarch…         n          n    14       0              
38 TRT01A      Placebo AEBODSYS    GENERAL … OCMQ01NAM          OCMQ3 hierarch…         N          N    86       0              
39 TRT01A      Placebo AEBODSYS    GENERAL … OCMQ01NAM          OCMQ3 hierarch…         p          % 0.163    <fn>              
40 TRT01A    Xanomeli… AEBODSYS    GENERAL … OCMQ01NAM          OCMQ3 hierarch…         n          n    26       0              
ℹ 77 more rows
ℹ Use `print(n = ...)` to see more rows
Code
tbl <-
  tbl_hierarchical(
    data,
    variables = c(AEBODSYS, OCMQ01NAM),
    by = TRT01A,
    id = USUBJID,
    denominator = adsl,
    label = list(AEBODSYS = "Organ System", OCMQ01NAM = "OCMQ (Narrow)")
  )

tbl

Source Code
---
title: Subjects With Adverse Events Leading to Treatment Discontinuation by Organ System and OCMQ (Narrow), Safety Population, Pooled Analysis (or Trial X)
subtitle: FDA Table 13
categories: [table, FDA, safety, adverse events]
---

::: panel-tabset
## Table Preview

```{r img, echo=FALSE, fig.align='center', out.width='60%'}
knitr::include_graphics("result.png")
```

## Setup

```{r setup, message=FALSE}
# Load libraries & data -------------------------------------
library(dplyr)
library(cards)
library(gtsummary)

set.seed(1)
adsl <- pharmaverseadam::adsl
adae <- pharmaverseadam::adae

adae <- adae |>
  rename(OCMQ01SC = AEHLTCD) |>
  mutate(
    AESER = sample(c("Y", "N"), size = nrow(adae), replace = TRUE),
    OCMQ01NAM = sample(c("OCMQ1", "OCMQ2", "OCMQ3"), size = nrow(adae), replace = TRUE)
  )

adae$OCMQ01SC[is.na(adae$OCMQ01SC)] <- "NARROW"

# Pre-processing --------------------------------------------
adsl <- adsl |>
  filter(SAFFL == "Y") # safety population

data <- adae |>
  filter(
    # safety population
    SAFFL == "Y",
    # narrow OCMQ
    OCMQ01SC == "NARROW"
  )

sliced_data <- data |>
  count(AEBODSYS, sort = TRUE) |>
  slice_head(n = 3) |> # keep top 3
  pull(AEBODSYS)

data <- data |>
  filter(AEBODSYS %in% sliced_data)
```

## Build ARD

```{r ard, message=FALSE, warning=FALSE, results='hide'}
ard <- ard_stack_hierarchical(
  data,
  variables = c(AEBODSYS, OCMQ01NAM),
  by = TRT01A,
  denominator = adsl,
  id = USUBJID
)

ard
```

```{r, echo=FALSE}
# Print ARD
withr::local_options(width = 9999)
print(ard, columns = "all", n = 40)
```

## Build Table

```{r tbl, results = 'hide'}
tbl <-
  tbl_hierarchical(
    data,
    variables = c(AEBODSYS, OCMQ01NAM),
    by = TRT01A,
    id = USUBJID,
    denominator = adsl,
    label = list(AEBODSYS = "Organ System", OCMQ01NAM = "OCMQ (Narrow)")
  )

tbl
```

```{r eval=FALSE, include=FALSE}
# Run chunk locally to generate image file
gt::gtsave(as_gt(tbl), filename = "result.png")
```

```{r img, echo=FALSE, fig.align='center', out.width='60%'}
```
:::
 
  • This website as well as code examples are licensed under the Apache License, Version 2.0.
Cookie Preferences