TL Catalog
  1. Tables
  2. Adverse Events
  3. TSFAE16
  • Introduction

  • Index

  • Tables
    • Adverse Events
      • TSFAE01A
      • TSFAE01B
      • TSFAE02
      • TSFAE02A
      • TSFAE03
      • TSFAE03A
      • TSFAE04
      • TSFAE04A
      • TSFAE05
      • TSFAE05A
      • TSFAE06A
      • TSFAE06B
      • TSFAE07A
      • TSFAE07B
      • TSFAE08
      • TSFAE09
      • TSFAE10
      • TSFAE11
      • TSFAE12
      • TSFAE13
      • TSFAE14
      • TSFAE15
      • TSFAE16
      • TSFAE17A
      • TSFAE17B
      • TSFAE17C
      • TSFAE17D
      • TSFAE19A
      • TSFAE19B
      • TSFAE19C
      • TSFAE19D
      • TSFAE20A
      • TSFAE20B
      • TSFAE20C
      • TSFAE21A
      • TSFAE21B
      • TSFAE21C
      • TSFAE21D
      • TSFAE22A
      • TSFAE22B
      • TSFAE22C
      • TSFAE23A
      • TSFAE23B
      • TSFAE23C
      • TSFAE23D
      • TSFAE24A
      • TSFAE24B
      • TSFAE24C
      • TSFAE24D
      • TSFAE24F
      • TSFDTH01
    • Clinical Laboratory Evaluation
      • TSFLAB01
      • TSFLAB01A
      • TSFLAB02
      • TSFLAB02A
      • TSFLAB02B
      • TSFLAB03
      • TSFLAB03A
      • TSFLAB04A
      • TSFLAB04B
      • TSFLAB05
      • TSFLAB06
      • TSFLAB07
    • Demographic
      • TSIDEM01
      • TSIDEM02
      • TSIMH01
    • Disposition of Subjects
      • TSIDS01
      • TSIDS02
      • TSIDS02A
    • Electrocardiograms
      • TSFECG01
      • TSFECG01A
      • TSFECG02
      • TSFECG03
      • TSFECG04
      • TSFECG05
    • Exposure
      • TSIEX01
      • TSIEX02
      • TSIEX03
      • TSIEX04
      • TSIEX06
      • TSIEX07
      • TSIEX08
      • TSIEX09
      • TSIEX10
      • TSIEX11
    • Pharmacokinetics
      • TPK01A
      • TPK01B
      • TPK02
      • TPK03
    • Prior and Concomitant Therapies
      • TSICM01
      • TSICM02
      • TSICM03
      • TSICM04
      • TSICM05
      • TSICM06
      • TSICM07
      • TSICM08
    • Vital Signs and Physical Findings
      • TSFVIT01
      • TSFVIT01A
      • TSFVIT02
      • TSFVIT03
      • TSFVIT04
      • TSFVIT05
      • TSFVIT06
  • Listings
    • Adverse Events
      • LSFAE01
      • LSFAE02
      • LSFAE03
      • LSFAE04
      • LSFAE05
      • LSFAE06A
      • LSFAE06B
      • LSFDTH01
    • Clinical Laboratory Evaluation
      • LSFLAB01
    • Demographic
      • LSIDEM01
      • LSIDEM02
      • LSIMH01
    • Disposition of Subjects
      • LSIDS01
      • LSIDS02
      • LSIDS03
      • LSIDS04
      • LSIDS05
    • Electrocardiograms
      • LSFECG01
      • LSFECG02
    • Exposure
      • LSIEX01
      • LSIEX02
      • LSIEX03
    • Prior and Concomitant Therapies
      • LSICM01
    • Vital Signs and Physical Findings
      • LSFVIT01
      • LSFVIT02

  • Reproducibility

  • Changelog

On this page

  • Output
  • Edit this page
  • Report an issue
  1. Tables
  2. Adverse Events
  3. TSFAE16

TSFAE16

Subjects With Treatment-emergent Adverse Events by Organ System and OCMQ (Broad and Narrow)


Output

  • Preview
Code
# Program Name:              tsfae16.R

# Prep Environment

library(envsetup)
library(tern)
library(dplyr)
library(rtables)
library(junco)

# Define script level parameters:

# - Define output ID and file location

tblid <- "TSFAE16"
fileid <- tblid
tab_titles <- get_titles_from_file(input_path = '../../_data/', tblid)
string_map <- default_str_map

trtvar <- "TRT01A"
popfl <- "SAFFL"

combined_colspan_trt <- FALSE
risk_diff <- TRUE
rr_method <- "wald"
ctrl_grp <- "Placebo"

QVAR_CLASS <- "OCMQCLSS"
QVAR_SOC <- "OCMQSOC"
QVAR_NAM <- "OCMQNAM"

if (combined_colspan_trt == TRUE) {
  # Set up levels and label for the required combined columns
  add_combo <- add_combo_facet(
    "Combined",
    label = "Combined",
    levels = c("Xanomeline High Dose", "Xanomeline Low Dose")
  )

  # choose if any facets need to be removed - e.g remove the combined column for ref group
  rm_combo_from_ref <- cond_rm_facets(
    facets = "Combined",
    ancestor_pos = NA,
    value = " ",
    split = "colspan_trt"
  )

  mysplit <- make_split_fun(post = list(add_combo, rm_combo_from_ref))
}

# Process Data:

adsl <- pharmaverseadamjnj::adsl %>%
  filter(!!rlang::sym(popfl) == "Y") %>%
  select(STUDYID, USUBJID, all_of(trtvar), all_of(popfl))

adsl0 <- adsl

adsl <- rbind(
  adsl0 %>% mutate(!!rlang::sym(QVAR_CLASS) := "Narrow"),
  adsl0 %>% mutate(!!rlang::sym(QVAR_CLASS) := "Broad")
)
### label slightly differs from values in dataset
QVAR_CLASS2 <- "OCMQCLS2"
adsl[[QVAR_CLASS2]] <- paste(adsl[[QVAR_CLASS]], "OCMQs")

