Skip to contents

Display the AE overview plot as a shiny module

Usage

tm_g_ae_oview(
  label,
  dataname,
  parentname = "ADSL",
  arm_var = teal.picks::variables(dplyr::starts_with("ACTARM")),
  flag_var_anl = teal.picks::variables(dplyr::matches("^(TMPFL|AEREL[1-9])")),
  fontsize = c(5, 3, 7),
  plot_height = c(600L, 200L, 2000L),
  plot_width = NULL,
  transformators = list(),
  decorators = list()
)

Arguments

label

(character(1)) Label shown in the navigation item for the module or module group. For modules() defaults to "root". See Details.

dataname

(character(1))
analysis data used in the teal module, needs to be available in the list passed to the data argument of teal::init().

parentname

(character(1))
analysis data used for several variables in the teal module, needs to be available in the list passed to the data argument of teal::init(). The default is "ADSL"

arm_var

Either a (teal.picks::variables()) object or a (teal.transform::choices_selected()) object.
choices_selected is being deprecated as an argument type and will be removed in the future. Object with all available choices and the pre-selected option for variable names that can be used as arm_var. Column arm_var in the dataname has to be a factor.

flag_var_anl

Either a (teal.picks::variables()) object or a (teal.transform::choices_selected()) object. choices_selected() is being deprecated as an argument type and will be removed in the future. Object with variables used to count adverse event sub-groups (e.g. Serious events, Related events, etc.)

fontsize

(numeric(1) or numeric(3))
Defines initial possible range of font-size. fontsize is set for teal.widgets::optionalSliderInputValMinMax() which controls font-size in the output plot.

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.

transformators

(list of teal_transform_module) that will be applied to transform module's data input. To learn more check vignette("transform-input-data", package = "teal").

decorators

[Experimental] (named list of teal_transform_module) optional, decorators for the module plot output.

Value

the teal::module() object.

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_ae_oview(
   ..., # 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:

Examples

data <- within(teal_data(), {
  library(dplyr)
  ADSL <- teal.data::rADSL
  ADAE <- teal.data::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)]
app <- suppressWarnings(init(
  data = data,
  modules = modules(
    tm_g_ae_oview(
      label = "AE Overview",
      dataname = "ADAE",
      parentname = "ADSL",
      arm_var = variables(
        choices = dplyr::starts_with("ACTARM"),
        selected = "ACTARMCD"
      ),
      flag_var_anl = variables(
        choices = c("TMPFL_SER", "TMPFL_REL", "TMPFL_GR5", "AEREL1", "AEREL2"),
        selected = "AEREL1"
      )
    )
  )
), classes = "picks_delayed")
#> Initializing tm_g_ae_oview
if (interactive()) {
  shinyApp(app$ui, app$server)
}