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_selectedordata_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 fromdatasetused 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 fromdatasetused 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_selectedordata_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_argsand 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
library(dplyr)
library(scda)
ADSL <- synthetic_cdisc_data("latest")$adsl %>%
mutate(
DTHFL = case_when( # nolint
!is.na(DTHDT) ~ "Y",
TRUE ~ ""
)
)
attr(ADSL[["DTHFL"]], "label") <- "Subject Death Flag"
ADAE <- synthetic_cdisc_data("latest")$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,
code =
'ADSL <- synthetic_cdisc_data("latest")$adsl %>%
mutate(
DTHFL = case_when( # nolint
!is.na(DTHDT) ~ "Y",
TRUE ~ ""
)
)
attr(ADSL[["DTHFL"]], "label") <- "Subject Death Flag"
ADSL'
),
cdisc_dataset("ADAE", ADAE,
code =
"ADAE <- synthetic_cdisc_data('latest')$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()"
)
),
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] 2022-10-14 09:10:46.5571 pid:3139 token:[] teal.modules.clinical Initializing tm_t_events_summary
if (FALSE) {
shinyApp(app$ui, app$server)
}