adae <- pharmaverseadamjnj::adaeocmq %>%
  filter(TRTEMFL == "Y") %>%
  select(USUBJID, TRTEMFL, all_of(c(QVAR_CLASS, QVAR_NAM, QVAR_SOC)))

adsl$colspan_trt <- factor(
  ifelse(adsl[[trtvar]] == ctrl_grp, " ", "Active Study Agent"),
  levels = c("Active Study Agent", " ")
)

# join data together
ae <- adae %>% inner_join(., adsl)

colspan_trt_map <- create_colspan_map(
  adsl,
  non_active_grp = ctrl_grp,
  non_active_grp_span_lbl = " ",
  active_grp_span_lbl = "Active Study Agent",
  colspan_var = "colspan_trt",
  trt_var = trtvar
)

if (risk_diff) {
  ## risk difference columns are created by this split function for FMQ table
  # to get risk diff column within FMQclass
  mysplfun1 <- make_split_fun(
    post = list(
      add_combo_facet(
        "RR_difference",
        label = "Risk Difference (%) (95% CI)",
        levels = c("Active Study Agent")
      )
    )
  )
} else {
  mysplfun1 <- NULL
}

# further split process to ensure only the required treatment columns remain in the layout
make_cond_rm_from_map <- function(map, diff_rm = "Placebo") {
  outer_levs <- unique(map[[1]])
  fnlst <- list()
  for (i in seq_along(outer_levs)) {
    inner_levs <- map[map[[1]] == outer_levs[[i]], 2, drop = TRUE]
    fnlst[[i]] <- cond_rm_facets(
      facets = inner_levs,
      ancestor_pos = -1,
      value = outer_levs[i],
      keep_matches = TRUE
    )
  }

  # remove ref group column within RR columns
  rr_rm_cond <- cond_rm_facets(
    facets = diff_rm,
    ancestor_pos = -1,
    value = "RR_difference",
    keep_matches = FALSE
  )

  # update label in risk diff column to include diff from reference in label
  post_relabel <- function(splres, spl, fulldf, .spl_context) {
    inrr <- grepl("difference", tail(.spl_context$value, 1))
    if (inrr) {
      splres$labels <- paste(splres$labels, "vs", diff_rm)
    }
    splres
  }

  make_split_fun(post = c(fnlst, rr_rm_cond, post_relabel))
}

cond_trt_splfun <- make_cond_rm_from_map(colspan_trt_map, diff_rm = ctrl_grp)

# Define layout and build table:

ref_path <- c("colspan_trt", " ", "TRT01A", "Placebo")
extra_args_rr <- list(
  method = rr_method,
  ref_path = ref_path,
  colgroup = "OCMQCLSS",
  .stats = c("count_unique_fraction")
)

lyt <- basic_table(
  top_level_section_div = " ",
  show_colcounts = TRUE,
  colcount_format = "N=xx"
) %>%
  split_cols_by(QVAR_CLASS, labels_var = QVAR_CLASS2) %>%
  split_cols_by("colspan_trt", split_fun = mysplfun1) %>%
  split_cols_by(trtvar, split_fun = cond_trt_splfun)

lyt <- lyt %>%
  split_rows_by(
    QVAR_SOC,
    split_label = "Organ System Class",
    split_fun = trim_levels_in_group(QVAR_NAM),
    label_pos = "topleft",
    section_div = c(" ")
  ) %>%
  summarize_row_groups(
    QVAR_SOC,
    cfun = a_freq_j,
    extra_args = append(extra_args_rr, NULL)
  ) %>%
  analyze(
    QVAR_NAM,
    afun = a_freq_j,
    extra_args = append(extra_args_rr, NULL)
  ) %>%
  append_topleft("  OCMQ, n (%)")

result <- build_table(lyt, ae, alt_counts_df = adsl)


# If there is no data display "No data to display" text
if (nrow(adae) == 0) {
  result <- safe_prune_table(result)
}

# Post-Processing step to sort by descending count on chosen active treatment columns.

if (nrow(adae) != 0) {
  # per guidance of DAS : sorting should be in Broad category
  # this can be achieved by specifying colpath in jj_complex_scorefun
  # see colpath argument -- category Broad is specified here
  # this will result in sorting according first number of first column in Broad category
  # ie sorting on decreasing frequency in Apa group in Broad category
  # you can be more specific (eg specific single column) if you further specify the colpath to trial needs
  cur_scorefun <- jj_complex_scorefun(
    colpath = c(QVAR_CLASS, "Broad")
  )

  result <- sort_at_path(result, c(QVAR_SOC), scorefun = cur_scorefun)
  result <- sort_at_path(
    result,
    c(QVAR_SOC, "*", QVAR_NAM),
    scorefun = cur_scorefun
  )
}

## Remove the N=xx column headers for the risk difference columns
### need to look at non-default level in the col_paths of the table - here at lvl 4 rather than 1
result <- remove_col_count(result, span_label_var = "RR_difference")

# Add titles and footnotes:

result <- set_titles(result, tab_titles)

# Convert to tbl file and output table

tt_to_tlgrtf(string_map = string_map, tt = result, file = fileid, orientation = "landscape")

TSFAE16: Subjects With Treatment-emergent Adverse Events by System Organ Class and FDA Medical Query (Broad and Narrow); Safety Analysis Set (Study jjcs - core)

Narrow OCMQs

Broad OCMQs

Active Study Agent

Risk Difference (%) (95% CI)

Active Study Agent

Risk Difference (%) (95% CI)

Organ System Class

Xanomeline High Dose

Xanomeline Low Dose

Placebo

Xanomeline High Dose vs Placebo

Xanomeline Low Dose vs Placebo

Xanomeline High Dose

Xanomeline Low Dose

Placebo

Xanomeline High Dose vs Placebo

