-
-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add decorators to all TMC modules #1371
Comments
This was referenced Nov 26, 2024
This was referenced Nov 27, 2024
This was referenced Nov 28, 2024
m7pr
added a commit
to insightsengineering/teal.modules.clinical
that referenced
this issue
Nov 28, 2024
Part of insightsengineering/teal#1371 WIP <details> <summary> Example with decorator </summary> ```r devtools::load_all("../teal") devtools::load_all(".") library(nestcolor) data <- teal_data() data <- within(data, { ADSL <- tmc_ex_adsl ADLB <- tmc_ex_adlb }) join_keys(data) <- default_cdisc_join_keys[names(data)] ADSL <- data[["ADSL"]] ADLB <- data[["ADLB"]] caption_decorator <- function(default_caption = "I am a good decorator", .var_to_replace = "plot") { teal_transform_module( label = "Caption", ui = function(id) shiny::textInput(shiny::NS(id, "footnote"), "Footnote", value = default_caption), server = make_teal_transform_server( substitute({ .var_to_replace <- .var_to_replace + ggplot2::labs(caption = footnote) }, env = list(.var_to_replace = as.name(.var_to_replace))) ) ) } app <- init( data = data, modules = modules( tm_g_ci( label = "Confidence Interval Plot", x_var = data_extract_spec( dataname = "ADSL", select = select_spec( choices = c("ARMCD", "BMRKR2"), selected = c("ARMCD"), multiple = FALSE, fixed = FALSE ) ), y_var = data_extract_spec( dataname = "ADLB", filter = list( filter_spec( vars = "PARAMCD", choices = levels(ADLB$PARAMCD), selected = levels(ADLB$PARAMCD)[1], multiple = FALSE, label = "Select lab:" ), filter_spec( vars = "AVISIT", choices = levels(ADLB$AVISIT), selected = levels(ADLB$AVISIT)[1], multiple = FALSE, label = "Select visit:" ) ), select = select_spec( label = "Analyzed Value", choices = c("AVAL", "CHG"), selected = "AVAL", multiple = FALSE, fixed = FALSE ) ), color = data_extract_spec( dataname = "ADSL", select = select_spec( label = "Color by variable", choices = c("SEX", "STRATA1", "STRATA2"), selected = c("STRATA1"), multiple = FALSE, fixed = FALSE ) ), decorators = list(caption_decorator(.var_to_replace = "plot")) ) ) ) shinyApp(app$ui, app$server) ``` </details> --------- Co-authored-by: Marcin <133694481+m7pr@users.noreply.github.com> Co-authored-by: m7pr <marcin.kosinski.mk1@roche.com>
m7pr
added a commit
to insightsengineering/teal.modules.clinical
that referenced
this issue
Nov 28, 2024
Part of insightsengineering/teal#1371 This module also returns a plot from `cowplot`, and I am not sure if the example I got works well (I am not that familiar with it). <details> <summary>Draft of an example</summary> ````r devtools::load_all("../teal.reporter") devtools::load_all("../teal") devtools::load_all(".") library(nestcolor) library(dplyr) caption_decorator <- function(annotation = "I am a good decorator", var_to_decorate = "plot") { teal_transform_module( label = "Annotation", ui = function(id) shiny::textInput(shiny::NS(id, "annotation"), "Annotation", value = annotation), server = make_teal_transform_server( substitute({ var_to_decorate <- cowplot::add_sub(var_to_decorate, annotation) }, env = list(var_to_decorate = as.name(var_to_decorate))) ) ) } data <- teal_data() data <- within(data, { ADSL <- tmc_ex_adsl ADRS <- tmc_ex_adrs %>% mutate(AVALC = d_onco_rsp_label(AVALC) %>% with_label("Character Result/Finding")) %>% filter(PARAMCD != "OVRINV" | AVISIT == "FOLLOW UP") }) join_keys(data) <- default_cdisc_join_keys[names(data)] ADSL <- data[["ADSL"]] ADRS <- data[["ADRS"]] arm_ref_comp <- list( ARM = list( ref = "B: Placebo", comp = c("A: Drug X", "C: Combination") ), ARMCD = list( ref = "ARM B", comp = c("ARM A", "ARM C") ) ) app <- init( data = data, modules = modules( tm_g_forest_rsp( label = "Forest Response", dataname = "ADRS", arm_var = choices_selected( variable_choices(ADSL, c("ARM", "ARMCD")), "ARMCD" ), arm_ref_comp = arm_ref_comp, paramcd = choices_selected( value_choices(ADRS, "PARAMCD", "PARAM"), "INVET" ), subgroup_var = choices_selected( variable_choices(ADSL, names(ADSL)), c("BMRKR2", "SEX") ), strata_var = choices_selected( variable_choices(ADSL, c("STRATA1", "STRATA2")), "STRATA2" ), plot_height = c(600L, 200L, 2000L), default_responses = list( BESRSPI = list( rsp = c("Stable Disease (SD)", "Not Evaluable (NE)"), levels = c( "Complete Response (CR)", "Partial Response (PR)", "Stable Disease (SD)", "Progressive Disease (PD)", "Not Evaluable (NE)" ) ), INVET = list( rsp = c("Complete Response (CR)", "Partial Response (PR)"), levels = c( "Complete Response (CR)", "Not Evaluable (NE)", "Partial Response (PR)", "Progressive Disease (PD)", "Stable Disease (SD)" ) ), OVRINV = list( rsp = c("Progressive Disease (PD)", "Stable Disease (SD)"), levels = c("Progressive Disease (PD)", "Stable Disease (SD)", "Not Evaluable (NE)") ) ), decorators = list(caption_decorator()) ) ) ) shinyApp(app$ui, app$server) ``` </details> --------- Co-authored-by: Marcin <133694481+m7pr@users.noreply.github.com> Co-authored-by: m7pr <marcin.kosinski.mk1@roche.com>
m7pr
added a commit
to insightsengineering/teal.modules.clinical
that referenced
this issue
Nov 28, 2024
Part of insightsengineering/teal#1371 <details><summary> Working Example </summary> ```r devtools::load_all("../teal.reporter") devtools::load_all("../teal") devtools::load_all(".") library(nestcolor) library(dplyr) caption_decorator <- function(annotation = "I am a good decorator", var_to_decorate = "plot") { teal_transform_module( label = "Annotation", ui = function(id) shiny::textInput(shiny::NS(id, "annotation"), "Annotation", value = annotation), server = make_teal_transform_server( substitute({ var_to_decorate <- cowplot::add_sub(var_to_decorate, annotation) }, env = list(var_to_decorate = as.name(var_to_decorate))) ) ) } data <- teal_data() data <- within(data, { ADSL <- tmc_ex_adsl ADTTE <- tmc_ex_adtte ADSL$RACE <- droplevels(ADSL$RACE) %>% with_label("Race") }) join_keys(data) <- default_cdisc_join_keys[names(data)] ADSL <- data[["ADSL"]] ADTTE <- data[["ADTTE"]] arm_ref_comp <- list( ARM = list( ref = "B: Placebo", comp = c("A: Drug X", "C: Combination") ), ARMCD = list( ref = "ARM B", comp = c("ARM A", "ARM C") ) ) app <- init( data = data, modules = modules( tm_g_forest_tte( label = "Forest Survival", dataname = "ADTTE", arm_var = choices_selected( variable_choices(ADSL, c("ARM", "ARMCD")), "ARMCD" ), arm_ref_comp = arm_ref_comp, paramcd = choices_selected( value_choices(ADTTE, "PARAMCD", "PARAM"), "OS" ), subgroup_var = choices_selected( variable_choices(ADSL, names(ADSL)), c("BMRKR2", "SEX") ), strata_var = choices_selected( variable_choices(ADSL, c("STRATA1", "STRATA2")), "STRATA2" ), decorators = list(caption_decorator()) ) ) ) shinyApp(app$ui, app$server) ``` </details>
m7pr
added a commit
to insightsengineering/teal.modules.clinical
that referenced
this issue
Nov 28, 2024
Part of insightsengineering/teal#1371 Alternative to #1259 <details><summary> Working Example </summary> ```r devtools::load_all("../teal.reporter") devtools::load_all("../teal") devtools::load_all(".") insert_rrow_decorator <- function(default_caption = "I am a good new row", .var_to_replace = "table") { teal_transform_module( label = "New row", ui = function(id) shiny::textInput(shiny::NS(id, "new_row"), "New row", value = default_caption), server = make_teal_transform_server( substitute({ .var_to_replace <- rtables::insert_rrow(.var_to_replace, rtables::rrow(new_row)) }, env = list(.var_to_replace = as.name(.var_to_replace))) ) ) } library(dplyr) data <- teal_data() data <- within(data, { ADSL <- tmc_ex_adsl ADQS <- tmc_ex_adqs %>% filter(ABLFL != "Y" & ABLFL2 != "Y") %>% mutate( AVISIT = as.factor(AVISIT), AVISITN = rank(AVISITN) %>% as.factor() %>% as.numeric() %>% as.factor(), AVALBIN = AVAL < 50 # Just as an example to get a binary endpoint. ) %>% droplevels() }) join_keys(data) <- default_cdisc_join_keys[names(data)] app <- init( data = data, modules = modules( tm_a_gee( label = "GEE", dataname = "ADQS", aval_var = choices_selected("AVALBIN", fixed = TRUE), id_var = choices_selected(c("USUBJID", "SUBJID"), "USUBJID"), arm_var = choices_selected(c("ARM", "ARMCD"), "ARM"), visit_var = choices_selected(c("AVISIT", "AVISITN"), "AVISIT"), paramcd = choices_selected( choices = value_choices(data[["ADQS"]], "PARAMCD", "PARAM"), selected = "FKSI-FWB" ), cov_var = choices_selected(c("BASE", "AGE", "SEX", "BASE:AVISIT"), NULL), decorators = list(insert_rrow_decorator("Hello world", "table")) ) ) ) if (interactive()) { shinyApp(app$ui, app$server) } ``` </details>
m7pr
added a commit
to insightsengineering/teal.modules.clinical
that referenced
this issue
Nov 28, 2024
Part of insightsengineering/teal#1371 <details><summary> Working Example </summary> ```r devtools::load_all("../teal") devtools::load_all(".") library(nestcolor) library(dplyr) data <- teal_data() data <- within(data, { ADSL <- tmc_ex_adsl %>% slice(1:20) %>% df_explicit_na() ADLB <- tmc_ex_adlb %>% filter(USUBJID %in% ADSL$USUBJID) %>% df_explicit_na() %>% filter(AVISIT != "SCREENING") }) join_keys(data) <- default_cdisc_join_keys[names(data)] ADSL <- data[["ADSL"]] ADLB <- data[["ADLB"]] caption_decorator <- function(default_caption = "I am a good decorator", .var_to_replace = "plot") { teal_transform_module( label = "Caption", ui = function(id) shiny::textInput(shiny::NS(id, "footnote"), "Footnote", value = default_caption), server = make_teal_transform_server( substitute({ .var_to_replace <- .var_to_replace + ggplot2::labs(caption = footnote) }, env = list(.var_to_replace = as.name(.var_to_replace))) ) ) } app <- init( data = data, modules = modules( tm_g_ipp( label = "Individual Patient Plot", dataname = "ADLB", arm_var = choices_selected( value_choices(ADLB, "ARMCD"), "ARM A" ), paramcd = choices_selected( value_choices(ADLB, "PARAMCD"), "ALT" ), aval_var = choices_selected( variable_choices(ADLB, c("AVAL", "CHG")), "AVAL" ), avalu_var = choices_selected( variable_choices(ADLB, c("AVALU")), "AVALU", fixed = TRUE ), id_var = choices_selected( variable_choices(ADLB, c("USUBJID")), "USUBJID", fixed = TRUE ), visit_var = choices_selected( variable_choices(ADLB, c("AVISIT")), "AVISIT" ), baseline_var = choices_selected( variable_choices(ADLB, c("BASE")), "BASE", fixed = TRUE ), add_baseline_hline = FALSE, separate_by_obs = FALSE, decorators = list(caption_decorator(.var_to_replace = "plot")) ) ) ) if (interactive()) { shinyApp(app$ui, app$server) } ``` </details>
This was referenced Nov 28, 2024
m7pr
added a commit
to insightsengineering/teal.modules.clinical
that referenced
this issue
Nov 29, 2024
Part of insightsengineering/teal#1371 <details> <summary>Example using cowplot::add_sub with ggplot2</summary> ```r devtools::load_all("../teal.modules.general") devtools::load_all("../teal.reporter") devtools::load_all("../teal") devtools::load_all(".") library(nestcolor) library(dplyr) data <- teal_data() data <- within(data, { ADAE <- tmc_ex_adae ADSL <- tmc_ex_adsl %>% filter(USUBJID %in% ADAE$USUBJID) ADCM <- tmc_ex_adcm %>% mutate( CMSTDY = case_when( CMCAT == "medcl B" ~ 20, CMCAT == "medcl C" ~ 150, TRUE ~ 1 ) %>% with_label("Study Day of Start of Medication"), CMENDY = case_when( CMCAT == "medcl B" ~ 700, CMCAT == "medcl C" ~ 1000, TRUE ~ 500 ) %>% with_label("Study Day of End of Medication"), CMASTDTM = ASTDTM, CMAENDTM = AENDTM ) }) join_keys(data) <- default_cdisc_join_keys[c("ADSL", "ADAE", "ADCM")] adcm_keys <- c("STUDYID", "USUBJID", "ASTDTM", "CMSEQ", "ATC1", "ATC2", "ATC3", "ATC4") join_keys(data)["ADCM", "ADCM"] <- adcm_keys join_keys(data)["ADAE", "ADCM"] <- c("STUDYID", "USUBJID") caption_decorator <- function(annotation = "I am a good decorator", var_to_decorate = "plot") { teal_transform_module( label = "Annotation", ui = function(id) shiny::textInput(shiny::NS(id, "annotation"), "Annotation", value = annotation), server = make_teal_transform_server( substitute({ var_to_decorate <- cowplot::add_sub(var_to_decorate, annotation) }, env = list(var_to_decorate = as.name(var_to_decorate))) ) ) } app <- init( data = data, modules = modules( tm_g_pp_patient_timeline( label = "Patient Timeline", dataname_adae = "ADAE", dataname_adcm = "ADCM", parentname = "ADSL", patient_col = "USUBJID", plot_height = c(600L, 200L, 2000L), cmdecod = choices_selected( choices = variable_choices(data[["ADCM"]], "CMDECOD"), selected = "CMDECOD", ), aeterm = choices_selected( choices = variable_choices(data[["ADAE"]], "AETERM"), selected = c("AETERM") ), aetime_start = choices_selected( choices = variable_choices(data[["ADAE"]], "ASTDTM"), selected = c("ASTDTM") ), aetime_end = choices_selected( choices = variable_choices(data[["ADAE"]], "AENDTM"), selected = c("AENDTM") ), dstime_start = choices_selected( choices = variable_choices(data[["ADCM"]], "CMASTDTM"), selected = c("CMASTDTM") ), dstime_end = choices_selected( choices = variable_choices(data[["ADCM"]], "CMAENDTM"), selected = c("CMAENDTM") ), aerelday_start = choices_selected( choices = variable_choices(data[["ADAE"]], "ASTDY"), selected = c("ASTDY") ), aerelday_end = choices_selected( choices = variable_choices(data[["ADAE"]], "AENDY"), selected = c("AENDY") ), dsrelday_start = choices_selected( choices = variable_choices(data[["ADCM"]], "ASTDY"), selected = c("ASTDY") ), dsrelday_end = choices_selected( choices = variable_choices(data[["ADCM"]], "AENDY"), selected = c("AENDY") ), decorators = list(caption_decorator()) ) ) ) shinyApp(app$ui, app$server) ``` </details> --------- Co-authored-by: m7pr <marcin.kosinski.mk1@roche.com>
m7pr
added a commit
to insightsengineering/teal.modules.clinical
that referenced
this issue
Nov 29, 2024
Part of insightsengineering/teal#1371 <details><summary> Working Example </summary> ```r devtools::load_all("../teal.reporter") devtools::load_all("../teal") devtools::load_all(".") library(nestcolor) library(dplyr) data <- teal_data() data <- within(data, { ADCM <- tmc_ex_adcm ADSL <- tmc_ex_adsl %>% filter(USUBJID %in% ADCM$USUBJID) ADCM$CMASTDTM <- ADCM$ASTDTM ADCM$CMAENDTM <- ADCM$AENDTM }) join_keys(data) <- default_cdisc_join_keys[c("ADSL", "ADCM")] adcm_keys <- c("STUDYID", "USUBJID", "ASTDTM", "CMSEQ", "ATC1", "ATC2", "ATC3", "ATC4") join_keys(data)["ADCM", "ADCM"] <- adcm_keys ADSL <- data[["ADSL"]] ADCM <- data[["ADCM"]] caption_decorator <- function(default_caption = "I am a good decorator", .var_to_replace = "plot") { teal_transform_module( label = "Caption", ui = function(id) shiny::textInput(shiny::NS(id, "footnote"), "Footnote", value = default_caption), server = make_teal_transform_server( substitute({ .var_to_replace <- .var_to_replace + ggplot2::labs(caption = footnote) }, env = list(.var_to_replace = as.name(.var_to_replace))) ) ) } head_decorator <- function(default_value = 6, .var_to_replace = "object") { teal_transform_module( label = "Head", ui = function(id) shiny::numericInput(shiny::NS(id, "n"), "N rows", value = default_value), server = make_teal_transform_server( substitute({ .var_to_replace <- utils::head(.var_to_replace, n = n) }, env = list(.var_to_replace = as.name(.var_to_replace))) ) ) } app <- init( data = data, modules = modules( tm_g_pp_therapy( label = "Therapy", dataname = "ADCM", parentname = "ADSL", patient_col = "USUBJID", plot_height = c(600L, 200L, 2000L), atirel = choices_selected( choices = variable_choices(ADCM, "ATIREL"), selected = c("ATIREL") ), cmdecod = choices_selected( choices = variable_choices(ADCM, "CMDECOD"), selected = "CMDECOD" ), cmindc = choices_selected( choices = variable_choices(ADCM, "CMINDC"), selected = "CMINDC" ), cmdose = choices_selected( choices = variable_choices(ADCM, "CMDOSE"), selected = "CMDOSE" ), cmtrt = choices_selected( choices = variable_choices(ADCM, "CMTRT"), selected = "CMTRT" ), cmdosu = choices_selected( choices = variable_choices(ADCM, "CMDOSU"), selected = c("CMDOSU") ), cmroute = choices_selected( choices = variable_choices(ADCM, "CMROUTE"), selected = "CMROUTE" ), cmdosfrq = choices_selected( choices = variable_choices(ADCM, "CMDOSFRQ"), selected = "CMDOSFRQ" ), cmstdy = choices_selected( choices = variable_choices(ADCM, "ASTDY"), selected = "ASTDY" ), cmendy = choices_selected( choices = variable_choices(ADCM, "AENDY"), selected = "AENDY" ), decorators = list(plot = caption_decorator('Marcin', 'plot'), table = head_decorator(2, 'table')) ) ) ) if (interactive()) { shinyApp(app$ui, app$server) } ``` </details>
m7pr
added a commit
to insightsengineering/teal.modules.clinical
that referenced
this issue
Nov 29, 2024
Part of insightsengineering/teal#1371 <details><summary> Working Example </summary> ```r devtools::load_all("../teal") devtools::load_all(".") library(nestcolor) data <- teal_data() data <- within(data, { ADSL <- tmc_ex_adsl ADVS <- tmc_ex_advs }) join_keys(data) <- default_cdisc_join_keys[names(data)] ADSL <- data[["ADSL"]] ADVS <- data[["ADVS"]] change_theme_decorator <- function(default_check = TRUE, .var_to_replace = "plot") { teal_transform_module( label = "Theme", server = make_teal_transform_server( substitute({ .var_to_replace <- .var_to_replace + ggplot2::theme_void() }, env = list(.var_to_replace = as.name(.var_to_replace)) ) ) ) } app <- init( data = data, modules = modules( tm_g_pp_vitals( label = "Vitals", dataname = "ADVS", parentname = "ADSL", patient_col = "USUBJID", plot_height = c(600L, 200L, 2000L), paramcd = choices_selected( choices = variable_choices(ADVS, "PARAMCD"), selected = "PARAMCD" ), xaxis = choices_selected( choices = variable_choices(ADVS, "ADY"), selected = "ADY" ), aval_var = choices_selected( choices = variable_choices(ADVS, "AVAL"), selected = "AVAL" )#, #decorators = list(plot = change_theme_decorator(TRUE, "plot")) ) ) ) if (interactive()) { shinyApp(app$ui, app$server) }devtools::load_all("../teal") devtools::load_all(".") library(nestcolor) library(dplyr) library(forcats) data <- teal_data() data <- within(data, { ADSL <- tmc_ex_adsl ADLB <- tmc_ex_adlb %>% mutate(AVISIT == fct_reorder(AVISIT, AVISITN, min)) }) join_keys(data) <- default_cdisc_join_keys[names(data)] ADSL <- data[["ADSL"]] ADLB <- data[["ADLB"]] change_theme_decorator <- function(default_check = TRUE, .var_to_replace = "plot") { teal_transform_module( label = "Theme", server = make_teal_transform_server( substitute({ .var_to_replace <- .var_to_replace + ggplot2::theme_void() }, env = list(.var_to_replace = as.name(.var_to_replace)) ) ) ) } app <- init( data = data, modules = modules( tm_g_lineplot( label = "Line Plot", dataname = "ADLB", strata = choices_selected( variable_choices(ADSL, c("ARM", "ARMCD", "ACTARMCD")), "ARM" ), y = choices_selected( variable_choices(ADLB, c("AVAL", "BASE", "CHG", "PCHG")), "AVAL" ), param = choices_selected( value_choices(ADLB, "PARAMCD", "PARAM"), "ALT" ), decorators = list(plot = change_theme_decorator(TRUE, "plot")) ) ) ) if (interactive()) { shinyApp(app$ui, app$server) } ``` </details> --------- Co-authored-by: André Veríssimo <211358+averissimo@users.noreply.github.com>
m7pr
added a commit
to insightsengineering/teal.modules.clinical
that referenced
this issue
Nov 29, 2024
Part of insightsengineering/teal#1371 <details><summary> Working Example </summary> ```r devtools::load_all("../teal") devtools::load_all(".") insert_rrow_decorator <- function(default_caption = "I am a good new row", .var_to_replace = "table") { teal_transform_module( label = "New row", ui = function(id) shiny::textInput(shiny::NS(id, "new_row"), "New row", value = default_caption), server = make_teal_transform_server( substitute({ .var_to_replace <- rtables::insert_rrow(.var_to_replace, rtables::rrow(new_row)) }, env = list(.var_to_replace = as.name(.var_to_replace))) ) ) } library(dplyr) data <- teal_data() data <- within(data, { ADSL <- tmc_ex_adsl ADLB <- tmc_ex_adlb %>% mutate( ONTRTFL = case_when( AVISIT %in% c("SCREENING", "BASELINE") ~ "", TRUE ~ "Y" ) %>% with_label("On Treatment Record Flag") ) }) join_keys(data) <- default_cdisc_join_keys[names(data)] ADSL <- data[["ADSL"]] ADLB <- data[["ADLB"]] app <- init( data = data, modules = modules( tm_t_abnormality( label = "Abnormality Table", dataname = "ADLB", arm_var = choices_selected( choices = variable_choices(ADSL, subset = c("ARM", "ARMCD")), selected = "ARM" ), add_total = FALSE, by_vars = choices_selected( choices = variable_choices(ADLB, subset = c("LBCAT", "PARAM", "AVISIT")), selected = c("LBCAT", "PARAM"), keep_order = TRUE ), baseline_var = choices_selected( variable_choices(ADLB, subset = "BNRIND"), selected = "BNRIND", fixed = TRUE ), grade = choices_selected( choices = variable_choices(ADLB, subset = "ANRIND"), selected = "ANRIND", fixed = TRUE ), abnormal = list(low = "LOW", high = "HIGH"), exclude_base_abn = FALSE, decorators = list(insert_rrow_decorator("I am a good new row")) ) ) ) if (interactive()) { shinyApp(app$ui, app$server) } ``` </details> --------- Co-authored-by: Lluís Revilla <185338939+llrs-roche@users.noreply.github.com> Co-authored-by: André Veríssimo <211358+averissimo@users.noreply.github.com>
m7pr
added a commit
to insightsengineering/teal.modules.clinical
that referenced
this issue
Nov 29, 2024
Part of insightsengineering/teal#1371 <details><summary> Working Example </summary> ```r devtools::load_all("../teal") devtools::load_all(".") library(nestcolor) data <- teal_data() data <- within(data, { ADSL <- tmc_ex_adsl ADTTE <- tmc_ex_adtte }) join_keys(data) <- default_cdisc_join_keys[names(data)] ADSL <- data[["ADSL"]] ADTTE <- data[["ADTTE"]] arm_ref_comp <- list( ACTARMCD = list( ref = "ARM B", comp = c("ARM A", "ARM C") ), ARM = list( ref = "B: Placebo", comp = c("A: Drug X", "C: Combination") ) ) change_theme_decorator <- function(default_check = TRUE, .var_to_replace = "plot") { teal_transform_module( label = "Theme", server = make_teal_transform_server( substitute({ .var_to_replace <- .var_to_replace + ggplot2::theme_void() }, env = list(.var_to_replace = as.name(.var_to_replace)) ) ) ) } app <- init( data = data, modules = modules( tm_g_km( label = "Kaplan-Meier Plot", dataname = "ADTTE", arm_var = choices_selected( variable_choices(ADSL, c("ARM", "ARMCD", "ACTARMCD")), "ARM" ), paramcd = choices_selected( value_choices(ADTTE, "PARAMCD", "PARAM"), "OS" ), arm_ref_comp = arm_ref_comp, strata_var = choices_selected( variable_choices(ADSL, c("SEX", "BMRKR2")), "SEX" ), facet_var = choices_selected( variable_choices(ADSL, c("SEX", "BMRKR2")), NULL ), decorators = list(plot = change_theme_decorator(TRUE, "plot")) ) ) ) if (interactive()) { shinyApp(app$ui, app$server) } ``` </details> --------- Co-authored-by: André Veríssimo <211358+averissimo@users.noreply.github.com>
m7pr
added a commit
to insightsengineering/teal.modules.clinical
that referenced
this issue
Nov 29, 2024
Part of insightsengineering/teal#1371 <details><summary> Working Example </summary> ```r devtools::load_all("../teal") devtools::load_all(".") library(nestcolor) library(dplyr) library(forcats) data <- teal_data() data <- within(data, { ADSL <- tmc_ex_adsl ADLB <- tmc_ex_adlb %>% mutate(AVISIT == fct_reorder(AVISIT, AVISITN, min)) }) join_keys(data) <- default_cdisc_join_keys[names(data)] ADSL <- data[["ADSL"]] ADLB <- data[["ADLB"]] change_theme_decorator <- function(default_check = TRUE, .var_to_replace = "plot") { teal_transform_module( label = "Theme", server = make_teal_transform_server( substitute({ .var_to_replace <- .var_to_replace + ggplot2::theme_void() }, env = list(.var_to_replace = as.name(.var_to_replace)) ) ) ) } app <- init( data = data, modules = modules( tm_g_lineplot( label = "Line Plot", dataname = "ADLB", strata = choices_selected( variable_choices(ADSL, c("ARM", "ARMCD", "ACTARMCD")), "ARM" ), y = choices_selected( variable_choices(ADLB, c("AVAL", "BASE", "CHG", "PCHG")), "AVAL" ), param = choices_selected( value_choices(ADLB, "PARAMCD", "PARAM"), "ALT" ), decorators = list(plot = change_theme_decorator(TRUE, "plot")) ) ) ) if (interactive()) { shinyApp(app$ui, app$server) } ``` </details> --------- Signed-off-by: Marcin <133694481+m7pr@users.noreply.github.com> Co-authored-by: André Veríssimo <211358+averissimo@users.noreply.github.com>
m7pr
added a commit
to insightsengineering/teal.modules.clinical
that referenced
this issue
Nov 29, 2024
Part of insightsengineering/teal#1371 <details><summary> Working Example </summary> ```r devtools::load_all("../teal") devtools::load_all(".") insert_rrow_decorator <- function(default_caption = "I am a good new row", .var_to_replace = "table") { teal_transform_module( label = "New row", ui = function(id) shiny::textInput(shiny::NS(id, "new_row"), "New row", value = default_caption), server = make_teal_transform_server( substitute({ .var_to_replace <- rtables::insert_rrow(.var_to_replace, rtables::rrow(new_row)) }, env = list(.var_to_replace = as.name(.var_to_replace))) ) ) } data <- teal_data() data <- within(data, { ADSL <- tmc_ex_adsl ADQS <- tmc_ex_adqs }) join_keys(data) <- default_cdisc_join_keys[names(data)] ADSL <- data[["ADSL"]] ADQS <- data[["ADQS"]] arm_ref_comp <- list( ARM = list( ref = "B: Placebo", comp = c("A: Drug X", "C: Combination") ), ACTARMCD = list( ref = "ARM B", comp = c("ARM A", "ARM C") ) ) app <- init( data = data, modules = modules( tm_t_ancova( label = "ANCOVA Table", dataname = "ADQS", avisit = choices_selected( choices = value_choices(ADQS, "AVISIT"), selected = "WEEK 1 DAY 8" ), arm_var = choices_selected( choices = variable_choices(ADSL, c("ARM", "ACTARMCD", "ARMCD")), selected = "ARMCD" ), arm_ref_comp = arm_ref_comp, aval_var = choices_selected( choices = variable_choices(ADQS, c("CHG", "AVAL")), selected = "CHG" ), cov_var = choices_selected( choices = variable_choices(ADQS, c("BASE", "STRATA1", "SEX")), selected = "STRATA1" ), paramcd = choices_selected( choices = value_choices(ADQS, "PARAMCD", "PARAM"), selected = "FKSI-FWB" ), interact_var = choices_selected( choices = variable_choices(ADQS, c("BASE", "STRATA1", "SEX")), selected = "STRATA1" ), decorators = list(insert_rrow_decorator("I am a good new row")) ) ) ) if (interactive()) { shinyApp(app$ui, app$server) } ``` </details> --------- Co-authored-by: André Veríssimo <211358+averissimo@users.noreply.github.com> Co-authored-by: Lluís Revilla <185338939+llrs-roche@users.noreply.github.com>
m7pr
added a commit
to insightsengineering/teal.modules.clinical
that referenced
this issue
Nov 29, 2024
Part of insightsengineering/teal#1371 <details><summary> Working Example </summary> ```r devtools::load_all("../teal") devtools::load_all(".") insert_rrow_decorator <- function(default_caption = "I am a good new row", .var_to_replace = "table") { teal_transform_module( label = "New row", ui = function(id) shiny::textInput(shiny::NS(id, "new_row"), "New row", value = default_caption), server = make_teal_transform_server( substitute({ .var_to_replace <- rtables::insert_rrow(.var_to_replace, rtables::rrow(new_row)) }, env = list(.var_to_replace = as.name(.var_to_replace))) ) ) } library(dplyr) data <- teal_data() data <- within(data, { ADSL <- tmc_ex_adsl ADLB <- tmc_ex_adlb %>% filter(!AVISIT %in% c("SCREENING", "BASELINE")) }) join_keys(data) <- default_cdisc_join_keys[names(data)] ADSL <- data[["ADSL"]] ADLB <- data[["ADLB"]] app <- init( data = data, modules = modules( tm_t_abnormality_by_worst_grade( label = "Laboratory Test Results with Highest Grade Post-Baseline", dataname = "ADLB", arm_var = choices_selected( choices = variable_choices(ADSL, subset = c("ARM", "ARMCD")), selected = "ARM" ), paramcd = choices_selected( choices = value_choices(ADLB, "PARAMCD", "PARAM"), selected = c("ALT", "CRP", "IGA") ), add_total = FALSE, decorators = list(insert_rrow_decorator("I am a good new row")) ) ), filter = teal_slices( teal_slice("ADSL", "SAFFL", selected = "Y"), teal_slice("ADLB", "ONTRTFL", selected = "Y") ) ) if (interactive()) { shinyApp(app$ui, app$server) } ``` </details> --------- Co-authored-by: Lluís Revilla <185338939+llrs-roche@users.noreply.github.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Blocked by #1368
table
,listing
,graph
Items:
Part 1
tm_a_gee
teal.modules.clinical#1262tm_g_barchart_simple
teal.modules.clinical#1267tm_g_ci
teal.modules.clinical#1265tm_g_forest_rsp
teal.modules.clinical#1266tm_g_forest_tte
teal.modules.clinical#1264tm_g_ipp
teal.modules.clinical#1263tm_g_km
teal.modules.clinical#1254tm_g_lineplot
teal.modules.clinical#1255tm_g_pp_adverse_events
teal.modules.clinical#1269tm_g_pp_patient_timeline
teal.modules.clinical#1270tm_g_pp_therapy
teal.modules.clinical#1268tm_g_pp_vitals
teal.modules.clinical#1261tm_t_abnormality
teal.modules.clinical#1257tm_t_abnormality_by_worst_grade
teal.modules.clinical#1260tm_t_ancova
teal.modules.clinical#1256Part 2
The text was updated successfully, but these errors were encountered: