B: Placebo C: Combination
MedDRA SOC and Preferred Term (N=134) (N=132)
———————————————————————————————————————————————————————————
Total number of deaths 70 (52.2%) 75 (56.8%)
cl D.1 / dcd D.1.1.1.1 42 (31.3%) 51 (38.6%)
cl B.1 / dcd B.1.1.1.1 49 (36.6%) 43 (32.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.
A: Drug X B: Placebo C: Combination
MedDRA SOC and Preferred Term (N=134) (N=134) (N=132)
———————————————————————————————————————————————————————————————————————
Total number of deaths 0 70 (52.2%) 75 (56.8%)
cl D.1 / dcd D.1.1.1.1 0 42 (31.3%) 51 (38.6%)
cl B.1 / dcd B.1.1.1.1 0 49 (36.6%) 43 (32.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.
For illustrative purposes, we will pre-process AESDTH in ADAE so there are no deaths in arm A and concatenate AEBODSYS and AEDECOD as per GDSR output standards for AET07.
Code
library(dplyr)library(tern)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)adae_f <- adae %>%mutate(AESDTH =as.character(AESDTH), # characterizing AESDTH for next stepAESDTH =case_when( ARM =="A: Drug X"~NA_character_, # For demonstration purpose only,TRUE~ AESDTH ), # make "A: Drug X" as the arm without AE leading to deathAESDTH =as.factor(AESDTH),SOC_PT =factor(paste(AEBODSYS, "/", AEDECOD)) ) %>%filter(AESDTH =="Y") %>%mutate(ARM =droplevels(ARM))
library(teal.modules.clinical)## Data reproducible codedata <-teal_data()data <-within(data, {library(dplyr) ADSL <- random.cdisc.data::cadsl ADAE <- 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) ADSL <- ADSL %>%mutate(DTHFL =case_when(!is.na(DTHDT) ~"Y",TRUE~"" ) ) %>%col_relabel(DTHFL ="Subject Death Flag" ) ADAE <- ADAE %>%mutate(AESDTH =as.character(AESDTH), # characterizing AESDTH for next stepAESDTH =case_when( ARM =="A: Drug X"~NA_character_, # For demonstration purpose only,TRUE~ AESDTH ), # make "A: Drug X" as the arm without AE leading to deathAESDTH =as.factor(AESDTH),SOC_PT =factor(paste(AEBODSYS, "/", AEDECOD)) ) %>%filter(AESDTH =="Y") %>%mutate(ARM =droplevels(ARM)) %>%col_relabel(SOC_PT ="MedDRA SOC and Preferred Term")})datanames <-c("ADSL", "ADAE")datanames(data) <- datanames
Warning: `datanames<-()` was deprecated in teal.data 0.7.0.
ℹ 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://insightsengineering.r-universe.dev", getOption("webr_pkg_repos")))# -- APP CODE --library(teal.modules.clinical)## Data reproducible codedata <- teal_data()data <- within(data, { library(dplyr) ADSL <- random.cdisc.data::cadsl ADAE <- 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) ADSL <- ADSL %>% mutate( DTHFL = case_when( !is.na(DTHDT) ~ "Y", TRUE ~ "" ) ) %>% col_relabel( DTHFL = "Subject Death Flag" ) ADAE <- ADAE %>% mutate( AESDTH = as.character(AESDTH), # characterizing AESDTH for next step AESDTH = case_when( ARM == "A: Drug X" ~ NA_character_, # For demonstration purpose only, TRUE ~ AESDTH ), # make "A: Drug X" as the arm without AE leading to death AESDTH = as.factor(AESDTH), SOC_PT = factor(paste(AEBODSYS, "/", AEDECOD)) ) %>% filter(AESDTH == "Y") %>% mutate(ARM = droplevels(ARM)) %>% col_relabel(SOC_PT = "MedDRA SOC and Preferred Term")})datanames <- c("ADSL", "ADAE")datanames(data) <- datanamesjoin_keys(data) <- default_cdisc_join_keys[datanames]## Reusable Configuration For ModulesADAE <- data[["ADAE"]]## Setup Appapp <- init( data = data, modules = modules( tm_t_events( label = "Adverse Event Table", dataname = "ADAE", arm_var = choices_selected(c("ARM", "ARMCD"), "ARM"), llt = choices_selected( choices = variable_choices(ADAE, c("AETERM", "AEDECOD", "SOC_PT")), selected = c("SOC_PT") ), hlt = choices_selected( choices = variable_choices(ADAE, c("AETERM", "AEDECOD", "SOC_PT")), selected = NULL ), add_total = FALSE, event_type = "adverse event" ) ))shinyApp(app$ui, app$server)
---title: AET07subtitle: Adverse Events Resulting in Death---------------------------------------------------------------------------{{< include ../../_utils/envir_hook.qmd >}}```{r setup, echo = FALSE, warning = FALSE, message = FALSE}library(dplyr)library(tern)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)adae_f <- adae %>%mutate(AESDTH =as.character(AESDTH), # characterizing AESDTH for next stepAESDTH =case_when( ARM =="A: Drug X"~NA_character_, # For demonstration purpose only,TRUE~ AESDTH ), # make "A: Drug X" as the arm without AE leading to deathAESDTH =as.factor(AESDTH),SOC_PT =factor(paste(AEBODSYS, "/", AEDECOD)) ) %>%filter(AESDTH =="Y") %>%mutate(ARM =droplevels(ARM))``````{r include = FALSE}webr_code_labels <-c("setup")```{{< include ../../_utils/webr_no_include.qmd >}}## Output::::: panel-tabset## Standard Table::: {.panel-tabset .nav-justified group="webr"}## {{< fa regular file-lines sm fw >}} Preview```{r variant1, test = list(result_v1 = "result")}# Define the split functionsplit_fun <- drop_split_levelslyt <-basic_table(show_colcounts =TRUE) %>%split_cols_by("ACTARM", split_fun = drop_split_levels) %>%analyze_num_patients(vars ="USUBJID",.stats ="unique",.labels =c(unique ="Total number of deaths"),show_labels ="hidden" ) %>%count_occurrences(vars ="SOC_PT" ) %>%append_topleft("MedDRA SOC and Preferred Term")result <-build_table(lyt = lyt,df = adae_f,alt_counts_df = adsl) %>%prune_table() %>%sort_at_path(path ="SOC_PT",scorefun = score_occurrences,decreasing =TRUE )result``````{r include = FALSE}webr_code_labels <-c("variant1")```{{< include ../../_utils/webr.qmd >}}:::## Table with Fill-In of Treatment Groups without Deaths::: {.panel-tabset .nav-justified group="webr"}## {{< fa regular file-lines sm fw >}} Preview```{r variant2, test = list(result_v2 = "result")}lyt <-basic_table(show_colcounts =TRUE) %>%split_cols_by("ACTARM") %>%analyze_num_patients(vars ="USUBJID",.stats ="unique",.labels =c(unique ="Total number of deaths"),show_labels ="hidden" ) %>%count_occurrences(vars ="SOC_PT" ) %>%append_topleft("MedDRA SOC and Preferred Term")result <-build_table(lyt = lyt,df = adae_f,alt_counts_df = adsl) %>%prune_table() %>%sort_at_path(path ="SOC_PT",scorefun = score_occurrences,decreasing =TRUE )result``````{r include = FALSE}webr_code_labels <-c("variant2")```{{< include ../../_utils/webr.qmd >}}:::## Data SetupFor illustrative purposes, we will pre-process `AESDTH` in ADAE so there are no deaths in arm A and concatenate `AEBODSYS` and `AEDECOD` as per GDSR output standards for AET07.```{r setup}#| code-fold: show```:::::{{< include ../../_utils/save_results.qmd >}}## `teal` App::: {.panel-tabset .nav-justified}## {{< fa regular file-lines fa-sm fa-fw >}} Preview```{r teal, opts.label = c("skip_if_testing", "app")}library(teal.modules.clinical)## Data reproducible codedata <-teal_data()data <-within(data, {library(dplyr) ADSL <- random.cdisc.data::cadsl ADAE <- 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) ADSL <- ADSL %>%mutate(DTHFL =case_when(!is.na(DTHDT) ~"Y",TRUE~"" ) ) %>%col_relabel(DTHFL ="Subject Death Flag" ) ADAE <- ADAE %>%mutate(AESDTH =as.character(AESDTH), # characterizing AESDTH for next stepAESDTH =case_when( ARM =="A: Drug X"~NA_character_, # For demonstration purpose only,TRUE~ AESDTH ), # make "A: Drug X" as the arm without AE leading to deathAESDTH =as.factor(AESDTH),SOC_PT =factor(paste(AEBODSYS, "/", AEDECOD)) ) %>%filter(AESDTH =="Y") %>%mutate(ARM =droplevels(ARM)) %>%col_relabel(SOC_PT ="MedDRA SOC and Preferred Term")})datanames <-c("ADSL", "ADAE")datanames(data) <- datanamesjoin_keys(data) <- default_cdisc_join_keys[datanames]## Reusable Configuration For ModulesADAE <- data[["ADAE"]]## Setup Appapp <-init(data = data,modules =modules(tm_t_events(label ="Adverse Event Table",dataname ="ADAE",arm_var =choices_selected(c("ARM", "ARMCD"), "ARM"),llt =choices_selected(choices =variable_choices(ADAE, c("AETERM", "AEDECOD", "SOC_PT")),selected =c("SOC_PT") ),hlt =choices_selected(choices =variable_choices(ADAE, c("AETERM", "AEDECOD", "SOC_PT")),selected =NULL ),add_total =FALSE,event_type ="adverse event" ) ))shinyApp(app$ui, app$server)```{{< include ../../_utils/shinylive.qmd >}}:::{{< include ../../repro.qmd >}}