Xanomeline Low Dose vs Placebo

OCMQ, n (%)

N=53

N=73

N=59

N=53

N=73

N=53

N=73

N=59

N=53

N=73

Immune system disorders

0

0

2 (3.4%)

-3.4 (-8.0, 1.2)

-3.4 (-8.0, 1.2)

42 (79.2%)

38 (52.1%)

19 (32.2%)

47.0 (30.9, 63.2)

19.9 (3.3, 36.4)

Hypersensitivity

0

0

2 (3.4%)

-3.4 (-8.0, 1.2)

-3.4 (-8.0, 1.2)

41 (77.4%)

38 (52.1%)

19 (32.2%)

45.2 (28.8, 61.6)

19.9 (3.3, 36.4)

Angioedema

0

0

0

0.0 (0.0, 0.0)

0.0 (0.0, 0.0)

1 (1.9%)

0

2 (3.4%)

-1.5 (-7.4, 4.4)

-3.4 (-8.0, 1.2)

Skin and subcutaneous tissue
 disorders

39 (73.6%)

39 (53.4%)

17 (28.8%)

44.8 (28.2, 61.3)

24.6 (8.3, 40.9)

24 (45.3%)

22 (30.1%)

12 (20.3%)

24.9 (8.1, 41.8)

9.8 (-4.9, 24.5)

Rash

14 (26.4%)

17 (23.3%)

4 (6.8%)

19.6 (6.1, 33.1)

16.5 (4.9, 28.1)

16 (30.2%)

12 (16.4%)

8 (13.6%)

16.6 (1.5, 31.8)

2.9 (-9.3, 15.1)

Urticaria

1 (1.9%)

2 (2.7%)

0

1.9 (-1.8, 5.5)

2.7 (-1.0, 6.5)

9 (17.0%)

11 (15.1%)

5 (8.5%)

8.5 (-3.8, 20.9)

6.6 (-4.3, 17.4)

Erythema

21 (39.6%)

18 (24.7%)

8 (13.6%)

26.1 (10.3, 41.9)

11.1 (-2.1, 24.3)

4 (7.5%)

4 (5.5%)

3 (5.1%)

2.5 (-6.6, 11.5)

0.4 (-7.3, 8.1)

Pruritus

36 (67.9%)

33 (45.2%)

10 (16.9%)

51.0 (35.2, 66.8)

28.3 (13.4, 43.2)

4 (7.5%)

4 (5.5%)

3 (5.1%)

2.5 (-6.6, 11.5)

0.4 (-7.3, 8.1)

Alopecia

0

0

1 (1.7%)

-1.7 (-5.0, 1.6)

-1.7 (-5.0, 1.6)

0

0

0

0.0 (0.0, 0.0)

0.0 (0.0, 0.0)

Nervous system disorders

12 (22.6%)

14 (19.2%)

5 (8.5%)

14.2 (0.8, 27.5)

10.7 (-0.8, 22.2)

15 (28.3%)

15 (20.5%)

3 (5.1%)

23.2 (9.9, 36.6)

15.5 (4.6, 26.3)

Syncope

2 (3.8%)

3 (4.1%)

0

3.8 (-1.4, 8.9)

4.1 (-0.4, 8.7)

8 (15.1%)

8 (11.0%)

2 (3.4%)

11.7 (1.0, 22.4)

7.6 (-1.0, 16.1)

Somnolence

2 (3.8%)

4 (5.5%)

1 (1.7%)

2.1 (-4.0, 8.2)

3.8 (-2.4, 10.0)

5 (9.4%)

5 (6.8%)

0

9.4 (1.6, 17.3)

6.8 (1.1, 12.6)

Confusional State

2 (3.8%)

3 (4.1%)

3 (5.1%)

-1.3 (-8.9, 6.3)

-1.0 (-8.2, 6.2)

1 (1.9%)

3 (4.1%)

1 (1.7%)

0.2 (-4.7, 5.1)

2.4 (-3.2, 8.0)

Dysgeusia

0

0

0

0.0 (0.0, 0.0)

0.0 (0.0, 0.0)

1 (1.9%)

0

0

1.9 (-1.8, 5.5)

0.0 (0.0, 0.0)

Headache

5 (9.4%)

3 (4.1%)

2 (3.4%)

6.0 (-3.1, 15.2)

0.7 (-5.8, 7.2)

0

0

0

0.0 (0.0, 0.0)

0.0 (0.0, 0.0)

Paresthesia

2 (3.8%)

1 (1.4%)

0

3.8 (-1.4, 8.9)

1.4 (-1.3, 4.0)

0

0

0

0.0 (0.0, 0.0)

0.0 (0.0, 0.0)

Seizure

1 (1.9%)

1 (1.4%)

0

1.9 (-1.8, 5.5)

1.4 (-1.3, 4.0)

0

0

0

0.0 (0.0, 0.0)

0.0 (0.0, 0.0)

Stroke and TIA

1 (1.9%)

2 (2.7%)

0

1.9 (-1.8, 5.5)

2.7 (-1.0, 6.5)

0

1 (1.4%)

0

0.0 (0.0, 0.0)

1.4 (-1.3, 4.0)

Gastrointestinal disorders

11 (20.8%)

9 (12.3%)

5 (8.5%)

12.3 (-0.7, 25.3)

3.9 (-6.5, 14.2)

12 (22.6%)

4 (5.5%)

1 (1.7%)

20.9 (9.2, 32.7)

3.8 (-2.4, 10.0)

Dyspepsia

0

1 (1.4%)

1 (1.7%)

-1.7 (-5.0, 1.6)

-0.3 (-4.6, 3.9)

5 (9.4%)

1 (1.4%)

1 (1.7%)

7.7 (-0.8, 16.3)

-0.3 (-4.6, 3.9)

Nausea

5 (9.4%)

2 (2.7%)

0

9.4 (1.6, 17.3)

2.7 (-1.0, 6.5)

