B: Placebo A: Drug X
Baseline Risk Factors Total n n Median (Months) n Median (Months) Hazard Ratio 95% Wald CI
—————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
All Patients 268 134 NA 134 NA 1.00 (0.69, 1.44)
Sex
F 161 82 NA 79 NA 0.79 (0.49, 1.28)
M 107 52 NA 55 9.6 1.39 (0.78, 2.47)
Categorical Level Biomarker 2
LOW 95 45 NA 50 9.3 1.14 (0.64, 2.02)
MEDIUM 93 56 NA 37 NA 0.97 (0.52, 1.82)
HIGH 80 33 NA 47 NA 0.97 (0.45, 2.12)
Code
# Add plot.plot <-g_forest(tbl = result)plot
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.
anl2 <- anl %>%mutate(# Recode levels of arm.ARM = forcats::fct_recode( ARM,"Placebo"="B: Placebo","Drug X"="A: Drug X" ),# Reorder levels of `SEX`.SEX = forcats::fct_relevel(SEX, "M", "F"),# Reorder levels of `STRATA1`` by frequency.STRATA1 = forcats::fct_infreq(STRATA1) )df <-extract_survival_subgroups(variables =list(tte ="AVAL", is_event ="is_event", arm ="ARM", subgroups =c("SEX", "STRATA1")),data = anl2)result <-basic_table() %>%tabulate_survival_subgroups(df = df,vars =c("n_tot", "n", "median", "hr", "ci"),time_unit = anl2$AVALU[1] )result
Placebo Drug X
Baseline Risk Factors Total n n Median (Months) n Median (Months) Hazard Ratio 95% Wald CI
———————————————————————————————————————————————————————————————————————————————————————————————————————————————
All Patients 268 134 NA 134 NA 1.00 (0.69, 1.44)
Sex
M 107 52 NA 55 9.6 1.39 (0.78, 2.47)
F 161 82 NA 79 NA 0.79 (0.49, 1.28)
Stratification Factor 1
C 94 45 NA 49 NA 0.75 (0.41, 1.38)
B 92 45 NA 47 NA 1.34 (0.71, 2.54)
A 82 44 NA 38 NA 1.02 (0.53, 1.97)
Code
plot <-g_forest(tbl = result)plot
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.
Baseline Risk Factors Total n Hazard Ratio 90% Wald CI
—————————————————————————————————————————————————————————————————————
All Patients 268 1.00 (0.74, 1.36)
Sex
F 161 0.79 (0.53, 1.19)
M 107 1.39 (0.86, 2.25)
Categorical Level Biomarker 2
LOW 95 1.14 (0.71, 1.84)
MEDIUM 93 0.97 (0.58, 1.64)
HIGH 80 0.97 (0.51, 1.87)
Code
# Add plot.plot <-g_forest(tbl = result)plot
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.
B: Placebo A: Drug X
Baseline Risk Factors Total n n Median (Months) n Median (Months) Hazard Ratio 95% Wald CI
—————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
All Patients 268 134 NA 134 NA 1.00 (0.69, 1.44)
Sex
F 161 82 NA 79 NA 0.79 (0.49, 1.28)
M 107 52 NA 55 9.6 1.39 (0.78, 2.47)
Categorical Level Biomarker 2
LOW 95 45 NA 50 9.3 1.14 (0.64, 2.02)
MEDIUM 93 56 NA 37 NA 0.97 (0.52, 1.82)
HIGH 80 33 NA 47 NA 0.97 (0.45, 2.12)
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.
Code
library(tern)library(dplyr)library(forcats)library(nestcolor)preprocess_adtte <-function(adtte) {# Save variable labels before data processing steps. adtte_labels <-var_labels(adtte) adtte <- adtte %>%df_explicit_na() %>% dplyr::filter( PARAMCD =="OS", ARM %in%c("B: Placebo", "A: Drug X"), SEX %in%c("M", "F") ) %>% dplyr::mutate(# Reorder levels of ARM to display reference arm before treatment arm.ARM =droplevels(forcats::fct_relevel(ARM, "B: Placebo")),SEX =droplevels(SEX),is_event = CNSR ==0,# Convert time to MONTHAVAL =day2month(AVAL),AVALU ="Months" ) %>%var_relabel(ARM = adtte_labels["ARM"],SEX = adtte_labels["SEX"],is_event ="Event Flag",AVAL = adtte_labels["AVAL"],AVALU = adtte_labels["AVALU"] ) adtte}anl <- random.cdisc.data::cadtte %>%preprocess_adtte()
library(teal.modules.clinical)## Data reproducible codedata <-teal_data()data <-within(data, {library(dplyr)library(forcats) ADSL <- random.cdisc.data::cadsl ADSL <- ADSL %>%filter(ARM %in%c("B: Placebo", "A: Drug X")) %>%mutate(ARM =droplevels(fct_relevel(ARM, "B: Placebo"))) %>%mutate(ARMCD =droplevels(fct_relevel(ARMCD, "ARM B"))) ADSL$RACE <-droplevels(ADSL$RACE) ADTTE <- random.cdisc.data::cadtte adtte_labels <-col_labels(ADTTE) ADTTE <- ADTTE %>%filter( PARAMCD =="OS", ARM %in%c("B: Placebo", "A: Drug X"), SEX %in%c("M", "F") ) %>%mutate(# Reorder levels of ARM to display reference arm before treatment arm.ARM =droplevels(fct_relevel(ARM, "B: Placebo")),SEX =droplevels(SEX),is_event = CNSR ==0,# Convert time to MONTHAVAL =day2month(AVAL),AVALU ="Months" ) %>%col_relabel(ARM = adtte_labels["ARM"],SEX = adtte_labels["SEX"],is_event ="Event Flag",AVAL = adtte_labels["AVAL"],AVALU = adtte_labels["AVALU"] )})datanames <-c("ADSL", "ADTTE")datanames(data) <- datanames
Warning: `datanames<-()` was deprecated in teal.data 0.6.1.
ℹ invalid to use `datanames()<-` or `names()<-` on an object of class
`teal_data`. See ?names.teal_data
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.
#| '!! shinylive warning !!': |#| shinylive does not work in self-contained HTML documents.#| Please set `embed-resources: false` in your metadata.#| standalone: true#| viewerHeight: 800#| editorHeight: 200#| components: [viewer, editor]#| layout: vertical# -- WEBR HELPERS --options(webr_pkg_repos = c("r-universe" = "https://pharmaverse.r-universe.dev", getOption("webr_pkg_repos")))# -- APP CODE --library(teal.modules.clinical)## Data reproducible codedata <- teal_data()data <- within(data, { library(dplyr) library(forcats) ADSL <- random.cdisc.data::cadsl ADSL <- ADSL %>% filter(ARM %in% c("B: Placebo", "A: Drug X")) %>% mutate(ARM = droplevels(fct_relevel(ARM, "B: Placebo"))) %>% mutate(ARMCD = droplevels(fct_relevel(ARMCD, "ARM B"))) ADSL$RACE <- droplevels(ADSL$RACE) ADTTE <- random.cdisc.data::cadtte adtte_labels <- col_labels(ADTTE) ADTTE <- ADTTE %>% filter( PARAMCD == "OS", ARM %in% c("B: Placebo", "A: Drug X"), SEX %in% c("M", "F") ) %>% mutate( # Reorder levels of ARM to display reference arm before treatment arm. ARM = droplevels(fct_relevel(ARM, "B: Placebo")), SEX = droplevels(SEX), is_event = CNSR == 0, # Convert time to MONTH AVAL = day2month(AVAL), AVALU = "Months" ) %>% col_relabel( ARM = adtte_labels["ARM"], SEX = adtte_labels["SEX"], is_event = "Event Flag", AVAL = adtte_labels["AVAL"], AVALU = adtte_labels["AVALU"] )})datanames <- c("ADSL", "ADTTE")datanames(data) <- datanamesjoin_keys(data) <- default_cdisc_join_keys[datanames]## Reusable Configuration For ModulesADSL <- data[["ADSL"]]ADTTE <- data[["ADTTE"]]## Setup Appapp <- init( data = data, modules = modules( tm_g_forest_tte( label = "Forest Survival", dataname = "ADTTE", arm_var = choices_selected(c("ARM", "ARMCD"), "ARM"), subgroup_var = choices_selected(names(ADSL), c("SEX", "BMRKR2")), paramcd = choices_selected(value_choices(ADTTE, "PARAMCD", "PARAM"), "OS"), strata_var = choices_selected(c("STRATA1", "STRATA2"), "STRATA2"), plot_height = c(600, 200, 2000), plot_width = c(1500, 200, 5000) ) ))shinyApp(app$ui, app$server)