Display patient profile plot as a shiny module
Usage
tm_g_patient_profile(
label = "Patient Profile Plot",
patient_id = teal.picks::variables(choices = dplyr::starts_with("USUBJ"), selected =
1L),
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(),
decorators = list()
)Arguments
- label
(
character(1)) Label shown in the navigation item for the module or module group. Formodules()defaults to"root". SeeDetails.- patient_id
Either a
teal.picks::variables()object, a fullteal.picks::picks()object, or avariables()object.choices_selected()is being deprecated as an argument type and will be removed in the future. Describing the unique subject ID selection.- sl_dataname
(
character) subject level dataset name, needs to be available in the list passed to thedataargument ofteal::init()- ex_dataname, ae_dataname, rs_dataname, cm_dataname, lb_dataname
(
character(1)) names of exposure, adverse events, response, concomitant medications, and labs datasets, respectively; must be available in the list passed to thedataargument ofteal::init()
set to NA (default) to omit from analysis- sl_start_date
Either a
teal.picks::variables()object, a fullteal.picks::picks()object, or avariables()object.choices_selected()is being deprecated as an argument type and will be removed in the future. For the study start date variable, usually set to treatment start date or randomization date.- ex_var
Either a
teal.picks::variables()object, a fullteal.picks::picks()object, or avariables()object.choices_selected()is being deprecated as an argument type and will be removed in the future. For the exposure variable to plot as each line. Leave unspecified or set toNULLif exposure data is not available.- ae_var
Either a
teal.picks::variables()object, a fullteal.picks::picks()object, or avariables()object.choices_selected()is being deprecated as an argument type and will be removed in the future. For the adverse event variable to plot as each line. Leave unspecified or set toNULLif adverse events data is not available.- ae_line_col_var
Either a
teal.picks::variables()object, a fullteal.picks::picks()object, or avariables()object.choices_selected()is being deprecated as an argument type and will be removed in the future. For coloringAElines. Leave unspecified or set toNULLif adverse events data is not available.- ae_line_col_opt
aesthetic values to map color values (named vector to map color values to each name). If not
NULL, please make sure this contains all possible values forae_line_col_varvalues.
leave unspecified or set toNULLif adverse events data is not available- rs_var
Either a
teal.picks::variables()object, a fullteal.picks::picks()object, or avariables()object.choices_selected()is being deprecated as an argument type and will be removed in the future. For the response variable to plot as each line. Leave unspecified or set toNULLif response data is not available.- cm_var
Either a
teal.picks::variables()object, a fullteal.picks::picks()object, or avariables()object.choices_selected()is being deprecated as an argument type and will be removed in the future. For the concomitant medication variable to plot as each line. Leave unspecified or set toNULLif concomitant medications data is not available.- lb_var
Either a
teal.picks::variables()object, a fullteal.picks::picks()object, or avariables()object.choices_selected()is being deprecated as an argument type and will be removed in the future. For the lab variable to plot as each line. Leave unspecified or set toNULLif labs data is not available.- x_limit
a single
characterstring with two numbers separated by a comma indicating the x-axis limit, default is "-28, 365"- plot_height
(
numeric(3))
vector to indicate default value, minimum and maximum values.- plot_width
(
numeric(3))
vector to indicate default value, minimum and maximum values.- pre_output
(
shiny.tag) optional,
with text placed before the output to put the output into context. For example a title.- post_output
(
shiny.tag) optional, with text placed after the output to put the output into context. For example theshiny::helpText()elements are useful.- transformators
(
listofteal_transform_module) that will be applied to transform module's data input. To learn more checkvignette("transform-input-data", package = "teal").- decorators
(named
listofteal_transform_module) optional, decorators for the moduleplotoutput.
Value
the teal::module() object.
Details
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, andADCM, it would be study day based onASTDTand/orAENDTin reference to the start dateIn
ADRSandADLB, it would be study day based onADTin reference to the start date
For every variable domain defined (i.e ae_var) please set its corresponding analysis dataset (i.e ae_dataset)
Decorating Module
This module generates the following objects, which can be modified in place using decorators:
plot(grob)
A Decorator is applied to the specific output using a named list of teal_transform_module objects.
The name of this list corresponds to the name of the output to which the decorator is applied.
See code snippet below:
tm_g_patient_profile(
..., # arguments for module
decorators = list(
plot = teal_transform_module(...), # applied to the `plot` output
)
)
For additional details and examples of decorators, refer to the vignette
vignette("decorate-module-output", package = "teal.modules.general").
To learn more please refer to the vignette
vignette("transform-module-output", package = "teal") or the teal::teal_transform_module() documentation.
Reporting
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")
Author
Xuefeng Hou (houx14) houx14@gene.com
Tina Cho (chot) tina.cho@roche.com
Molly He (hey59) hey59@gene.com
Ting Qi (qit3) qit3@gene.com
Examples
data <- within(teal_data(), {
library(nestcolor)
library(dplyr)
ADSL <- teal.data::rADSL
ADAE <- teal.data::rADAE %>% mutate(ASTDT = as.Date(ASTDTM), AENDT = as.Date(AENDTM))
ADCM <- teal.data::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 <- teal.data::rADRS %>% mutate(ADT = as.Date(ADTM))
ADEX <- teal.data::rADEX %>% mutate(ASTDT = as.Date(ASTDTM), AENDT = as.Date(AENDTM))
ADLB <- teal.data::rADLB %>% mutate(ADT = as.Date(ADTM), LBSTRESN = as.numeric(LBSTRESC))
})
join_keys(data) <- default_cdisc_join_keys[names(data)]
app <- init(
data = data,
modules = modules(
tm_g_patient_profile(
label = "Patient Profile Plot",
patient_id = variables(
choices = "USUBJID",
selected = "USUBJID"
),
sl_dataname = "ADSL",
ex_dataname = "ADEX",
ae_dataname = "ADAE",
rs_dataname = "ADRS",
cm_dataname = "ADCM",
lb_dataname = "ADLB",
sl_start_date = variables(
selected = "TRTSDTM",
choices = c("TRTSDTM", "RANDDT")
),
ex_var = variables(
selected = "PARCAT2",
choices = "PARCAT2"
),
ae_var = variables(
selected = "AEDECOD",
choices = c("AEDECOD", "AESOC")
),
ae_line_col_var = variables(
selected = "AESER",
choices = c("AESER", "AEREL")
),
ae_line_col_opt = c("Y" = "red", "N" = "blue"),
rs_var = variables(
selected = "PARAMCD",
choices = "PARAMCD"
),
cm_var = variables(
selected = "CMDECOD",
choices = c("CMDECOD", "CMCAT")
),
lb_var = variables(
selected = "LBTESTCD",
choices = c("LBTESTCD", "LBCAT")
),
x_limit = "-28, 750",
plot_height = c(1200, 400, 5000)
)
)
)
if (interactive()) {
shinyApp(app$ui, app$server)
}