# Program Name: tsfae23b.R# Prep environmentlibrary(envsetup)library(tern)library(dplyr)library(rtables)library(junco)# Define script level parameterstblid <-"TSFAE23b"fileid <- tblidpopfl <-"SAFFL"trtvar <-"TRT01A"aerelvar <-"AEREL"combined_colspan_trt <-TRUEtab_titles <-get_titles_from_file(input_path ='../../_data/', tblid)string_map <- default_str_mapif (combined_colspan_trt ==TRUE) {# If no combined treatment column(s) needed for your study then this next# section of code can be removed# 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 dataadsl <- pharmaverseadamjnj::adsl %>%filter(!!rlang::sym(popfl) =="Y") %>%create_colspan_var(non_active_grp =c("Placebo"),non_active_grp_span_lbl =" ",active_grp_span_lbl ="Active Study Agent",colspan_var ="colspan_trt",trt_var = trtvar ) %>%select( STUDYID, USUBJID,!!rlang::sym(popfl),!!rlang::sym(trtvar), colspan_trt )trt_map <-create_colspan_map(df = adsl,non_active_grp =c("Placebo"),non_active_grp_span_lbl =" ",active_grp_span_lbl ="Active Study Agent",colspan_var ="colspan_trt",trt_var = trtvar)ref_path <-c("colspan_trt", " ", trtvar, "Placebo")adae0 <- pharmaverseadamjnj::adae %>%filter(!!rlang::sym(popfl) =="Y"&!!rlang::sym(aerelvar) =="RELATED"& TRTEMFL =="Y"& AEOUT =="FATAL" ) %>%left_join(subset(adsl, select =c("STUDYID", "USUBJID", "colspan_trt")),by =c("STUDYID", "USUBJID") ) %>%select( STUDYID, USUBJID,!!rlang::sym(trtvar),!!rlang::sym(popfl),!!rlang::sym(aerelvar), TRTEMFL, AEOUT, AEDECOD, colspan_trt )if (nrow(adae0) ==0) { adae <- adae0 %>%select(STUDYID, USUBJID, TRTEMFL, AEDECOD) %>%right_join(adsl, by =c("STUDYID", "USUBJID"))} else { adae <- adae0}# Define layout and build tablelyt <-basic_table(show_colcounts =TRUE,colcount_format ="N=xx",top_level_section_div =" ") %>%split_cols_by("colspan_trt", split_fun =trim_levels_to_map(map = 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(vars ="TRTEMFL",show_labels ="hidden",afun = a_freq_j,extra_args =list(label ="Subjects with >=1 related fatal AE",.stats =c("count_unique_fraction"),val ="Y" ),section_div =c(" ") )if (nrow(adae0) >0) { lyt <- lyt %>%count_occurrences(vars ="AEDECOD",.stats =c("count_fraction_fixed_dp"),.indent_mods =c(count_fraction =-1L),.formats =c("count_fraction_fixed_dp"= jjcsformat_count_fraction),nested =FALSE ) %>%append_topleft("Preferred Term, n (%)")} else { lyt <- lyt %>%append_topleft("Preferred Term, n (%)")}result <-build_table(lyt, df = adae, alt_counts_df = adsl)# Post-processingif (nrow(adae0) >0) {# Post-Processing step to sort by descending count in the Combined# Xanomeline High Dose column result <-sort_at_path(tt = result,path =c("root", "AEDECOD"),scorefun =jj_complex_scorefun(spanningheadercolvar ="colspan_trt",colpath =NULL ) )}if (nrow(adae0) ==0) {# Post-Processing step to remove 'Subjects with' row result <-safe_prune_table( result,prune_func =remove_rows(removerowtext ="Subjects with >=1 related fatal AE" ) )}# Retrieve titles and footnotesresult <-set_titles(result, tab_titles)# Convert to tbl file and output tablett_to_tlgrtf(string_map = string_map, tt = result, file = fileid)
TSFAE23b:Subjects With Related Fatal Treatment-emergent Adverse Events by Preferred Term; Safety Analysis Set (Study jjcs - core)
Active Study Agent
Xanomeline High Dose
Xanomeline Low Dose
Combined
Placebo
Preferred Term, n (%)
N=53
N=73
N=126
N=59
- No Data To Display -
Note: An AE is assessed by the investigator as related. Fatal AEs are based on AE outcome of Fatal. 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.