| Title: | 'teal' Modules for TLG Functions in Osprey |
|---|---|
| Description: | Community efforts to collect 'teal' modules for TLGs defined in 'osprey' package. Enables 'teal' app developers to create 'shiny' applications with a use of 'osprey' analysis functions. |
| Authors: | Nina Qi [aut, cre], Dawid Kaledkowski [aut], Chendi Liao [aut], Liming Li [aut], Konrad Pagacz [aut], Molly He [ctb], Carolyn Zhang [ctb], Tina Cho [ctb], F. Hoffmann-La Roche AG [cph, fnd] |
| Maintainer: | Nina Qi <[email protected]> |
| License: | Apache License 2.0 |
| Version: | 0.4.0 |
| Built: | 2026-05-25 07:07:06 UTC |
| Source: | https://github.com/insightsengineering/teal.osprey |
AE variables in AE osprey functions
label_aevar is deprecated and will be unexported in the next release.Automatically switch variable labels for standard AE variables in AE osprey functions
label_aevar is deprecated and will be unexported in the next release.
label_aevar(x)label_aevar(x)
x |
variable key |
Adds teal.widgets::plot_with_settings_ui()
plot_decorate_output(id)plot_decorate_output(id)
id |
( |
An html element.
Utility function for quick filter
quick_filter(filter_opt, ANL)quick_filter(filter_opt, ANL)
filter_opt |
vector of string names of flag variable to filter (keep Y rows only) |
ANL |
input dataset |
a filtered dataframe
Carolyn Zhang (zhanc107) [email protected]
This is used in tm_g_ae_oview() and tm_g_events_term_id().
srv_g_decorate( id, plot_id = "out", plt = reactive(NULL), plot_height, plot_width )srv_g_decorate( id, plot_id = "out", plt = reactive(NULL), plot_height, plot_width )
id |
( |
plot_id |
( |
plt |
( |
plot_height |
( |
plot_width |
( |
AE overviewDisplay the AE overview plot as a shiny module
tm_g_ae_oview( label, dataname, arm_var, flag_var_anl, fontsize = c(5, 3, 7), plot_height = c(600L, 200L, 2000L), plot_width = NULL, transformators = list() )tm_g_ae_oview( label, dataname, arm_var, flag_var_anl, fontsize = c(5, 3, 7), plot_height = c(600L, 200L, 2000L), plot_width = NULL, transformators = list() )
label |
( |
dataname |
( |
arm_var |
( |
flag_var_anl |
( |
fontsize |
( |
plot_height |
( |
plot_width |
( |
transformators |
( |
the teal::module() object.
This module returns an object of class teal_module, that contains a server function.
Since the server function returns a teal_report object, this makes this module reportable, which means that
the reporting functionality will be turned on automatically by the teal framework.
For more information on reporting in teal, see the vignettes:
vignette("reportable-shiny-application", package = "teal.reporter")
vignette("adding-support-for-reporting-to-custom-modules", package = "teal")
data <- teal_data() %>% within({ library(dplyr) ADSL <- rADSL ADAE <- rADAE .add_event_flags <- function(dat) { dat <- dat %>% mutate( TMPFL_SER = AESER == "Y", TMPFL_REL = AEREL == "Y", TMPFL_GR5 = AETOXGR == "5", AEREL1 = (AEREL == "Y" & ACTARM == "A: Drug X"), AEREL2 = (AEREL == "Y" & ACTARM == "B: Placebo") ) labels <- c( "Serious AE", "Related AE", "Grade 5 AE", "AE related to A: Drug X", "AE related to B: Placebo" ) cols <- c("TMPFL_SER", "TMPFL_REL", "TMPFL_GR5", "AEREL1", "AEREL2") for (i in seq_along(labels)) { attr(dat[[cols[i]]], "label") <- labels[i] } dat } ADAE <- .add_event_flags(ADAE) }) join_keys(data) <- default_cdisc_join_keys[names(data)] ADAE <- data[["ADAE"]] app <- init( data = data, modules = modules( tm_g_ae_oview( label = "AE Overview", dataname = "ADAE", arm_var = choices_selected( selected = "ACTARM", choices = c("ACTARM", "ACTARMCD") ), flag_var_anl = choices_selected( selected = "AEREL1", choices = variable_choices( ADAE, c("TMPFL_SER", "TMPFL_REL", "TMPFL_GR5", "AEREL1", "AEREL2") ), ), plot_height = c(600, 200, 2000) ) ) ) if (interactive()) { shinyApp(app$ui, app$server) }data <- teal_data() %>% within({ library(dplyr) ADSL <- rADSL ADAE <- rADAE .add_event_flags <- function(dat) { dat <- dat %>% mutate( TMPFL_SER = AESER == "Y", TMPFL_REL = AEREL == "Y", TMPFL_GR5 = AETOXGR == "5", AEREL1 = (AEREL == "Y" & ACTARM == "A: Drug X"), AEREL2 = (AEREL == "Y" & ACTARM == "B: Placebo") ) labels <- c( "Serious AE", "Related AE", "Grade 5 AE", "AE related to A: Drug X", "AE related to B: Placebo" ) cols <- c("TMPFL_SER", "TMPFL_REL", "TMPFL_GR5", "AEREL1", "AEREL2") for (i in seq_along(labels)) { attr(dat[[cols[i]]], "label") <- labels[i] } dat } ADAE <- .add_event_flags(ADAE) }) join_keys(data) <- default_cdisc_join_keys[names(data)] ADAE <- data[["ADAE"]] app <- init( data = data, modules = modules( tm_g_ae_oview( label = "AE Overview", dataname = "ADAE", arm_var = choices_selected( selected = "ACTARM", choices = c("ACTARM", "ACTARMCD") ), flag_var_anl = choices_selected( selected = "AEREL1", choices = variable_choices( ADAE, c("TMPFL_SER", "TMPFL_REL", "TMPFL_GR5", "AEREL1", "AEREL2") ), ), plot_height = c(600, 200, 2000) ) ) ) if (interactive()) { shinyApp(app$ui, app$server) }
AE by subgroupsDisplay the AE by subgroups plot as a teal module
tm_g_ae_sub( label, dataname, arm_var, group_var, plot_height = c(600L, 200L, 2000L), plot_width = NULL, fontsize = c(5, 3, 7), transformators = list() )tm_g_ae_sub( label, dataname, arm_var, group_var, plot_height = c(600L, 200L, 2000L), plot_width = NULL, fontsize = c(5, 3, 7), transformators = list() )
label |
( |
dataname |
( |
arm_var |
( |
group_var |
( |
plot_height |
( |
plot_width |
( |
fontsize |
( |
transformators |
( |
the teal::module() object.
This module returns an object of class teal_module, that contains a server function.
Since the server function returns a teal_report object, this makes this module reportable, which means that
the reporting functionality will be turned on automatically by the teal framework.
For more information on reporting in teal, see the vignettes:
vignette("reportable-shiny-application", package = "teal.reporter")
vignette("adding-support-for-reporting-to-custom-modules", package = "teal")
Liming Li (Lil128) [email protected]
Molly He (hey59) [email protected]
# Example using stream (ADaM) dataset data <- teal_data() %>% within({ ADSL <- rADSL ADAE <- rADAE }) join_keys(data) <- default_cdisc_join_keys[names(data)] app <- init( data = data, modules = modules( tm_g_ae_sub( label = "AE by Subgroup", dataname = "ADAE", arm_var = choices_selected( selected = "ACTARMCD", choices = c("ACTARM", "ACTARMCD") ), group_var = choices_selected( selected = c("SEX", "REGION1", "RACE"), choices = c("SEX", "REGION1", "RACE") ), plot_height = c(600, 200, 2000) ) ) ) if (interactive()) { shinyApp(app$ui, app$server) }# Example using stream (ADaM) dataset data <- teal_data() %>% within({ ADSL <- rADSL ADAE <- rADAE }) join_keys(data) <- default_cdisc_join_keys[names(data)] app <- init( data = data, modules = modules( tm_g_ae_sub( label = "AE by Subgroup", dataname = "ADAE", arm_var = choices_selected( selected = "ACTARMCD", choices = c("ACTARM", "ACTARMCD") ), group_var = choices_selected( selected = c("SEX", "REGION1", "RACE"), choices = c("SEX", "REGION1", "RACE") ), plot_height = c(600, 200, 2000) ) ) ) if (interactive()) { shinyApp(app$ui, app$server) }
Display butterfly plot as a shiny module
tm_g_butterfly( label, dataname, filter_var = NULL, right_var, left_var, category_var, color_by_var, count_by_var, facet_var = NULL, sort_by_var = teal.transform::choices_selected(selected = "count", choices = c("count", "alphabetical")), legend_on = TRUE, plot_height = c(600L, 200L, 2000L), plot_width = NULL, pre_output = NULL, post_output = NULL, transformators = list() )tm_g_butterfly( label, dataname, filter_var = NULL, right_var, left_var, category_var, color_by_var, count_by_var, facet_var = NULL, sort_by_var = teal.transform::choices_selected(selected = "count", choices = c("count", "alphabetical")), legend_on = TRUE, plot_height = c(600L, 200L, 2000L), plot_width = NULL, pre_output = NULL, post_output = NULL, transformators = list() )
label |
( |
dataname |
( |
filter_var |
( |
right_var |
( |
left_var |
( |
category_var |
( |
color_by_var |
( |
count_by_var |
( |
facet_var |
( |
sort_by_var |
( |
legend_on |
( |
plot_height |
( |
plot_width |
( |
pre_output |
( |
post_output |
( |
transformators |
( |
filter_var option is designed to work in conjunction with
filtering function provided by teal (encoding panel on the right
hand side of the shiny app). It can be used as quick access to predefined
subsets of the domain datasets (not subject-level dataset) to be used for
analysis, denoted by an value of "Y". Each variable within the
filter_var_choices is expected to contain values of either "Y" or
"N". If multiple variables are selected as filter_var, only
observations with "Y" value in each and every selected variables will be
used for subsequent analysis. Flag variables (from ADaM datasets) can be
used directly as filter.
the teal::module() object.
This module returns an object of class teal_module, that contains a server function.
Since the server function returns a teal_report object, this makes this module reportable, which means that
the reporting functionality will be turned on automatically by the teal framework.
For more information on reporting in teal, see the vignettes:
vignette("reportable-shiny-application", package = "teal.reporter")
vignette("adding-support-for-reporting-to-custom-modules", package = "teal")
Carolyn Zhang (zhanc107) [email protected]
Chendi Liao (liaoc10) [email protected]
# Example using stream (ADaM) dataset data <- teal_data() %>% eval_code("set.seed(23) # @linksto ADSL") %>% within({ library(nestcolor) library(dplyr) ADSL <- rADSL ADAE <- rADAE ADSL <- mutate(ADSL, DOSE = paste(sample(1:3, n(), replace = TRUE), "UG")) ADAE <- mutate( ADAE, flag1 = ifelse(AETOXGR == 1, 1, 0), flag2 = ifelse(AETOXGR == 2, 1, 0), flag3 = ifelse(AETOXGR == 3, 1, 0), flag1_filt = rep("Y", n()) ) }) join_keys(data) <- default_cdisc_join_keys[names(data)] app <- init( data = data, modules = modules( tm_g_butterfly( label = "Butterfly Plot", dataname = "ADAE", right_var = choices_selected( selected = "SEX", choices = c("SEX", "ARM", "RACE") ), left_var = choices_selected( selected = "RACE", choices = c("SEX", "ARM", "RACE") ), category_var = choices_selected( selected = "AEBODSYS", choices = c("AEDECOD", "AEBODSYS") ), color_by_var = choices_selected( selected = "AETOXGR", choices = c("AETOXGR", "None") ), count_by_var = choices_selected( selected = "# of patients", choices = c("# of patients", "# of AEs") ), facet_var = choices_selected( selected = NULL, choices = c("RACE", "SEX", "ARM") ), sort_by_var = choices_selected( selected = "count", choices = c("count", "alphabetical") ), legend_on = TRUE, plot_height = c(600, 200, 2000) ) ) ) if (interactive()) { shinyApp(app$ui, app$server) }# Example using stream (ADaM) dataset data <- teal_data() %>% eval_code("set.seed(23) # @linksto ADSL") %>% within({ library(nestcolor) library(dplyr) ADSL <- rADSL ADAE <- rADAE ADSL <- mutate(ADSL, DOSE = paste(sample(1:3, n(), replace = TRUE), "UG")) ADAE <- mutate( ADAE, flag1 = ifelse(AETOXGR == 1, 1, 0), flag2 = ifelse(AETOXGR == 2, 1, 0), flag3 = ifelse(AETOXGR == 3, 1, 0), flag1_filt = rep("Y", n()) ) }) join_keys(data) <- default_cdisc_join_keys[names(data)] app <- init( data = data, modules = modules( tm_g_butterfly( label = "Butterfly Plot", dataname = "ADAE", right_var = choices_selected( selected = "SEX", choices = c("SEX", "ARM", "RACE") ), left_var = choices_selected( selected = "RACE", choices = c("SEX", "ARM", "RACE") ), category_var = choices_selected( selected = "AEBODSYS", choices = c("AEDECOD", "AEBODSYS") ), color_by_var = choices_selected( selected = "AETOXGR", choices = c("AETOXGR", "None") ), count_by_var = choices_selected( selected = "# of patients", choices = c("# of patients", "# of AEs") ), facet_var = choices_selected( selected = NULL, choices = c("RACE", "SEX", "ARM") ), sort_by_var = choices_selected( selected = "count", choices = c("count", "alphabetical") ), legend_on = TRUE, plot_height = c(600, 200, 2000) ) ) ) if (interactive()) { shinyApp(app$ui, app$server) }
Display Events by Term plot as a shiny module
tm_g_events_term_id( label, dataname, term_var, arm_var, fontsize = c(5, 3, 7), plot_height = c(600L, 200L, 2000L), plot_width = NULL, transformators = list() )tm_g_events_term_id( label, dataname, term_var, arm_var, fontsize = c(5, 3, 7), plot_height = c(600L, 200L, 2000L), plot_width = NULL, transformators = list() )
label |
( |
dataname |
( |
term_var |
teal.transform::choices_selected object with all available choices and pre-selected option names that can be used to specify the term for events |
arm_var |
( |
fontsize |
( |
plot_height |
( |
plot_width |
( |
transformators |
( |
the teal::module() object.
This module returns an object of class teal_module, that contains a server function.
Since the server function returns a teal_report object, this makes this module reportable, which means that
the reporting functionality will be turned on automatically by the teal framework.
For more information on reporting in teal, see the vignettes:
vignette("reportable-shiny-application", package = "teal.reporter")
vignette("adding-support-for-reporting-to-custom-modules", package = "teal")
Liming Li (lil128) [email protected]
Molly He (hey59) [email protected]
data <- teal_data() %>% within({ ADSL <- rADSL ADAE <- rADAE }) join_keys(data) <- default_cdisc_join_keys[names(data)] app <- init( data = data, modules = modules( tm_g_events_term_id( label = "Common AE", dataname = "ADAE", term_var = choices_selected( selected = "AEDECOD", choices = c( "AEDECOD", "AETERM", "AEHLT", "AELLT", "AEBODSYS" ) ), arm_var = choices_selected( selected = "ACTARMCD", choices = c("ACTARM", "ACTARMCD") ), plot_height = c(600, 200, 2000) ) ) ) if (interactive()) { shinyApp(app$ui, app$server) }data <- teal_data() %>% within({ ADSL <- rADSL ADAE <- rADAE }) join_keys(data) <- default_cdisc_join_keys[names(data)] app <- init( data = data, modules = modules( tm_g_events_term_id( label = "Common AE", dataname = "ADAE", term_var = choices_selected( selected = "AEDECOD", choices = c( "AEDECOD", "AETERM", "AEHLT", "AELLT", "AEBODSYS" ) ), arm_var = choices_selected( selected = "ACTARMCD", choices = c("ACTARM", "ACTARMCD") ), plot_height = c(600, 200, 2000) ) ) ) if (interactive()) { shinyApp(app$ui, app$server) }
Display the heatmap by grade as a shiny module
tm_g_heat_bygrade( label, sl_dataname, ex_dataname, ae_dataname, cm_dataname = NA, id_var, visit_var, ongo_var, anno_var, heat_var, conmed_var = NULL, fontsize = c(5, 3, 7), plot_height = c(600L, 200L, 2000L), plot_width = NULL, transformators = list() )tm_g_heat_bygrade( label, sl_dataname, ex_dataname, ae_dataname, cm_dataname = NA, id_var, visit_var, ongo_var, anno_var, heat_var, conmed_var = NULL, fontsize = c(5, 3, 7), plot_height = c(600L, 200L, 2000L), plot_width = NULL, transformators = list() )
label |
( |
sl_dataname |
( |
ex_dataname |
( |
ae_dataname |
( |
cm_dataname |
( |
id_var |
( |
visit_var |
( |
ongo_var |
( |
anno_var |
( |
heat_var |
( |
conmed_var |
( |
fontsize |
( |
plot_height |
( |
plot_width |
( |
transformators |
( |
the teal::module() object.
This module returns an object of class teal_module, that contains a server function.
Since the server function returns a teal_report object, this makes this module reportable, which means that
the reporting functionality will be turned on automatically by the teal framework.
For more information on reporting in teal, see the vignettes:
vignette("reportable-shiny-application", package = "teal.reporter")
vignette("adding-support-for-reporting-to-custom-modules", package = "teal")
data <- teal_data() %>% within({ library(dplyr) library(nestcolor) ADSL <- rADSL %>% slice(1:30) ADEX <- rADEX %>% filter(USUBJID %in% ADSL$USUBJID) ADAE <- rADAE %>% filter(USUBJID %in% ADSL$USUBJID) ADCM <- rADCM %>% filter(USUBJID %in% ADSL$USUBJID) # This preprocess is only to force legacy standard on ADCM ADCM <- ADCM %>% select(-starts_with("ATC")) %>% unique() # function to derive AVISIT from ADEX .add_visit <- function(data_need_visit) { visit_dates <- ADEX %>% filter(PARAMCD == "DOSE") %>% distinct(USUBJID, AVISIT, ASTDTM) %>% group_by(USUBJID) %>% arrange(ASTDTM) %>% mutate(next_vis = lead(ASTDTM), is_last = ifelse(is.na(next_vis), TRUE, FALSE)) %>% rename(this_vis = ASTDTM) data_visit <- data_need_visit %>% select(USUBJID, ASTDTM) %>% left_join(visit_dates, by = "USUBJID") %>% filter(ASTDTM > this_vis & (ASTDTM < next_vis | is_last == TRUE)) %>% left_join(data_need_visit) %>% distinct() return(data_visit) } # derive AVISIT for ADAE and ADCM ADAE <- .add_visit(ADAE) ADCM <- .add_visit(ADCM) # derive ongoing status variable for ADEX ADEX <- ADEX %>% filter(PARCAT1 == "INDIVIDUAL") %>% mutate(ongo_status = (EOSSTT == "ONGOING")) }) join_keys(data) <- default_cdisc_join_keys[names(data)] ADCM <- data[["ADCM"]] app <- init( data = data, modules = modules( tm_g_heat_bygrade( label = "Heatmap by grade", sl_dataname = "ADSL", ex_dataname = "ADEX", ae_dataname = "ADAE", cm_dataname = "ADCM", id_var = choices_selected( selected = "USUBJID", choices = c("USUBJID", "SUBJID") ), visit_var = choices_selected( selected = "AVISIT", choices = c("AVISIT") ), ongo_var = choices_selected( selected = "ongo_status", choices = c("ongo_status") ), anno_var = choices_selected( selected = c("SEX", "COUNTRY"), choices = c("SEX", "COUNTRY", "USUBJID") ), heat_var = choices_selected( selected = "AETOXGR", choices = c("AETOXGR") ), conmed_var = choices_selected( selected = "CMDECOD", choices = c("CMDECOD") ), plot_height = c(600, 200, 2000) ) ) ) if (interactive()) { shinyApp(app$ui, app$server) }data <- teal_data() %>% within({ library(dplyr) library(nestcolor) ADSL <- rADSL %>% slice(1:30) ADEX <- rADEX %>% filter(USUBJID %in% ADSL$USUBJID) ADAE <- rADAE %>% filter(USUBJID %in% ADSL$USUBJID) ADCM <- rADCM %>% filter(USUBJID %in% ADSL$USUBJID) # This preprocess is only to force legacy standard on ADCM ADCM <- ADCM %>% select(-starts_with("ATC")) %>% unique() # function to derive AVISIT from ADEX .add_visit <- function(data_need_visit) { visit_dates <- ADEX %>% filter(PARAMCD == "DOSE") %>% distinct(USUBJID, AVISIT, ASTDTM) %>% group_by(USUBJID) %>% arrange(ASTDTM) %>% mutate(next_vis = lead(ASTDTM), is_last = ifelse(is.na(next_vis), TRUE, FALSE)) %>% rename(this_vis = ASTDTM) data_visit <- data_need_visit %>% select(USUBJID, ASTDTM) %>% left_join(visit_dates, by = "USUBJID") %>% filter(ASTDTM > this_vis & (ASTDTM < next_vis | is_last == TRUE)) %>% left_join(data_need_visit) %>% distinct() return(data_visit) } # derive AVISIT for ADAE and ADCM ADAE <- .add_visit(ADAE) ADCM <- .add_visit(ADCM) # derive ongoing status variable for ADEX ADEX <- ADEX %>% filter(PARCAT1 == "INDIVIDUAL") %>% mutate(ongo_status = (EOSSTT == "ONGOING")) }) join_keys(data) <- default_cdisc_join_keys[names(data)] ADCM <- data[["ADCM"]] app <- init( data = data, modules = modules( tm_g_heat_bygrade( label = "Heatmap by grade", sl_dataname = "ADSL", ex_dataname = "ADEX", ae_dataname = "ADAE", cm_dataname = "ADCM", id_var = choices_selected( selected = "USUBJID", choices = c("USUBJID", "SUBJID") ), visit_var = choices_selected( selected = "AVISIT", choices = c("AVISIT") ), ongo_var = choices_selected( selected = "ongo_status", choices = c("ongo_status") ), anno_var = choices_selected( selected = c("SEX", "COUNTRY"), choices = c("SEX", "COUNTRY", "USUBJID") ), heat_var = choices_selected( selected = "AETOXGR", choices = c("AETOXGR") ), conmed_var = choices_selected( selected = "CMDECOD", choices = c("CMDECOD") ), plot_height = c(600, 200, 2000) ) ) ) if (interactive()) { shinyApp(app$ui, app$server) }
Display patient profile plot as a shiny module
tm_g_patient_profile( label = "Patient Profile Plot", patient_id, sl_dataname, ex_dataname = NA, ae_dataname = NA, rs_dataname = NA, cm_dataname = NA, lb_dataname = NA, sl_start_date, ex_var = NULL, ae_var = NULL, ae_line_col_var = NULL, ae_line_col_opt = NULL, rs_var = NULL, cm_var = NULL, lb_var = NULL, x_limit = "-28, 365", plot_height = c(1200L, 400L, 5000L), plot_width = NULL, pre_output = NULL, post_output = NULL, transformators = list() )tm_g_patient_profile( label = "Patient Profile Plot", patient_id, sl_dataname, ex_dataname = NA, ae_dataname = NA, rs_dataname = NA, cm_dataname = NA, lb_dataname = NA, sl_start_date, ex_var = NULL, ae_var = NULL, ae_line_col_var = NULL, ae_line_col_opt = NULL, rs_var = NULL, cm_var = NULL, lb_var = NULL, x_limit = "-28, 365", plot_height = c(1200L, 400L, 5000L), plot_width = NULL, pre_output = NULL, post_output = NULL, transformators = list() )
label |
( |
patient_id |
( |
sl_dataname |
( |
ex_dataname, ae_dataname, rs_dataname, cm_dataname, lb_dataname
|
( |
sl_start_date |
|
ex_var |
|
ae_var |
|
ae_line_col_var |
|
ae_line_col_opt |
aesthetic values to map color values
(named vector to map color values to each name).
If not |
rs_var |
|
cm_var |
|
lb_var |
|
x_limit |
a single |
plot_height |
( |
plot_width |
( |
pre_output |
( |
post_output |
( |
transformators |
( |
As the patient profile module plots different domains in one plot, the study day (x-axis)
is derived for consistency based the start date of user's choice in the app (for example,
ADSL.RANDDT or ADSL.TRTSDT):
In ADAE, ADEX, and ADCM, it would be study day based on ASTDT and/or
AENDT in reference to the start date
In ADRS and ADLB, it would be study day based on ADT in reference to
the start date
the teal::module() object.
This module returns an object of class teal_module, that contains a server function.
Since the server function returns a teal_report object, this makes this module reportable, which means that
the reporting functionality will be turned on automatically by the teal framework.
For more information on reporting in teal, see the vignettes:
vignette("reportable-shiny-application", package = "teal.reporter")
vignette("adding-support-for-reporting-to-custom-modules", package = "teal")
Xuefeng Hou (houx14) [email protected]
Tina Cho (chot) [email protected]
Molly He (hey59) [email protected]
Ting Qi (qit3) [email protected]
data <- teal_data() %>% within({ library(nestcolor) library(dplyr) ADSL <- rADSL ADAE <- rADAE %>% mutate(ASTDT = as.Date(ASTDTM), AENDT = as.Date(AENDTM)) ADCM <- rADCM %>% mutate(ASTDT = as.Date(ASTDTM), AENDT = as.Date(AENDTM)) # The step below is to pre-process ADCM to legacy standard ADCM <- ADCM %>% select(-starts_with("ATC")) %>% unique() ADRS <- rADRS %>% mutate(ADT = as.Date(ADTM)) ADEX <- rADEX %>% mutate(ASTDT = as.Date(ASTDTM), AENDT = as.Date(AENDTM)) ADLB <- rADLB %>% mutate(ADT = as.Date(ADTM), LBSTRESN = as.numeric(LBSTRESC)) }) join_keys(data) <- default_cdisc_join_keys[names(data)] ADSL <- data[["ADSL"]] app <- init( data = data, modules = modules( tm_g_patient_profile( label = "Patient Profile Plot", patient_id = choices_selected( choices = unique(ADSL$USUBJID), selected = unique(ADSL$USUBJID)[1] ), sl_dataname = "ADSL", ex_dataname = "ADEX", ae_dataname = "ADAE", rs_dataname = "ADRS", cm_dataname = "ADCM", lb_dataname = "ADLB", sl_start_date = choices_selected( selected = "TRTSDTM", choices = c("TRTSDTM", "RANDDT") ), ex_var = choices_selected( selected = "PARCAT2", choices = "PARCAT2" ), ae_var = choices_selected( selected = "AEDECOD", choices = c("AEDECOD", "AESOC") ), ae_line_col_var = choices_selected( selected = "AESER", choices = c("AESER", "AEREL") ), ae_line_col_opt = c("Y" = "red", "N" = "blue"), rs_var = choices_selected( selected = "PARAMCD", choices = "PARAMCD" ), cm_var = choices_selected( selected = "CMDECOD", choices = c("CMDECOD", "CMCAT") ), lb_var = choices_selected( selected = "LBTESTCD", choices = c("LBTESTCD", "LBCAT") ), x_limit = "-28, 750", plot_height = c(1200, 400, 5000) ) ) ) if (interactive()) { shinyApp(app$ui, app$server) }data <- teal_data() %>% within({ library(nestcolor) library(dplyr) ADSL <- rADSL ADAE <- rADAE %>% mutate(ASTDT = as.Date(ASTDTM), AENDT = as.Date(AENDTM)) ADCM <- rADCM %>% mutate(ASTDT = as.Date(ASTDTM), AENDT = as.Date(AENDTM)) # The step below is to pre-process ADCM to legacy standard ADCM <- ADCM %>% select(-starts_with("ATC")) %>% unique() ADRS <- rADRS %>% mutate(ADT = as.Date(ADTM)) ADEX <- rADEX %>% mutate(ASTDT = as.Date(ASTDTM), AENDT = as.Date(AENDTM)) ADLB <- rADLB %>% mutate(ADT = as.Date(ADTM), LBSTRESN = as.numeric(LBSTRESC)) }) join_keys(data) <- default_cdisc_join_keys[names(data)] ADSL <- data[["ADSL"]] app <- init( data = data, modules = modules( tm_g_patient_profile( label = "Patient Profile Plot", patient_id = choices_selected( choices = unique(ADSL$USUBJID), selected = unique(ADSL$USUBJID)[1] ), sl_dataname = "ADSL", ex_dataname = "ADEX", ae_dataname = "ADAE", rs_dataname = "ADRS", cm_dataname = "ADCM", lb_dataname = "ADLB", sl_start_date = choices_selected( selected = "TRTSDTM", choices = c("TRTSDTM", "RANDDT") ), ex_var = choices_selected( selected = "PARCAT2", choices = "PARCAT2" ), ae_var = choices_selected( selected = "AEDECOD", choices = c("AEDECOD", "AESOC") ), ae_line_col_var = choices_selected( selected = "AESER", choices = c("AESER", "AEREL") ), ae_line_col_opt = c("Y" = "red", "N" = "blue"), rs_var = choices_selected( selected = "PARAMCD", choices = "PARAMCD" ), cm_var = choices_selected( selected = "CMDECOD", choices = c("CMDECOD", "CMCAT") ), lb_var = choices_selected( selected = "LBTESTCD", choices = c("LBTESTCD", "LBCAT") ), x_limit = "-28, 750", plot_height = c(1200, 400, 5000) ) ) ) if (interactive()) { shinyApp(app$ui, app$server) }
Display spider plot as a shiny module
tm_g_spiderplot( label, dataname, paramcd, x_var, y_var, marker_var, line_colorby_var, xfacet_var = NULL, yfacet_var = NULL, vref_line = NULL, href_line = NULL, anno_txt_var = TRUE, legend_on = FALSE, plot_height = c(600L, 200L, 2000L), plot_width = NULL, pre_output = NULL, post_output = NULL, transformators = list() )tm_g_spiderplot( label, dataname, paramcd, x_var, y_var, marker_var, line_colorby_var, xfacet_var = NULL, yfacet_var = NULL, vref_line = NULL, href_line = NULL, anno_txt_var = TRUE, legend_on = FALSE, plot_height = c(600L, 200L, 2000L), plot_width = NULL, pre_output = NULL, post_output = NULL, transformators = list() )
label |
( |
dataname |
( |
paramcd |
( |
x_var |
x-axis variables |
y_var |
y-axis variables |
marker_var |
variable dictates marker symbol |
line_colorby_var |
variable dictates line color |
xfacet_var |
variable for x facets |
yfacet_var |
variable for y facets |
vref_line |
vertical reference lines |
href_line |
horizontal reference lines |
anno_txt_var |
annotation text |
legend_on |
boolean value for whether legend is displayed |
plot_height |
( |
plot_width |
( |
pre_output |
( |
post_output |
( |
transformators |
( |
the teal::module() object.
This module returns an object of class teal_module, that contains a server function.
Since the server function returns a teal_report object, this makes this module reportable, which means that
the reporting functionality will be turned on automatically by the teal framework.
For more information on reporting in teal, see the vignettes:
vignette("reportable-shiny-application", package = "teal.reporter")
vignette("adding-support-for-reporting-to-custom-modules", package = "teal")
Carolyn Zhang (zhanc107) [email protected]
Chendi Liao (liaoc10) [email protected]
# Example using stream (ADaM) dataset data <- teal_data() %>% within({ library(nestcolor) ADSL <- rADSL ADTR <- rADTR }) join_keys(data) <- default_cdisc_join_keys[names(data)] app <- init( data = data, modules = modules( tm_g_spiderplot( label = "Spider plot", dataname = "ADTR", paramcd = choices_selected( choices = "SLDINV", selected = "SLDINV" ), x_var = choices_selected( choices = "ADY", selected = "ADY" ), y_var = choices_selected( choices = c("PCHG", "CHG", "AVAL"), selected = "PCHG" ), marker_var = choices_selected( choices = c("SEX", "RACE", "USUBJID"), selected = "SEX" ), line_colorby_var = choices_selected( choices = c("SEX", "USUBJID", "RACE"), selected = "SEX" ), xfacet_var = choices_selected( choices = c("SEX", "ARM"), selected = "SEX" ), yfacet_var = choices_selected( choices = c("SEX", "ARM"), selected = "ARM" ), vref_line = "10, 37", href_line = "-20, 0" ) ) ) if (interactive()) { shinyApp(app$ui, app$server) }# Example using stream (ADaM) dataset data <- teal_data() %>% within({ library(nestcolor) ADSL <- rADSL ADTR <- rADTR }) join_keys(data) <- default_cdisc_join_keys[names(data)] app <- init( data = data, modules = modules( tm_g_spiderplot( label = "Spider plot", dataname = "ADTR", paramcd = choices_selected( choices = "SLDINV", selected = "SLDINV" ), x_var = choices_selected( choices = "ADY", selected = "ADY" ), y_var = choices_selected( choices = c("PCHG", "CHG", "AVAL"), selected = "PCHG" ), marker_var = choices_selected( choices = c("SEX", "RACE", "USUBJID"), selected = "SEX" ), line_colorby_var = choices_selected( choices = c("SEX", "USUBJID", "RACE"), selected = "SEX" ), xfacet_var = choices_selected( choices = c("SEX", "ARM"), selected = "SEX" ), yfacet_var = choices_selected( choices = c("SEX", "ARM"), selected = "ARM" ), vref_line = "10, 37", href_line = "-20, 0" ) ) ) if (interactive()) { shinyApp(app$ui, app$server) }
Swimlane PlotThis is teal module that generates a swimlane plot (bar plot with markers) for ADaM data
tm_g_swimlane( label, dataname, bar_var, bar_color_var = NULL, sort_var = NULL, marker_pos_var = NULL, marker_shape_var = NULL, marker_shape_opt = NULL, marker_color_var = NULL, marker_color_opt = NULL, anno_txt_var = NULL, vref_line = NULL, plot_height = c(1200L, 400L, 5000L), plot_width = NULL, pre_output = NULL, post_output = NULL, x_label = "Time from First Treatment (Day)", transformators = list() )tm_g_swimlane( label, dataname, bar_var, bar_color_var = NULL, sort_var = NULL, marker_pos_var = NULL, marker_shape_var = NULL, marker_shape_opt = NULL, marker_color_var = NULL, marker_color_opt = NULL, anno_txt_var = NULL, vref_line = NULL, plot_height = c(1200L, 400L, 5000L), plot_width = NULL, pre_output = NULL, post_output = NULL, x_label = "Time from First Treatment (Day)", transformators = list() )
label |
( |
dataname |
analysis data used for plotting, needs to be available in the list passed to the |
bar_var |
teal.transform::choices_selected subject-level numeric variable from dataset to plot as the bar length |
bar_color_var |
teal.transform::choices_selected color by variable (subject-level) |
sort_var |
|
marker_pos_var |
teal.transform::choices_selected variable for marker position from marker data
(Note: make sure that marker position has the same relative start day as bar length variable |
marker_shape_var |
teal.transform::choices_selected marker shape variable from marker data |
marker_shape_opt |
aesthetic values to map shape values (named vector to map shape values to each name).
If not |
marker_color_var |
marker color variable from marker data |
marker_color_opt |
aesthetic values to map color values (named vector to map color values to each name).
If not |
anno_txt_var |
character vector with subject-level variable names that are selected as annotation |
vref_line |
vertical reference lines |
plot_height |
( |
plot_width |
( |
pre_output |
( |
post_output |
( |
x_label |
the label of the x axis |
transformators |
( |
the teal::module() object.
This module returns an object of class teal_module, that contains a server function.
Since the server function returns a teal_report object, this makes this module reportable, which means that
the reporting functionality will be turned on automatically by the teal framework.
For more information on reporting in teal, see the vignettes:
vignette("reportable-shiny-application", package = "teal.reporter")
vignette("adding-support-for-reporting-to-custom-modules", package = "teal")
Ting Qi (qit3) [email protected]
# Example using stream (ADaM) dataset data <- teal_data() %>% within({ library(nestcolor) library(dplyr) ADSL <- rADSL %>% mutate(TRTDURD = as.integer(TRTEDTM - TRTSDTM) + 1) %>% filter(STRATA1 == "A" & ARMCD == "ARM A") ADRS <- rADRS %>% filter(PARAMCD == "LSTASDI" & DCSREAS == "Death") %>% mutate(AVALC = DCSREAS, ADY = EOSDY) %>% rbind(rADRS %>% filter(PARAMCD == "OVRINV" & AVALC != "NE")) %>% arrange(USUBJID) }) join_keys(data) <- default_cdisc_join_keys[names(data)] ADSL <- data[["ADSL"]] ADRS <- data[["ADRS"]] app <- init( data = data, modules = modules( tm_g_swimlane( label = "Swimlane Plot", dataname = "ADRS", bar_var = choices_selected( selected = "TRTDURD", choices = c("TRTDURD", "EOSDY") ), bar_color_var = choices_selected( selected = "EOSSTT", choices = c("EOSSTT", "ARM", "ARMCD", "ACTARM", "ACTARMCD", "SEX") ), sort_var = choices_selected( selected = "ACTARMCD", choices = c("USUBJID", "SITEID", "ACTARMCD", "TRTDURD") ), marker_pos_var = choices_selected( selected = "ADY", choices = c("ADY") ), marker_shape_var = choices_selected( selected = "AVALC", c("AVALC", "AVISIT") ), marker_shape_opt = c("CR" = 16, "PR" = 17, "SD" = 18, "PD" = 15, "Death" = 8), marker_color_var = choices_selected( selected = "AVALC", choices = c("AVALC", "AVISIT") ), marker_color_opt = c( "CR" = "green", "PR" = "blue", "SD" = "goldenrod", "PD" = "red", "Death" = "black" ), vref_line = c(30, 60), anno_txt_var = choices_selected( selected = c("ACTARM", "SEX"), choices = c( "ARM", "ARMCD", "ACTARM", "ACTARMCD", "AGEGR1", "SEX", "RACE", "COUNTRY", "DCSREAS", "DCSREASP" ) ) ) ) ) if (interactive()) { shinyApp(app$ui, app$server) }# Example using stream (ADaM) dataset data <- teal_data() %>% within({ library(nestcolor) library(dplyr) ADSL <- rADSL %>% mutate(TRTDURD = as.integer(TRTEDTM - TRTSDTM) + 1) %>% filter(STRATA1 == "A" & ARMCD == "ARM A") ADRS <- rADRS %>% filter(PARAMCD == "LSTASDI" & DCSREAS == "Death") %>% mutate(AVALC = DCSREAS, ADY = EOSDY) %>% rbind(rADRS %>% filter(PARAMCD == "OVRINV" & AVALC != "NE")) %>% arrange(USUBJID) }) join_keys(data) <- default_cdisc_join_keys[names(data)] ADSL <- data[["ADSL"]] ADRS <- data[["ADRS"]] app <- init( data = data, modules = modules( tm_g_swimlane( label = "Swimlane Plot", dataname = "ADRS", bar_var = choices_selected( selected = "TRTDURD", choices = c("TRTDURD", "EOSDY") ), bar_color_var = choices_selected( selected = "EOSSTT", choices = c("EOSSTT", "ARM", "ARMCD", "ACTARM", "ACTARMCD", "SEX") ), sort_var = choices_selected( selected = "ACTARMCD", choices = c("USUBJID", "SITEID", "ACTARMCD", "TRTDURD") ), marker_pos_var = choices_selected( selected = "ADY", choices = c("ADY") ), marker_shape_var = choices_selected( selected = "AVALC", c("AVALC", "AVISIT") ), marker_shape_opt = c("CR" = 16, "PR" = 17, "SD" = 18, "PD" = 15, "Death" = 8), marker_color_var = choices_selected( selected = "AVALC", choices = c("AVALC", "AVISIT") ), marker_color_opt = c( "CR" = "green", "PR" = "blue", "SD" = "goldenrod", "PD" = "red", "Death" = "black" ), vref_line = c(30, 60), anno_txt_var = choices_selected( selected = c("ACTARM", "SEX"), choices = c( "ARM", "ARMCD", "ACTARM", "ACTARMCD", "AGEGR1", "SEX", "RACE", "COUNTRY", "DCSREAS", "DCSREASP" ) ) ) ) ) if (interactive()) { shinyApp(app$ui, app$server) }
This is teal module that generates a waterfall plot for ADaM data
tm_g_waterfall( label, dataname_tr = "ADTR", dataname_rs = "ADRS", bar_paramcd, bar_var, bar_color_var, bar_color_opt = NULL, sort_var, add_label_var_sl, add_label_paramcd_rs, anno_txt_var_sl, anno_txt_paramcd_rs, facet_var, ytick_at = 20, href_line = NULL, gap_point_val = NULL, show_value = TRUE, plot_height = c(1200L, 400L, 5000L), plot_width = NULL, pre_output = NULL, post_output = NULL, transformators = list() )tm_g_waterfall( label, dataname_tr = "ADTR", dataname_rs = "ADRS", bar_paramcd, bar_var, bar_color_var, bar_color_opt = NULL, sort_var, add_label_var_sl, add_label_paramcd_rs, anno_txt_var_sl, anno_txt_paramcd_rs, facet_var, ytick_at = 20, href_line = NULL, gap_point_val = NULL, show_value = TRUE, plot_height = c(1200L, 400L, 5000L), plot_width = NULL, pre_output = NULL, post_output = NULL, transformators = list() )
label |
( |
dataname_tr |
tumor burden analysis data used in teal module to plot as bar height, needs to
be available in the list passed to the |
dataname_rs |
response analysis data used in teal module to label response parameters, needs to
be available in the list passed to the |
bar_paramcd |
|
bar_var |
|
bar_color_var |
|
bar_color_opt |
aesthetic values to map color values (named vector to map color values to each name).
If not |
sort_var |
|
add_label_var_sl |
|
add_label_paramcd_rs |
|
anno_txt_var_sl |
|
anno_txt_paramcd_rs |
|
facet_var |
|
ytick_at |
bar height axis interval, default is 20 |
href_line |
numeric vector to plot horizontal reference lines, default is |
gap_point_val |
singular numeric value for adding bar break when some bars are significantly higher
than others, default is |
show_value |
boolean of whether value of bar height is shown, default is |
plot_height |
( |
plot_width |
( |
pre_output |
( |
post_output |
( |
transformators |
( |
the teal::module() object.
This module returns an object of class teal_module, that contains a server function.
Since the server function returns a teal_report object, this makes this module reportable, which means that
the reporting functionality will be turned on automatically by the teal framework.
For more information on reporting in teal, see the vignettes:
vignette("reportable-shiny-application", package = "teal.reporter")
vignette("adding-support-for-reporting-to-custom-modules", package = "teal")
Ting Qi (qit3) [email protected]
houx14 [email protected]
data <- teal_data() %>% within({ library(nestcolor) ADSL <- rADSL ADRS <- rADRS ADTR <- rADTR ADSL$SEX <- factor(ADSL$SEX, levels = unique(ADSL$SEX)) }) join_keys(data) <- default_cdisc_join_keys[names(data)] app <- init( data = data, modules = modules( tm_g_waterfall( label = "Waterfall", dataname_tr = "ADTR", dataname_rs = "ADRS", bar_paramcd = choices_selected(c("SLDINV"), "SLDINV"), bar_var = choices_selected(c("PCHG", "AVAL"), "PCHG"), bar_color_var = choices_selected(c("ARMCD", "SEX"), "ARMCD"), bar_color_opt = NULL, sort_var = choices_selected(c("ARMCD", "SEX"), NULL), add_label_var_sl = choices_selected(c("SEX", "EOSDY"), NULL), add_label_paramcd_rs = choices_selected(c("BESRSPI", "OBJRSPI"), NULL), anno_txt_var_sl = choices_selected(c("SEX", "ARMCD", "BMK1", "BMK2"), NULL), anno_txt_paramcd_rs = choices_selected(c("BESRSPI", "OBJRSPI"), NULL), facet_var = choices_selected(c("SEX", "ARMCD", "STRATA1", "STRATA2"), NULL), href_line = "-30, 20" ) ) ) if (interactive()) { shinyApp(app$ui, app$server) }data <- teal_data() %>% within({ library(nestcolor) ADSL <- rADSL ADRS <- rADRS ADTR <- rADTR ADSL$SEX <- factor(ADSL$SEX, levels = unique(ADSL$SEX)) }) join_keys(data) <- default_cdisc_join_keys[names(data)] app <- init( data = data, modules = modules( tm_g_waterfall( label = "Waterfall", dataname_tr = "ADTR", dataname_rs = "ADRS", bar_paramcd = choices_selected(c("SLDINV"), "SLDINV"), bar_var = choices_selected(c("PCHG", "AVAL"), "PCHG"), bar_color_var = choices_selected(c("ARMCD", "SEX"), "ARMCD"), bar_color_opt = NULL, sort_var = choices_selected(c("ARMCD", "SEX"), NULL), add_label_var_sl = choices_selected(c("SEX", "EOSDY"), NULL), add_label_paramcd_rs = choices_selected(c("BESRSPI", "OBJRSPI"), NULL), anno_txt_var_sl = choices_selected(c("SEX", "ARMCD", "BMK1", "BMK2"), NULL), anno_txt_paramcd_rs = choices_selected(c("BESRSPI", "OBJRSPI"), NULL), facet_var = choices_selected(c("SEX", "ARMCD", "STRATA1", "STRATA2"), NULL), href_line = "-30, 20" ) ) ) if (interactive()) { shinyApp(app$ui, app$server) }
This is used in tm_g_ae_oview() and tm_g_events_term_id().
ui_g_decorate( id, titles = "Titles", footnotes = "footnotes", fontsize = c(5, 4, 11) )ui_g_decorate( id, titles = "Titles", footnotes = "footnotes", fontsize = c(5, 4, 11) )
id |
( |
titles |
( |
footnotes |
( |
fontsize |
( |