Teal Module: Adverse Events Summary
Usage
tm_t_events_summary(
label,
dataname,
parentname = ifelse(inherits(arm_var, "data_extract_spec"),
teal.transform::datanames_input(arm_var), "ADSL"),
arm_var,
flag_var_anl = NULL,
flag_var_aesi = NULL,
dthfl_var =
teal.transform::choices_selected(teal.transform::variable_choices(parentname,
"DTHFL"), "DTHFL", fixed = TRUE),
dcsreas_var =
teal.transform::choices_selected(teal.transform::variable_choices(parentname,
"DCSREAS"), "DCSREAS", fixed = TRUE),
llt = teal.transform::choices_selected(teal.transform::variable_choices(dataname,
"AEDECOD"), "AEDECOD", fixed = TRUE),
aeseq_var = teal.transform::choices_selected(teal.transform::variable_choices(dataname,
"AESEQ"), "AESEQ", fixed = TRUE),
add_total = TRUE,
count_subj = TRUE,
count_pt = TRUE,
count_events = TRUE,
pre_output = NULL,
post_output = NULL,
basic_table_args = teal.widgets::basic_table_args()
)
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
(
choices_selected
ordata_extract_spec
)
object with all available choices and preselected option for variable names that can be used asarm_var
. It defines the grouping variable(s) in the results table. If there are two elements selected forarm_var
, second variable will be nested under the first variable.- flag_var_anl
(
teal.transform::choices_selected()
orteal.transform::data_extract_spec()
)
vector with names of flag variables fromdataset
used to count adverse event sub-groups (e.g. Serious events, Related events, etc.). Variable labels are used as table row names if they exist.- flag_var_aesi
(
teal.transform::choices_selected()
orteal.transform::data_extract_spec()
)
vector with names of flag variables fromdataset
used to count adverse event special interest groups. All flag variables must be of typelogical
. Variable labels are used as table row names if they exist.- dthfl_var
(
teal.transform::choices_selected()
orteal.transform::data_extract_spec()
)
variable for subject death flag fromparentname
. Records with `"Y"`` are summarized in the table row for "Total number of deaths".- dcsreas_var
(
teal.transform::choices_selected()
orteal.transform::data_extract_spec()
)
variable for study discontinuation reason fromparentname
. Records with"ADVERSE EVENTS"
are summarized in the table row for "Total number of patients withdrawn from study due to an AE".- llt
(
choices_selected
ordata_extract_spec
)
name of the variable with low level term for events.- aeseq_var
(
teal.transform::choices_selected()
orteal.transform::data_extract_spec()
)
variable for adverse events sequence number fromdataset
. Used for counting total number of events.- add_total
(
logical
)
whether to include column with total number of patients.- count_subj
(
logical
)
w whether to show count of unique subjects based onUSUBJID
. Only applies if event flag variables are provided.- count_pt
(
logical
)
whether to show count of unique preferred terms based onllt
. Only applies if event flag variables are provided.- count_events
(
logical
)
whether to show count of events based onaeseq_var
. Only applies if event flag variables are provided.- pre_output
optional, (
shiny.tag
)
with text placed before the output to put the output into context. For example a title.- post_output
optional, (
shiny.tag
)
with text placed after the output to put the output into context. For example theshiny::helpText()
elements are useful.- basic_table_args
-
optional, (
basic_table_args
)
object created byteal.widgets::basic_table_args()
with settings for the module table. The argument is merged with optionteal.basic_table_args
and with default module arguments (hard coded in the module body).For more details, see the vignette:
vignette("custom-basic-table-arguments", package = "teal.widgets")
.
Examples
adsl <- tmc_ex_adsl %>%
dplyr::mutate(
DTHFL = dplyr::case_when( # nolint
!is.na(DTHDT) ~ "Y",
TRUE ~ ""
) %>% formatters::with_label("Subject Death Flag")
)
adae <- tmc_ex_adae
add_event_flags <- function(dat) {
dat <- dat %>%
dplyr::mutate(
TMPFL_SER = AESER == "Y",
TMPFL_REL = AEREL == "Y",
TMPFL_GR5 = AETOXGR == "5",
TMP_SMQ01 = !is.na(SMQ01NAM),
TMP_SMQ02 = !is.na(SMQ02NAM),
TMP_CQ01 = !is.na(CQ01NAM)
)
column_labels <- list(
TMPFL_SER = "Serious AE",
TMPFL_REL = "Related AE",
TMPFL_GR5 = "Grade 5 AE",
TMP_SMQ01 = aesi_label(dat[["SMQ01NAM"]], dat[["SMQ01SC"]]),
TMP_SMQ02 = aesi_label("Y.9.9.9.9/Z.9.9.9.9 AESI"),
TMP_CQ01 = aesi_label(dat[["CQ01NAM"]])
)
formatters::var_labels(dat)[names(column_labels)] <- as.character(column_labels)
dat
}
# Generating user-defined event flags.
adae <- adae %>% add_event_flags()
ae_anl_vars <- names(adae)[startsWith(names(adae), "TMPFL_")]
aesi_vars <- names(adae)[startsWith(names(adae), "TMP_")]
app <- init(
data = cdisc_data(
cdisc_dataset("ADSL", adsl),
cdisc_dataset("ADAE", adae)
),
modules = modules(
tm_t_events_summary(
label = "Adverse Events Summary",
dataname = "ADAE",
arm_var = choices_selected(
choices = variable_choices("ADSL", c("ARM", "ARMCD")),
selected = "ARM"
),
flag_var_anl = choices_selected(
choices = variable_choices("ADAE", ae_anl_vars),
selected = ae_anl_vars[1],
keep_order = TRUE,
fixed = FALSE
),
flag_var_aesi = choices_selected(
choices = variable_choices("ADAE", aesi_vars),
selected = aesi_vars[1],
keep_order = TRUE,
fixed = FALSE
),
add_total = TRUE
)
)
)
#> [INFO] 2023-05-31 23:41:43.2318 pid:3043 token:[] teal.modules.clinical Initializing tm_t_events_summary
if (interactive()) {
shinyApp(app$ui, app$server)
}