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

Subjects With Adverse Events by System Organ Class and Preferred Term, Safety Population, Pooled Analysis (or Trial X)

FDA Table 14

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

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

adsl <- pharmaverseadam::adsl
adae <- pharmaverseadam::adae

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

# for display purpose showing only bottom 5 SOCs
sliced_data <- adae |>
  count(AESOC) |>
  slice_min(order_by = n, n = 5) |>
  pull(AESOC)

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

ard
{cards} data frame: 126 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>                 AESOC      CONGENIT… hierarch…         n          n     0       0              
11 TRT01A      Placebo   <NA>                 AESOC      CONGENIT… hierarch…         N          N    86       0              
12 TRT01A      Placebo   <NA>                 AESOC      CONGENIT… hierarch…         p          %     0    <fn>              
13 TRT01A    Xanomeli…   <NA>                 AESOC      CONGENIT… hierarch…         n          n     2       0              
14 TRT01A    Xanomeli…   <NA>                 AESOC      CONGENIT… hierarch…         N          N    72       0              
15 TRT01A    Xanomeli…   <NA>                 AESOC      CONGENIT… hierarch…         p          % 0.028    <fn>              
16 TRT01A    Xanomeli…   <NA>                 AESOC      CONGENIT… hierarch…         n          n     1       0              
17 TRT01A    Xanomeli…   <NA>                 AESOC      CONGENIT… hierarch…         N          N    96       0              
18 TRT01A    Xanomeli…   <NA>                 AESOC      CONGENIT… hierarch…         p          %  0.01    <fn>              
19 TRT01A      Placebo  AESOC    CONGENIT…  AEDECOD      VENTRICU… hierarch…         n          n     0       0              
20 TRT01A      Placebo  AESOC    CONGENIT…  AEDECOD      VENTRICU… hierarch…         N          N    86       0              
21 TRT01A      Placebo  AESOC    CONGENIT…  AEDECOD      VENTRICU… hierarch…         p          %     0    <fn>              
22 TRT01A    Xanomeli…  AESOC    CONGENIT…  AEDECOD      VENTRICU… hierarch…         n          n     2       0              
23 TRT01A    Xanomeli…  AESOC    CONGENIT…  AEDECOD      VENTRICU… hierarch…         N          N    72       0              
24 TRT01A    Xanomeli…  AESOC    CONGENIT…  AEDECOD      VENTRICU… hierarch…         p          % 0.028    <fn>              
25 TRT01A    Xanomeli…  AESOC    CONGENIT…  AEDECOD      VENTRICU… hierarch…         n          n     1       0              
26 TRT01A    Xanomeli…  AESOC    CONGENIT…  AEDECOD      VENTRICU… hierarch…         N          N    96       0              
27 TRT01A    Xanomeli…  AESOC    CONGENIT…  AEDECOD      VENTRICU… hierarch…         p          %  0.01    <fn>              
28 TRT01A      Placebo   <NA>                 AESOC      HEPATOBI… hierarch…         n          n     1       0              
29 TRT01A      Placebo   <NA>                 AESOC      HEPATOBI… hierarch…         N          N    86       0              
30 TRT01A      Placebo   <NA>                 AESOC      HEPATOBI… hierarch…         p          % 0.012    <fn>              
31 TRT01A    Xanomeli…   <NA>                 AESOC      HEPATOBI… hierarch…         n          n     0       0              
32 TRT01A    Xanomeli…   <NA>                 AESOC      HEPATOBI… hierarch…         N          N    72       0              
33 TRT01A    Xanomeli…   <NA>                 AESOC      HEPATOBI… hierarch…         p          %     0    <fn>              
34 TRT01A    Xanomeli…   <NA>                 AESOC      HEPATOBI… hierarch…         n          n     0       0              
35 TRT01A    Xanomeli…   <NA>                 AESOC      HEPATOBI… hierarch…         N          N    96       0              
36 TRT01A    Xanomeli…   <NA>                 AESOC      HEPATOBI… hierarch…         p          %     0    <fn>              
37 TRT01A      Placebo  AESOC    HEPATOBI…  AEDECOD      HYPERBIL… hierarch…         n          n     1       0              
38 TRT01A      Placebo  AESOC    HEPATOBI…  AEDECOD      HYPERBIL… hierarch…         N          N    86       0              
39 TRT01A      Placebo  AESOC    HEPATOBI…  AEDECOD      HYPERBIL… hierarch…         p          % 0.012    <fn>              
40 TRT01A    Xanomeli…  AESOC    HEPATOBI…  AEDECOD      HYPERBIL… hierarch…         n          n     0       0              
ℹ 86 more rows
ℹ Use `print(n = ...)` to see more rows
Code
# create table using ARD-first approach (ARD -> table)
tbl <-
  tbl_ard_hierarchical(
    ard,
    variables = c(AESOC, AEDECOD),
    by = TRT01A,
    # add custom variable labels
    label = list(
      AESOC = "System Organ Class",
      AEDECOD = "Preferred Term"
    )
  )

tbl

Source Code
---
title: Subjects With Adverse Events by System Organ Class and Preferred Term, Safety Population, Pooled Analysis (or Trial X)
subtitle: FDA Table 14
categories: [table, FDA, safety, adverse events]
---

::: panel-tabset
## Table Preview

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

## Setup

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

adsl <- pharmaverseadam::adsl
adae <- pharmaverseadam::adae

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

# for display purpose showing only bottom 5 SOCs
sliced_data <- adae |>
  count(AESOC) |>
  slice_min(order_by = n, n = 5) |>
  pull(AESOC)

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

## Build ARD

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

ard
```

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

## Build Table

```{r tbl, results = 'hide'}
# create table using ARD-first approach (ARD -> table)
tbl <-
  tbl_ard_hierarchical(
    ard,
    variables = c(AESOC, AEDECOD),
    by = TRT01A,
    # add custom variable labels
    label = list(
      AESOC = "System Organ Class",
      AEDECOD = "Preferred Term"
    )
  )

tbl
```

```{r eval=FALSE, include=FALSE}
gt::gtsave(as_gt(tbl), filename = "result.png")
```

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