Subjects With Treatment-emergent Adverse Events (Excluding Serious Adverse Events) With Frequency =5% in Any Treatment Group by System Organ Class and Preferred Term
# Program Name: tsfae08.R# Prep Environmentlibrary(envsetup)library(tern)library(dplyr)library(rtables)library(junco)# Define script level parameters:# - Define output ID and file locationtblid <-"TSFAE08"fileid <- tblidtab_titles <-get_titles_from_file(input_path ='../../_data/', tblid)string_map <- default_str_maptrtvar <-"TRT01A"popfl <-"SAFFL"combined_colspan_trt <-TRUEif (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 placebo rm_combo_from_placebo <-cond_rm_facets(facets ="Combined",ancestor_pos =NA,value =" ",split ="colspan_trt" ) mysplit <-make_split_fun(post =list(add_combo, rm_combo_from_placebo))}# Process Data:adsl <- pharmaverseadamjnj::adsl %>%filter(!!rlang::sym(popfl) =="Y") %>%select(STUDYID, USUBJID, all_of(trtvar), all_of(popfl))adae <- pharmaverseadamjnj::adae %>%filter(TRTEMFL =="Y"& AESER =="N") %>%select(USUBJID, TRTEMFL, AEBODSYS, AEDECOD)adsl$colspan_trt <-factor(ifelse(adsl[[trtvar]] =="Placebo", " ", "Active Study Agent"),levels =c("Active Study Agent", " "))# join data togetherae <- adae %>%right_join(., adsl, by =c("USUBJID"))colspan_trt_map <-create_colspan_map( adsl,non_active_grp ="Placebo",non_active_grp_span_lbl =" ",active_grp_span_lbl ="Active Study Agent",colspan_var ="colspan_trt",trt_var = trtvar)# Define layout and build table:extra_args_1 <-list(denom ="n_altdf",.stats =c("count_unique_fraction"))lyt <- rtables::basic_table(top_level_section_div =" ",show_colcounts =TRUE,colcount_format ="N=xx") %>%split_cols_by("colspan_trt",split_fun =trim_levels_to_map(map = colspan_trt_map) )if (combined_colspan_trt ==TRUE) { lyt <- lyt %>%split_cols_by(trtvar, split_fun = mysplit)} else { lyt <- lyt %>%split_cols_by(trtvar)}lyt <- lyt %>%analyze("TRTEMFL",afun = a_freq_j,show_labels ="hidden",extra_args =append( extra_args_1,list(label ="Subjects with >=1 AE", val ="Y") ) ) %>%split_rows_by("AEBODSYS",child_labels ="hidden",split_label ="System Organ Class",label_pos ="topleft",split_fun =trim_levels_in_group("AEDECOD"),section_div =c(" "),indent_mod =0L ) %>%summarize_row_groups("AEBODSYS",cfun = a_freq_j,extra_args = extra_args_1 ) %>%analyze("AEDECOD", afun = a_freq_j, extra_args = extra_args_1) %>%append_topleft(" Preferred Term, n (%)")result <-build_table(lyt, ae, alt_counts_df = adsl)# If there is no data remove top row and display "No data to display" textif (length(adae$TRTEMFL) ==0) { result <-safe_prune_table( result,prune_func =remove_rows(removerowtext ="Subjects with >=1 AE") )}# Post-Processing step to sort by descending count on chosen active treatment columns.if (length(adae$TRTEMFL) !=0) { result <-sort_at_path( result,c("root", "AEBODSYS"),scorefun =jj_complex_scorefun() ) result <-sort_at_path( result,c("root", "AEBODSYS", "*", "AEDECOD"),scorefun =jj_complex_scorefun() )################################################################################# Prune table to only keep those that meet x% criteria, but top row is not subject to pruning################################################################################ result <-safe_prune_table( result,prune_func =bspt_pruner(fraction =0.05,keeprowtext ="Subjects with >=1 AE",cols =c(trtvar) ) )}# Add titles and footnotes:result <-set_titles(result, tab_titles)# Convert to tbl file and output tablett_to_tlgrtf(string_map = string_map, tt = result, file = fileid, orientation ="portrait")
TSFAE08:Subjects With Treatment-emergent Adverse Events (Excluding Serious Adverse Events) With Frequency =[5]% in [Any Treatment Group] by System Organ Class and Preferred Term; Safety Analysis Set (Study jjcs - core)
Active Study Agent
System Organ Class
Xanomeline High Dose
Xanomeline Low Dose
Combined
Placebo
Preferred Term, n (%)
N=53
N=73
N=126
N=59
Subjects with ≥1 AE
47 (88.7%)
54 (74.0%)
101 (80.2%)
34 (57.6%)
General disorders and administration site conditions
21 (39.6%)
26 (35.6%)
47 (37.3%)
10 (16.9%)
APPLICATION SITE PRURITUS
7 (13.2%)
12 (16.4%)
19 (15.1%)
3 (5.1%)
APPLICATION SITE ERYTHEMA
6 (11.3%)
7 (9.6%)
13 (10.3%)
1 (1.7%)
APPLICATION SITE IRRITATION
5 (9.4%)
5 (6.8%)
10 (7.9%)
1 (1.7%)
APPLICATION SITE DERMATITIS
1 (1.9%)
4 (5.5%)
5 (4.0%)
3 (5.1%)
Skin and subcutaneous tissue disorders
25 (47.2%)
21 (28.8%)
46 (36.5%)
10 (16.9%)
PRURITUS
13 (24.5%)
7 (9.6%)
20 (15.9%)
5 (8.5%)
ERYTHEMA
5 (9.4%)
4 (5.5%)
9 (7.1%)
2 (3.4%)
RASH
3 (5.7%)
6 (8.2%)
9 (7.1%)
3 (5.1%)
HYPERHIDROSIS
5 (9.4%)
1 (1.4%)
6 (4.8%)
0
SKIN IRRITATION
3 (5.7%)
3 (4.1%)
6 (4.8%)
1 (1.7%)
Nervous system disorders
13 (24.5%)
11 (15.1%)
24 (19.0%)
2 (3.4%)
DIZZINESS
6 (11.3%)
6 (8.2%)
12 (9.5%)
0
HEADACHE
4 (7.5%)
0
4 (3.2%)
1 (1.7%)
Cardiac disorders
8 (15.1%)
8 (11.0%)
16 (12.7%)
4 (6.8%)
SINUS BRADYCARDIA
5 (9.4%)
2 (2.7%)
7 (5.6%)
0
Gastrointestinal disorders
6 (11.3%)
6 (8.2%)
12 (9.5%)
4 (6.8%)
NAUSEA
3 (5.7%)
2 (2.7%)
5 (4.0%)
0
DIARRHOEA
0
1 (1.4%)
1 (0.8%)
3 (5.1%)
Respiratory, thoracic and mediastinal disorders
5 (9.4%)
5 (6.8%)
10 (7.9%)
4 (6.8%)
COUGH
1 (1.9%)
4 (5.5%)
5 (4.0%)
1 (1.7%)
NASAL CONGESTION
3 (5.7%)
0
3 (2.4%)
2 (3.4%)
Infections and infestations
4 (7.5%)
4 (5.5%)
8 (6.3%)
11 (18.6%)
UPPER RESPIRATORY TRACT INFECTION
1 (1.9%)
0
1 (0.8%)
3 (5.1%)
Note: Subjects are counted only once for any given event, regardless of the number of times they actually experienced the event.
Note: Adverse events are coded using MedDRA version 26.0.