5 (9.4%)

2 (2.7%)

0

9.4 (1.6, 17.3)

2.7 (-1.0, 6.5)

Vomiting

5 (9.4%)

2 (2.7%)

0

9.4 (1.6, 17.3)

2.7 (-1.0, 6.5)

5 (9.4%)

2 (2.7%)

1 (1.7%)

7.7 (-0.8, 16.3)

1.0 (-3.9, 6.0)

Abdominal Pain

2 (3.8%)

2 (2.7%)

1 (1.7%)

2.1 (-4.0, 8.2)

1.0 (-3.9, 6.0)

0

0

0

0.0 (0.0, 0.0)

0.0 (0.0, 0.0)

Constipation

0

0

1 (1.7%)

-1.7 (-5.0, 1.6)

-1.7 (-5.0, 1.6)

0

0

0

0.0 (0.0, 0.0)

0.0 (0.0, 0.0)

Diarrhea

2 (3.8%)

3 (4.1%)

3 (5.1%)

-1.3 (-8.9, 6.3)

-1.0 (-8.2, 6.2)

0

0

1 (1.7%)

-1.7 (-5.0, 1.6)

-1.7 (-5.0, 1.6)

General disorders and
 administration site conditions

20 (37.7%)

22 (30.1%)

12 (20.3%)

17.4 (0.8, 34.0)

9.8 (-4.9, 24.5)

11 (20.8%)

15 (20.5%)

3 (5.1%)

15.7 (3.4, 27.9)

15.5 (4.6, 26.3)

Fall

1 (1.9%)

2 (2.7%)

1 (1.7%)

0.2 (-4.7, 5.1)

1.0 (-3.9, 6.0)

10 (18.9%)

12 (16.4%)

2 (3.4%)

15.5 (4.0, 27.0)

13.0 (3.4, 22.7)

Fatigue

7 (13.2%)

6 (8.2%)

1 (1.7%)

11.5 (1.8, 21.2)

6.5 (-0.6, 13.6)

2 (3.8%)

2 (2.7%)

1 (1.7%)

2.1 (-4.0, 8.2)

1.0 (-3.9, 6.0)

Pyrexia

0

2 (2.7%)

2 (3.4%)

-3.4 (-8.0, 1.2)

-0.7 (-6.6, 5.3)

1 (1.9%)

0

0

1.9 (-1.8, 5.5)

0.0 (0.0, 0.0)

Decreased Appetite

0

0

1 (1.7%)

-1.7 (-5.0, 1.6)

-1.7 (-5.0, 1.6)

0

0

0

0.0 (0.0, 0.0)

0.0 (0.0, 0.0)

Dizziness

9 (17.0%)

10 (13.7%)

0

17.0 (6.9, 27.1)

13.7 (5.8, 21.6)

0

0

0

0.0 (0.0, 0.0)

0.0 (0.0, 0.0)

Local Administration Reaction

7 (13.2%)

9 (12.3%)

5 (8.5%)

4.7 (-6.8, 16.3)

3.9 (-6.5, 14.2)

0

0

0

0.0 (0.0, 0.0)

0.0 (0.0, 0.0)

Peripheral Edema

1 (1.9%)

1 (1.4%)

2 (3.4%)

-1.5 (-7.4, 4.4)

-2.0 (-7.4, 3.3)

0

1 (1.4%)

0

0.0 (0.0, 0.0)

1.4 (-1.3, 4.0)

Volume Depletion

0

0

1 (1.7%)

-1.7 (-5.0, 1.6)

-1.7 (-5.0, 1.6)

0

0

0

0.0 (0.0, 0.0)

0.0 (0.0, 0.0)

Cardiac disorders

11 (20.8%)

12 (16.4%)

8 (13.6%)

7.2 (-6.8, 21.2)

2.9 (-9.3, 15.1)

10 (18.9%)

14 (19.2%)

7 (11.9%)

7.0 (-6.4, 20.4)

7.3 (-4.9, 19.5)

Arrhythmia

9 (17.0%)

9 (12.3%)

3 (5.1%)

11.9 (0.3, 23.5)

7.2 (-2.2, 16.6)

9 (17.0%)

11 (15.1%)

0

17.0 (6.9, 27.1)

15.1 (6.9, 23.3)

Heart Failure

0

0

0

0.0 (0.0, 0.0)

0.0 (0.0, 0.0)

1 (1.9%)

3 (4.1%)

2 (3.4%)

-1.5 (-7.4, 4.4)

0.7 (-5.8, 7.2)

Myocardial Ischemia

3 (5.7%)

1 (1.4%)

3 (5.1%)

0.6 (-7.8, 8.9)

-3.7 (-9.9, 2.5)

1 (1.9%)

3 (4.1%)

4 (6.8%)

-4.9 (-12.3, 2.5)

-2.7 (-10.5, 5.2)

Acute Coronary Syndrome

3 (5.7%)

1 (1.4%)

3 (5.1%)

0.6 (-7.8, 8.9)

-3.7 (-9.9, 2.5)

0

1 (1.4%)

4 (6.8%)

-6.8 (-13.2, -0.4)

-5.4 (-12.4, 1.5)

Cardiac Conduction
 Disturbance

0

3 (4.1%)

3 (5.1%)

-5.1 (-10.7, 0.5)

-1.0 (-8.2, 6.2)

0

0

0

0.0 (0.0, 0.0)

0.0 (0.0, 0.0)

Myocardial Infarction

3 (5.7%)

1 (1.4%)

3 (5.1%)

0.6 (-7.8, 8.9)

-3.7 (-9.9, 2.5)

0

1 (1.4%)

0

0.0 (0.0, 0.0)

1.4 (-1.3, 4.0)

Palpitations

0

2 (2.7%)

0

0.0 (0.0, 0.0)

2.7 (-1.0, 6.5)

0

0

0

0.0 (0.0, 0.0)

0.0 (0.0, 0.0)

