This module produces a ggplot
-style Kaplan-Meier plot for data with ADaM structure.
Usage
tm_g_km(
label,
dataname,
parentname = ifelse(inherits(arm_var, "data_extract_spec"),
teal.transform::datanames_input(arm_var), "ADSL"),
arm_var,
arm_ref_comp = NULL,
paramcd,
strata_var,
facet_var,
time_unit_var =
teal.transform::choices_selected(teal.transform::variable_choices(dataname, "AVALU"),
"AVALU", fixed = TRUE),
aval_var = teal.transform::choices_selected(teal.transform::variable_choices(dataname,
"AVAL"), "AVAL", fixed = TRUE),
cnsr_var = teal.transform::choices_selected(teal.transform::variable_choices(dataname,
"CNSR"), "CNSR", fixed = TRUE),
conf_level = teal.transform::choices_selected(c(0.95, 0.9, 0.8), 0.95, keep_order =
TRUE),
font_size = c(11L, 1L, 30),
control_annot_surv_med = control_surv_med_annot(),
control_annot_coxph = control_coxph_annot(x = 0.27, y = 0.35, w = 0.3),
legend_pos = c(0.9, 0.5),
rel_height_plot = c(80L, 0L, 100L),
plot_height = c(800L, 400L, 5000L),
plot_width = NULL,
pre_output = NULL,
post_output = NULL
)
Arguments
- label
(
character
)
menu item label of the module in the teal app.- dataname
(
character
)
analysis data used in teal module.- parentname
(
character
)
parent analysis data used in teal module, usually this refers toADSL
.- arm_var
(
teal.transform::choices_selected()
)
object with all available choices and preselected option for variable names that can be used asarm_var
. It defines the grouping variable in the results table.- arm_ref_comp
(
list
) optional,
if specified it must be a named list with each element corresponding to an arm variable inADSL
and the element must be another list (possibly with delayedteal.transform::variable_choices()
or delayedteal.transform::value_choices()
with the elements namedref
andcomp
that the defined the default reference and comparison arms when the arm variable is changed.- paramcd
(
teal.transform::choices_selected()
)
object with all available choices and preselected option for the parameter code variable fromdataname
.- strata_var
(
teal.transform::choices_selected()
)
names of the variables for stratified analysis.- facet_var
(
teal.transform::choices_selected()
)
object with all available choices and preselected option for names of variable that can be used for plot faceting.- time_unit_var
(
teal.transform::choices_selected()
)
object with all available choices and pre-selected option for the time unit variable.- aval_var
(
teal.transform::choices_selected()
)
object with all available choices and pre-selected option for the analysis variable.- cnsr_var
(
teal.transform::choices_selected()
)
object with all available choices and preselected option for the censoring variable.- conf_level
(
teal.transform::choices_selected()
)
object with all available choices and pre-selected option for the confidence level, each within range of (0, 1).- font_size
(
numeric
)
numeric vector of length 3 of current, minimum and maximum font size values.- control_annot_surv_med
(
list
)
parameters to control the position and size of the annotation table added to the plot whenannot_surv_med = TRUE
, specified using thecontrol_surv_med_annot()
function. Parameter options are:x
,y
,w
,h
, andfill
. Seecontrol_surv_med_annot()
for details.- control_annot_coxph
(
list
)
parameters to control the position and size of the annotation table added to the plot whenannot_coxph = TRUE
, specified using thecontrol_coxph_annot()
function. Parameter options are:x
,y
,w
,h
,fill
, andref_lbls
. Seecontrol_coxph_annot()
for details.- legend_pos
(
numeric(2)
orNULL
)
vector containing x- and y-coordinates, respectively, for the legend position relative to the KM plot area. IfNULL
(default), the legend is positioned in the bottom right corner of the plot, or the middle right of the plot if needed to prevent overlapping.- rel_height_plot
(
proportion
)
proportion of total figure height to allocate to the Kaplan-Meier plot. Relative height of patients at risk table is then1 - rel_height_plot
. Ifannot_at_risk = FALSE
oras_list = TRUE
, this parameter is ignored.- plot_height
(
numeric
) optional
vector of length three withc(value, min, max)
. Specifies the height of the main plot and renders a slider on the plot to interactively adjust the plot height.- plot_width
(
numeric
) optional
vector of length three withc(value, min, max)
. Specifies the width of the main plot and renders a slider on the plot to interactively adjust the plot width.- 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.
See also
The TLG Catalog where additional example apps implementing this module can be found.
Examples
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")
)
)
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
)
)
)
)
#> Initializing tm_g_km
#> Initializing reporter_previewer_module
if (interactive()) {
shinyApp(app$ui, app$server)
}