aesi_vars <-c("FATAL", "SER", "SERWD", "SERDSM", "RELSER", "WD", "DSM", "REL", "RELWD", "RELDSM", "SEV")# Layout for variables from adsl dataset.lyt_adsl <-basic_table(show_colcounts =TRUE) %>%split_cols_by("ACTARM") %>%count_patients_with_event("USUBJID",filters =c("DTHFL"="Y"),denom ="N_col",.labels =c(count_fraction ="Total number of deaths") ) %>%count_patients_with_event("USUBJID",filters =c("DCSREAS"="ADVERSE EVENT"),denom ="N_col",.labels =c(count_fraction ="Total number of patients withdrawn from study due to an AE"),table_names ="tot_wd" )result_adsl <-build_table(lyt_adsl, df = adsl, alt_counts_df = adsl)# Layout for variables from adae dataset.lyt_adae <-basic_table(show_colcounts =TRUE) %>%split_cols_by("ACTARM") %>%analyze_num_patients(vars ="USUBJID",.stats =c("unique", "nonunique"),.labels =c(unique ="Total number of patients with at least one AE",nonunique ="Total number of AEs" ),.formats =list(unique = format_count_fraction_fixed_dp, nonunique ="xx"),show_labels ="hidden" ) %>%count_patients_with_flags("USUBJID",flag_variables = aesi_vars,denom ="N_col",var_labels ="Total number of patients with at least one",show_labels ="visible" )result_adae <-build_table(lyt_adae, df = adae, alt_counts_df = adsl)# Combine tables.col_info(result_adsl) <-col_info(result_adae)result <-rbind( result_adae[1:2, ], result_adsl, result_adae[3:nrow(result_adae), ])result
A: Drug X B: Placebo C: Combination
(N=134) (N=134) (N=132)
——————————————————————————————————————————————————————————————————————————————————————————————————————
Total number of patients with at least one AE 100 (74.6%) 98 (73.1%) 103 (78.0%)
Total number of AEs 502 480 604
Total number of deaths 25 (18.7%) 23 (17.2%) 22 (16.7%)
Total number of patients withdrawn from study due to an AE 3 (2.2%) 6 (4.5%) 5 (3.8%)
Total number of patients with at least one
AE with fatal outcome 5 (3.7%) 5 (3.7%) 6 (4.5%)
Serious AE 85 (63.4%) 80 (59.7%) 87 (65.9%)
Serious AE leading to withdrawal from treatment 6 (4.5%) 12 (9.0%) 9 (6.8%)
Serious AE leading to dose modification/interruption 36 (26.9%) 40 (29.9%) 47 (35.6%)
Related Serious AE 64 (47.8%) 52 (38.8%) 64 (48.5%)
AE leading to withdrawal from treatment 20 (14.9%) 24 (17.9%) 26 (19.7%)
AE leading to dose modification/interruption 63 (47.0%) 70 (52.2%) 77 (58.3%)
Related AE 86 (64.2%) 85 (63.4%) 92 (69.7%)
Related AE leading to withdrawal from treatment 10 (7.5%) 9 (6.7%) 12 (9.1%)
Related AE leading to dose modification/interruption 44 (32.8%) 44 (32.8%) 51 (38.6%)
Severe AE (at greatest intensity) 77 (57.5%) 70 (52.2%) 79 (59.8%)
Experimental use!
WebR is a tool allowing you to run R code in the web browser. Modify the code below and click run to see the results. Alternatively, copy the code and click here to open WebR in a new tab.
aesi_vars <-c("FATAL", "SER", "SERWD", "SERDSM", "RELSER", "WD", "DSM", "REL", "RELWD", "RELDSM", "CTC35")basket_vars <-c("SMQ01", "SMQ02", "CQ01")# Layout for variables from adsl dataset.lyt_adsl <-basic_table(show_colcounts =TRUE) %>%split_cols_by("ACTARM") %>%count_patients_with_event("USUBJID",filters =c("DTHFL"="Y"),denom ="N_col",.labels =c(count_fraction ="Total number of deaths") ) %>%count_patients_with_event("USUBJID",filters =c("DCSREAS"="ADVERSE EVENT"),denom ="N_col",.labels =c(count_fraction ="Total number of patients withdrawn from study due to an AE"),table_names ="tot_wd" )result_adsl <-build_table(lyt_adsl, df = adsl, alt_counts_df = adsl)# Layout for variables from adae dataset.lyt_adae <-basic_table(show_colcounts =TRUE) %>%split_cols_by("ACTARM") %>%analyze_num_patients(vars ="USUBJID",.stats =c("unique", "nonunique"),.labels =c(unique ="Total number of patients with at least one AE",nonunique ="Total number of AEs" ),.formats =list(unique = format_count_fraction_fixed_dp, nonunique ="xx"),show_labels ="hidden" ) %>%count_patients_with_flags("USUBJID",flag_variables = aesi_vars,denom ="N_col",var_labels ="Total number of patients with at least one",show_labels ="visible" ) %>%count_patients_with_flags("USUBJID",flag_variables = basket_vars,table_names ="table_aesi",denom ="N_col",var_labels ="Total number of patients with at least one",show_labels ="visible" )result_adae <-build_table(lyt_adae, df = adae, alt_counts_df = adsl)# Combine tables.col_info(result_adsl) <-col_info(result_adae)result <-rbind( result_adae[1:2, ], result_adsl, result_adae[3:nrow(result_adae), ])result
A: Drug X B: Placebo C: Combination
(N=134) (N=134) (N=132)
——————————————————————————————————————————————————————————————————————————————————————————————————————
Total number of patients with at least one AE 100 (74.6%) 98 (73.1%) 103 (78.0%)
Total number of AEs 502 480 604
Total number of deaths 25 (18.7%) 23 (17.2%) 22 (16.7%)
Total number of patients withdrawn from study due to an AE 3 (2.2%) 6 (4.5%) 5 (3.8%)
Total number of patients with at least one
AE with fatal outcome 5 (3.7%) 5 (3.7%) 6 (4.5%)
Serious AE 85 (63.4%) 80 (59.7%) 87 (65.9%)
Serious AE leading to withdrawal from treatment 6 (4.5%) 12 (9.0%) 9 (6.8%)
Serious AE leading to dose modification/interruption 36 (26.9%) 40 (29.9%) 47 (35.6%)
Related Serious AE 64 (47.8%) 52 (38.8%) 64 (48.5%)
AE leading to withdrawal from treatment 20 (14.9%) 24 (17.9%) 26 (19.7%)
AE leading to dose modification/interruption 63 (47.0%) 70 (52.2%) 77 (58.3%)
Related AE 86 (64.2%) 85 (63.4%) 92 (69.7%)
Related AE leading to withdrawal from treatment 10 (7.5%) 9 (6.7%) 12 (9.1%)
Related AE leading to dose modification/interruption 44 (32.8%) 44 (32.8%) 51 (38.6%)
Grade 3-5 AE 90 (67.2%) 83 (61.9%) 93 (70.5%)
Total number of patients with at least one
C.1.1.1.3/B.2.2.3.1 AESI (BROAD) 58 (43.3%) 60 (44.8%) 66 (50.0%)
SMQ 02 Reference Name 0 0 0
D.2.1.5.3/A.1.1.1.1 AESI 62 (46.3%) 61 (45.5%) 76 (57.6%)
Experimental use!
WebR is a tool allowing you to run R code in the web browser. Modify the code below and click run to see the results. Alternatively, copy the code and click here to open WebR in a new tab.
aesi_vars <-c("FATAL", "SER", "WD", "REL", "CTC35", "CTC45")# Layout for variables from adsl dataset.lyt_adsl <-basic_table(show_colcounts =TRUE) %>%split_cols_by("ACTARM") %>%count_patients_with_event("USUBJID",filters =c("DTHFL"="Y"),denom ="N_col",.labels =c(count_fraction ="Total number of deaths") ) %>%count_patients_with_event("USUBJID",filters =c("DCSREAS"="ADVERSE EVENT"),denom ="N_col",.labels =c(count_fraction ="Total number of patients withdrawn from study due to an AE"),table_names ="tot_wd" ) %>%count_patients_with_event("USUBJID",filters =c("DCSREAS"="WITHDRAWAL BY SUBJECT"),denom ="N_col",.labels =c(count_fraction ="Total number of patients withdrawn informed consent"),table_names ="tot_dscsreas_wd" )result_adsl <-build_table(lyt_adsl, df = adsl, alt_counts_df = adsl)# Layout for variables from adae dataset.lyt_adae <-basic_table(show_colcounts =TRUE) %>%split_cols_by("ACTARM") %>%analyze_num_patients(vars ="USUBJID",.stats =c("unique", "nonunique"),.labels =c(unique ="Total number of patients with at least one AE",nonunique ="Total number of AEs" ),.formats =list(unique = format_count_fraction_fixed_dp, nonunique ="xx"),show_labels ="hidden" ) %>%count_patients_with_flags("USUBJID",flag_variables = aesi_vars,denom ="N_col",var_labels ="Total number of patients with at least one",show_labels ="visible" )result_adae <-build_table(lyt_adae, df = adae, alt_counts_df = adsl)# Combine tables.col_info(result_adsl) <-col_info(result_adae)result <-rbind( result_adae[1:2, ], result_adsl, result_adae[3:nrow(result_adae), ])result
A: Drug X B: Placebo C: Combination
(N=134) (N=134) (N=132)
——————————————————————————————————————————————————————————————————————————————————————————————————————
Total number of patients with at least one AE 100 (74.6%) 98 (73.1%) 103 (78.0%)
Total number of AEs 502 480 604
Total number of deaths 25 (18.7%) 23 (17.2%) 22 (16.7%)
Total number of patients withdrawn from study due to an AE 3 (2.2%) 6 (4.5%) 5 (3.8%)
Total number of patients withdrawn informed consent 1 (0.7%) 1 (0.7%) 1 (0.8%)
Total number of patients with at least one
AE with fatal outcome 5 (3.7%) 5 (3.7%) 6 (4.5%)
Serious AE 85 (63.4%) 80 (59.7%) 87 (65.9%)
AE leading to withdrawal from treatment 20 (14.9%) 24 (17.9%) 26 (19.7%)
Related AE 86 (64.2%) 85 (63.4%) 92 (69.7%)
Grade 3-5 AE 90 (67.2%) 83 (61.9%) 93 (70.5%)
Grade 4/5 AE 77 (57.5%) 70 (52.2%) 79 (59.8%)
Experimental use!
WebR is a tool allowing you to run R code in the web browser. Modify the code below and click run to see the results. Alternatively, copy the code and click here to open WebR in a new tab.
count_subj_vars <-c("FATAL", "SER", "WD", "DSM", "REL", "CTC35")count_term_vars <-c("SER", "DSM", "REL", "CTC35", "CTC45")count_ae_vars <-c("SER", "DSM", "REL", "CTC35", "CTC45")# Layout for variables from adsl dataset.lyt_adsl <-basic_table(show_colcounts =TRUE) %>%split_cols_by("ACTARM") %>%count_patients_with_event("USUBJID",filters =c("DTHFL"="Y"),denom ="N_col",.labels =c(count_fraction ="Total number of deaths") ) %>%count_patients_with_event("USUBJID",filters =c("DCSREAS"="ADVERSE EVENT"),denom ="N_col",.labels =c(count_fraction ="Total number of patients withdrawn from study due to an AE"),table_names ="tot_wd" )result_adsl <-build_table(lyt_adsl, df = adsl, alt_counts_df = adsl)# Layout for variables from adae dataset.lyt_adae <-basic_table(show_colcounts =TRUE) %>%split_cols_by("ACTARM") %>%analyze_num_patients(vars ="USUBJID",.stats =c("unique", "nonunique"),.labels =c(unique ="Total number of patients with at least one AE",nonunique ="Total number of AEs" ),.formats =list(unique = format_count_fraction_fixed_dp, nonunique ="xx"),show_labels ="hidden" ) %>%count_patients_with_flags("USUBJID",flag_variables = count_subj_vars,denom ="N_col",var_labels ="Total number of patients with at least one",show_labels ="visible" ) %>%count_patients_with_flags("AEDECOD",flag_variables = count_term_vars,.stats ="count",.formats =c(count ="xx"),table_names ="table_term",var_labels ="Total number of unique preferred terms which are",show_labels ="visible" ) %>%count_patients_with_flags("USUBJID_AESEQ",flag_variables = count_ae_vars,.stats ="count",.formats =c(count ="xx"),table_names ="table_ae",var_labels ="Total number of adverse events which are",show_labels ="visible" )result_adae <-build_table(lyt_adae, df = adae, alt_counts_df = adsl)# Combine tables.col_info(result_adsl) <-col_info(result_adae)result <-rbind( result_adae[1:2, ], result_adsl, result_adae[3:nrow(result_adae), ])result
A: Drug X B: Placebo C: Combination
(N=134) (N=134) (N=132)
——————————————————————————————————————————————————————————————————————————————————————————————————————
Total number of patients with at least one AE 100 (74.6%) 98 (73.1%) 103 (78.0%)
Total number of AEs 502 480 604
Total number of deaths 25 (18.7%) 23 (17.2%) 22 (16.7%)
Total number of patients withdrawn from study due to an AE 3 (2.2%) 6 (4.5%) 5 (3.8%)
Total number of patients with at least one
AE with fatal outcome 5 (3.7%) 5 (3.7%) 6 (4.5%)
Serious AE 85 (63.4%) 80 (59.7%) 87 (65.9%)
AE leading to withdrawal from treatment 20 (14.9%) 24 (17.9%) 26 (19.7%)
AE leading to dose modification/interruption 63 (47.0%) 70 (52.2%) 77 (58.3%)
Related AE 86 (64.2%) 85 (63.4%) 92 (69.7%)
Grade 3-5 AE 90 (67.2%) 83 (61.9%) 93 (70.5%)
Total number of unique preferred terms which are
Serious AE 4 4 4
AE leading to dose modification/interruption 10 10 10
Related AE 5 5 5
Grade 3-5 AE 5 5 5
Grade 4/5 AE 3 3 3
Total number of adverse events which are
Serious AE 204 194 245
AE leading to dose modification/interruption 123 135 158
Related AE 231 231 290
Grade 3-5 AE 249 229 277
Grade 4/5 AE 143 134 168
Experimental use!
WebR is a tool allowing you to run R code in the web browser. Modify the code below and click run to see the results. Alternatively, copy the code and click here to open WebR in a new tab.
To illustrate, additional variables such as flags (TRUE/FALSE) for select AEs of interest and select AE baskets are added to the adae dataset.
Code
library(tern)library(dplyr)adsl <- random.cdisc.data::cadsladae <- random.cdisc.data::cadae# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.adsl <-df_explicit_na(adsl)adae <-df_explicit_na( adae,omit_columns =c("SMQ01NAM", "SMQ01SC", "SMQ02NAM", "SMQ02SC", "CQ01NAM", "STUDYID", "USUBJID"))set.seed(99)adae <- adae %>%mutate(AEDECOD =with_label(as.character(AEDECOD), "Dictionary-Derived Term"),AESDTH =with_label(sample(c("N", "Y"), size =nrow(adae), replace =TRUE, prob =c(0.99, 0.01)),"Results in Death" ),AEACN =with_label(sample(c("DOSE NOT CHANGED", "DOSE INCREASED", "DRUG INTERRUPTED", "DRUG WITHDRAWN"),size =nrow(adae),replace =TRUE, prob =c(0.68, 0.02, 0.25, 0.05) ),"Action Taken with Study Treatment" ),FATAL =with_label(AESDTH =="Y", "AE with fatal outcome"),SEV =with_label(AESEV =="SEVERE", "Severe AE (at greatest intensity)"),SER =with_label(AESER =="Y", "Serious AE"),SERWD =with_label(AESER =="Y"& AEACN =="DRUG WITHDRAWN", "Serious AE leading to withdrawal from treatment"),SERDSM =with_label( AESER =="Y"& AEACN %in%c("DRUG INTERRUPTED", "DOSE INCREASED", "DOSE REDUCED"),"Serious AE leading to dose modification/interruption" ),RELSER =with_label(AESER =="Y"& AEREL =="Y", "Related Serious AE"),WD =with_label(AEACN =="DRUG WITHDRAWN", "AE leading to withdrawal from treatment"),DSM =with_label( AEACN %in%c("DRUG INTERRUPTED", "DOSE INCREASED", "DOSE REDUCED"), "AE leading to dose modification/interruption" ),REL =with_label(AEREL =="Y", "Related AE"),RELWD =with_label(AEREL =="Y"& AEACN =="DRUG WITHDRAWN", "Related AE leading to withdrawal from treatment"),RELDSM =with_label( AEREL =="Y"& AEACN %in%c("DRUG INTERRUPTED", "DOSE INCREASED", "DOSE REDUCED"),"Related AE leading to dose modification/interruption" ),CTC35 =with_label(AETOXGR %in%c("3", "4", "5"), "Grade 3-5 AE"),CTC45 =with_label(AETOXGR %in%c("4", "5"), "Grade 4/5 AE"),SMQ01 =with_label(SMQ01NAM !="", aesi_label(adae$SMQ01NAM, adae$SMQ01SC)),SMQ02 =with_label(SMQ02NAM !="", aesi_label(adae$SMQ02NAM, adae$SMQ02SC)),CQ01 =with_label(CQ01NAM !="", aesi_label(adae$CQ01NAM)),USUBJID_AESEQ =paste(USUBJID, AESEQ, sep ="@@") # Create unique ID per AE in dataset. ) %>%filter(ANL01FL =="Y")
Warning in rlang::hash(list(data = data, modules = modules)):
'package:teal.modules.clinical' may not be available when loading
Code
shinyApp(app$ui, app$server)
Experimental use!
shinylive allow you to modify to run shiny application entirely in the web browser. Modify the code below and click re-run the app to see the results. The performance is slighly worse and some of the features (e.g. downloading) might not work at all.