Systemic Hypertension

0

1 (1.4%)

1 (1.7%)

-1.7 (-5.0, 1.6)

-0.3 (-4.6, 3.9)

0

0

0

0.0 (0.0, 0.0)

0.0 (0.0, 0.0)

Tachycardia

0

1 (1.4%)

1 (1.7%)

-1.7 (-5.0, 1.6)

-0.3 (-4.6, 3.9)

0

0

0

0.0 (0.0, 0.0)

0.0 (0.0, 0.0)

Ear and labyrinth disorders

1 (1.9%)

1 (1.4%)

0

1.9 (-1.8, 5.5)

1.4 (-1.3, 4.0)

8 (15.1%)

9 (12.3%)

0

15.1 (5.5, 24.7)

12.3 (4.8, 19.9)

Vertigo

1 (1.9%)

1 (1.4%)

0

1.9 (-1.8, 5.5)

1.4 (-1.3, 4.0)

8 (15.1%)

9 (12.3%)

0

15.1 (5.5, 24.7)

12.3 (4.8, 19.9)

Psychiatric disorders

5 (9.4%)

7 (9.6%)

4 (6.8%)

2.7 (-7.5, 12.8)

2.8 (-6.5, 12.1)

6 (11.3%)

4 (5.5%)

2 (3.4%)

7.9 (-1.8, 17.6)

2.1 (-4.9, 9.1)

Psychosis

2 (3.8%)

0

1 (1.7%)

2.1 (-4.0, 8.2)

-1.7 (-5.0, 1.6)

3 (5.7%)

0

0

5.7 (-0.6, 11.9)

0.0 (0.0, 0.0)

Study Agent Abuse Potential

1 (1.9%)

3 (4.1%)

1 (1.7%)

0.2 (-4.7, 5.1)

2.4 (-3.2, 8.0)

3 (5.7%)

0

1 (1.7%)

4.0 (-3.1, 11.0)

-1.7 (-5.0, 1.6)

Anxiety

0

1 (1.4%)

0

0.0 (0.0, 0.0)

1.4 (-1.3, 4.0)

1 (1.9%)

4 (5.5%)

1 (1.7%)

0.2 (-4.7, 5.1)

3.8 (-2.4, 10.0)

Depression

0

1 (1.4%)

0

0.0 (0.0, 0.0)

1.4 (-1.3, 4.0)

0

0

0

0.0 (0.0, 0.0)

0.0 (0.0, 0.0)

Insomnia

1 (1.9%)

0

1 (1.7%)

0.2 (-4.7, 5.1)

-1.7 (-5.0, 1.6)

0

0

0

0.0 (0.0, 0.0)

0.0 (0.0, 0.0)

Irritability

0

3 (4.1%)

1 (1.7%)

-1.7 (-5.0, 1.6)

2.4 (-3.2, 8.0)

0

0

0

0.0 (0.0, 0.0)

0.0 (0.0, 0.0)

Mania

0

0

0

0.0 (0.0, 0.0)

0.0 (0.0, 0.0)

0

3 (4.1%)

2 (3.4%)

-3.4 (-8.0, 1.2)

0.7 (-5.8, 7.2)

Parasomnia

1 (1.9%)

0

0

1.9 (-1.8, 5.5)

0.0 (0.0, 0.0)

0

0

0

0.0 (0.0, 0.0)

0.0 (0.0, 0.0)

Infections and infestations

8 (15.1%)

6 (8.2%)

10 (16.9%)

-1.9 (-15.4, 11.7)

-8.7 (-20.2, 2.7)

4 (7.5%)

2 (2.7%)

10 (16.9%)

-9.4 (-21.3, 2.5)

-14.2 (-24.5, -3.9)

Viral Infection

1 (1.9%)

1 (1.4%)

2 (3.4%)

-1.5 (-7.4, 4.4)

-2.0 (-7.4, 3.3)

3 (5.7%)

1 (1.4%)

6 (10.2%)

-4.5 (-14.4, 5.4)

-8.8 (-17.0, -0.6)

Pneumonia

0

1 (1.4%)

0

0.0 (0.0, 0.0)

1.4 (-1.3, 4.0)

2 (3.8%)

1 (1.4%)

1 (1.7%)

2.1 (-4.0, 8.2)

-0.3 (-4.6, 3.9)

Bacterial Infection

2 (3.8%)

1 (1.4%)

2 (3.4%)

0.4 (-6.5, 7.3)

-2.0 (-7.4, 3.3)

1 (1.9%)

1 (1.4%)

3 (5.1%)

-3.2 (-9.9, 3.5)

-3.7 (-9.9, 2.5)

Nasopharyngitis

6 (11.3%)

3 (4.1%)

7 (11.9%)

-0.5 (-12.4, 11.3)

-7.8 (-17.2, 1.7)

0

0

0

0.0 (0.0, 0.0)

0.0 (0.0, 0.0)

Musculoskeletal and connective
 tissue disorders

5 (9.4%)

2 (2.7%)

2 (3.4%)

6.0 (-3.1, 15.2)

-0.7 (-6.6, 5.3)

1 (1.9%)

2 (2.7%)

1 (1.7%)

0.2 (-4.7, 5.1)

1.0 (-3.9, 6.0)

Arthritis

0

0

0

0.0 (0.0, 0.0)

0.0 (0.0, 0.0)

1 (1.9%)

1 (1.4%)

0

1.9 (-1.8, 5.5)

1.4 (-1.3, 4.0)

Arthralgia

1 (1.9%)

1 (1.4%)

0

1.9 (-1.8, 5.5)

1.4 (-1.3, 4.0)

0

0

0

0.0 (0.0, 0.0)

0.0 (0.0, 0.0)

Back Pain

3 (5.7%)

1 (1.4%)

1 (1.7%)

4.0 (-3.1, 11.0)

-0.3 (-4.6, 3.9)

0

0

0

0.0 (0.0, 0.0)

0.0 (0.0, 0.0)

Fracture

1 (1.9%)

0

1 (1.7%)

0.2 (-4.7, 5.1)

-1.7 (-5.0, 1.6)

0

0

0

0.0 (0.0, 0.0)

0.0 (0.0, 0.0)

Muscle Injury

0

0

0

0.0 (0.0, 0.0)

0.0 (0.0, 0.0)

0

0

1 (1.7%)

-1.7 (-5.0, 1.6)

-1.7 (-5.0, 1.6)

Myalgia

1 (1.9%)

0

0

1.9 (-1.8, 5.5)

0.0 (0.0, 0.0)

0

1 (1.4%)

0

0.0 (0.0, 0.0)

1.4 (-1.3, 4.0)

Osteoporosis

0

0

1 (1.7%)

-1.7 (-5.0, 1.6)

-1.7 (-5.0, 1.6)

0

0

0

0.0 (0.0, 0.0)

0.0 (0.0, 0.0)

Renal and urinary disorders

1 (1.9%)

0

2 (3.4%)

-1.5 (-7.4, 4.4)

-3.4 (-8.0, 1.2)

1 (1.9%)

3 (4.1%)

3 (5.1%)

-3.2 (-9.9, 3.5)

-1.0 (-8.2, 6.2)

Urinary Retention

0

0

0

0.0 (0.0, 0.0)

0.0 (0.0, 0.0)

1 (1.9%)

3 (4.1%)

3 (5.1%)

-3.2 (-9.9, 3.5)

-1.0 (-8.2, 6.2)

Renal & Urinary Tract
 Infection

1 (1.9%)

0

2 (3.4%)

-1.5 (-7.4, 4.4)

-3.4 (-8.0, 1.2)

0

1 (1.4%)

1 (1.7%)

-1.7 (-5.0, 1.6)

-0.3 (-4.6, 3.9)

Endocrine disorders

1 (1.9%)

1 (1.4%)

0

1.9 (-1.8, 5.5)

1.4 (-1.3, 4.0)

0

0

0

0.0 (0.0, 0.0)

0.0 (0.0, 0.0)

Hyperglycemia

1 (1.9%)

1 (1.4%)

0

1.9 (-1.8, 5.5)

1.4 (-1.3, 4.0)

0

0

0

0.0 (0.0, 0.0)

0.0 (0.0, 0.0)

Eye disorders

0

0

0

0.0 (0.0, 0.0)

0.0 (0.0, 0.0)

0

0

1 (1.7%)

-1.7 (-5.0, 1.6)

-1.7 (-5.0, 1.6)

Glaucoma

0

0

0

0.0 (0.0, 0.0)

0.0 (0.0, 0.0)

0

0

1 (1.7%)

-1.7 (-5.0, 1.6)

-1.7 (-5.0, 1.6)

Hepatobiliary disorders

0

0

0

0.0 (0.0, 0.0)

0.0 (0.0, 0.0)

0

0

1 (1.7%)

-1.7 (-5.0, 1.6)

-1.7 (-5.0, 1.6)

Hepatic Injury

0

0

0

0.0 (0.0, 0.0)

0.0 (0.0, 0.0)

0

0

1 (1.7%)

-1.7 (-5.0, 1.6)

-1.7 (-5.0, 1.6)

Metabolism and nutrition
 disorders

1 (1.9%)

0

0

1.9 (-1.8, 5.5)

0.0 (0.0, 0.0)

0

1 (1.4%)

0

0.0 (0.0, 0.0)

1.4 (-1.3, 4.0)

Cachexia

0

0

0

0.0 (0.0, 0.0)

0.0 (0.0, 0.0)

0

1 (1.4%)

0

0.0 (0.0, 0.0)

1.4 (-1.3, 4.0)

Lipid Disorder

1 (1.9%)

0

0

1.9 (-1.8, 5.5)

0.0 (0.0, 0.0)

0

0

0

0.0 (0.0, 0.0)

0.0 (0.0, 0.0)

Neoplasms benign, malignant
 and unspecified (incl cysts
 and polyps)

1 (1.9%)

1 (1.4%)

0

1.9 (-1.8, 5.5)

1.4 (-1.3, 4.0)

0

0

0

0.0 (0.0, 0.0)

0.0 (0.0, 0.0)

Malignancy

1 (1.9%)

1 (1.4%)

0

1.9 (-1.8, 5.5)

1.4 (-1.3, 4.0)

0

0

0

0.0 (0.0, 0.0)

0.0 (0.0, 0.0)

Reproductive system and breast
 disorders

3 (5.7%)

0

2 (3.4%)

2.3 (-5.5, 10.0)

-3.4 (-8.0, 1.2)

0

1 (1.4%)

3 (5.1%)

-5.1 (-10.7, 0.5)

-3.7 (-9.9, 2.5)

Abnormal Uterine Bleeding

1 (1.9%)

0

0

1.9 (-1.8, 5.5)

0.0 (0.0, 0.0)

0

1 (1.4%)

1 (1.7%)

-1.7 (-5.0, 1.6)

-0.3 (-4.6, 3.9)

Erectile Dysfunction

1 (1.9%)

0

1 (1.7%)

0.2 (-4.7, 5.1)

-1.7 (-5.0, 1.6)

0

0

1 (1.7%)

-1.7 (-5.0, 1.6)

-1.7 (-5.0, 1.6)

Excessive Menstrual Bleeding

1 (1.9%)

0

0

1.9 (-1.8, 5.5)

0.0 (0.0, 0.0)

0

0

0

0.0 (0.0, 0.0)

0.0 (0.0, 0.0)

Sexual Dysfunction

2 (3.8%)

0

2 (3.4%)

0.4 (-6.5, 7.3)

-3.4 (-8.0, 1.2)

0

0

1 (1.7%)

-1.7 (-5.0, 1.6)

-1.7 (-5.0, 1.6)

Respiratory, thoracic and
 mediastinal disorders

4 (7.5%)

5 (6.8%)

1 (1.7%)

5.9 (-2.0, 13.7)

5.2 (-1.5, 11.8)

0

1 (1.4%)

1 (1.7%)

-1.7 (-5.0, 1.6)

-0.3 (-4.6, 3.9)

Bronchospasm

0

0

0

0.0 (0.0, 0.0)

0.0 (0.0, 0.0)

0

1 (1.4%)

0

0.0 (0.0, 0.0)

1.4 (-1.3, 4.0)

Cough

4 (7.5%)

4 (5.5%)

1 (1.7%)

5.9 (-2.0, 13.7)

3.8 (-2.4, 10.0)

0

0

1 (1.7%)

-1.7 (-5.0, 1.6)

-1.7 (-5.0, 1.6)

Dyspnea

0

1 (1.4%)

0

0.0 (0.0, 0.0)

1.4 (-1.3, 4.0)

0

0

0

0.0 (0.0, 0.0)

0.0 (0.0, 0.0)

Respiratory Failure

0

0

0

0.0 (0.0, 0.0)

0.0 (0.0, 0.0)

0

1 (1.4%)

0

0.0 (0.0, 0.0)

1.4 (-1.3, 4.0)

Vascular disorders

7 (13.2%)

8 (11.0%)

4 (6.8%)

6.4 (-4.7, 17.6)

4.2 (-5.4, 13.8)

0

0

1 (1.7%)

-1.7 (-5.0, 1.6)

-1.7 (-5.0, 1.6)

Hemorrhage

3 (5.7%)

4 (5.5%)

1 (1.7%)

4.0 (-3.1, 11.0)

3.8 (-2.4, 10.0)

0

0

0

0.0 (0.0, 0.0)

0.0 (0.0, 0.0)

Hypotension

0

1 (1.4%)

2 (3.4%)

-3.4 (-8.0, 1.2)

-2.0 (-7.4, 3.3)

0

0

1 (1.7%)

-1.7 (-5.0, 1.6)

-1.7 (-5.0, 1.6)

Thrombosis

4 (7.5%)

3 (4.1%)

3 (5.1%)

2.5 (-6.6, 11.5)

-1.0 (-8.2, 6.2)

0

0

0

0.0 (0.0, 0.0)

0.0 (0.0, 0.0)

Thrombosis Arterial

4 (7.5%)

3 (4.1%)

3 (5.1%)

2.5 (-6.6, 11.5)

-1.0 (-8.2, 6.2)

0

0

0

0.0 (0.0, 0.0)

0.0 (0.0, 0.0)

Key: FMQ=FDA Medical Query

a Each FMQ is aligned to a single system organ class based on clinical judgment, as defined by FDA. However, some FMQs may contain preferred terms from more than one system organ class.

Note: Adverse events are coded using MedDRA version 26.0.

Download RTF file

TSFAE15
TSFAE17A
Source Code
---
title: TSFAE16
subtitle: Subjects With Treatment-emergent Adverse Events by Organ System and OCMQ (Broad and Narrow)
---

------------------------------------------------------------------------

{{< include ../../_utils/envir_hook.qmd >}}

```{r setup, echo = FALSE, warning = FALSE, message = FALSE}
options(docx.add_datetime = FALSE, tidytlg.add_datetime = FALSE)
envsetup_config_name <- "default"

# Path to the combined config file
envsetup_file_path <- file.path("../..", "envsetup.yml")

Sys.setenv(ENVSETUP_ENVIRON = '')
library(envsetup)
loaded_config <- config::get(config = envsetup_config_name, file = envsetup_file_path)
envsetup::rprofile(loaded_config)


dpscomp <- compound
dpspdr <- paste(protocol,dbrelease,rpteff,sep="__")

aptcomp <- compound
aptpdr <- paste(protocol,dbrelease,rpteff,sep="__")

###### Study specific updates (formerly in envre)

dpscomp <- "standards"
dpspdr <- "jjcs__NULL__jjcs - core"

apt <- FALSE
library(junco)
default_str_map <- rbind(default_str_map, c("&ctcae", "5.0"))

```

## Output

:::: panel-tabset
## {{< fa regular file-lines sm fw >}} Preview

```{r variant1, results='hide', warning = FALSE, message = FALSE}

# Program Name:              tsfae16.R

# Prep Environment

library(envsetup)
library(tern)
library(dplyr)
library(rtables)
library(junco)

# Define script level parameters:

# - Define output ID and file location

tblid <- "TSFAE16"
fileid <- tblid
tab_titles <- get_titles_from_file(input_path = '../../_data/', tblid)
string_map <- default_str_map

trtvar <- "TRT01A"
popfl <- "SAFFL"

combined_colspan_trt <- FALSE
risk_diff <- TRUE
rr_method <- "wald"
ctrl_grp <- "Placebo"

QVAR_CLASS <- "OCMQCLSS"
QVAR_SOC <- "OCMQSOC"
QVAR_NAM <- "OCMQNAM"

if (combined_colspan_trt == TRUE) {
  # Set up levels and label for the required combined columns
  add_combo <- add_combo_facet(
    "Combined",
    label = "Combined",
    levels = c("Xanomeline High Dose", "Xanomeline Low Dose")
  )

  # choose if any facets need to be removed - e.g remove the combined column for ref group
  rm_combo_from_ref <- cond_rm_facets(
    facets = "Combined",
    ancestor_pos = NA,
    value = " ",
    split = "colspan_trt"
  )

  mysplit <- make_split_fun(post = list(add_combo, rm_combo_from_ref))
}

# Process Data:

adsl <- pharmaverseadamjnj::adsl %>%
  filter(!!rlang::sym(popfl) == "Y") %>%
  select(STUDYID, USUBJID, all_of(trtvar), all_of(popfl))

adsl0 <- adsl

adsl <- rbind(
  adsl0 %>% mutate(!!rlang::sym(QVAR_CLASS) := "Narrow"),
  adsl0 %>% mutate(!!rlang::sym(QVAR_CLASS) := "Broad")
)
### label slightly differs from values in dataset
QVAR_CLASS2 <- "OCMQCLS2"
adsl[[QVAR_CLASS2]] <- paste(adsl[[QVAR_CLASS]], "OCMQs")

adae <- pharmaverseadamjnj::adaeocmq %>%
  filter(TRTEMFL == "Y") %>%
  select(USUBJID, TRTEMFL, all_of(c(QVAR_CLASS, QVAR_NAM, QVAR_SOC)))

adsl$colspan_trt <- factor(
  ifelse(adsl[[trtvar]] == ctrl_grp, " ", "Active Study Agent"),
  levels = c("Active Study Agent", " ")
)

# join data together
ae <- adae %>% inner_join(., adsl)

colspan_trt_map <- create_colspan_map(
  adsl,
  non_active_grp = ctrl_grp,
  non_active_grp_span_lbl = " ",
  active_grp_span_lbl = "Active Study Agent",
  colspan_var = "colspan_trt",
  trt_var = trtvar
)

if (risk_diff) {
  ## risk difference columns are created by this split function for FMQ table
  # to get risk diff column within FMQclass
  mysplfun1 <- make_split_fun(
    post = list(
      add_combo_facet(
        "RR_difference",
        label = "Risk Difference (%) (95% CI)",
        levels = c("Active Study Agent")
      )
    )
  )
} else {
  mysplfun1 <- NULL
}

# further split process to ensure only the required treatment columns remain in the layout
make_cond_rm_from_map <- function(map, diff_rm = "Placebo") {
  outer_levs <- unique(map[[1]])
  fnlst <- list()
  for (i in seq_along(outer_levs)) {
    inner_levs <- map[map[[1]] == outer_levs[[i]], 2, drop = TRUE]
    fnlst[[i]] <- cond_rm_facets(
      facets = inner_levs,
      ancestor_pos = -1,
      value = outer_levs[i],
      keep_matches = TRUE
    )
  }

  # remove ref group column within RR columns
  rr_rm_cond <- cond_rm_facets(
    facets = diff_rm,
    ancestor_pos = -1,
    value = "RR_difference",
    keep_matches = FALSE
  )

  # update label in risk diff column to include diff from reference in label
  post_relabel <- function(splres, spl, fulldf, .spl_context) {
    inrr <- grepl("difference", tail(.spl_context$value, 1))
    if (inrr) {
      splres$labels <- paste(splres$labels, "vs", diff_rm)
    }
    splres
  }

  make_split_fun(post = c(fnlst, rr_rm_cond, post_relabel))
}

cond_trt_splfun <- make_cond_rm_from_map(colspan_trt_map, diff_rm = ctrl_grp)

# Define layout and build table:

ref_path <- c("colspan_trt", " ", "TRT01A", "Placebo")
extra_args_rr <- list(
  method = rr_method,
  ref_path = ref_path,
  colgroup = "OCMQCLSS",
  .stats = c("count_unique_fraction")
)

lyt <- basic_table(
  top_level_section_div = " ",
  show_colcounts = TRUE,
  colcount_format = "N=xx"
) %>%
  split_cols_by(QVAR_CLASS, labels_var = QVAR_CLASS2) %>%
  split_cols_by("colspan_trt", split_fun = mysplfun1) %>%
  split_cols_by(trtvar, split_fun = cond_trt_splfun)

lyt <- lyt %>%
  split_rows_by(
    QVAR_SOC,
    split_label = "Organ System Class",
    split_fun = trim_levels_in_group(QVAR_NAM),
    label_pos = "topleft",
    section_div = c(" ")
  ) %>%
  summarize_row_groups(
    QVAR_SOC,
    cfun = a_freq_j,
    extra_args = append(extra_args_rr, NULL)
  ) %>%
  analyze(
    QVAR_NAM,
    afun = a_freq_j,
    extra_args = append(extra_args_rr, NULL)
  ) %>%
  append_topleft("  OCMQ, n (%)")

result <- build_table(lyt, ae, alt_counts_df = adsl)


# If there is no data display "No data to display" text
if (nrow(adae) == 0) {
  result <- safe_prune_table(result)
}

# Post-Processing step to sort by descending count on chosen active treatment columns.

if (nrow(adae) != 0) {
  # per guidance of DAS : sorting should be in Broad category
  # this can be achieved by specifying colpath in jj_complex_scorefun
  # see colpath argument -- category Broad is specified here
  # this will result in sorting according first number of first column in Broad category
  # ie sorting on decreasing frequency in Apa group in Broad category
  # you can be more specific (eg specific single column) if you further specify the colpath to trial needs
  cur_scorefun <- jj_complex_scorefun(
    colpath = c(QVAR_CLASS, "Broad")
  )

  result <- sort_at_path(result, c(QVAR_SOC), scorefun = cur_scorefun)
  result <- sort_at_path(
    result,
    c(QVAR_SOC, "*", QVAR_NAM),
    scorefun = cur_scorefun
  )
}

## Remove the N=xx column headers for the risk difference columns
### need to look at non-default level in the col_paths of the table - here at lvl 4 rather than 1
result <- remove_col_count(result, span_label_var = "RR_difference")

# Add titles and footnotes:

result <- set_titles(result, tab_titles)

# Convert to tbl file and output table

tt_to_tlgrtf(string_map = string_map, tt = result, file = fileid, orientation = "landscape")
```
```{r result1, echo=FALSE, message=FALSE, warning=FALSE, test = list(result_v1 = "result")}
tt_to_flextable_j(result, tblid, string_map = string_map) 
```

[Download RTF file](`r paste0(tolower(tblid), '.rtf')`)
::::

Made with ❤️ by the J&J Team

  • Edit this page
  • Report an issue
Cookie Preferences