Title: 'teal' Modules for Standard Clinical Outputs
Version: 0.10.0
Date: 2025-02-26
Description: Provides user-friendly tools for creating and customizing clinical trial reports. By leveraging the 'teal' framework, this package provides 'teal' modules to easily create an interactive panel that allows for seamless adjustments to data presentation, thereby streamlining the creation of detailed and accurate reports.
License: Apache License 2.0
URL: https://insightsengineering.github.io/teal.modules.clinical/, https://github.com/insightsengineering/teal.modules.clinical/
BugReports: https://github.com/insightsengineering/teal.modules.clinical/issues
Depends: R (≥ 4.0), teal (≥ 0.16.0), teal.transform (≥ 0.6.0), tern (≥ 0.9.7)
Imports: broom (≥ 0.7.10), checkmate (≥ 2.1.0), cowplot (≥ 0.7.0), dplyr (≥ 1.0.5), DT (≥ 0.13), ggplot2 (≥ 3.4.0), ggrepel, grid, lifecycle (≥ 0.2.0), methods, rlistings (≥ 0.2.10), rmarkdown (≥ 2.23), rtables (≥ 0.6.11), scales, shiny (≥ 1.6.0), shinyjs, shinyvalidate, shinyWidgets (≥ 0.5.1), stats, teal.code (≥ 0.6.1), teal.data (≥ 0.7.0), teal.logger (≥ 0.3.2), teal.reporter (≥ 0.4.0), teal.widgets (≥ 0.4.3), tern.gee (≥ 0.1.5), tern.mmrm (≥ 0.3.1), utils, vistime (≥ 1.2.3)
Suggests: forcats, knitr (≥ 1.42), logger (≥ 0.2.0), lubridate (≥ 1.7.9), nestcolor (≥ 0.1.0), pkgload, roxy.shinylive, rvest, shinytest2, styler, testthat (≥ 3.1.5), withr (> 2.0.1.5)
VignetteBuilder: knitr, rmarkdown
Config/Needs/verdepcheck: insightsengineering/teal, insightsengineering/teal.slice, insightsengineering/teal.transform, insightsengineering/tern, tidymodels/broom, mllg/checkmate, wilkelab/cowplot, tidyverse/dplyr, rstudio/DT, tidyverse/ggplot2, slowkow/ggrepel, r-lib/lifecycle, daroczig/logger, insightsengineering/rlistings, rstudio/rmarkdown, insightsengineering/rtables, r-lib/scales, rstudio/shiny, daattali/shinyjs, rstudio/shinyvalidate, dreamRs/shinyWidgets, insightsengineering/teal.code, insightsengineering/teal.data, insightsengineering/teal.logger, insightsengineering/teal.reporter, insightsengineering/teal.widgets, insightsengineering/tern.gee, insightsengineering/tern.mmrm, shosaco/vistime, tidyverse/forcats, yihui/knitr, tidyverse/lubridate, insightsengineering/nestcolor, r-lib/pkgload, insightsengineering/roxy.shinylive, tidyverse/rvest, rstudio/shinytest2, r-lib/styler, r-lib/testthat, r-lib/withr
Config/Needs/website: insightsengineering/nesttemplate
Config/testthat/edition: 3
Encoding: UTF-8
Language: en-US
LazyData: true
RoxygenNote: 7.3.2
NeedsCompilation: no
Packaged: 2025-02-28 15:10:15 UTC; unardid
Author: Joe Zhu ORCID iD [aut], Jana Stoilova [aut], Davide Garolini [aut], Emily de la Rua [aut], Abinaya Yogasekaram [aut], Mahmoud Hallal [aut], Dawid Kaledkowski [aut, cre], Rosemary Li [aut], Heng Wang [aut], Pawel Rucki [aut], Nikolas Burkoff [aut], Konrad Pagacz [aut], Vaakesan Sundrelingam [ctb], Francois Collin [ctb], Imanol Zubizarreta [ctb], F. Hoffmann-La Roche AG [cph, fnd]
Maintainer: Dawid Kaledkowski <dawid.kaledkowski@roche.com>
Repository: CRAN
Date/Publication: 2025-02-28 15:50:02 UTC

teal Modules for Standard Clinical Outputs

Description

Provides teal modules for the standard clinical trials outputs. The teal modules add an encoding panel to interactively change the encodings within teal.

Author(s)

Maintainer: Dawid Kaledkowski dawid.kaledkowski@roche.com

Authors:

Other contributors:

See Also

Useful links:


Expression List

Description

Add a new expression to a list (of expressions).

Usage

add_expr(expr_ls, new_expr)

Arguments

expr_ls

(list of call)
the list to which a new expression should be added.

new_expr

(call)
the new expression to add.

Details

Offers a stricter control to add new expressions to an existing list. The list of expressions can be later used to generate a pipeline, for instance with pipe_expr.

Value

a list of call.

Examples

library(rtables)

lyt <- list()
lyt <- add_expr(lyt, substitute(basic_table()))
lyt <- add_expr(
  lyt, substitute(split_cols_by(var = arm), env = list(armcd = "ARMCD"))
)
lyt <- add_expr(
  lyt,
  substitute(
    test_proportion_diff(
      vars = "rsp", method = "cmh", variables = list(strata = "strata")
    )
  )
)
lyt <- add_expr(lyt, quote(build_table(df = dta)))
pipe_expr(lyt)

Observer for Treatment reference variable

Description

[Stable] Updates the reference and comparison Treatments when the selected Treatment variable changes

Usage

arm_ref_comp_observer(
  session,
  input,
  output,
  id_ref = "Ref",
  id_comp = "Comp",
  id_arm_var,
  data,
  arm_ref_comp,
  module,
  on_off = reactive(TRUE),
  input_id = "buckets",
  output_id = "arms_buckets"
)

Arguments

session

(environment)
shiny session

input

(character)
shiny input

output

(character)
shiny input

id_ref

(character)
id of reference Treatment input UI element

id_comp

(character)
id of comparison group input UI element

id_arm_var

(character)
id of Treatment variable input UI element

data

(reactive or data.frame)
dataset used to validate Treatment reference inputs and set id_ref input.

arm_ref_comp

(unknown)
Treatment reference and compare variables provided as a nested list where each Treatment variable corresponds a list specifying the default levels for the reference and comparison treatments.

module

(character)
name of the module where this is called (this is only used to produce more informative error messages)

on_off

(logical)
A reactive that can be used to stop the whole observer if FALSE.

input_id

(character)
unique id that the buckets will be referenced with.

output_id

(character)
name of the UI id that the output will be written to.

Value

Returns a shinyvalidate::InputValidator which checks that there is at least one reference and comparison arm


Parse text input to numeric vector

Description

Generic to parse text into numeric vectors. This was initially designed for a robust interpretation of text input in teal modules.

Usage

as_num(str)

## Default S3 method:
as_num(str)

## S3 method for class 'character'
as_num(str)

## S3 method for class 'numeric'
as_num(str)

## S3 method for class 'factor'
as_num(str)

## S3 method for class 'logical'
as_num(str)

Arguments

str

(vector)
to extract numeric from.

Details

The function is intended to extract any numeric from a character string, factor levels, boolean and return a vector of numeric.

Value

As vector of numeric if directly parsed from numeric or boolean. A list of numeric if parsed from a character string, each character string associated with an list item.

Examples

dta <- list(
  character = c("text10,20.5letter30.!", "!-.40$$-50e5[", NA),
  factor    = factor(c("]+60e-6, 7.7%%8L", "%90sep.100\"1L", NA_character_)),
  numeric   = c(1, -5e+2, NA),
  logical   = c(TRUE, FALSE, NA)
)
lapply(dta, as_num)

Expressions in Brackets

Description

Groups several expressions in a single bracketed expression.

Usage

bracket_expr(exprs)

Arguments

exprs

(list of call)
expressions to concatenate into a single bracketed expression.

Value

a ⁠{⁠ object. See base::Paren() for details.

Examples

adsl <- tmc_ex_adsl
adrs <- tmc_ex_adrs

expr1 <- substitute(
  expr = anl <- subset(df, PARAMCD == param),
  env = list(df = as.name("adrs"), param = "INVET")
)
expr2 <- substitute(expr = anl$rsp_lab <- d_onco_rsp_label(anl$AVALC))
expr3 <- substitute(
  expr = {
    anl$is_rsp <- anl$rsp_lab %in%
      c("Complete Response (CR)", "Partial Response (PR)")
  }
)

res <- bracket_expr(list(expr1, expr2, expr3))
eval(res)
table(anl$rsp_lab, anl$is_rsp)


Concatenate expressions via a binary operator

Description

e.g. combine with + for ggplot without introducing parentheses due to associativity

Usage

call_concatenate(args, bin_op = "+")

Arguments

args

arguments to concatenate with operator

bin_op

binary operator to concatenate it with

Value

a call

Examples

library(ggplot2)

# What we want to achieve
call("+", quote(f), quote(g))
call("+", quote(f), call("+", quote(g), quote(h))) # parentheses not wanted
call("+", call("+", quote(f), quote(g)), quote(h)) # as expected without unnecessary parentheses
Reduce(function(existing, new) call("+", existing, new), list(quote(f), quote(g), quote(h)))

# how we do it
call_concatenate(list(quote(f), quote(g), quote(h)))
call_concatenate(list(quote(f)))
call_concatenate(list())
call_concatenate(
  list(quote(ggplot(mtcars)), quote(geom_point(aes(wt, mpg))))
)

eval(
  call_concatenate(
    list(quote(ggplot(mtcars)), quote(geom_point(aes(wt, mpg))))
  )
)


Check if the Treatment variable is reference or compare

Description

[Stable]

Usage

check_arm_ref_comp(x, df_to_check, module)

Arguments

x

(character)
Name of the variable

df_to_check

(data.frame)
table to check

module

(character)
teal module the ref and comp are called in

Value

TRUE or FALSE whether the variable is in ref or comp


Clean up categorical variable description

Description

Cleaning categorical variable descriptions before presenting.

Usage

clean_description(x)

Arguments

x

(character)
vector with categories descriptions.

Value

a string

Examples

clean_description("Level A (other text)")
clean_description("A long string that should be shortened")


Mapping function for Laboratory Table

Description

Map value and level characters to values with with proper html tags, colors and icons.

Usage

color_lab_values(
  x,
  classes = c("HIGH", "NORMAL", "LOW"),
  colors = list(HIGH = "red", NORMAL = "grey", LOW = "blue"),
  default_color = "black",
  icons = list(HIGH = "glyphicon glyphicon-arrow-up", LOW =
    "glyphicon glyphicon-arrow-down")
)

Arguments

x

(character)
vector with elements under the format (⁠value level⁠).

classes

(character)
classes vector.

colors

(list)
color per class.

default_color

(character)
default color.

icons

(list)
certain icons per level.

Value

a character vector where each element is a formatted HTML tag corresponding to a value in x.

Examples

color_lab_values(c("LOW", "LOW", "HIGH", "NORMAL", "HIGH"))


Get full label, useful for annotating plots

Description

Get full label, useful for annotating plots

Usage

column_annotation_label(dataset, column, omit_raw_name = FALSE)

Arguments

dataset

(data.frame)
dataset

column

(character)
column to get label from

omit_raw_name

(logical)
omits the raw name in square brackets if label is found

Value

"Label ⁠[Column name]⁠" if label exists, otherwise "Column name".

Examples

data <- mtcars
column_annotation_label(data, "cyl")
attr(data[["cyl"]], "label") <- "Cylinder"
column_annotation_label(data, "cyl")
column_annotation_label(data, "cyl", omit_raw_name = TRUE)
column_annotation_label(tmc_ex_adsl, "ACTARM")

Control Function for Time-To-Event teal Module

Description

Controls the arguments for Cox regression and survival analysis results.

Usage

control_tte(
  surv_time = list(conf_level = 0.95, conf_type = "plain", quantiles = c(0.25, 0.75)),
  coxph = list(pval_method = "log-rank", ties = "efron", conf_level = 0.95),
  surv_timepoint = control_surv_timepoint(conf_level = 0.95, conf_type = c("plain",
    "none", "log", "log-log"))
)

Arguments

surv_time

(list)
control parameters for survfit model. See tern::control_surv_time() for details.

coxph

(list)
control parameters for Cox-PH model. See tern::control_coxph() for details.

surv_timepoint

(list)
control parameters for survfit model at time point. See tern::control_surv_timepoint() for details.

See Also

template_tte(), tm_t_tte()


Convert choices_selected to data_extract_spec with only filter_spec

Description

Convert choices_selected to data_extract_spec with only filter_spec

Usage

cs_to_des_filter(
  cs,
  dataname,
  multiple = FALSE,
  include_vars = FALSE,
  label = "Filter by"
)

Arguments

cs

(choices_selected)
object to be transformed. See teal.transform::choices_selected() for details.

dataname

(character)
name of the data

multiple

(logical)
Whether multiple values shall be allowed in the shiny shiny::selectInput().

include_vars

(flag)
whether to include the filter variables as fixed selection in the result. This can be useful for preserving for reuse in rtables code e.g.

label

(character)
Label to print over the selection field. For no label, set to NULL.

Value

(teal.transform::data_extract_spec())


Convert choices_selected to data_extract_spec with only select_spec

Description

Convert choices_selected to data_extract_spec with only select_spec

Usage

cs_to_des_select(
  cs,
  dataname,
  multiple = FALSE,
  ordered = FALSE,
  label = "Select"
)

Arguments

cs

(choices_selected)
object to be transformed. See teal.transform::choices_selected() for details.

dataname

(character)
name of the data

multiple

(logical)
Whether multiple values shall be allowed in the shiny shiny::selectInput().

ordered

(logical(1))
Flags whether selection order should be tracked.

label

(character)
Label to print over the selection field. For no label, set to NULL.

Value

(teal.transform::data_extract_spec())


Convert choices_selected to filter_spec

Description

Convert choices_selected to filter_spec

Usage

cs_to_filter_spec(cs, multiple = FALSE, label = "Filter by")

Arguments

cs

(choices_selected)
object to be transformed. See teal.transform::choices_selected() for details.

multiple

(logical)
Whether multiple values shall be allowed in the shiny shiny::selectInput().

label

(character)
Label to print over the selection field. For no label, set to NULL.

Value

(teal.transform::filter_spec())


Convert choices_selected to select_spec

Description

Convert choices_selected to select_spec

Usage

cs_to_select_spec(cs, multiple = FALSE, ordered = FALSE, label = "Select")

Arguments

cs

(choices_selected)
object to be transformed. See teal.transform::choices_selected() for details.

multiple

(logical)
Whether multiple values shall be allowed in the shiny shiny::selectInput().

ordered

(logical(1))
Flags whether selection order should be tracked.

label

(character)
Label to print over the selection field. For no label, set to NULL.

Value

(select_spec)


Default string for total column label

Description

[Stable]

The default string used as a label for the "total" column. This value is used as the default value for the total_label argument throughout the teal.modules.clinical package. If not specified for each module by the user via the total_label argument, or in the R environment options via set_default_total_label(), then "All Patients" is used.

Usage

default_total_label()

set_default_total_label(total_label)

Arguments

total_label

(string)
Single string value to set in the R environment options as the default label to use for the "total" column. Use getOption("tmc_default_total_label") to check the current value set in the R environment (defaults to "All Patients" if not set).

Value

Functions

Examples

# Default settings
default_total_label()
getOption("tmc_default_total_label")

# Set custom value
set_default_total_label("All Patients")

# Settings after value has been set
default_total_label()
getOption("tmc_default_total_label")


Simulated CDISC Data for Examples

Description

Simulated CDISC Data for Examples

Usage

tmc_ex_adsl

tmc_ex_adae

tmc_ex_adaette

tmc_ex_adcm

tmc_ex_adeg

tmc_ex_adex

tmc_ex_adlb

tmc_ex_admh

tmc_ex_adqs

tmc_ex_adrs

tmc_ex_adtte

tmc_ex_advs

Format

rds (data.frame)

An object of class tbl_df (inherits from tbl, data.frame) with 200 rows and 26 columns.

An object of class tbl_df (inherits from tbl, data.frame) with 541 rows and 51 columns.

An object of class tbl_df (inherits from tbl, data.frame) with 1800 rows and 35 columns.

An object of class tbl_df (inherits from tbl, data.frame) with 512 rows and 45 columns.

An object of class tbl_df (inherits from tbl, data.frame) with 5200 rows and 48 columns.

An object of class tbl_df (inherits from tbl, data.frame) with 200 rows and 37 columns.

An object of class tbl_df (inherits from tbl, data.frame) with 3000 rows and 58 columns.

An object of class tbl_df (inherits from tbl, data.frame) with 1077 rows and 33 columns.

An object of class tbl_df (inherits from tbl, data.frame) with 7000 rows and 36 columns.

An object of class tbl_df (inherits from tbl, data.frame) with 1600 rows and 34 columns.

An object of class tbl_df (inherits from tbl, data.frame) with 1000 rows and 34 columns.

An object of class tbl_df (inherits from tbl, data.frame) with 8400 rows and 34 columns.

Functions


Extracts html id for data_extract_ui

Description

The data_extract_ui is located under extended html id. We could not use ns("original id") for reference, as it is extended with specific suffixes.

Usage

extract_input(varname, dataname, filter = FALSE)

Arguments

varname

(character)
the original html id. This should be retrieved with ns("original id") in the UI function or session$ns("original id")/"original id" in the server function.

dataname

(character)
dataname from data_extract input. This might be retrieved like data_extract_spec(...)[[1]]$dataname.

filter

(logical) optional,
if the connected extract_data_spec has objects passed to its filter argument

Value

a string

Examples

extract_input("ARM", "ADSL")


Facetting formula x_facet ~ y_facet

Description

[Stable] Replaces x_facet or y_facet by . when empty character

Usage

facet_grid_formula(x_facet, y_facet)

Arguments

x_facet

(character(1))
name of x facet, if empty, will not facet along x.

y_facet

(character(1))
name of y facet, if empty, will not facet along y.

Value

facet grid formula formula(x_facet ~ y_facet)


Utility function for extracting paramcd for forest plots

Description

Utility function for extracting paramcd for forest plots

Usage

get_g_forest_obj_var_name(paramcd, input, filter_idx = 1)

Arguments

paramcd

teal.transform::data_extract_spec() variable value designating the studied parameter.

input

shiny app input

filter_idx

filter section index (default 1)


Extract the associated parameter value for paramcd

Description

Utility function for extracting the parameter value that is associated with the paramcd value label. If there is no parameter value for the paramcd label, the paramcd value is returned. This is used for generating the title.

Usage

get_paramcd_label(anl, paramcd)

Arguments

anl

Analysis dataset

paramcd

teal.transform::data_extract_spec() variable value designating the studied parameter.


Get variable labels

Description

[Deprecated]

Usage

get_var_labels(datasets, dataname, vars)

Arguments

datasets

(teal::FilteredData)
Data built up by teal

dataname

(character)
name of the dataset

vars

(character)
Column names in the data

Value

character variable labels.


Expression Deparsing

Description

Deparse an expression into a string.

Usage

h_concat_expr(expr)

Arguments

expr

(call)
or an object which can be used as so.

Value

a string.

Examples

expr <- quote({
  library(rtables)
  basic_table() %>%
    split_cols_by(var = "ARMCD") %>%
    test_proportion_diff(
      vars = "rsp", method = "cmh", variables = list(strata = "strata")
    ) %>%
    build_table(df = dta)
})

h_concat_expr(expr)

Whether object is of class teal.transform::choices_selected()

Description

Whether object is of class teal.transform::choices_selected()

Usage

is.cs_or_des(x)

Arguments

x

object to be checked

Value

(logical)


ggplot2 call to generate simple bar chart

Description

ggplot2 call to generate simple bar chart

Usage

make_barchart_simple_call(
  y_name,
  x_name = NULL,
  fill_name = NULL,
  x_facet_name = NULL,
  y_facet_name = NULL,
  label_bars = TRUE,
  barlayout = c("side_by_side", "stacked"),
  flip_axis = FALSE,
  rotate_bar_labels = FALSE,
  rotate_x_label = FALSE,
  rotate_y_label = FALSE,
  expand_y_range = 0,
  facet_scales = "free_x",
  ggplot2_args = teal.widgets::ggplot2_args()
)

Arguments

y_name

(character or NULL)
name of the y-axis variable.

x_name

(character or NULL)
name of the x-axis variable. Defaults to NULL because it is dependent on extract input which can be empty.

fill_name

(character or NULL)
name of the variable to determine the bar fill color.

x_facet_name

(character or NULL)
name of the variable to use for horizontal plot faceting.

y_facet_name

(character or NULL)
name of the variable to use for vertical plot faceting.

label_bars

(logical or NULL)
whether bars should be labeled. If TRUE, label bar numbers would also be drawn as text.

barlayout

(character or NULL)
type of the bar layout. Options are "stacked" (default) or "side_by_side".

flip_axis

(character or NULL)
whether to flip the plot axis.

rotate_bar_labels

(logical or NULL)
whether bar labels should be rotated by 45 degrees.

rotate_x_label

(logical or NULL)
whether x-axis labels should be rotated by 45 degrees.

rotate_y_label

(logical or NULL)
whether y-axis labels should be rotated by 45 degrees.

expand_y_range

(numeric or NULL)
fraction of y-axis range to further expand by.

facet_scales

(character)
value passed to scales argument of ggplot2::facet_grid(). Options are fixed, free_x, free_y, and free.

ggplot2_args

(ggplot2_args) optional
object created by teal.widgets::ggplot2_args() with settings for the module plot. The argument is merged with option teal.ggplot2_args and with default module arguments (hard coded in the module body). For more details, see the vignette: vignette("custom-ggplot2-arguments", package = "teal.widgets").

Value

call to produce a ggplot object.


Standard Module Arguments

Description

The documentation to this function lists all the arguments in teal modules that are used repeatedly to express an analysis.

Arguments

arm_ref_comp

(list) optional,
if specified it must be a named list with each element corresponding to an arm variable in ADSL and the element must be another list (possibly with delayed teal.transform::variable_choices() or delayed teal.transform::value_choices() with the elements named ref and comp that the defined the default reference and comparison arms when the arm variable is changed.

arm_var

(teal.transform::choices_selected())
object with all available choices and preselected option for variable names that can be used as arm_var. It defines the grouping variable in the results table.

atirel

(teal.transform::choices_selected())
object with all available choices and preselected option for the ATIREL variable from dataname.

aval_var

(teal.transform::choices_selected())
object with all available choices and pre-selected option for the analysis variable.

avalu_var

(teal.transform::choices_selected())
object with all available choices and preselected option for the analysis unit variable.

avisit

(teal.transform::choices_selected())
value of analysis visit AVISIT of interest.

baseline_var

(teal.transform::choices_selected())
object with all available choices and preselected option for variable values that can be used as baseline_var.

by_vars

(teal.transform::choices_selected())
object with all available choices and preselected option for variable names used to split the summary by rows.

cmdecod

(teal.transform::choices_selected())
object with all available choices and preselected option for the CMDECOD variable from dataname.

cmindc

(teal.transform::choices_selected())
object with all available choices and preselected option for the CMINDC variable from dataname.

cmstdy

(teal.transform::choices_selected())
object with all available choices and preselected option for the CMSTDY variable from dataname.

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).

cov_var

(teal.transform::choices_selected())
object with all available choices and preselected option for the covariates variables.

dataname

(character)
analysis data used in teal module.

default_responses

(list or character)
defines the default codes for the response variable in the module per value of paramcd. A passed vector is transmitted for all paramcd values. A passed list must be named and contain arrays, each name corresponding to a single value of paramcd. Each array may contain default response values or named arrays rsp of default selected response values and levels of default level choices.

fixed_symbol_size

(logical)
When (TRUE), the same symbol size is used for plotting each estimate. Otherwise, the symbol size will be proportional to the sample size in each each subgroup.

font_size

(numeric)
numeric vector of length 3 of current, minimum and maximum font size values.

hlt

(teal.transform::choices_selected())
name of the variable with high level term for events.

id_var

(teal.transform::choices_selected())
object specifying the variable name for subject id.

interact_var

(character)
name of the variable that should have interactions with arm. If the interaction is not needed, the default option is NULL.

interact_y

(character)
a selected item from the interact_var column which will be used to select the specific ANCOVA results when interact_var is discrete. If the interaction is not needed, the default option is FALSE.

label

(character)
menu item label of the module in the teal app.

llt

(teal.transform::choices_selected())
name of the variable with low level term for events.

paramcd

(teal.transform::choices_selected())
object with all available choices and preselected option for the parameter code variable from dataname.

parentname

(character)
parent analysis data used in teal module, usually this refers to ADSL.

patient_col

(character)
name of patient ID variable.

plot_height

(numeric) optional
vector of length three with c(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 with c(value, min, max). Specifies the width of the main plot and renders a slider on the plot to interactively adjust the plot width.

post_output

(shiny.tag) optional,
with text placed after the output to put the output into context. For example the shiny::helpText() elements are useful.

pre_output

(shiny.tag) optional,
with text placed before the output to put the output into context. For example a title.

strata_var

(teal.transform::choices_selected())
names of the variables for stratified analysis.

summarize_vars

(teal.transform::choices_selected())
names of the variables that should be summarized.

subgroup_var

(teal.transform::choices_selected())
object with all available choices and preselected option for variable names that can be used as the default subgroups.

time_points

(teal.transform::choices_selected())
object with all available choices and preselected option for time points that can be used in tern::surv_timepoint().

time_unit_var

(teal.transform::choices_selected())
object with all available choices and pre-selected option for the time unit variable.

treatment_flag

(teal.transform::choices_selected())
value indicating on treatment records in treatment_flag_var.

treatment_flag_var

(teal.transform::choices_selected())
on treatment flag variable.

useNA

(character)
whether missing data (NA) should be displayed as a level.

visit_var

(teal.transform::choices_selected())
object with all available choices and preselected option for variable names that can be used as visit variable. Must be a factor in dataname.

worst_flag_indicator

(teal.transform::choices_selected())
value indicating worst grade.

worst_flag_var

(teal.transform::choices_selected())
object with all available choices and preselected option for variable names that can be used as worst flag variable.

decorators

[Experimental] (named list of lists of teal_transform_module) optional, decorator for tables or plots included in the module output reported. The decorators are applied to the respective output objects.

See section "Decorating Module" below for more details.

Details

Value

a teal_module object.

See Also

The TLG Catalog where additional example apps implementing this module can be found.


Expressions as a Pipeline

Description

Concatenate expressions in a single pipeline-flavor expression.

Usage

pipe_expr(exprs, pipe_str = "%>%")

Arguments

exprs

(list of call)
expressions to concatenate in a pipeline (⁠%>%⁠).

pipe_str

(character)
the character which separates the expressions.

Value

a call

Examples

pipe_expr(
  list(
    expr1 = substitute(df),
    expr2 = substitute(head)
  )
)


Expression: Arm Preparation

Description

The function generate the standard expression for pre-processing of dataset in teal module applications. This is especially of interest when the same preprocessing steps needs to be applied similarly to several datasets (e.g. ADSL and ADRS).

Usage

prepare_arm(
  dataname,
  arm_var,
  ref_arm,
  comp_arm,
  compare_arm = !is.null(ref_arm),
  ref_arm_val = paste(ref_arm, collapse = "/"),
  drop = TRUE
)

Arguments

dataname

(character)
analysis data used in teal module.

arm_var

(character)
variable names that can be used as arm_var.

ref_arm

(character)
the level of reference arm in case of arm comparison.

comp_arm

(character)
the level of comparison arm in case of arm comparison.

compare_arm

(logical)
triggers the comparison between study arms.

ref_arm_val

(character)
replacement name for the reference level.

drop

(logical)
drop the unused variable levels.

Details

In teal.modules.clinical, the user interface includes manipulation of the study arms. Classically: the arm variable itself (e.g. ARM, ACTARM), the reference arm (0 or more), the comparison arm (1 or more) and the possibility to combine comparison arms.

Note that when no arms should be compared with each other, then the produced expression is reduced to optionally dropping non-represented levels of the arm.

When comparing arms, the pre-processing includes three steps:

  1. Filtering of the dataset to retain only the arms of interest (reference and comparison).

  2. Optional, if more than one arm is designated as reference they are combined into a single level.

  3. The reference is explicitly reassigned and the non-represented levels of arm are dropped.

Value

a call

Examples

prepare_arm(
  dataname = "adrs",
  arm_var = "ARMCD",
  ref_arm = "ARM A",
  comp_arm = c("ARM B", "ARM C")
)

prepare_arm(
  dataname = "adsl",
  arm_var = "ARMCD",
  ref_arm = c("ARM B", "ARM C"),
  comp_arm = "ARM A"
)


Expression: Prepare Arm Levels

Description

This function generates the standard expression for pre-processing of dataset arm levels in and is used to apply the same steps in safety teal modules.

Usage

prepare_arm_levels(dataname, parentname, arm_var, drop_arm_levels = TRUE)

Arguments

dataname

(character)
analysis data used in teal module.

parentname

(character)
parent analysis data used in teal module, usually this refers to ADSL.

arm_var

(character)
variable names that can be used as arm_var.

drop_arm_levels

(logical)
whether to drop unused levels of arm_var. If TRUE, arm_var levels are set to those used in the dataname dataset. If FALSE, arm_var levels are set to those used in the parentname dataset. If dataname and parentname are the same, then drop_arm_levels is set to TRUE and user input for this parameter is ignored.

Value

a ⁠{⁠ object. See base::Paren() for details.

Examples

prepare_arm_levels(
  dataname = "adae",
  parentname = "adsl",
  arm_var = "ARMCD",
  drop_arm_levels = TRUE
)

prepare_arm_levels(
  dataname = "adae",
  parentname = "adsl",
  arm_var = "ARMCD",
  drop_arm_levels = FALSE
)


Subset decorators based on the scope

Description

Subset decorators based on the scope

Usage

select_decorators(decorators, scope)

Arguments

decorators

(named list) of list decorators to subset.

scope

(character) a character vector of decorator names to include.

Value

Subsetted list with all decorators to include. It can be an empty list if none of the scope exists in decorators argument.


Split choices_selected objects with interactions into their component variables

Description

Split choices_selected objects with interactions into their component variables

Usage

split_choices(x)

Arguments

x

(choices_selected)
object with interaction terms

Value

a teal.transform::choices_selected() object.

Note

uses the regex ⁠\\*|:⁠ to perform the split.

Examples

split_choices(choices_selected(choices = c("x:y", "a*b"), selected = all_choices()))


Split-Column Expression

Description

Renders the expression for column split in rtables depending on:

Usage

split_col_expr(compare, combine, ref, arm_var)

Arguments

compare

(logical)
if TRUE the reference level is included.

combine

(logical)
if TRUE the group combination is included.

ref

(character)
the reference level (not used for combine = TRUE).

arm_var

(character)
the arm or grouping variable name.

Value

a call

Examples

split_col_expr(
  compare = TRUE,
  combine = FALSE,
  ref = "ARM A",
  arm_var = "ARMCD"
)


Split interaction terms into their component variables

Description

Split interaction terms into their component variables

Usage

split_interactions(x, by = "\\*|:")

Arguments

x

(character)
string representing the interaction usually in the form x:y or x*y.

by

(character)
regex with which to split the interaction term by.

Value

a vector of strings where each element is a component variable extracted from interaction term x.

Examples

split_interactions("x:y")
split_interactions("x*y")


Wrappers around srv_transform_teal_data that allows to decorate the data

Description

Wrappers around srv_transform_teal_data that allows to decorate the data

Usage

srv_decorate_teal_data(id, data, decorators, expr, expr_is_reactive = FALSE)

ui_decorate_teal_data(id, decorators, ...)

Arguments

id

(character(1)) shiny module instance id.

data

(reactive returning teal_data)

expr

(expression or reactive) to evaluate on the output of the decoration. When an expression it must be inline code. See within() Default is NULL which won't evaluate any appending code.

expr_is_reactive

(logical(1)) whether expr is a reactive expression that skips defusing the argument.

Details

srv_decorate_teal_data is a wrapper around srv_transform_teal_data that allows to decorate the data with additional expressions. When original teal_data object is in error state, it will show that error first.

ui_decorate_teal_data is a wrapper around ui_transform_teal_data.


Substitute Names in a Quoted Expression

Description

This function substitutes the names on both left- and right-hand sides in a quoted expression. In addition it can also do other standard substitutions on the right-hand side.

Usage

substitute_names(expr, names, others = list())

h_subst_lhs_names(qexpr, names)

substitute_lhs_names(qexpr, names)

substitute_rhs(qexpr, env)

Arguments

expr

(language)
an expression.

names

(named list of name)
requested name substitutions.

others

(named list)
requested other substitutions which will only happen on the right-hand side.

qexpr

(language)
a quoted expression.

env

(environment or list)
requested variable substitutions.

Value

The modified expression.

Functions

See Also

substitute_q()


Substitute in Quoted Expressions

Description

This version of substitute is needed because substitute() does not evaluate it's first argument, and it's often useful to be able to modify a quoted expression.

Usage

substitute_q(qexpr, env)

Arguments

qexpr

(language)
a quoted expression.

env

(environment or list)
requested variable substitutions.

Value

The modified expression.

Note

This is simplified from the package pryr to avoid another dependency.

See Also

substitute_names()


Template for Generalized Estimating Equations (GEE) analysis module

Description

Creates a valid expression to generate an analysis table using Generalized Estimating Equations (GEE).

Usage

template_a_gee(
  output_table,
  data_model_fit = "ANL",
  dataname_lsmeans = "ANL_ADSL",
  input_arm_var = "ARM",
  ref_group = "A: Drug X",
  aval_var,
  id_var,
  arm_var,
  visit_var,
  split_covariates,
  cor_struct,
  conf_level = 0.95,
  basic_table_args = teal.widgets::basic_table_args()
)

Arguments

output_table

(character)
type of output table (⁠"t_gee_cov", "t_gee_coef", "t_gee_lsmeans"⁠).

data_model_fit

(character)
dataset used to fit the model by tern.gee::fit_gee().

dataname_lsmeans

(character)
dataset used for alt_counts_df argument of rtables::build_table().

aval_var

(character)
name of the analysis value variable.

id_var

(character)
the variable name for subject id.

arm_var

(character)
variable names that can be used as arm_var.

visit_var

(character)
variable names that can be used as visit variable. Must be a factor in dataname.

split_covariates

(character)
vector of names of variables to use as covariates in tern.gee::vars_gee().

cor_struct

(character)
assumed correlation structure in tern.gee::fit_gee.

conf_level

(numeric)
value for the confidence level within the range of (0, 1).

basic_table_args

(basic_table_args) optional
object created by teal.widgets::basic_table_args() with settings for the module table. The argument is merged with option teal.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").

Value

a list of expressions to generate a table or plot object.

See Also

tm_a_gee()


Template: Abnormality Summary Table

Description

Creates a valid expression to generate a table to summarize abnormality.

Usage

template_abnormality(
  parentname,
  dataname,
  arm_var,
  id_var = "USUBJID",
  by_vars,
  abnormal = list(low = c("LOW", "LOW LOW"), high = c("HIGH", "HIGH HIGH")),
  grade = "ANRIND",
  baseline_var = "BNRIND",
  treatment_flag_var = "ONTRTFL",
  treatment_flag = "Y",
  add_total = FALSE,
  total_label = default_total_label(),
  exclude_base_abn = FALSE,
  drop_arm_levels = TRUE,
  na_level = default_na_str(),
  basic_table_args = teal.widgets::basic_table_args(),
  tbl_title
)

Arguments

parentname

(character)
parent analysis data used in teal module, usually this refers to ADSL.

dataname

(character)
analysis data used in teal module.

arm_var

(character)
variable names that can be used as arm_var.

id_var

(character)
the variable name for subject id.

by_vars

(character)
variable names used to split the summary by rows.

abnormal

(⁠named list⁠)
indicating abnormality direction and grades.

grade

(character)
name of the variable used to specify the abnormality grade. Variable must be factor.

baseline_var

(character)
name of the variable specifying baseline abnormality grade.

treatment_flag_var

(character)
name of the on treatment flag variable.

treatment_flag

(character)
name of the value indicating on treatment records in treatment_flag_var.

add_total

(logical)
whether to include column with total number of patients.

total_label

(string)
string to display as total column/row label if column/row is enabled (see add_total). Defaults to "All Patients". To set a new default total_label to apply in all modules, run set_default_total_label("new_default").

exclude_base_abn

(logical)
whether to exclude patients who had abnormal values at baseline.

drop_arm_levels

(logical)
whether to drop unused levels of arm_var. If TRUE, arm_var levels are set to those used in the dataname dataset. If FALSE, arm_var levels are set to those used in the parentname dataset. If dataname and parentname are the same, then drop_arm_levels is set to TRUE and user input for this parameter is ignored.

na_level

(character)
the NA level in the input dataset, defaults to "<Missing>".

basic_table_args

(basic_table_args) optional
object created by teal.widgets::basic_table_args() with settings for the module table. The argument is merged with option teal.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").

tbl_title

(character)
Title with label of variables from by bars

Value

a list of expressions to generate a table or plot object.

See Also

tm_t_abnormality()


Template: Laboratory test results with highest grade post-baseline

Description

Creates a valid expression to generate a table to summarize abnormality by grade.

Usage

template_abnormality_by_worst_grade(
  parentname,
  dataname,
  arm_var,
  id_var = "USUBJID",
  paramcd = "PARAMCD",
  atoxgr_var = "ATOXGR",
  worst_high_flag_var = "WGRHIFL",
  worst_low_flag_var = "WGRLOFL",
  worst_flag_indicator = "Y",
  add_total = FALSE,
  total_label = default_total_label(),
  drop_arm_levels = TRUE,
  basic_table_args = teal.widgets::basic_table_args()
)

Arguments

parentname

(character)
parent analysis data used in teal module, usually this refers to ADSL.

dataname

(character)
analysis data used in teal module.

arm_var

(character)
variable names that can be used as arm_var.

id_var

(character)
the variable name for subject id.

paramcd

(character)
name of the parameter code variable.

atoxgr_var

(character)
name of the variable indicating Analysis Toxicity Grade.

worst_high_flag_var

(character)
name of the variable indicating Worst High Grade flag

worst_low_flag_var

(character)
name of the variable indicating Worst Low Grade flag

worst_flag_indicator

(character)
flag value indicating the worst grade.

add_total

(logical)
whether to include column with total number of patients.

total_label

(string)
string to display as total column/row label if column/row is enabled (see add_total). Defaults to "All Patients". To set a new default total_label to apply in all modules, run set_default_total_label("new_default").

drop_arm_levels

(logical)
whether to drop unused levels of arm_var. If TRUE, arm_var levels are set to those used in the dataname dataset. If FALSE, arm_var levels are set to those used in the parentname dataset. If dataname and parentname are the same, then drop_arm_levels is set to TRUE and user input for this parameter is ignored.

basic_table_args

(basic_table_args) optional
object created by teal.widgets::basic_table_args() with settings for the module table. The argument is merged with option teal.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").

Value

a list of expressions to generate a table or plot object.

See Also

tm_t_abnormality_by_worst_grade()


Template: Patient Profile Adverse Events Table and Plot

Description

Creates a valid expression to generate an adverse events table and ggplot2::ggplot() plot using ADaM datasets.

Usage

template_adverse_events(
  dataname = "ANL",
  aeterm = "AETERM",
  tox_grade = "AETOXGR",
  causality = "AEREL",
  outcome = "AEOUT",
  action = "AEACN",
  time = "ASTDY",
  decod = NULL,
  patient_id,
  font_size = 12L,
  ggplot2_args = teal.widgets::ggplot2_args()
)

Arguments

dataname

(character)
analysis data used in teal module.

aeterm

(character)
name of the reported term for the adverse event variable.

tox_grade

(character)
name of the standard toxicity grade variable.

causality

(character)
name of the causality variable.

outcome

(character)
name of outcome of adverse event variable.

action

(character)
name of action taken with study treatment variable.

time

(character)
name of study day of start of adverse event variable.

decod

(character)
name of dictionary derived term variable.

patient_id

(character)
patient ID.

font_size

(numeric)
font size value.

ggplot2_args

(ggplot2_args) optional
object created by teal.widgets::ggplot2_args() with settings for the module plot. The argument is merged with option teal.ggplot2_args and with default module arguments (hard coded in the module body). For more details, see the vignette: vignette("custom-ggplot2-arguments", package = "teal.widgets").

Value

a list of expressions to generate a table or plot object.

See Also

tm_g_pp_adverse_events()


Template: ANCOVA Summary

Description

Creates a valid expression to generate an analysis of variance summary table.

Usage

template_ancova(
  dataname = "ANL",
  parentname = "ADSL",
  arm_var,
  ref_arm = NULL,
  comp_arm = NULL,
  combine_comp_arms = FALSE,
  aval_var,
  label_aval = NULL,
  cov_var,
  include_interact = FALSE,
  interact_var = NULL,
  interact_y = FALSE,
  paramcd_levels = "",
  paramcd_var = "PARAMCD",
  label_paramcd = NULL,
  visit_levels = "",
  visit_var = "AVISIT",
  conf_level = 0.95,
  basic_table_args = teal.widgets::basic_table_args()
)

Arguments

dataname

(character)
analysis data used in teal module.

parentname

(character)
parent analysis data used in teal module, usually this refers to ADSL.

arm_var

(character)
variable names that can be used as arm_var.

ref_arm

(character)
the level of reference arm in case of arm comparison.

comp_arm

(character)
the level of comparison arm in case of arm comparison.

combine_comp_arms

(logical)
triggers the combination of comparison arms.

aval_var

(character)
name of the analysis value variable.

label_aval

(character)
label of value variable used for title rendering.

cov_var

(character)
names of the covariates variables.

include_interact

(logical)
whether an interaction term should be included in the model.

interact_var

(character)
name of the variable that should have interactions with arm. If the interaction is not needed, the default option is NULL.

interact_y

(character)
a selected item from the interact_var column which will be used to select the specific ANCOVA results. If the interaction is not needed, the default option is FALSE.

paramcd_levels

(character)
variable levels for the studied parameter.

paramcd_var

(character)
variable name for the studied parameter.

label_paramcd

(character)
variable label used for title rendering.

visit_levels

(character)
variable levels for studied visits.

visit_var

(character)
variable names that can be used as visit variable. Must be a factor in dataname.

conf_level

(numeric)
value for the confidence level within the range of (0, 1).

basic_table_args

(basic_table_args) optional
object created by teal.widgets::basic_table_args() with settings for the module table. The argument is merged with option teal.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").

Value

a list of expressions to generate a table or plot object.

See Also

tm_t_ancova()


Standard Template Arguments

Description

The documentation to this function lists all the arguments in teal module templates that are used repeatedly to express an analysis.

Arguments

add_total

(logical)
whether to include column with total number of patients.

anl_name

(character)
analysis data used in teal module.

arm_var

(character)
variable names that can be used as arm_var.

atirel

(character)
name of time relation of medication variable.

aval

[Deprecated] Please use the aval_var argument instead.

avalu

[Deprecated] Please use the avalu_var argument instead.

avalu_var

(character)
name of the analysis value unit variable.

aval_var

(character)
name of the analysis value variable.

baseline_var

(character)
name of the variable for baseline values of the analysis variable.

base_var

[Deprecated] Please use the baseline_var argument instead.

basic_table_args

(basic_table_args) optional
object created by teal.widgets::basic_table_args() with settings for the module table. The argument is merged with option teal.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").

by_vars

(character)
variable names used to split the summary by rows.

cmdecod

(character)
name of standardized medication name variable.

cmindc

(character)
name of indication variable.

cmstdy

(character)
name of study relative day of start of medication variable.

cnsr_var

(character)
name of the censoring variable.

combine_comp_arms

(logical)
triggers the combination of comparison arms.

compare_arm

(logical)
triggers the comparison between study arms.

comp_arm

(character)
the level of comparison arm in case of arm comparison.

conf_level

(numeric)
value for the confidence level within the range of (0, 1).

control

(list)
list of settings for the analysis.

cov_var

(character)
names of the covariates variables.

dataname

(character)
analysis data used in teal module.

denominator

(character)
chooses how percentages are calculated. With option N, the reference population from the column total is used as the denominator. With option n, the number of non-missing records in this row and column intersection is used as the denominator. If omit is chosen, then the percentage is omitted.

drop_arm_levels

(logical)
whether to drop unused levels of arm_var. If TRUE, arm_var levels are set to those used in the dataname dataset. If FALSE, arm_var levels are set to those used in the parentname dataset. If dataname and parentname are the same, then drop_arm_levels is set to TRUE and user input for this parameter is ignored.

event_type

(character)
type of event that is summarized (e.g. adverse event, treatment). Default is "event".

font_size

(numeric)
font size value.

ggplot2_args

(ggplot2_args) optional
object created by teal.widgets::ggplot2_args() with settings for the module plot. The argument is merged with option teal.ggplot2_args and with default module arguments (hard coded in the module body). For more details, see the vignette: vignette("custom-ggplot2-arguments", package = "teal.widgets").

hlt

(character)
name of the variable with high level term for events.

id_var

(character)
the variable name for subject id.

include_interact

(logical)
whether an interaction term should be included in the model.

label_hlt

(string)
label of the hlt variable from dataname. The label will be extracted from the module.

label_llt

(string)
label of the llt variable from dataname. The label will be extracted from the module.

llt

(character)
name of the variable with low level term for events.

na_level

(string)
used to replace all NA or empty values in character or factor variables in the data. Defaults to "<Missing>". To set a default na_level to apply in all modules, run set_default_na_str("new_default").

na.rm

(logical)
whether NA values should be removed prior to analysis.

numeric_stats

(character)
names of statistics to display for numeric summary variables. Available statistics are n, mean_sd, mean_ci, median, median_ci, quantiles, range, and geom_mean.

paramcd

(character)
name of the parameter code variable.

parentname

(character)
parent analysis data used in teal module, usually this refers to ADSL.

patient_id

(character)
patient ID.

prune_diff

(number)
threshold to use for trimming table using as criteria difference in rates between any two columns.

prune_freq

(number)
threshold to use for trimming table using event incidence rate in any column.

ref_arm

(character)
the level of reference arm in case of arm comparison.

sort_criteria

(character)
how to sort the final table. Default option freq_desc sorts on column sort_freq_col by decreasing number of patients with event. Alternative option alpha sorts events alphabetically.

strata_var

(character)
names of the variables for stratified analysis.

subgroup_var

(character)
with variable names that can be used as subgroups.

sum_vars

(character)
names of the variables that should be summarized.

time_points

(character)
time points that can be used in tern::surv_timepoint().

time_unit_var

(character)
name of the variable representing time units.

title

(character)
title of the output.

total_label

(string)
string to display as total column/row label if column/row is enabled (see add_total). Defaults to "All Patients". To set a new default total_label to apply in all modules, run set_default_total_label("new_default").

treatment_flag

(character)
name of the value indicating on treatment records in treatment_flag_var.

treatment_flag_var

(character)
name of the on treatment flag variable.

useNA

(character)
whether missing data (NA) should be displayed as a level.

var_labels

(named character) optional
variable labels for relabeling the analysis variables.

visit_var

(character)
variable names that can be used as visit variable. Must be a factor in dataname.

worst_flag_indicator

(character)
value indicating worst grade.

worst_flag_var

(character)
name of the worst flag variable.

Details

Although this function just returns NULL it has two uses, for the teal module users it provides a documentation of arguments that are commonly and consistently used in the framework. For the developer it adds a single reference point to import the roxygen argument description with: ⁠@inheritParams template_arguments⁠

Value

a list of expressions to generate a table or plot object.


Template: Patient Profile Basic Info

Description

Creates a valid expression to generate a patient profile basic info report using ADaM datasets.

Usage

template_basic_info(dataname = "ANL", vars, patient_id = NULL)

Arguments

dataname

(character)
analysis data used in teal module.

vars

(character)
names of the variables to be shown in the table.

patient_id

(character)
patient ID.

Value

a list of expressions to generate a table or plot object.

See Also

tm_t_pp_basic_info()


Template: Binary Outcome

Description

Creates a valid expression to generate a binary outcome analysis.

Usage

template_binary_outcome(
  dataname,
  parentname,
  arm_var,
  paramcd,
  ref_arm = NULL,
  comp_arm = NULL,
  compare_arm = FALSE,
  combine_comp_arms = FALSE,
  aval_var = "AVALC",
  show_rsp_cat = TRUE,
  responder_val = c("Complete Response (CR)", "Partial Response (PR)"),
  responder_val_levels = responder_val,
  control = list(global = list(method = "waldcc", conf_level = 0.95), unstrat =
    list(method_ci = "waldcc", method_test = "schouten", odds = TRUE), strat =
    list(method_ci = "cmh", method_test = "cmh", strat = NULL)),
  add_total = FALSE,
  total_label = default_total_label(),
  na_level = default_na_str(),
  basic_table_args = teal.widgets::basic_table_args()
)

Arguments

dataname

(character)
analysis data used in teal module.

parentname

(character)
parent analysis data used in teal module, usually this refers to ADSL.

arm_var

(character)
variable names that can be used as arm_var.

paramcd

(character)
response parameter value to use in the table title.

ref_arm

(character)
the level of reference arm in case of arm comparison.

comp_arm

(character)
the level of comparison arm in case of arm comparison.

compare_arm

(logical)
triggers the comparison between study arms.

combine_comp_arms

(logical)
triggers the combination of comparison arms.

aval_var

(character)
name of the analysis value variable.

show_rsp_cat

(logical)
display the multinomial response estimations.

responder_val

(character)
the short label for observations to translate AVALC into responder/non-responder.

responder_val_levels

(character)
the levels of responses that will be shown in the multinomial response estimations.

control

(list)
list of settings for the analysis.

add_total

(logical)
whether to include column with total number of patients.

total_label

(string)
string to display as total column/row label if column/row is enabled (see add_total). Defaults to "All Patients". To set a new default total_label to apply in all modules, run set_default_total_label("new_default").

na_level

(string)
used to replace all NA or empty values in character or factor variables in the data. Defaults to "<Missing>". To set a default na_level to apply in all modules, run set_default_na_str("new_default").

basic_table_args

(basic_table_args) optional
object created by teal.widgets::basic_table_args() with settings for the module table. The argument is merged with option teal.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").

Value

a list of expressions to generate a table or plot object.

See Also

tm_t_binary_outcome()


Template: Multi-Variable Cox Regression

Description

Creates a valid expression to generate a multi-variable Cox regression analysis.

Usage

template_coxreg_m(
  dataname,
  cov_var,
  arm_var,
  cnsr_var,
  aval_var,
  ref_arm,
  comp_arm,
  paramcd,
  at = list(),
  strata_var = NULL,
  combine_comp_arms = FALSE,
  control = control_coxreg(),
  na_level = default_na_str(),
  basic_table_args = teal.widgets::basic_table_args()
)

Arguments

dataname

(character)
analysis data used in teal module.

cov_var

(character)
names of the covariates variables.

arm_var

(character)
variable names that can be used as arm_var.

cnsr_var

(character)
name of the censoring variable.

aval_var

(character)
name of the analysis value variable.

ref_arm

(character)
the level of reference arm in case of arm comparison.

comp_arm

(character)
the level of comparison arm in case of arm comparison.

paramcd

(character)
name of the parameter code variable.

at

(list of numeric)
when the candidate covariate is a numeric type variable, use at to specify the value of the covariate at which the effect should be estimated.

strata_var

(character)
names of the variables for stratified analysis.

combine_comp_arms

(logical)
triggers the combination of comparison arms.

control

(list)
list of settings for the analysis (see tern::control_coxreg()).

na_level

(string)
used to replace all NA or empty values in character or factor variables in the data. Defaults to "<Missing>". To set a default na_level to apply in all modules, run set_default_na_str("new_default").

basic_table_args

(basic_table_args) optional
object created by teal.widgets::basic_table_args() with settings for the module table. The argument is merged with option teal.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").

Value

a list of expressions to generate a table or plot object.

See Also

template_coxreg_u(), tm_t_coxreg()


Template: Univariable Cox Regression

Description

Creates a valid expression to generate a univariable Cox regression analysis.

Usage

template_coxreg_u(
  dataname,
  cov_var,
  arm_var,
  cnsr_var,
  aval_var,
  ref_arm,
  comp_arm,
  paramcd,
  at = list(),
  strata_var = NULL,
  combine_comp_arms = FALSE,
  control = control_coxreg(),
  na_level = default_na_str(),
  append = FALSE,
  basic_table_args = teal.widgets::basic_table_args()
)

Arguments

dataname

(character)
analysis data used in teal module.

cov_var

(character)
names of the covariates variables.

arm_var

(character)
variable names that can be used as arm_var.

cnsr_var

(character)
name of the censoring variable.

aval_var

(character)
name of the analysis value variable.

ref_arm

(character)
the level of reference arm in case of arm comparison.

comp_arm

(character)
the level of comparison arm in case of arm comparison.

paramcd

(character)
name of the parameter code variable.

at

(list of numeric)
when the candidate covariate is a numeric type variable, use at to specify the value of the covariate at which the effect should be estimated.

strata_var

(character)
names of the variables for stratified analysis.

combine_comp_arms

(logical)
triggers the combination of comparison arms.

control

(list)
list of settings for the analysis (see tern::control_coxreg()).

na_level

(string)
used to replace all NA or empty values in character or factor variables in the data. Defaults to "<Missing>". To set a default na_level to apply in all modules, run set_default_na_str("new_default").

append

(logical)
whether the result should be appended to the previous one.

basic_table_args

(basic_table_args) optional
object created by teal.widgets::basic_table_args() with settings for the module table. The argument is merged with option teal.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").

Value

a list of expressions to generate a table or plot object.

See Also

template_coxreg_m(), tm_t_coxreg()


Template: Events by Term

Description

Creates a valid expression to generate a table of events by term.

Usage

template_events(
  dataname,
  parentname,
  arm_var,
  hlt,
  llt,
  label_hlt = NULL,
  label_llt = NULL,
  add_total = TRUE,
  total_label = default_total_label(),
  na_level = default_na_str(),
  event_type = "event",
  sort_criteria = c("freq_desc", "alpha"),
  sort_freq_col = total_label,
  prune_freq = 0,
  prune_diff = 0,
  drop_arm_levels = TRUE,
  incl_overall_sum = TRUE,
  basic_table_args = teal.widgets::basic_table_args()
)

Arguments

dataname

(character)
analysis data used in teal module.

parentname

(character)
parent analysis data used in teal module, usually this refers to ADSL.

arm_var

(character)
variable names that can be used as arm_var.

hlt

(character)
name of the variable with high level term for events.

llt

(character)
name of the variable with low level term for events.

label_hlt

(string)
label of the hlt variable from dataname. The label will be extracted from the module.

label_llt

(string)
label of the llt variable from dataname. The label will be extracted from the module.

add_total

(logical)
whether to include column with total number of patients.

total_label

(string)
string to display as total column/row label if column/row is enabled (see add_total). Defaults to "All Patients". To set a new default total_label to apply in all modules, run set_default_total_label("new_default").

na_level

(string)
used to replace all NA or empty values in character or factor variables in the data. Defaults to "<Missing>". To set a default na_level to apply in all modules, run set_default_na_str("new_default").

event_type

(character)
type of event that is summarized (e.g. adverse event, treatment). Default is "event".

sort_criteria

(character)
how to sort the final table. Default option freq_desc sorts on column sort_freq_col by decreasing number of patients with event. Alternative option alpha sorts events alphabetically.

sort_freq_col

(character)
column to sort by frequency on if sort_criteria is set to freq_desc.

prune_freq

(number)
threshold to use for trimming table using event incidence rate in any column.

prune_diff

(number)
threshold to use for trimming table using as criteria difference in rates between any two columns.

drop_arm_levels

(logical)
whether to drop unused levels of arm_var. If TRUE, arm_var levels are set to those used in the dataname dataset. If FALSE, arm_var levels are set to those used in the parentname dataset. If dataname and parentname are the same, then drop_arm_levels is set to TRUE and user input for this parameter is ignored.

incl_overall_sum

(flag)
whether two rows which summarize the overall number of adverse events should be included at the top of the table.

basic_table_args

(basic_table_args) optional
object created by teal.widgets::basic_table_args() with settings for the module table. The argument is merged with option teal.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").

Value

a list of expressions to generate a table or plot object.

See Also

tm_t_events()


Template: Events by Grade

Description

Creates a valid expression to generate a table to summarize events by grade.

Usage

template_events_by_grade(
  dataname,
  parentname,
  arm_var,
  id = "",
  hlt,
  llt,
  label_hlt = NULL,
  label_llt = NULL,
  grade,
  label_grade = NULL,
  prune_freq = 0,
  prune_diff = 0,
  add_total = TRUE,
  total_label = default_total_label(),
  na_level = default_na_str(),
  drop_arm_levels = TRUE,
  basic_table_args = teal.widgets::basic_table_args()
)

Arguments

dataname

(character)
analysis data used in teal module.

parentname

(character)
parent analysis data used in teal module, usually this refers to ADSL.

arm_var

(character)
variable names that can be used as arm_var.

id

(character)
unique identifier of patients in datasets, default to "USUBJID".

hlt

(character)
name of the variable with high level term for events.

llt

(character)
name of the variable with low level term for events.

label_hlt

(string)
label of the hlt variable from dataname. The label will be extracted from the module.

label_llt

(string)
label of the llt variable from dataname. The label will be extracted from the module.

grade

(character)
name of the severity level variable.

label_grade

(string)
label of the grade variable from dataname. The label will be extracted from the module.

prune_freq

(number)
threshold to use for trimming table using event incidence rate in any column.

prune_diff

(number)
threshold to use for trimming table using as criteria difference in rates between any two columns.

add_total

(logical)
whether to include column with total number of patients.

total_label

(string)
string to display as total column/row label if column/row is enabled (see add_total). Defaults to "All Patients". To set a new default total_label to apply in all modules, run set_default_total_label("new_default").

na_level

(string)
used to replace all NA or empty values in character or factor variables in the data. Defaults to "<Missing>". To set a default na_level to apply in all modules, run set_default_na_str("new_default").

drop_arm_levels

(logical)
whether to drop unused levels of arm_var. If TRUE, arm_var levels are set to those used in the dataname dataset. If FALSE, arm_var levels are set to those used in the parentname dataset. If dataname and parentname are the same, then drop_arm_levels is set to TRUE and user input for this parameter is ignored.

basic_table_args

(basic_table_args) optional
object created by teal.widgets::basic_table_args() with settings for the module table. The argument is merged with option teal.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").

Value

a list of expressions to generate a table or plot object.

See Also

tm_t_events_by_grade()


Template: Adverse Events Grouped by Grade with Threshold

Description

Creates a valid expression to generate a table to summarize adverse events grouped by grade.

Usage

template_events_col_by_grade(
  dataname,
  parentname,
  arm_var,
  grading_groups = list(`Any Grade (%)` = c("1", "2", "3", "4", "5"), `Grade 1-2 (%)` =
    c("1", "2"), `Grade 3-4 (%)` = c("3", "4"), `Grade 5 (%)` = "5"),
  add_total = TRUE,
  total_label = default_total_label(),
  id = "USUBJID",
  hlt,
  llt,
  label_hlt = NULL,
  label_llt = NULL,
  grade = "AETOXGR",
  label_grade = NULL,
  prune_freq = 0.1,
  prune_diff = 0,
  na_level = default_na_str(),
  drop_arm_levels = TRUE,
  basic_table_args = teal.widgets::basic_table_args()
)

Arguments

dataname

(character)
analysis data used in teal module.

parentname

(character)
parent analysis data used in teal module, usually this refers to ADSL.

arm_var

(character)
variable names that can be used as arm_var.

grading_groups

(list)
named list of grading groups.

add_total

(logical)
whether to include column with total number of patients.

total_label

(string)
string to display as total column/row label if column/row is enabled (see add_total). Defaults to "All Patients". To set a new default total_label to apply in all modules, run set_default_total_label("new_default").

id

(character)
name of variable to uniquely identify patients in datasets.

hlt

(character)
name of the variable with high level term for events.

llt

(character)
name of the variable with low level term for events.

label_hlt

(string)
label of the hlt variable from dataname. The label will be extracted from the module.

label_llt

(string)
label of the llt variable from dataname. The label will be extracted from the module.

grade

(character)
name of grade variable to base grading_groups on.

label_grade

(character)
label of the grade variable from dataname.

prune_freq

(number)
threshold to use for trimming table using event incidence rate in any column.

prune_diff

(number)
threshold to use for trimming table using as criteria difference in rates between any two columns.

na_level

(string)
used to replace all NA or empty values in character or factor variables in the data. Defaults to "<Missing>". To set a default na_level to apply in all modules, run set_default_na_str("new_default").

drop_arm_levels

(logical)
whether to drop unused levels of arm_var. If TRUE, arm_var levels are set to those used in the dataname dataset. If FALSE, arm_var levels are set to those used in the parentname dataset. If dataname and parentname are the same, then drop_arm_levels is set to TRUE and user input for this parameter is ignored.

basic_table_args

(basic_table_args) optional
object created by teal.widgets::basic_table_args() with settings for the module table. The argument is merged with option teal.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").

Value

a list of expressions to generate a table or plot object.

See Also

tm_t_events_by_grade()


Template: Event Rates Adjusted for Patient-Years

Description

Creates a valid expression to generate a table of event rates adjusted for patient-years.

Usage

template_events_patyear(
  dataname,
  parentname,
  arm_var,
  events_var,
  label_paramcd,
  aval_var = "AVAL",
  add_total = TRUE,
  total_label = default_total_label(),
  na_level = default_na_str(),
  control = control_incidence_rate(),
  drop_arm_levels = TRUE,
  basic_table_args = teal.widgets::basic_table_args()
)

Arguments

dataname

(character)
analysis data used in teal module.

parentname

(character)
parent analysis data used in teal module, usually this refers to ADSL.

arm_var

(character)
variable names that can be used as arm_var.

events_var

(character)
name of the variable for number of observed events.

label_paramcd

(character)
paramcd variable text to use in the table title.

aval_var

(character)
name of the analysis value variable.

add_total

(logical)
whether to include column with total number of patients.

total_label

(string)
string to display as total column/row label if column/row is enabled (see add_total). Defaults to "All Patients". To set a new default total_label to apply in all modules, run set_default_total_label("new_default").

na_level

(string)
used to replace all NA or empty values in character or factor variables in the data. Defaults to "<Missing>". To set a default na_level to apply in all modules, run set_default_na_str("new_default").

control

(list)
list of settings for the analysis.

drop_arm_levels

(logical)
whether to drop unused levels of arm_var. If TRUE, arm_var levels are set to those used in the dataname dataset. If FALSE, arm_var levels are set to those used in the parentname dataset. If dataname and parentname are the same, then drop_arm_levels is set to TRUE and user input for this parameter is ignored.

basic_table_args

(basic_table_args) optional
object created by teal.widgets::basic_table_args() with settings for the module table. The argument is merged with option teal.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").

Value

a list of expressions to generate a table or plot object.

See Also

tm_t_events_patyear()


Template: Adverse Events Summary

Description

Creates a valid expression to generate an adverse events summary table.

Usage

template_events_summary(
  anl_name,
  parentname,
  arm_var,
  dthfl_var = "DTHFL",
  dcsreas_var = "DCSREAS",
  flag_var_anl = NULL,
  flag_var_aesi = NULL,
  aeseq_var = "AESEQ",
  llt = "AEDECOD",
  add_total = TRUE,
  total_label = default_total_label(),
  na_level = default_na_str(),
  count_dth = TRUE,
  count_wd = TRUE,
  count_subj = TRUE,
  count_pt = TRUE,
  count_events = TRUE
)

Arguments

anl_name

(character)
analysis data used in teal module.

parentname

(character)
parent analysis data used in teal module, usually this refers to ADSL.

arm_var

(character)
variable names that can be used as arm_var.

dthfl_var

(character)
name of variable for subject death flag from parentname. Records with "Y" are summarized in the table row for "Total number of deaths".

dcsreas_var

(character)
name of variable for study discontinuation reason from parentname. Records with "ADVERSE EVENTS" are summarized in the table row for "Total number of patients withdrawn from study due to an AE".

flag_var_anl

(character)
name of flag variable from dataset 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

(character)
name of flag variable from dataset used to count adverse event special interest groups. All flag variables must be of type logical. Variable labels are used as table row names if they exist.

aeseq_var

(character)
name of variable for adverse events sequence number from dataset. Used for counting total number of events.

llt

(character)
name of the variable with low level term for events.

add_total

(logical)
whether to include column with total number of patients.

total_label

(string)
string to display as total column/row label if column/row is enabled (see add_total). Defaults to "All Patients". To set a new default total_label to apply in all modules, run set_default_total_label("new_default").

na_level

(string)
used to replace all NA or empty values in character or factor variables in the data. Defaults to "<Missing>". To set a default na_level to apply in all modules, run set_default_na_str("new_default").

count_dth

(logical)
whether to show count of total deaths (based on dthfl_var). Defaults to TRUE.

count_wd

(logical)
whether to show count of patients withdrawn from study due to an adverse event (based on dcsreas_var). Defaults to TRUE.

count_subj

(logical)
whether to show count of unique subjects (based on USUBJID). Only applies if event flag variables are provided.

count_pt

(logical)
whether to show count of unique preferred terms (based on llt). Only applies if event flag variables are provided.

count_events

(logical)
whether to show count of events (based on aeseq_var). Only applies if event flag variables are provided.

Value

a list of expressions to generate a table or plot object.

See Also

tm_t_events_summary()


Template: Exposure Table for Risk management plan

Description

Creates a valid expression to generate exposure table for risk management plan.

Usage

template_exposure(
  parentname,
  dataname,
  id_var,
  paramcd,
  paramcd_label = NULL,
  row_by_var,
  col_by_var = NULL,
  add_total = FALSE,
  total_label = "Total",
  add_total_row = TRUE,
  total_row_label = "Total number of patients and patient time*",
  drop_levels = TRUE,
  na_level = default_na_str(),
  aval_var,
  avalu_var,
  basic_table_args = teal.widgets::basic_table_args()
)

Arguments

parentname

(character)
parent analysis data used in teal module, usually this refers to ADSL.

dataname

(character)
analysis data used in teal module.

id_var

(character)
the variable name for subject id.

paramcd

(character)
name of the parameter code variable.

paramcd_label

(character)
the column from the dataname dataset where the value will be used to label the argument paramcd.

row_by_var

(character)
variable name used to split the values by rows.

col_by_var

(character)
variable name used to split the values by columns.

add_total

(logical)
whether to include column with total number of patients.

total_label

(string)
string to display as total column/row label if column/row is enabled (see add_total). Defaults to "All Patients". To set a new default total_label to apply in all modules, run set_default_total_label("new_default").

add_total_row

(flag)
whether a "total" level should be added after the others which includes all the levels that constitute the split. A custom label can be set for this level via the total_row_label argument.

total_row_label

(character)
string to display as total row label if row is enabled (see add_total_row).

drop_levels

(flag)
whether empty rows should be removed from the table.

na_level

(string)
used to replace all NA or empty values in character or factor variables in the data. Defaults to "<Missing>". To set a default na_level to apply in all modules, run set_default_na_str("new_default").

aval_var

(character)
name of the analysis value variable.

avalu_var

(character)
name of the analysis value unit variable.

basic_table_args

(basic_table_args) optional
object created by teal.widgets::basic_table_args() with settings for the module table. The argument is merged with option teal.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").

Value

a list of expressions to generate a table or plot object.

See Also

tm_t_exposure()


Template: Mixed Model Repeated Measurements (MMRM) Analysis

Description

Creates a valid expression to generate analysis tables and plots for Mixed Model Repeated Measurements.

Usage

template_fit_mmrm(
  parentname,
  dataname,
  aval_var,
  arm_var,
  ref_arm,
  comp_arm = NULL,
  combine_comp_arms = FALSE,
  id_var,
  visit_var,
  cov_var,
  conf_level = 0.95,
  method = "Satterthwaite",
  cor_struct = "unstructured",
  weights_emmeans = "proportional",
  parallel = FALSE
)

template_mmrm_tables(
  parentname,
  dataname,
  fit_name,
  arm_var,
  ref_arm,
  visit_var,
  paramcd,
  show_relative = c("increase", "reduction", "none"),
  table_type = "t_mmrm_cov",
  total_label = default_total_label(),
  basic_table_args = teal.widgets::basic_table_args()
)

template_mmrm_plots(
  fit_name,
  lsmeans_plot = list(select = c("estimates", "contrasts"), width = 0.6, show_pval =
    FALSE),
  diagnostic_plot = list(type = "fit-residual", z_threshold = NULL),
  ggplot2_args = teal.widgets::ggplot2_args()
)

Arguments

parentname

(character)
parent analysis data used in teal module, usually this refers to ADSL.

dataname

(character)
analysis data used in teal module.

aval_var

(character)
name of the analysis value variable.

arm_var

(character)
variable names that can be used as arm_var.

ref_arm

(character)
the level of reference arm in case of arm comparison.

comp_arm

(character)
the level of comparison arm in case of arm comparison.

combine_comp_arms

(logical)
triggers the combination of comparison arms.

id_var

(character)
the variable name for subject id.

visit_var

(character)
variable names that can be used as visit variable. Must be a factor in dataname.

cov_var

(character)
names of the covariates variables.

conf_level

(numeric)
value for the confidence level within the range of (0, 1).

method

(string)
a string specifying the adjustment method.

cor_struct

(string)
a string specifying the correlation structure, defaults to "unstructured". See tern.mmrm::build_formula() for more options.

weights_emmeans

argument from emmeans::emmeans(), "proportional" by default.

parallel

(flag)
flag that controls whether optimizer search can use available free cores on the machine (not default).

fit_name

(string)
name of fitted MMRM object.

paramcd

(character)
name of the parameter code variable.

show_relative

(string)
should the "reduction" (control - treatment, default) or the "increase" (treatment - control) be shown for the relative change from baseline.

table_type

(string)
type of table to output.

total_label

(string)
string to display as total column/row label if column/row is enabled (see add_total). Defaults to "All Patients". To set a new default total_label to apply in all modules, run set_default_total_label("new_default").

basic_table_args

(basic_table_args) optional
object created by teal.widgets::basic_table_args() with settings for the module table. The argument is merged with option teal.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").

lsmeans_plot

(named list)
a list of controls for LS means plot. See more tern.mmrm::g_mmrm_lsmeans().

diagnostic_plot

(named list)
a list of controls for diagnostic_plot. See more tern.mmrm::g_mmrm_diagnostic().

ggplot2_args

(ggplot2_args) optional
object created by teal.widgets::ggplot2_args() with settings for the module plot. The argument is merged with option teal.ggplot2_args and with default module arguments (hard coded in the module body). For more details, see the vignette: vignette("custom-ggplot2-arguments", package = "teal.widgets").

Value

a list of expressions to generate a table or plot object.

Functions

See Also

tm_a_mmrm()


Template: Response Forest Plot

Description

Creates a valid expression to generate a response forest plot.

Usage

template_forest_rsp(
  dataname = "ANL",
  parentname = "ADSL",
  arm_var,
  ref_arm = NULL,
  comp_arm = NULL,
  obj_var_name = "",
  aval_var = "AVALC",
  responders = c("CR", "PR"),
  subgroup_var,
  strata_var = NULL,
  stats = c("n_tot", "n", "n_rsp", "prop", "or", "ci"),
  riskdiff = NULL,
  conf_level = 0.95,
  col_symbol_size = NULL,
  font_size = 15,
  ggplot2_args = teal.widgets::ggplot2_args()
)

Arguments

dataname

(character)
analysis data used in teal module.

parentname

(character)
parent analysis data used in teal module, usually this refers to ADSL.

arm_var

(character)
variable names that can be used as arm_var.

ref_arm

(character)
the level of reference arm in case of arm comparison.

comp_arm

(character)
the level of comparison arm in case of arm comparison.

obj_var_name

(character)
additional text to append to the table title.

aval_var

(character)
name of the analysis value variable.

responders

(character)
values of aval_var that are considered to be responders.

subgroup_var

(character)
with variable names that can be used as subgroups.

strata_var

(character)
names of the variables for stratified analysis.

stats

(character)
the names of statistics to be reported among:

  • n: Total number of observations per group.

  • n_rsp: Number of responders per group.

  • prop: Proportion of responders.

  • n_tot: Total number of observations.

  • or: Odds ratio.

  • ci : Confidence interval of odds ratio.

  • pval: p-value of the effect. Note, the statistics n_tot, or, and ci are required.

riskdiff

(list)
if a risk (proportion) difference column should be added, a list of settings to apply within the column. See tern::control_riskdiff() for details. If NULL, no risk difference column will be added.

conf_level

(numeric)
value for the confidence level within the range of (0, 1).

col_symbol_size

(integer or NULL)
column index to be used to determine relative size for estimator plot symbol. Typically, the symbol size is proportional to the sample size used to calculate the estimator. If NULL, the same symbol size is used for all subgroups.

font_size

(numeric(1))
font size.

ggplot2_args

(ggplot2_args) optional
object created by teal.widgets::ggplot2_args() with settings for the module plot. For this module, this argument will only accept ggplot2_args object with labs list of following child elements: title, caption. No other elements would be taken into account. The argument is merged with option teal.ggplot2_args and with default module arguments (hard coded in the module body).

For more details, see the vignette: vignette("custom-ggplot2-arguments", package = "teal.widgets").

Value

a list of expressions to generate a table or plot object.

See Also

tm_g_forest_rsp()


Template: Survival Forest Plot

Description

Creates a valid expression to generate a survival forest plot.

Usage

template_forest_tte(
  dataname = "ANL",
  parentname = "ANL_ADSL",
  arm_var,
  ref_arm = NULL,
  comp_arm = NULL,
  obj_var_name = "",
  aval_var = "AVAL",
  cnsr_var = "CNSR",
  subgroup_var,
  strata_var = NULL,
  stats = c("n_tot_events", "n_events", "median", "hr", "ci"),
  riskdiff = NULL,
  conf_level = 0.95,
  col_symbol_size = NULL,
  time_unit_var = "AVALU",
  font_size = 15,
  ggplot2_args = teal.widgets::ggplot2_args()
)

Arguments

dataname

(character)
analysis data used in teal module.

parentname

(character)
parent analysis data used in teal module, usually this refers to ADSL.

arm_var

(character)
variable names that can be used as arm_var.

ref_arm

(character)
the level of reference arm in case of arm comparison.

comp_arm

(character)
the level of comparison arm in case of arm comparison.

obj_var_name

(character)
additional text to append to the table title.

aval_var

(character)
name of the analysis value variable.

cnsr_var

(character)
name of the censoring variable.

subgroup_var

(character)
with variable names that can be used as subgroups.

strata_var

(character)
names of the variables for stratified analysis.

stats

(character)
the names of statistics to be reported among:

  • n_tot_events: Total number of events per group.

  • n_events: Number of events per group.

  • n_tot: Total number of observations per group.

  • n: Number of observations per group.

  • median: Median survival time.

  • hr: Hazard ratio.

  • ci: Confidence interval of hazard ratio.

  • pval: p-value of the effect. Note, one of the statistics n_tot and n_tot_events, as well as both hr and ci are required.

riskdiff

(list)
if a risk (proportion) difference column should be added, a list of settings to apply within the column. See tern::control_riskdiff() for details. If NULL, no risk difference column will be added.

conf_level

(numeric)
value for the confidence level within the range of (0, 1).

col_symbol_size

(integer or NULL)
column index to be used to determine relative size for estimator plot symbol. Typically, the symbol size is proportional to the sample size used to calculate the estimator. If NULL, the same symbol size is used for all subgroups.

time_unit_var

(character)
name of the variable representing time units.

font_size

(numeric)
font size value.

ggplot2_args

(ggplot2_args) optional
object created by teal.widgets::ggplot2_args() with settings for the module plot. The argument is merged with option teal.ggplot2_args and with default module arguments (hard coded in the module body). For more details, see the vignette: vignette("custom-ggplot2-arguments", package = "teal.widgets").

Value

a list of expressions to generate a table or plot object.

See Also

tm_g_forest_tte()


Template: Confidence Interval Plot

Description

Creates a valid expression to generate a ggplot2::ggplot() confidence interval plot.

Usage

template_g_ci(
  dataname,
  x_var,
  y_var,
  grp_var = NULL,
  stat = c("mean", "median"),
  conf_level = 0.95,
  unit_var = "AVALU",
  ggplot2_args = teal.widgets::ggplot2_args()
)

Arguments

dataname

(character)
analysis data used in teal module.

x_var

(character)
name of the treatment variable to put on the x-axis.

y_var

(character)
name of the response variable to put on the y-axis.

grp_var

(character)
name of the group variable used to determine the plot colors, point shapes, and line types.

stat

(character)
statistic to plot. Options are "mean" and "median".

conf_level

(numeric)
value for the confidence level within the range of (0, 1).

unit_var

(character)
name of the unit variable.

ggplot2_args

(ggplot2_args) optional
object created by teal.widgets::ggplot2_args() with settings for the module plot. The argument is merged with option teal.ggplot2_args and with default module arguments (hard coded in the module body). For more details, see the vignette: vignette("custom-ggplot2-arguments", package = "teal.widgets").

Value

a list of expressions to generate a table or plot object.

See Also

tm_g_ci()


Template: Individual Patient Plots

Description

Creates a valid expression to generate ggplot2::ggplot() plots of individual patients.

Usage

template_g_ipp(
  dataname = "ANL",
  paramcd,
  arm_var,
  arm_levels,
  avalu_first,
  paramcd_first,
  aval_var = "AVAL",
  avalu_var = "AVALU",
  id_var = "USUBJID",
  visit_var = "AVISIT",
  base_var = lifecycle::deprecated(),
  baseline_var = "BASE",
  add_baseline_hline = FALSE,
  separate_by_obs = FALSE,
  ggplot2_args = teal.widgets::ggplot2_args(),
  suppress_legend = FALSE,
  add_avalu = TRUE
)

Arguments

dataname

(character)
analysis data used in teal module.

paramcd

(character)
name of the parameter code variable.

arm_var

(character)
variable names that can be used as arm_var.

arm_levels

(character)
vector of all levels of arm_var.

avalu_first

(character)
avalu_var text to append to the plot title and y-axis label if add_avalu is TRUE.

paramcd_first

(character)
paramcd text to append to the plot title and y-axis label.

aval_var

(character)
name of the analysis value variable.

avalu_var

(character)
name of the analysis value unit variable.

id_var

(character)
the variable name for subject id.

visit_var

(character)
name of the variable for visit timepoints.

base_var

[Deprecated] Please use the baseline_var argument instead.

baseline_var

(character)
name of the variable for baseline values of the analysis variable.

add_baseline_hline

(logical)
whether a horizontal line should be added to the plot at baseline y-value.

separate_by_obs

(logical)
whether to create multi-panel plots.

ggplot2_args

(ggplot2_args) optional
object created by teal.widgets::ggplot2_args() with settings for the module plot. For this module, this argument will only accept ggplot2_args object with labs list of the following child elements: title, subtitle, x, y. No other elements are taken into account. The argument is merged with option teal.ggplot2_args and with default module arguments (hard coded in the module body).

For more details, see the vignette: vignette("custom-ggplot2-arguments", package = "teal.widgets").

suppress_legend

(logical)
whether to suppress the plot legend.

add_avalu

(logical)
whether avalu_first text should be appended to the plot title and y-axis label.

Value

a list of expressions to generate a table or plot object.

See Also

tm_g_ipp()


Template: Kaplan-Meier Plot

Description

Creates a valid expression to generate a Kaplan-Meier plot.

Usage

template_g_km(
  dataname = "ANL",
  arm_var = "ARM",
  ref_arm = NULL,
  comp_arm = NULL,
  compare_arm = FALSE,
  combine_comp_arms = FALSE,
  aval_var = "AVAL",
  cnsr_var = "CNSR",
  xticks = NULL,
  strata_var = NULL,
  time_points = NULL,
  facet_var = "SEX",
  font_size = 11,
  conf_level = 0.95,
  ties = "efron",
  xlab = "Survival time",
  time_unit_var = "AVALU",
  yval = "Survival",
  ylim = NULL,
  pval_method = "log-rank",
  annot_surv_med = TRUE,
  annot_coxph = TRUE,
  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 = NULL,
  position_coxph = lifecycle::deprecated(),
  width_annots = lifecycle::deprecated(),
  rel_height_plot = 0.8,
  ci_ribbon = FALSE,
  title = "KM Plot"
)

Arguments

dataname

(character)
analysis data used in teal module.

arm_var

(character)
variable names that can be used as arm_var.

ref_arm

(character)
the level of reference arm in case of arm comparison.

comp_arm

(character)
the level of comparison arm in case of arm comparison.

compare_arm

(logical)
triggers the comparison between study arms.

combine_comp_arms

(logical)
triggers the combination of comparison arms.

aval_var

(character)
name of the analysis value variable.

cnsr_var

(character)
name of the censoring variable.

xticks

(numeric or NULL)
numeric vector of tick positions or a single number with spacing between ticks on the x-axis. If NULL (default), labeling::extended() is used to determine optimal tick positions on the x-axis.

strata_var

(character)
names of the variables for stratified analysis.

time_points

(character)
time points that can be used in tern::surv_timepoint().

facet_var

(character)
name of the variable to use to facet the plot.

font_size

(numeric)
font size value.

conf_level

(numeric)
value for the confidence level within the range of (0, 1).

ties

(string)
among exact (equivalent to DISCRETE in SAS), efron and breslow, see survival::coxph(). Note: there is no equivalent of SAS EXACT method in R.

xlab

(string)
x-axis label.

time_unit_var

(character)
name of the variable representing time units.

yval

(string)
type of plot, to be plotted on the y-axis. Options are Survival (default) and Failure probability.

ylim

(numeric(2))
vector containing lower and upper limits for the y-axis, respectively. If NULL (default), the default scale range is used.

pval_method

(string)
the method used for estimation of p.values; wald (default) or likelihood.

annot_surv_med

(flag)
compute and add the annotation table on the Kaplan-Meier curve estimating the median survival time per group.

annot_coxph

(flag)
whether to add the annotation table from a survival::coxph() model.

control_annot_surv_med

(list)
parameters to control the position and size of the annotation table added to the plot when annot_surv_med = TRUE, specified using the control_surv_med_annot() function. Parameter options are: x, y, w, h, and fill. See control_surv_med_annot() for details.

control_annot_coxph

(list)
parameters to control the position and size of the annotation table added to the plot when annot_coxph = TRUE, specified using the control_coxph_annot() function. Parameter options are: x, y, w, h, fill, and ref_lbls. See control_coxph_annot() for details.

legend_pos

(numeric(2) or NULL)
vector containing x- and y-coordinates, respectively, for the legend position relative to the KM plot area. If NULL (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.

position_coxph

[Deprecated] Please use the x and y elements of control_annot_coxph instead.

width_annots

[Deprecated] Please use the w element of control_annot_surv_med (for surv_med) and control_annot_coxph (for coxph)."

rel_height_plot

(proportion)
proportion of total figure height to allocate to the Kaplan-Meier plot. Relative height of patients at risk table is then 1 - rel_height_plot. If annot_at_risk = FALSE or as_list = TRUE, this parameter is ignored.

ci_ribbon

(flag)
whether the confidence interval should be drawn around the Kaplan-Meier curve.

title

(character)
title of the output.

Value

a list of expressions to generate a table or plot object.

See Also

tm_g_km()


Template: Line Plot

Description

Creates a valid expression to generate a ggplot2::ggplot() line plot.

Usage

template_g_lineplot(
  dataname = "ANL",
  strata = lifecycle::deprecated(),
  group_var = "ARM",
  x = "AVISIT",
  y = "AVAL",
  y_unit = "AVALU",
  paramcd = "PARAMCD",
  param = "ALT",
  mid = "mean",
  interval = "mean_ci",
  whiskers = c("mean_ci_lwr", "mean_ci_upr"),
  table = c("n", "mean_sd", "median", "range"),
  mid_type = "pl",
  conf_level = 0.95,
  incl_screen = TRUE,
  mid_point_size = 2,
  table_font_size = 4,
  title = "Line Plot",
  y_lab = "",
  ggplot2_args = teal.widgets::ggplot2_args()
)

Arguments

dataname

(character)
analysis data used in teal module.

strata

[Deprecated] Please use the group_var argument instead.

group_var

(string or NA)
group variable name.

x

(string)
x-variable name.

y

(string)
y-variable name.

y_unit

(string or NA)
y-axis unit variable name.

paramcd

(string or NA)
parameter code variable name.

param

(character)
parameter to filter the data by.

mid

(character or NULL)
names of the statistics that will be plotted as midpoints. All the statistics indicated in mid variable must be present in the object returned by sfun, and be of a double or numeric type vector of length one.

interval

(character or NULL)
names of the statistics that will be plotted as intervals. All the statistics indicated in interval variable must be present in the object returned by sfun, and be of a double or numeric type vector of length two. Set interval = NULL if intervals should not be added to the plot.

whiskers

(character)
names of the interval whiskers that will be plotted. Names must match names of the list element interval that will be returned by sfun (e.g. mean_ci_lwr element of sfun(x)[["mean_ci"]]). It is possible to specify one whisker only, or to suppress all whiskers by setting interval = NULL.

table

(character or NULL)
names of the statistics that will be displayed in the table below the plot. All the statistics indicated in table variable must be present in the object returned by sfun.

mid_type

(string)
controls the type of the mid plot, it can be point ("p"), line ("l"), or point and line ("pl").

conf_level

(numeric)
value for the confidence level within the range of (0, 1).

incl_screen

(logical)
whether the screening visit should be included.

mid_point_size

(numeric(1))
font size of the mid plot points.

table_font_size

(numeric(1))
font size of the text in the table.

title

(string)
plot title.

y_lab

(string or NULL)
y-axis label. If NULL then no label will be added.

ggplot2_args

(ggplot2_args) optional
object created by teal.widgets::ggplot2_args() with settings for the module plot. For this module, this argument will only accept ggplot2_args object with labs list of following child elements: title, subtitle, caption, y, lty. No other elements would be taken into account. The argument is merged with option teal.ggplot2_args and with default module arguments (hard coded in the module body).

For more details, see the vignette: vignette("custom-ggplot2-arguments", package = "teal.widgets").

Value

a list of expressions to generate a table or plot object.

See Also

tm_g_lineplot()


Template: Patient Profile Laboratory Table

Description

Creates a valid expression to generate a patient profile laboratory table using ADaM datasets.

Usage

template_laboratory(
  dataname = "ANL",
  paramcd = "PARAMCD",
  param = "PARAM",
  anrind = "ANRIND",
  timepoints = "ADY",
  aval = lifecycle::deprecated(),
  aval_var = "AVAL",
  avalu = lifecycle::deprecated(),
  avalu_var = "AVALU",
  patient_id = NULL,
  round_value = 0L
)

Arguments

dataname

(character)
analysis data used in teal module.

paramcd

(character)
name of the parameter code variable.

param

(character)
name of the parameter variable.

anrind

(character)
name of the analysis reference range indicator variable.

timepoints

(character)
name of time variable.

aval

[Deprecated] Please use the aval_var argument instead.

aval_var

(character)
name of the analysis value variable.

avalu

[Deprecated] Please use the avalu_var argument instead.

avalu_var

(character)
name of the analysis value unit variable.

patient_id

(character)
patient ID.

round_value

(numeric)
number of decimal places to round to.

Value

a list of expressions to generate a table or plot object.

See Also

tm_t_pp_laboratory()


Template: Logistic Regression

Description

Creates a valid expression to generate a logistic regression table.

Usage

template_logistic(
  dataname,
  arm_var,
  aval_var,
  paramcd = lifecycle::deprecated(),
  label_paramcd,
  cov_var,
  interaction_var,
  ref_arm,
  comp_arm,
  topleft = "Logistic Regression",
  conf_level = 0.95,
  combine_comp_arms = FALSE,
  responder_val = c("CR", "PR"),
  at = NULL,
  basic_table_args = teal.widgets::basic_table_args()
)

Arguments

dataname

(character)
analysis data used in teal module.

arm_var

(character)
variable names that can be used as arm_var. To fit a logistic model with no arm/treatment variable, set to NULL.

aval_var

(character)
name of the analysis value variable.

paramcd

[Deprecated] The paramcd argument is not used in this function.

label_paramcd

(character)
label of response parameter value to print in the table title.

cov_var

(character)
names of the covariates variables.

interaction_var

(character)
names of the variables that can be used for interaction variable selection.

ref_arm

(character)
the level of reference arm in case of arm comparison.

comp_arm

(character)
the level of comparison arm in case of arm comparison.

topleft

(character)
text to use as top-left annotation in the table.

conf_level

(numeric)
value for the confidence level within the range of (0, 1).

combine_comp_arms

(logical)
triggers the combination of comparison arms.

responder_val

(character)
values of the responder variable corresponding with a successful response.

at

(numeric or NULL)
optional values for the interaction variable. Otherwise the median is used.

basic_table_args

(basic_table_args) optional
object created by teal.widgets::basic_table_args() with settings for the module table. The argument is merged with option teal.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").

Value

a list of expressions to generate a table or plot object.

See Also

tm_t_logistic()


Template: Patient Profile Medical History

Description

Creates a valid expression to generate a patient profile medical history report using ADaM datasets.

Usage

template_medical_history(
  dataname = "ANL",
  mhterm = "MHTERM",
  mhbodsys = "MHBODSYS",
  mhdistat = "MHDISTAT",
  patient_id = NULL
)

Arguments

dataname

(character)
analysis data used in teal module.

mhterm

(character)
name of the reported term for the medical history variable.

mhbodsys

(character)
name of the body system or organ class variable.

mhdistat

(character)
name of the status of the disease variable.

patient_id

(character)
patient ID.

Value

a list of expressions to generate a table or plot object.

See Also

tm_t_pp_medical_history()


Template: Multiple Events by Term

Description

Creates a valid expression to generate a table of multiple events by term.

Usage

template_mult_events(
  dataname,
  parentname,
  arm_var,
  seq_var,
  hlt,
  llt,
  add_total = TRUE,
  total_label = default_total_label(),
  na_level = default_na_str(),
  event_type = "event",
  drop_arm_levels = TRUE,
  basic_table_args = teal.widgets::basic_table_args()
)

Arguments

dataname

(character)
analysis data used in teal module.

parentname

(character)
parent analysis data used in teal module, usually this refers to ADSL.

arm_var

(character)
variable names that can be used as arm_var.

seq_var

(character)
name of analysis sequence number variable. Used for counting the unique number of events.

hlt

(character)
name of the variable with high level term for events.

llt

(character)
name of the variable with low level term for events.

add_total

(logical)
whether to include column with total number of patients.

total_label

(string)
string to display as total column/row label if column/row is enabled (see add_total). Defaults to "All Patients". To set a new default total_label to apply in all modules, run set_default_total_label("new_default").

na_level

(string)
used to replace all NA or empty values in character or factor variables in the data. Defaults to "<Missing>". To set a default na_level to apply in all modules, run set_default_na_str("new_default").

event_type

(character)
type of event that is summarized (e.g. adverse event, treatment). Default is "event".

drop_arm_levels

(logical)
whether to drop unused levels of arm_var. If TRUE, arm_var levels are set to those used in the dataname dataset. If FALSE, arm_var levels are set to those used in the parentname dataset. If dataname and parentname are the same, then drop_arm_levels is set to TRUE and user input for this parameter is ignored.

basic_table_args

(basic_table_args) optional
object created by teal.widgets::basic_table_args() with settings for the module table. The argument is merged with option teal.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").

Value

a list of expressions to generate a table or plot object.

See Also

tm_t_mult_events()


Template: Patient Profile Timeline Plot

Description

Creates a valid expression to generate a patient profile timeline ggplot2::ggplot() plot using ADaM datasets.

Usage

template_patient_timeline(
  dataname = "ANL",
  aeterm = "AETERM",
  aetime_start = "ASTDTM",
  aetime_end = "AENDTM",
  dstime_start = "CMASTDTM",
  dstime_end = "CMAENDTM",
  cmdecod = "CMDECOD",
  aerelday_start = NULL,
  aerelday_end = NULL,
  dsrelday_start = NULL,
  dsrelday_end = NULL,
  relative_day = FALSE,
  patient_id,
  font_size = 12L,
  ggplot2_args = teal.widgets::ggplot2_args()
)

Arguments

dataname

(character)
analysis data used in teal module.

aeterm

(character)
name of the reported term for the adverse event variable.

aetime_start

(character)
name of start date/time of adverse event variable.

aetime_end

(character)
name of end date/time of adverse event variable.

dstime_start

(character)
name of date/time of first exposure to treatment variable.

dstime_end

(character)
name of date/time of last exposure to treatment variable.

cmdecod

(character)
name of standardized medication name variable.

aerelday_start

(character)
name of adverse event study start day variable.

aerelday_end

(character)
name of adverse event study end day variable.

dsrelday_start

(character)
name of concomitant medications study start day variable.

dsrelday_end

(character)
name of concomitant medications study day start variable.

relative_day

(logical)
whether to use relative days (TRUE) or absolute dates (FALSE).

patient_id

(character)
patient ID.

font_size

(numeric)
font size value.

ggplot2_args

(ggplot2_args) optional
object created by teal.widgets::ggplot2_args() with settings for the module plot. The argument is merged with option teal.ggplot2_args and with default module arguments (hard coded in the module body). For more details, see the vignette: vignette("custom-ggplot2-arguments", package = "teal.widgets").

Value

a list of expressions to generate a table or plot object.

See Also

tm_g_pp_patient_timeline()


Template: Patient Profile Prior Medication

Description

Creates a valid expression to generate a patient profile prior medication report using ADaM datasets.

Usage

template_prior_medication(
  dataname = "ANL",
  atirel = "ATIREL",
  cmdecod = "CMDECOD",
  cmindc = "CMINDC",
  cmstdy = "CMSTDY"
)

Arguments

dataname

(character)
analysis data used in teal module.

atirel

(character)
name of time relation of medication variable.

cmdecod

(character)
name of standardized medication name variable.

cmindc

(character)
name of indication variable.

cmstdy

(character)
name of study relative day of start of medication variable.

Value

a list of expressions to generate a table or plot object.

See Also

tm_t_pp_prior_medication()


Template: Shift by Arm

Description

Creates a valid expression to generate a summary table of analysis indicator levels by arm.

Usage

template_shift_by_arm(
  dataname,
  parentname,
  arm_var = "ARM",
  paramcd = "PARAMCD",
  visit_var = "AVISIT",
  treatment_flag_var = "ONTRTFL",
  treatment_flag = "Y",
  aval_var = "ANRIND",
  base_var = lifecycle::deprecated(),
  baseline_var = "BNRIND",
  na.rm = FALSE,
  na_level = default_na_str(),
  add_total = FALSE,
  total_label = default_total_label(),
  basic_table_args = teal.widgets::basic_table_args()
)

Arguments

dataname

(character)
analysis data used in teal module.

parentname

(character)
parent analysis data used in teal module, usually this refers to ADSL.

arm_var

(character)
variable names that can be used as arm_var.

paramcd

(character)
name of the parameter code variable.

visit_var

(character)
variable names that can be used as visit variable. Must be a factor in dataname.

treatment_flag_var

(character)
name of the on treatment flag variable.

treatment_flag

(character)
name of the value indicating on treatment records in treatment_flag_var.

aval_var

(character)
name of the analysis reference range indicator variable.

base_var

[Deprecated] Please use the baseline_var argument instead.

baseline_var

(character)
name of the baseline reference range indicator variable.

na.rm

(logical)
whether NA values should be removed prior to analysis.

na_level

(string)
used to replace all NA or empty values in character or factor variables in the data. Defaults to "<Missing>". To set a default na_level to apply in all modules, run set_default_na_str("new_default").

add_total

(logical)
whether to include row with total number of patients.

total_label

(string)
string to display as total column/row label if column/row is enabled (see add_total). Defaults to "All Patients". To set a new default total_label to apply in all modules, run set_default_total_label("new_default").

basic_table_args

(basic_table_args) optional
object created by teal.widgets::basic_table_args() with settings for the module table. The argument is merged with option teal.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").

Value

a list of expressions to generate a table or plot object.

See Also

tm_t_shift_by_arm()


Template: Shift by Arm by Worst Analysis Indicator Level

Description

Creates a valid expression to generate a summary table of worst analysis indicator variable level per subject by arm.

Usage

template_shift_by_arm_by_worst(
  dataname,
  parentname,
  arm_var = "ARM",
  paramcd = "PARAMCD",
  worst_flag_var = "WORS02FL",
  worst_flag = "Y",
  treatment_flag_var = "ONTRTFL",
  treatment_flag = "Y",
  aval_var = "ANRIND",
  base_var = lifecycle::deprecated(),
  baseline_var = "BNRIND",
  na.rm = FALSE,
  na_level = default_na_str(),
  add_total = FALSE,
  total_label = default_total_label(),
  basic_table_args = teal.widgets::basic_table_args()
)

Arguments

dataname

(character)
analysis data used in teal module.

parentname

(character)
parent analysis data used in teal module, usually this refers to ADSL.

arm_var

(character)
variable names that can be used as arm_var.

paramcd

(character)
name of the parameter code variable.

worst_flag_var

(character)
name of the worst flag variable.

worst_flag

(character)
value indicating worst analysis indicator level.

treatment_flag_var

(character)
name of the on treatment flag variable.

treatment_flag

(character)
name of the value indicating on treatment records in treatment_flag_var.

aval_var

(character)
name of the analysis reference range indicator variable.

base_var

[Deprecated] Please use the baseline_var argument instead.

baseline_var

(character)
name of the baseline reference range indicator variable.

na.rm

(logical)
whether NA values should be removed prior to analysis.

na_level

(string)
used to replace all NA or empty values in character or factor variables in the data. Defaults to "<Missing>". To set a default na_level to apply in all modules, run set_default_na_str("new_default").

add_total

(logical)
whether to include row with total number of patients.

total_label

(string)
string to display as total column/row label if column/row is enabled (see add_total). Defaults to "All Patients". To set a new default total_label to apply in all modules, run set_default_total_label("new_default").

basic_table_args

(basic_table_args) optional
object created by teal.widgets::basic_table_args() with settings for the module table. The argument is merged with option teal.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").

Value

a list of expressions to generate a table or plot object.

See Also

tm_t_shift_by_arm()


Template: Grade Summary Table

Description

Creates a valid expression to generate a grade summary table.

Usage

template_shift_by_grade(
  parentname,
  dataname,
  arm_var = "ARM",
  id_var = "USUBJID",
  visit_var = "AVISIT",
  worst_flag_var = c("WGRLOVFL", "WGRLOFL", "WGRHIVFL", "WGRHIFL"),
  worst_flag_indicator = "Y",
  anl_toxgrade_var = "ATOXGR",
  base_toxgrade_var = "BTOXGR",
  paramcd = "PARAMCD",
  drop_arm_levels = TRUE,
  add_total = FALSE,
  total_label = default_total_label(),
  na_level = default_na_str(),
  code_missing_baseline = FALSE,
  basic_table_args = teal.widgets::basic_table_args()
)

Arguments

parentname

(character)
parent analysis data used in teal module, usually this refers to ADSL.

dataname

(character)
analysis data used in teal module.

arm_var

(character)
variable names that can be used as arm_var.

id_var

(character)
the variable name for subject id.

visit_var

(character)
variable names that can be used as visit variable. Must be a factor in dataname.

worst_flag_var

(character)
name of the worst flag variable.

worst_flag_indicator

(character)
value indicating worst grade.

anl_toxgrade_var

(character)
name of the variable indicating the analysis toxicity grade.

base_toxgrade_var

(character)
name of the variable indicating the baseline toxicity grade.

paramcd

(character)
name of the parameter code variable.

drop_arm_levels

(logical)
whether to drop unused levels of arm_var. If TRUE, arm_var levels are set to those used in the dataname dataset. If FALSE, arm_var levels are set to those used in the parentname dataset. If dataname and parentname are the same, then drop_arm_levels is set to TRUE and user input for this parameter is ignored.

add_total

(logical)
whether to include column with total number of patients.

total_label

(string)
string to display as total column/row label if column/row is enabled (see add_total). Defaults to "All Patients". To set a new default total_label to apply in all modules, run set_default_total_label("new_default").

na_level

(string)
used to replace all NA or empty values in character or factor variables in the data. Defaults to "<Missing>". To set a default na_level to apply in all modules, run set_default_na_str("new_default").

code_missing_baseline

(logical)
whether missing baseline grades should be counted as grade 0.

basic_table_args

(basic_table_args) optional
object created by teal.widgets::basic_table_args() with settings for the module table. The argument is merged with option teal.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").

Value

a list of expressions to generate a table or plot object.

See Also

tm_t_shift_by_grade()


Template: Adverse Events Table by Standardized MedDRA Query

Description

Creates a valid expression to generate an adverse events table by Standardized MedDRA Query.

Usage

template_smq(
  dataname,
  parentname,
  arm_var,
  llt = "AEDECOD",
  add_total = TRUE,
  total_label = default_total_label(),
  sort_criteria = c("freq_desc", "alpha"),
  drop_arm_levels = TRUE,
  na_level = default_na_str(),
  smq_varlabel = "Standardized MedDRA Query",
  baskets = c("SMQ01NAM", "SMQ02NAM", "CQ01NAM"),
  id_var = "USUBJID",
  basic_table_args = teal.widgets::basic_table_args()
)

Arguments

dataname

(character)
analysis data used in teal module.

parentname

(character)
parent analysis data used in teal module, usually this refers to ADSL.

arm_var

(character)
variable names that can be used as arm_var.

llt

(character)
name of the variable with low level term for events.

add_total

(logical)
whether to include column with total number of patients.

total_label

(string)
string to display as total column/row label if column/row is enabled (see add_total). Defaults to "All Patients". To set a new default total_label to apply in all modules, run set_default_total_label("new_default").

sort_criteria

(character)
how to sort the final table. Default option freq_desc sorts on column sort_freq_col by decreasing number of patients with event. Alternative option alpha sorts events alphabetically.

drop_arm_levels

(logical)
whether to drop unused levels of arm_var. If TRUE, arm_var levels are set to those used in the dataname dataset. If FALSE, arm_var levels are set to those used in the parentname dataset. If dataname and parentname are the same, then drop_arm_levels is set to TRUE and user input for this parameter is ignored.

na_level

(string)
used to replace all NA or empty values in character or factor variables in the data. Defaults to "<Missing>". To set a default na_level to apply in all modules, run set_default_na_str("new_default").

smq_varlabel

(character)
label to use for new column SMQ created by tern::h_stack_by_baskets().

baskets

(character)
names of the selected standardized/customized queries variables.

id_var

(character)
the variable name for subject id.

basic_table_args

(basic_table_args) optional
object created by teal.widgets::basic_table_args() with settings for the module table. The argument is merged with option teal.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").

Value

a list of expressions to generate a table or plot object.

See Also

tm_t_smq()


Template: Summary of Variables

Description

Creates a valid expression to generate a table to summarize variables.

Usage

template_summary(
  dataname,
  parentname,
  arm_var,
  sum_vars,
  show_labels = lifecycle::deprecated(),
  add_total = TRUE,
  total_label = default_total_label(),
  var_labels = character(),
  arm_var_labels = NULL,
  na.rm = FALSE,
  na_level = default_na_str(),
  numeric_stats = c("n", "mean_sd", "mean_ci", "median", "median_ci", "quantiles",
    "range", "geom_mean"),
  denominator = c("N", "n", "omit"),
  drop_arm_levels = TRUE,
  basic_table_args = teal.widgets::basic_table_args()
)

Arguments

dataname

(character)
analysis data used in teal module.

parentname

(character)
parent analysis data used in teal module, usually this refers to ADSL.

arm_var

(character)
variable names that can be used as arm_var.

sum_vars

(character)
names of the variables that should be summarized.

show_labels

[Deprecated]

add_total

(logical)
whether to include column with total number of patients.

total_label

(string)
string to display as total column/row label if column/row is enabled (see add_total). Defaults to "All Patients". To set a new default total_label to apply in all modules, run set_default_total_label("new_default").

var_labels

(named character) optional
variable labels for relabeling the analysis variables.

arm_var_labels

(character or NULL)
vector of column variable labels to display, of the same length as arm_var. If NULL, no labels will be displayed.

na.rm

(logical)
whether NA values should be removed prior to analysis.

na_level

(string)
used to replace all NA or empty values in character or factor variables in the data. Defaults to "<Missing>". To set a default na_level to apply in all modules, run set_default_na_str("new_default").

numeric_stats

(character)
names of statistics to display for numeric summary variables. Available statistics are n, mean_sd, mean_ci, median, median_ci, quantiles, range, and geom_mean.

denominator

(character)
chooses how percentages are calculated. With option N, the reference population from the column total is used as the denominator. With option n, the number of non-missing records in this row and column intersection is used as the denominator. If omit is chosen, then the percentage is omitted.

drop_arm_levels

(logical)
whether to drop unused levels of arm_var. If TRUE, arm_var levels are set to those used in the dataname dataset. If FALSE, arm_var levels are set to those used in the parentname dataset. If dataname and parentname are the same, then drop_arm_levels is set to TRUE and user input for this parameter is ignored.

basic_table_args

(basic_table_args) optional
object created by teal.widgets::basic_table_args() with settings for the module table. The argument is merged with option teal.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").

Value

a list of expressions to generate a table or plot object.

See Also

tm_t_summary()


Template: Summarize Variables by Row Groups Module

Description

Creates a valid expression to generate a table to summarize variables by row groups.

Usage

template_summary_by(
  parentname,
  dataname,
  arm_var,
  id_var,
  sum_vars,
  by_vars,
  var_labels = character(),
  add_total = TRUE,
  total_label = default_total_label(),
  parallel_vars = FALSE,
  row_groups = FALSE,
  na.rm = FALSE,
  na_level = default_na_str(),
  numeric_stats = c("n", "mean_sd", "mean_ci", "median", "median_ci", "quantiles",
    "range"),
  denominator = c("N", "n", "omit"),
  drop_arm_levels = TRUE,
  drop_zero_levels = TRUE,
  basic_table_args = teal.widgets::basic_table_args()
)

Arguments

parentname

(character)
parent analysis data used in teal module, usually this refers to ADSL.

dataname

(character)
analysis data used in teal module.

arm_var

(character)
variable names that can be used as arm_var.

id_var

(character)
the variable name for subject id.

sum_vars

(character)
names of the variables that should be summarized.

by_vars

(character)
variable names used to split the summary by rows.

var_labels

(named character) optional
variable labels for relabeling the analysis variables.

add_total

(logical)
whether to include column with total number of patients.

total_label

(string)
string to display as total column/row label if column/row is enabled (see add_total). Defaults to "All Patients". To set a new default total_label to apply in all modules, run set_default_total_label("new_default").

parallel_vars

(logical)
whether summarized variables should be arranged in columns. Can only be set to TRUE if all chosen analysis variables are numeric.

row_groups

(logical)
whether summarized variables should be arranged in row groups.

na.rm

(logical)
whether NA values should be removed prior to analysis.

na_level

(string)
used to replace all NA or empty values in character or factor variables in the data. Defaults to "<Missing>". To set a default na_level to apply in all modules, run set_default_na_str("new_default").

numeric_stats

(character)
names of statistics to display for numeric summary variables. Available statistics are n, mean_sd, mean_ci, median, median_ci, quantiles, range, and geom_mean.

denominator

(character)
chooses how percentages are calculated. With option N, the reference population from the column total is used as the denominator. With option n, the number of non-missing records in this row and column intersection is used as the denominator. If omit is chosen, then the percentage is omitted.

drop_arm_levels

(logical)
whether to drop unused levels of arm_var. If TRUE, arm_var levels are set to those used in the dataname dataset. If FALSE, arm_var levels are set to those used in the parentname dataset. If dataname and parentname are the same, then drop_arm_levels is set to TRUE and user input for this parameter is ignored.

drop_zero_levels

(logical)
whether rows with zero counts in all columns should be removed from the table.

basic_table_args

(basic_table_args) optional
object created by teal.widgets::basic_table_args() with settings for the module table. The argument is merged with option teal.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").

Value

a list of expressions to generate a table or plot object.

See Also

tm_t_summary_by()


Template: Patient Profile Therapy Table and Plot

Description

Creates a valid expression to generate a patient profile therapy table and ggplot2::ggplot() plot using ADaM datasets.

Usage

template_therapy(
  dataname = "ANL",
  atirel = "ATIREL",
  cmdecod = "CMDECOD",
  cmindc = "CMINDC",
  cmdose = "CMDOSE",
  cmtrt = "CMTRT",
  cmdosu = "CMDOSU",
  cmroute = "CMROUTE",
  cmdosfrq = "CMDOSFRQ",
  cmstdy = "CMSTDY",
  cmendy = "CMENDY",
  patient_id,
  font_size = 12L,
  ggplot2_args = teal.widgets::ggplot2_args()
)

Arguments

dataname

(character)
analysis data used in teal module.

atirel

(character)
name of time relation of medication variable.

cmdecod

(character)
name of standardized medication name variable.

cmindc

(character)
name of indication variable.

cmdose

(character)
name of dose per administration variable.

cmtrt

(character)
name of reported name of drug, med, or therapy variable.

cmdosu

(character)
name of dose units variable.

cmroute

(character)
name of route of administration variable.

cmdosfrq

(character)
name of dosing frequency per interval variable.

cmstdy

(character)
name of study relative day of start of medication variable.

cmendy

(character)
name of study day of end of medication variable.

patient_id

(character)
patient ID.

font_size

(numeric)
font size value.

ggplot2_args

(ggplot2_args) optional
object created by teal.widgets::ggplot2_args() with settings for the module plot. The argument is merged with option teal.ggplot2_args and with default module arguments (hard coded in the module body). For more details, see the vignette: vignette("custom-ggplot2-arguments", package = "teal.widgets").

Value

a list of expressions to generate a table or plot object.

See Also

tm_g_pp_therapy()


Template: Time-To-Event

Description

Creates a valid expression to generate a time-to-event analysis.

Usage

template_tte(
  dataname = "ANL",
  parentname = "ADSL",
  arm_var = "ARM",
  paramcd,
  ref_arm = NULL,
  comp_arm = NULL,
  compare_arm = FALSE,
  combine_comp_arms = FALSE,
  aval_var = "AVAL",
  cnsr_var = "CNSR",
  strata_var = NULL,
  time_points = NULL,
  time_unit_var = "AVALU",
  event_desc_var = "EVNTDESC",
  control = control_tte(),
  add_total = FALSE,
  total_label = default_total_label(),
  na_level = default_na_str(),
  basic_table_args = teal.widgets::basic_table_args()
)

Arguments

dataname

(character)
analysis data used in teal module.

parentname

(character)
parent analysis data used in teal module, usually this refers to ADSL.

arm_var

(character)
variable names that can be used as arm_var.

paramcd

(character)
endpoint parameter value to use in the table title.

ref_arm

(character)
the level of reference arm in case of arm comparison.

comp_arm

(character)
the level of comparison arm in case of arm comparison.

compare_arm

(logical)
triggers the comparison between study arms.

combine_comp_arms

(logical)
triggers the combination of comparison arms.

aval_var

(character)
name of the analysis value variable.

cnsr_var

(character)
name of the censoring variable.

strata_var

(character)
names of the variables for stratified analysis.

time_points

(character)
time points that can be used in tern::surv_timepoint().

time_unit_var

(character)
name of the variable representing time units.

event_desc_var

(character)
name of the variable with events description.

control

(list)
list of settings for the analysis. See control_tte() for details.

add_total

(logical)
whether to include column with total number of patients.

total_label

(string)
string to display as total column/row label if column/row is enabled (see add_total). Defaults to "All Patients". To set a new default total_label to apply in all modules, run set_default_total_label("new_default").

na_level

(string)
used to replace all NA or empty values in character or factor variables in the data. Defaults to "<Missing>". To set a default na_level to apply in all modules, run set_default_na_str("new_default").

basic_table_args

(basic_table_args) optional
object created by teal.widgets::basic_table_args() with settings for the module table. The argument is merged with option teal.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").

Value

a list of expressions to generate a table or plot object.

See Also

control_tte(), tm_t_tte()


Template: Patient Profile Vitals Plot

Description

Creates a valid expression to generate a patient profile vitals ggplot2::ggplot() plot using ADaM datasets.

Usage

template_vitals(
  dataname = "ANL",
  paramcd = "PARAMCD",
  paramcd_levels = c("SYSBP", "DIABP", "PUL", "RESP", "OXYSAT", "WGHT", "TEMP"),
  xaxis = "ADY",
  aval = lifecycle::deprecated(),
  aval_var = "AVAL",
  patient_id,
  font_size = 12L,
  ggplot2_args = teal.widgets::ggplot2_args()
)

Arguments

dataname

(character)
analysis data used in teal module.

paramcd

(character)
name of the parameter code variable.

paramcd_levels

(character)
vector of all levels of paramcd.

xaxis

(character)
name of the time variable to put on the x-axis.

aval

[Deprecated] Please use the aval_var argument instead.

aval_var

(character)
name of the analysis value variable.

patient_id

(character)
patient ID.

font_size

(numeric)
font size value.

ggplot2_args

(ggplot2_args) optional
object created by teal.widgets::ggplot2_args() with settings for the module plot. The argument is merged with option teal.ggplot2_args and with default module arguments (hard coded in the module body). For more details, see the vignette: vignette("custom-ggplot2-arguments", package = "teal.widgets").

Value

a list of expressions to generate a table or plot object.

See Also

tm_g_pp_vitals()


teal Module: Generalized Estimating Equations (GEE) analysis

Description

This module produces an analysis table using Generalized Estimating Equations (GEE).

Usage

tm_a_gee(
  label,
  dataname,
  parentname = ifelse(inherits(arm_var, "data_extract_spec"),
    teal.transform::datanames_input(arm_var), "ADSL"),
  aval_var,
  id_var,
  arm_var,
  visit_var,
  cov_var,
  arm_ref_comp = NULL,
  paramcd,
  conf_level = teal.transform::choices_selected(c(0.95, 0.9, 0.8), 0.95, keep_order =
    TRUE),
  pre_output = NULL,
  post_output = NULL,
  basic_table_args = teal.widgets::basic_table_args(),
  transformators = list(),
  decorators = list()
)

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 to ADSL.

aval_var

(teal.transform::choices_selected())
object with all available choices and pre-selected option for the analysis variable.

id_var

(teal.transform::choices_selected())
object specifying the variable name for subject id.

arm_var

(teal.transform::choices_selected())
object with all available choices and preselected option for variable names that can be used as arm_var. It defines the grouping variable in the results table.

visit_var

(teal.transform::choices_selected())
object with all available choices and preselected option for variable names that can be used as visit variable. Must be a factor in dataname.

cov_var

(teal.transform::choices_selected())
object with all available choices and preselected option for the covariates variables.

arm_ref_comp

(list) optional,
if specified it must be a named list with each element corresponding to an arm variable in ADSL and the element must be another list (possibly with delayed teal.transform::variable_choices() or delayed teal.transform::value_choices() with the elements named ref and comp 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 from dataname.

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).

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 the shiny::helpText() elements are useful.

basic_table_args

(basic_table_args) optional
object created by teal.widgets::basic_table_args() with settings for the module table. The argument is merged with option teal.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").

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 lists of teal_transform_module) optional, decorator for tables or plots included in the module output reported. The decorators are applied to the respective output objects.

See section "Decorating Module" below for more details.

Value

a teal_module object.

Decorating Module

This module generates the following objects, which can be modified in place using decorators:

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_a_gee(
   ..., # arguments for module
   decorators = list(
     table = teal_transform_module(...) # applied to the `table` output
   )
)

For additional details and examples of decorators, refer to the vignette vignette("decorate-module-output", package = "teal.modules.clinical").

To learn more please refer to the vignette vignette("transform-module-output", package = "teal") or the teal::teal_transform_module() documentation.

Examples in Shinylive

example-1

Open in Shinylive

See Also

The TLG Catalog where additional example apps implementing this module can be found.

Examples

library(dplyr)

data <- teal_data()
data <- within(data, {
  ADSL <- tmc_ex_adsl
  ADQS <- tmc_ex_adqs %>%
    filter(ABLFL != "Y" & ABLFL2 != "Y") %>%
    mutate(
      AVISIT = as.factor(AVISIT),
      AVISITN = rank(AVISITN) %>%
        as.factor() %>%
        as.numeric() %>%
        as.factor(),
      AVALBIN = AVAL < 50 # Just as an example to get a binary endpoint.
    ) %>%
    droplevels()
})
join_keys(data) <- default_cdisc_join_keys[names(data)]

app <- init(
  data = data,
  modules = modules(
    tm_a_gee(
      label = "GEE",
      dataname = "ADQS",
      aval_var = choices_selected("AVALBIN", fixed = TRUE),
      id_var = choices_selected(c("USUBJID", "SUBJID"), "USUBJID"),
      arm_var = choices_selected(c("ARM", "ARMCD"), "ARM"),
      visit_var = choices_selected(c("AVISIT", "AVISITN"), "AVISIT"),
      paramcd = choices_selected(
        choices = value_choices(data[["ADQS"]], "PARAMCD", "PARAM"),
        selected = "FKSI-FWB"
      ),
      cov_var = choices_selected(c("BASE", "AGE", "SEX", "BASE:AVISIT"), NULL)
    )
  )
)
if (interactive()) {
  shinyApp(app$ui, app$server)
}


teal Module: Mixed Model Repeated Measurements (MMRM) Analysis

Description

This module produces analysis tables and plots for Mixed Model Repeated Measurements.

Usage

tm_a_mmrm(
  label,
  dataname,
  parentname = ifelse(inherits(arm_var, "data_extract_spec"),
    teal.transform::datanames_input(arm_var), "ADSL"),
  aval_var,
  id_var,
  arm_var,
  visit_var,
  cov_var,
  arm_ref_comp = NULL,
  paramcd,
  method = teal.transform::choices_selected(c("Satterthwaite", "Kenward-Roger",
    "Kenward-Roger-Linear"), "Satterthwaite", keep_order = TRUE),
  conf_level = teal.transform::choices_selected(c(0.95, 0.9, 0.8), 0.95, keep_order =
    TRUE),
  plot_height = c(700L, 200L, 2000L),
  plot_width = NULL,
  total_label = default_total_label(),
  pre_output = NULL,
  post_output = NULL,
  basic_table_args = teal.widgets::basic_table_args(),
  ggplot2_args = teal.widgets::ggplot2_args(),
  transformators = list(),
  decorators = list()
)

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 to ADSL.

aval_var

(teal.transform::choices_selected())
object with all available choices and pre-selected option for the analysis variable.

id_var

(teal.transform::choices_selected())
object specifying the variable name for subject id.

arm_var

(teal.transform::choices_selected())
object with all available choices and preselected option for variable names that can be used as arm_var. It defines the grouping variable in the results table.

visit_var

(teal.transform::choices_selected())
object with all available choices and preselected option for variable names that can be used as visit variable. Must be a factor in dataname.

cov_var

(teal.transform::choices_selected())
object with all available choices and preselected option for the covariates variables.

arm_ref_comp

(list) optional,
if specified it must be a named list with each element corresponding to an arm variable in ADSL and the element must be another list (possibly with delayed teal.transform::variable_choices() or delayed teal.transform::value_choices() with the elements named ref and comp 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 from dataname.

method

(teal.transform::choices_selected())
object with all available choices and pre-selected option for the adjustment method.

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).

plot_height

(numeric) optional
vector of length three with c(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 with c(value, min, max). Specifies the width of the main plot and renders a slider on the plot to interactively adjust the plot width.

total_label

(string)
string to display as total column/row label if column/row is enabled (see add_total). Defaults to "All Patients". To set a new default total_label to apply in all modules, run set_default_total_label("new_default").

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 the shiny::helpText() elements are useful.

basic_table_args

(basic_table_args) optional
object created by teal.widgets::basic_table_args() with settings for the module table. The argument is merged with option teal.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").

ggplot2_args

(ggplot2_args) optional
object created by teal.widgets::ggplot2_args() with settings for all the plots or named list of ggplot2_args objects for plot-specific settings. List names should match the following: c("default", "lsmeans", "diagnostic"). The argument is merged with option teal.ggplot2_args and with default module arguments (hard coded in the module body). For more details, see the help vignette: vignette("custom-ggplot2-arguments", package = "teal.widgets").

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 lists of teal_transform_module) optional, decorator for tables or plots included in the module output reported. The decorators are applied to the respective output objects.

See section "Decorating Module" below for more details.

Value

a teal_module object.

Decorating Module

This module generates the following objects, which can be modified in place using decorators:

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_a_mrmm(
   ..., # arguments for module
   decorators = list(
     lsmeans_plot = teal_transform_module(...), # applied only to `lsmeans_plot` output
     diagnostic_plot = teal_transform_module(...), # applied only to `diagnostic_plot` output
     lsmeans_table = teal_transform_module(...), # applied only to `lsmeans_table` output
     covariance_table = teal_transform_module(...), # applied only to `covariance_table` output
     fixed_effects_table = teal_transform_module(...), # applied only to `fixed_effects_table` output
     diagnostic_table = teal_transform_module(...) # applied only to `diagnostic_table` output
   )
)

For additional details and examples of decorators, refer to the vignette vignette("decorate-module-output", package = "teal.modules.clinical").

To learn more please refer to the vignette vignette("transform-module-output", package = "teal") or the teal::teal_transform_module() documentation.

Examples in Shinylive

example-1

Open in Shinylive

Note

The ordering of the input data sets can lead to slightly different numerical results or different convergence behavior. This is a known observation with the used package lme4. However, once convergence is achieved, the results are reliable up to numerical precision.

See Also

The TLG Catalog where additional example apps implementing this module can be found.

Examples

library(dplyr)

arm_ref_comp <- list(
  ARMCD = list(
    ref = "ARM B",
    comp = c("ARM A", "ARM C")
  )
)

data <- teal_data()
data <- within(data, {
  ADSL <- tmc_ex_adsl
  ADQS <- tmc_ex_adqs %>%
    filter(ABLFL != "Y" & ABLFL2 != "Y") %>%
    filter(AVISIT %in% c("WEEK 1 DAY 8", "WEEK 2 DAY 15", "WEEK 3 DAY 22")) %>%
    mutate(
      AVISIT = as.factor(AVISIT),
      AVISITN = rank(AVISITN) %>%
        as.factor() %>%
        as.numeric() %>%
        as.factor() #' making consecutive numeric factor
    )
})
join_keys(data) <- default_cdisc_join_keys[names(data)]

app <- init(
  data = data,
  modules = modules(
    tm_a_mmrm(
      label = "MMRM",
      dataname = "ADQS",
      aval_var = choices_selected(c("AVAL", "CHG"), "AVAL"),
      id_var = choices_selected(c("USUBJID", "SUBJID"), "USUBJID"),
      arm_var = choices_selected(c("ARM", "ARMCD"), "ARM"),
      visit_var = choices_selected(c("AVISIT", "AVISITN"), "AVISIT"),
      arm_ref_comp = arm_ref_comp,
      paramcd = choices_selected(
        choices = value_choices(data[["ADQS"]], "PARAMCD", "PARAM"),
        selected = "FKSI-FWB"
      ),
      cov_var = choices_selected(c("BASE", "AGE", "SEX", "BASE:AVISIT"), NULL)
    )
  )
)
if (interactive()) {
  shinyApp(app$ui, app$server)
}


teal Module: Simple Bar Chart and Table of Counts per Category

Description

This module produces a ggplot2::ggplot() type bar chart and summary table of counts per category.

Usage

tm_g_barchart_simple(
  x = NULL,
  fill = NULL,
  x_facet = NULL,
  y_facet = NULL,
  label = "Count Barchart",
  plot_options = NULL,
  plot_height = c(600L, 200L, 2000L),
  plot_width = NULL,
  pre_output = NULL,
  post_output = NULL,
  ggplot2_args = teal.widgets::ggplot2_args(),
  transformators = list(),
  decorators = list()
)

Arguments

x

(data_extract_spec)
variable on the x-axis.

fill

(data_extract_spec)
grouping variable to determine bar colors.

x_facet

(data_extract_spec)
row-wise faceting groups.

y_facet

(data_extract_spec)
column-wise faceting groups.

label

(character)
menu item label of the module in the teal app.

plot_options

(list)
list of plot options.

plot_height

(numeric) optional
vector of length three with c(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 with c(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 the shiny::helpText() elements are useful.

ggplot2_args

(ggplot2_args) optional
object created by teal.widgets::ggplot2_args() with settings for the module plot. The argument is merged with option teal.ggplot2_args and with default module arguments (hard coded in the module body). For more details, see the vignette: vignette("custom-ggplot2-arguments", package = "teal.widgets").

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 lists of teal_transform_module) optional, decorator for tables or plots included in the module output reported. The decorators are applied to the respective output objects.

See section "Decorating Module" below for more details.

Details

Categories can be defined up to four levels deep and are defined through the x, fill, x_facet, and y_facet parameters. Any parameters set to NULL (default) are ignored.

Value

a teal_module object.

Decorating Module

This module generates the following objects, which can be modified in place using decorators:

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_barchart_simple(
   ..., # arguments for module
   decorators = list(
     plot = teal_transform_module(...) # applied only to `plot` output
   )
)

For additional details and examples of decorators, refer to the vignette vignette("decorate-module-output", package = "teal.modules.clinical").

To learn more please refer to the vignette vignette("transform-module-output", package = "teal") or the teal::teal_transform_module() documentation.

Examples in Shinylive

example-1

Open in Shinylive

See Also

The TLG Catalog where additional example apps implementing this module can be found.

Examples

library(nestcolor)
library(dplyr)

data <- teal_data()
data <- within(data, {
  ADSL <- tmc_ex_adsl %>%
    mutate(ITTFL = factor("Y") %>%
      with_label("Intent-To-Treat Population Flag"))
  ADAE <- tmc_ex_adae %>%
    filter(!((AETOXGR == 1) & (AESEV == "MILD") & (ARM == "A: Drug X")))
})
join_keys(data) <- default_cdisc_join_keys[names(data)]

ADSL <- data[["ADSL"]]
ADAE <- data[["ADAE"]]

app <- init(
  data = data,
  modules = modules(
    tm_g_barchart_simple(
      label = "ADAE Analysis",
      x = data_extract_spec(
        dataname = "ADSL",
        select = select_spec(
          choices = variable_choices(
            ADSL,
            c(
              "ARM", "ACTARM", "SEX",
              "RACE", "ITTFL", "SAFFL", "STRATA2"
            )
          ),
          selected = "ACTARM",
          multiple = FALSE
        )
      ),
      fill = list(
        data_extract_spec(
          dataname = "ADSL",
          select = select_spec(
            choices = variable_choices(
              ADSL,
              c(
                "ARM", "ACTARM", "SEX",
                "RACE", "ITTFL", "SAFFL", "STRATA2"
              )
            ),
            selected = "SEX",
            multiple = FALSE
          )
        ),
        data_extract_spec(
          dataname = "ADAE",
          select = select_spec(
            choices = variable_choices(ADAE, c("AETOXGR", "AESEV", "AESER")),
            selected = NULL,
            multiple = FALSE
          )
        )
      ),
      x_facet = list(
        data_extract_spec(
          dataname = "ADAE",
          select = select_spec(
            choices = variable_choices(ADAE, c("AETOXGR", "AESEV", "AESER")),
            selected = "AETOXGR",
            multiple = FALSE
          )
        ),
        data_extract_spec(
          dataname = "ADSL",
          select = select_spec(
            choices = variable_choices(
              ADSL,
              c(
                "ARM", "ACTARM", "SEX",
                "RACE", "ITTFL", "SAFFL", "STRATA2"
              )
            ),
            selected = NULL,
            multiple = FALSE
          )
        )
      ),
      y_facet = list(
        data_extract_spec(
          dataname = "ADAE",
          select = select_spec(
            choices = variable_choices(ADAE, c("AETOXGR", "AESEV", "AESER")),
            selected = "AESEV",
            multiple = FALSE
          )
        ),
        data_extract_spec(
          dataname = "ADSL",
          select = select_spec(
            choices = variable_choices(
              ADSL,
              c(
                "ARM", "ACTARM", "SEX",
                "RACE", "ITTFL", "SAFFL", "STRATA2"
              )
            ),
            selected = NULL,
            multiple = FALSE
          )
        )
      )
    )
  )
)
if (interactive()) {
  shinyApp(app$ui, app$server)
}


teal Module: Confidence Interval Plot

Description

This module produces a ggplot2::ggplot() type confidence interval plot consistent with the TLG Catalog template CIG01 available here.

Usage

tm_g_ci(
  label,
  x_var,
  y_var,
  color,
  stat = c("mean", "median"),
  conf_level = teal.transform::choices_selected(c(0.95, 0.9, 0.8), 0.95, keep_order =
    TRUE),
  plot_height = c(700L, 200L, 2000L),
  plot_width = NULL,
  pre_output = NULL,
  post_output = NULL,
  ggplot2_args = teal.widgets::ggplot2_args(),
  transformators = list(),
  decorators = list()
)

Arguments

label

(character)
menu item label of the module in the teal app.

x_var

(character)
name of the treatment variable to put on the x-axis.

y_var

(character)
name of the response variable to put on the y-axis.

color

(data_extract_spec)
the group variable used to determine the plot colors, shapes, and line types.

stat

(character)
statistic to plot. Options are "mean" and "median".

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).

plot_height

(numeric) optional
vector of length three with c(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 with c(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 the shiny::helpText() elements are useful.

ggplot2_args

(ggplot2_args) optional
object created by teal.widgets::ggplot2_args() with settings for the module plot. The argument is merged with option teal.ggplot2_args and with default module arguments (hard coded in the module body). For more details, see the vignette: vignette("custom-ggplot2-arguments", package = "teal.widgets").

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 lists of teal_transform_module) optional, decorator for tables or plots included in the module output reported. The decorators are applied to the respective output objects.

See section "Decorating Module" below for more details.

Value

a teal_module object.

Decorating Module

This module generates the following objects, which can be modified in place using decorators:

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_ci(
   ..., # arguments for module
   decorators = list(
     plot = teal_transform_module(...) # applied only to `plot` output
   )
)

For additional details and examples of decorators, refer to the vignette vignette("decorate-module-output", package = "teal.modules.clinical").

To learn more please refer to the vignette vignette("transform-module-output", package = "teal") or the teal::teal_transform_module() documentation.

Examples in Shinylive

example-1

Open in Shinylive

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
  ADLB <- tmc_ex_adlb
})
join_keys(data) <- default_cdisc_join_keys[names(data)]

ADSL <- data[["ADSL"]]
ADLB <- data[["ADLB"]]

app <- init(
  data = data,
  modules = modules(
    tm_g_ci(
      label = "Confidence Interval Plot",
      x_var = data_extract_spec(
        dataname = "ADSL",
        select = select_spec(
          choices = c("ARMCD", "BMRKR2"),
          selected = c("ARMCD"),
          multiple = FALSE,
          fixed = FALSE
        )
      ),
      y_var = data_extract_spec(
        dataname = "ADLB",
        filter = list(
          filter_spec(
            vars = "PARAMCD",
            choices = levels(ADLB$PARAMCD),
            selected = levels(ADLB$PARAMCD)[1],
            multiple = FALSE,
            label = "Select lab:"
          ),
          filter_spec(
            vars = "AVISIT",
            choices = levels(ADLB$AVISIT),
            selected = levels(ADLB$AVISIT)[1],
            multiple = FALSE,
            label = "Select visit:"
          )
        ),
        select = select_spec(
          label = "Analyzed Value",
          choices = c("AVAL", "CHG"),
          selected = "AVAL",
          multiple = FALSE,
          fixed = FALSE
        )
      ),
      color = data_extract_spec(
        dataname = "ADSL",
        select = select_spec(
          label = "Color by variable",
          choices = c("SEX", "STRATA1", "STRATA2"),
          selected = c("STRATA1"),
          multiple = FALSE,
          fixed = FALSE
        )
      )
    )
  )
)
if (interactive()) {
  shinyApp(app$ui, app$server)
}


teal Module: Forest Response Plot

Description

This module produces a grid-style forest plot for response data with ADaM structure.

Usage

tm_g_forest_rsp(
  label,
  dataname,
  parentname = ifelse(inherits(arm_var, "data_extract_spec"),
    teal.transform::datanames_input(arm_var), "ADSL"),
  arm_var,
  arm_ref_comp = NULL,
  paramcd,
  aval_var = teal.transform::choices_selected(teal.transform::variable_choices(dataname,
    "AVALC"), "AVALC", fixed = TRUE),
  subgroup_var,
  strata_var,
  stats = c("n_tot", "n", "n_rsp", "prop", "or", "ci"),
  riskdiff = NULL,
  fixed_symbol_size = TRUE,
  conf_level = teal.transform::choices_selected(c(0.95, 0.9, 0.8), 0.95, keep_order =
    TRUE),
  default_responses = c("CR", "PR", "Y", "Complete Response (CR)",
    "Partial Response (PR)"),
  plot_height = c(500L, 200L, 2000L),
  plot_width = c(1500L, 800L, 3000L),
  rel_width_forest = c(25L, 0L, 100L),
  font_size = c(15L, 1L, 30L),
  pre_output = NULL,
  post_output = NULL,
  ggplot2_args = teal.widgets::ggplot2_args(),
  transformators = list(),
  decorators = list()
)

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 to ADSL.

arm_var

(teal.transform::choices_selected())
object with all available choices and preselected option for variable names that can be used as arm_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 in ADSL and the element must be another list (possibly with delayed teal.transform::variable_choices() or delayed teal.transform::value_choices() with the elements named ref and comp 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 from dataname.

aval_var

(teal.transform::choices_selected())
object with all available choices and pre-selected option for the analysis variable.

subgroup_var

(teal.transform::choices_selected())
object with all available choices and preselected option for variable names that can be used as the default subgroups.

strata_var

(teal.transform::choices_selected())
names of the variables for stratified analysis.

stats

(character)
the names of statistics to be reported among:

  • n: Total number of observations per group.

  • n_rsp: Number of responders per group.

  • prop: Proportion of responders.

  • n_tot: Total number of observations.

  • or: Odds ratio.

  • ci : Confidence interval of odds ratio.

  • pval: p-value of the effect. Note, the statistics n_tot, or, and ci are required.

riskdiff

(list)
if a risk (proportion) difference column should be added, a list of settings to apply within the column. See tern::control_riskdiff() for details. If NULL, no risk difference column will be added.

fixed_symbol_size

(logical)
When (TRUE), the same symbol size is used for plotting each estimate. Otherwise, the symbol size will be proportional to the sample size in each each subgroup.

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).

default_responses

(list or character)
defines the default codes for the response variable in the module per value of paramcd. A passed vector is transmitted for all paramcd values. A passed list must be named and contain arrays, each name corresponding to a single value of paramcd. Each array may contain default response values or named arrays rsp of default selected response values and levels of default level choices.

plot_height

(numeric) optional
vector of length three with c(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 with c(value, min, max). Specifies the width of the main plot and renders a slider on the plot to interactively adjust the plot width.

rel_width_forest

(proportion)
proportion of total width to allocate to the forest plot. Relative width of table is then 1 - rel_width_forest. If as_list = TRUE, this parameter is ignored.

font_size

(numeric(1))
font size.

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 the shiny::helpText() elements are useful.

ggplot2_args

(ggplot2_args) optional
object created by teal.widgets::ggplot2_args() with settings for the module plot. For this module, this argument will only accept ggplot2_args object with labs list of following child elements: title, caption. No other elements would be taken into account. The argument is merged with option teal.ggplot2_args and with default module arguments (hard coded in the module body).

For more details, see the vignette: vignette("custom-ggplot2-arguments", package = "teal.widgets").

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 lists of teal_transform_module) optional, decorator for tables or plots included in the module output reported. The decorators are applied to the respective output objects.

See section "Decorating Module" below for more details.

Value

a teal_module object.

Decorating Module

This module generates the following objects, which can be modified in place using decorators:

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_forest_rsp(
   ..., # arguments for module
   decorators = list(
     plot = teal_transform_module(...) # applied only to `plot` output
   )
)

For additional details and examples of decorators, refer to the vignette vignette("decorate-module-output", package = "teal.modules.clinical").

To learn more please refer to the vignette vignette("transform-module-output", package = "teal") or the teal::teal_transform_module() documentation.

Examples in Shinylive

example-1

Open in Shinylive

See Also

The TLG Catalog where additional example apps implementing this module can be found.

Examples

library(nestcolor)
library(dplyr)

data <- teal_data()
data <- within(data, {
  ADSL <- tmc_ex_adsl
  ADRS <- tmc_ex_adrs %>%
    mutate(AVALC = d_onco_rsp_label(AVALC) %>%
      with_label("Character Result/Finding")) %>%
    filter(PARAMCD != "OVRINV" | AVISIT == "FOLLOW UP")
})
join_keys(data) <- default_cdisc_join_keys[names(data)]

ADSL <- data[["ADSL"]]
ADRS <- data[["ADRS"]]

arm_ref_comp <- list(
  ARM = list(
    ref = "B: Placebo",
    comp = c("A: Drug X", "C: Combination")
  ),
  ARMCD = list(
    ref = "ARM B",
    comp = c("ARM A", "ARM C")
  )
)

app <- init(
  data = data,
  modules = modules(
    tm_g_forest_rsp(
      label = "Forest Response",
      dataname = "ADRS",
      arm_var = choices_selected(
        variable_choices(ADSL, c("ARM", "ARMCD")),
        "ARMCD"
      ),
      arm_ref_comp = arm_ref_comp,
      paramcd = choices_selected(
        value_choices(ADRS, "PARAMCD", "PARAM"),
        "INVET"
      ),
      subgroup_var = choices_selected(
        variable_choices(ADSL, names(ADSL)),
        c("BMRKR2", "SEX")
      ),
      strata_var = choices_selected(
        variable_choices(ADSL, c("STRATA1", "STRATA2")),
        "STRATA2"
      ),
      plot_height = c(600L, 200L, 2000L),
      default_responses = list(
        BESRSPI = list(
          rsp = c("Stable Disease (SD)", "Not Evaluable (NE)"),
          levels = c(
            "Complete Response (CR)", "Partial Response (PR)", "Stable Disease (SD)",
            "Progressive Disease (PD)", "Not Evaluable (NE)"
          )
        ),
        INVET = list(
          rsp = c("Complete Response (CR)", "Partial Response (PR)"),
          levels = c(
            "Complete Response (CR)", "Not Evaluable (NE)", "Partial Response (PR)",
            "Progressive Disease (PD)", "Stable Disease (SD)"
          )
        ),
        OVRINV = list(
          rsp = c("Progressive Disease (PD)", "Stable Disease (SD)"),
          levels = c("Progressive Disease (PD)", "Stable Disease (SD)", "Not Evaluable (NE)")
        )
      )
    )
  )
)
if (interactive()) {
  shinyApp(app$ui, app$server)
}


teal Module: Forest Survival Plot

Description

This module produces a grid-style forest plot for time-to-event data with ADaM structure.

Usage

tm_g_forest_tte(
  label,
  dataname,
  parentname = ifelse(inherits(arm_var, "data_extract_spec"),
    teal.transform::datanames_input(arm_var), "ADSL"),
  arm_var,
  arm_ref_comp = NULL,
  subgroup_var,
  paramcd,
  strata_var,
  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),
  stats = c("n_tot_events", "n_events", "median", "hr", "ci"),
  riskdiff = NULL,
  conf_level = teal.transform::choices_selected(c(0.95, 0.9, 0.8), 0.95, keep_order =
    TRUE),
  time_unit_var =
    teal.transform::choices_selected(teal.transform::variable_choices(dataname, "AVALU"),
    "AVALU", fixed = TRUE),
  fixed_symbol_size = TRUE,
  plot_height = c(500L, 200L, 2000L),
  plot_width = c(1500L, 800L, 3000L),
  rel_width_forest = c(25L, 0L, 100L),
  font_size = c(15L, 1L, 30L),
  pre_output = NULL,
  post_output = NULL,
  ggplot2_args = teal.widgets::ggplot2_args(),
  transformators = list(),
  decorators = list()
)

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 to ADSL.

arm_var

(teal.transform::choices_selected())
object with all available choices and preselected option for variable names that can be used as arm_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 in ADSL and the element must be another list (possibly with delayed teal.transform::variable_choices() or delayed teal.transform::value_choices() with the elements named ref and comp that the defined the default reference and comparison arms when the arm variable is changed.

subgroup_var

(teal.transform::choices_selected())
object with all available choices and preselected option for variable names that can be used as the default subgroups.

paramcd

(teal.transform::choices_selected())
object with all available choices and preselected option for the parameter code variable from dataname.

strata_var

(teal.transform::choices_selected())
names of the variables for stratified analysis.

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.

stats

(character)
the names of statistics to be reported among:

  • n_tot_events: Total number of events per group.

  • n_events: Number of events per group.

  • n_tot: Total number of observations per group.

  • n: Number of observations per group.

  • median: Median survival time.

  • hr: Hazard ratio.

  • ci: Confidence interval of hazard ratio.

  • pval: p-value of the effect. Note, one of the statistics n_tot and n_tot_events, as well as both hr and ci are required.

riskdiff

(list)
if a risk (proportion) difference column should be added, a list of settings to apply within the column. See tern::control_riskdiff() for details. If NULL, no risk difference column will be added.

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).

time_unit_var

(teal.transform::choices_selected())
object with all available choices and pre-selected option for the time unit variable.

fixed_symbol_size

(logical)
When (TRUE), the same symbol size is used for plotting each estimate. Otherwise, the symbol size will be proportional to the sample size in each each subgroup.

plot_height

(numeric) optional
vector of length three with c(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 with c(value, min, max). Specifies the width of the main plot and renders a slider on the plot to interactively adjust the plot width.

rel_width_forest

(proportion)
proportion of total width to allocate to the forest plot. Relative width of table is then 1 - rel_width_forest. If as_list = TRUE, this parameter is ignored.

font_size

(numeric(1))
font size.

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 the shiny::helpText() elements are useful.

ggplot2_args

(ggplot2_args) optional
object created by teal.widgets::ggplot2_args() with settings for the module plot. The argument is merged with option teal.ggplot2_args and with default module arguments (hard coded in the module body). For more details, see the vignette: vignette("custom-ggplot2-arguments", package = "teal.widgets").

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 lists of teal_transform_module) optional, decorator for tables or plots included in the module output reported. The decorators are applied to the respective output objects.

See section "Decorating Module" below for more details.

Value

a teal_module object.

Decorating Module

This module generates the following objects, which can be modified in place using decorators:

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_forest_tte(
   ..., # arguments for module
   decorators = list(
     plot = teal_transform_module(...) # applied only to `plot` output
   )
)

For additional details and examples of decorators, refer to the vignette vignette("decorate-module-output", package = "teal.modules.clinical").

To learn more please refer to the vignette vignette("transform-module-output", package = "teal") or the teal::teal_transform_module() documentation.

Examples in Shinylive

example-1

Open in Shinylive

See Also

The TLG Catalog where additional example apps implementing this module can be found.

Examples

library(nestcolor)
library(dplyr)

data <- teal_data()
data <- within(data, {
  ADSL <- tmc_ex_adsl
  ADTTE <- tmc_ex_adtte
  ADSL$RACE <- droplevels(ADSL$RACE) %>% with_label("Race")
})
join_keys(data) <- default_cdisc_join_keys[names(data)]

ADSL <- data[["ADSL"]]
ADTTE <- data[["ADTTE"]]

arm_ref_comp <- list(
  ARM = list(
    ref = "B: Placebo",
    comp = c("A: Drug X", "C: Combination")
  ),
  ARMCD = list(
    ref = "ARM B",
    comp = c("ARM A", "ARM C")
  )
)

app <- init(
  data = data,
  modules = modules(
    tm_g_forest_tte(
      label = "Forest Survival",
      dataname = "ADTTE",
      arm_var = choices_selected(
        variable_choices(ADSL, c("ARM", "ARMCD")),
        "ARMCD"
      ),
      arm_ref_comp = arm_ref_comp,
      paramcd = choices_selected(
        value_choices(ADTTE, "PARAMCD", "PARAM"),
        "OS"
      ),
      subgroup_var = choices_selected(
        variable_choices(ADSL, names(ADSL)),
        c("BMRKR2", "SEX")
      ),
      strata_var = choices_selected(
        variable_choices(ADSL, c("STRATA1", "STRATA2")),
        "STRATA2"
      )
    )
  )
)
if (interactive()) {
  shinyApp(app$ui, app$server)
}


teal Module: Individual Patient Plots

Description

This module produces ggplot2::ggplot() type individual patient plots that display trends in parameter values over time for each patient, using data with ADaM structure.

Usage

tm_g_ipp(
  label,
  dataname,
  parentname = ifelse(inherits(arm_var, "data_extract_spec"),
    teal.transform::datanames_input(arm_var), "ADSL"),
  arm_var,
  paramcd,
  id_var = teal.transform::choices_selected(teal.transform::variable_choices(dataname,
    "USUBJID"), "USUBJID", fixed = TRUE),
  visit_var = teal.transform::choices_selected(teal.transform::variable_choices(dataname,
    "AVISIT"), "AVISIT", fixed = TRUE),
  aval_var = teal.transform::choices_selected(teal.transform::variable_choices(dataname,
    "AVAL"), "AVAL", fixed = TRUE),
  avalu_var = teal.transform::choices_selected(teal.transform::variable_choices(dataname,
    "AVALU"), "AVALU", fixed = TRUE),
  base_var = lifecycle::deprecated(),
  baseline_var =
    teal.transform::choices_selected(teal.transform::variable_choices(dataname, "BASE"),
    "BASE", fixed = TRUE),
  add_baseline_hline = FALSE,
  separate_by_obs = FALSE,
  suppress_legend = FALSE,
  add_avalu = TRUE,
  plot_height = c(1200L, 400L, 5000L),
  plot_width = NULL,
  pre_output = NULL,
  post_output = NULL,
  ggplot2_args = teal.widgets::ggplot2_args(),
  transformators = list(),
  decorators = list()
)

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 to ADSL.

arm_var

(teal.transform::choices_selected())
object with all available choices and preselected option for variable values that can be used as arm variable.

paramcd

(teal.transform::choices_selected())
object with all available choices and preselected option for the parameter code variable from dataname.

id_var

(teal.transform::choices_selected())
object specifying the variable name for subject id.

visit_var

(teal.transform::choices_selected())
object with all available choices and preselected option for variable names that can be used as visit variable. Must be a factor in dataname.

aval_var

(teal.transform::choices_selected())
object with all available choices and pre-selected option for the analysis variable.

avalu_var

(teal.transform::choices_selected())
object with all available choices and preselected option for the analysis unit variable.

base_var

[Deprecated] Please use the baseline_var argument instead.

baseline_var

(teal.transform::choices_selected())
object with all available choices and preselected option for variable values that can be used as baseline_var.

add_baseline_hline

(logical)
whether a horizontal line should be added to the plot at baseline y-value.

separate_by_obs

(logical)
whether to create multi-panel plots.

suppress_legend

(logical)
whether to suppress the plot legend.

add_avalu

(logical)
whether avalu_first text should be appended to the plot title and y-axis label.

plot_height

(numeric) optional
vector of length three with c(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 with c(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 the shiny::helpText() elements are useful.

ggplot2_args

(ggplot2_args) optional
object created by teal.widgets::ggplot2_args() with settings for the module plot. For this module, this argument will only accept ggplot2_args object with labs list of the following child elements: title, subtitle, x, y. No other elements are taken into account. The argument is merged with option teal.ggplot2_args and with default module arguments (hard coded in the module body).

For more details, see the vignette: vignette("custom-ggplot2-arguments", package = "teal.widgets").

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 lists of teal_transform_module) optional, decorator for tables or plots included in the module output reported. The decorators are applied to the respective output objects.

See section "Decorating Module" below for more details.

Value

a teal_module object.

Decorating Module

This module generates the following objects, which can be modified in place using decorators:

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_ipp(
   ..., # arguments for module
   decorators = list(
     plot = teal_transform_module(...) # applied only to `plot` output
   )
)

For additional details and examples of decorators, refer to the vignette vignette("decorate-module-output", package = "teal.modules.clinical").

To learn more please refer to the vignette vignette("transform-module-output", package = "teal") or the teal::teal_transform_module() documentation.

Examples in Shinylive

example-1

Open in Shinylive

See Also

The TLG Catalog where additional example apps implementing this module can be found.

Examples

library(nestcolor)
library(dplyr)

data <- teal_data()
data <- within(data, {
  ADSL <- tmc_ex_adsl %>%
    slice(1:20) %>%
    df_explicit_na()
  ADLB <- tmc_ex_adlb %>%
    filter(USUBJID %in% ADSL$USUBJID) %>%
    df_explicit_na() %>%
    filter(AVISIT != "SCREENING")
})
join_keys(data) <- default_cdisc_join_keys[names(data)]

ADSL <- data[["ADSL"]]
ADLB <- data[["ADLB"]]

app <- init(
  data = data,
  modules = modules(
    tm_g_ipp(
      label = "Individual Patient Plot",
      dataname = "ADLB",
      arm_var = choices_selected(
        value_choices(ADLB, "ARMCD"),
        "ARM A"
      ),
      paramcd = choices_selected(
        value_choices(ADLB, "PARAMCD"),
        "ALT"
      ),
      aval_var = choices_selected(
        variable_choices(ADLB, c("AVAL", "CHG")),
        "AVAL"
      ),
      avalu_var = choices_selected(
        variable_choices(ADLB, c("AVALU")),
        "AVALU",
        fixed = TRUE
      ),
      id_var = choices_selected(
        variable_choices(ADLB, c("USUBJID")),
        "USUBJID",
        fixed = TRUE
      ),
      visit_var = choices_selected(
        variable_choices(ADLB, c("AVISIT")),
        "AVISIT"
      ),
      baseline_var = choices_selected(
        variable_choices(ADLB, c("BASE")),
        "BASE",
        fixed = TRUE
      ),
      add_baseline_hline = FALSE,
      separate_by_obs = FALSE
    )
  )
)
if (interactive()) {
  shinyApp(app$ui, app$server)
}


teal Module: Kaplan-Meier Plot

Description

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,
  transformators = list(),
  decorators = list()
)

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 to ADSL.

arm_var

(teal.transform::choices_selected())
object with all available choices and preselected option for variable names that can be used as arm_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 in ADSL and the element must be another list (possibly with delayed teal.transform::variable_choices() or delayed teal.transform::value_choices() with the elements named ref and comp 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 from dataname.

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 when annot_surv_med = TRUE, specified using the control_surv_med_annot() function. Parameter options are: x, y, w, h, and fill. See control_surv_med_annot() for details.

control_annot_coxph

(list)
parameters to control the position and size of the annotation table added to the plot when annot_coxph = TRUE, specified using the control_coxph_annot() function. Parameter options are: x, y, w, h, fill, and ref_lbls. See control_coxph_annot() for details.

legend_pos

(numeric(2) or NULL)
vector containing x- and y-coordinates, respectively, for the legend position relative to the KM plot area. If NULL (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 then 1 - rel_height_plot. If annot_at_risk = FALSE or as_list = TRUE, this parameter is ignored.

plot_height

(numeric) optional
vector of length three with c(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 with c(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 the shiny::helpText() elements are useful.

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 lists of teal_transform_module) optional, decorator for tables or plots included in the module output reported. The decorators are applied to the respective output objects.

See section "Decorating Module" below for more details.

Value

a teal_module object.

Decorating Module

This module generates the following objects, which can be modified in place using decorators:

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_km(
   ..., # arguments for module
   decorators = list(
     plot = teal_transform_module(...) # applied only to `plot` output
   )
)

For additional details and examples of decorators, refer to the vignette vignette("decorate-module-output", package = "teal.modules.clinical").

To learn more please refer to the vignette vignette("transform-module-output", package = "teal") or the teal::teal_transform_module() documentation.

Examples in Shinylive

example-1

Open in Shinylive

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
      )
    )
  )
)
if (interactive()) {
  shinyApp(app$ui, app$server)
}


teal Module: Line Plot

Description

This module produces a ggplot2::ggplot() type line plot, with optional summary table, for standard ADaM data.

Usage

tm_g_lineplot(
  label,
  dataname,
  parentname = NULL,
  strata = lifecycle::deprecated(),
  group_var =
    teal.transform::choices_selected(teal.transform::variable_choices(parentname,
    c("ARM", "ARMCD", "ACTARMCD")), "ARM"),
  x = teal.transform::choices_selected(teal.transform::variable_choices(dataname,
    "AVISIT"), "AVISIT", fixed = TRUE),
  y = teal.transform::choices_selected(teal.transform::variable_choices(dataname,
    c("AVAL", "BASE", "CHG", "PCHG")), "AVAL"),
  y_unit = teal.transform::choices_selected(teal.transform::variable_choices(dataname,
    "AVALU"), "AVALU", fixed = TRUE),
  paramcd = teal.transform::choices_selected(teal.transform::variable_choices(dataname,
    "PARAMCD"), "PARAMCD", fixed = TRUE),
  param = teal.transform::choices_selected(teal.transform::value_choices(dataname,
    "PARAMCD", "PARAM"), "ALT"),
  conf_level = teal.transform::choices_selected(c(0.95, 0.9, 0.8), 0.95, keep_order =
    TRUE),
  interval = "mean_ci",
  mid = "mean",
  whiskers = c("mean_ci_lwr", "mean_ci_upr"),
  table = c("n", "mean_sd", "median", "range"),
  mid_type = "pl",
  mid_point_size = c(2, 1, 5),
  table_font_size = c(4, 2, 6),
  plot_height = c(1000L, 200L, 4000L),
  plot_width = NULL,
  pre_output = NULL,
  post_output = NULL,
  ggplot2_args = teal.widgets::ggplot2_args(),
  transformators = list(),
  decorators = list()
)

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 to ADSL.

strata

[Deprecated] Please use the group_var argument instead.

group_var

(string or NA)
group variable name.

x

(teal_module or teal_modules) Object to format/print.

y

(string)
y-variable name.

y_unit

(string or NA)
y-axis unit variable name.

paramcd

(teal.transform::choices_selected())
object with all available choices and preselected option for the parameter code variable from dataname.

param

(character)
parameter to filter the data by.

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).

interval

(character or NULL)
names of the statistics that will be plotted as intervals. All the statistics indicated in interval variable must be present in the object returned by sfun, and be of a double or numeric type vector of length two. Set interval = NULL if intervals should not be added to the plot.

mid

(character or NULL)
names of the statistics that will be plotted as midpoints. All the statistics indicated in mid variable must be present in the object returned by sfun, and be of a double or numeric type vector of length one.

whiskers

(character)
names of the interval whiskers that will be plotted. Names must match names of the list element interval that will be returned by sfun (e.g. mean_ci_lwr element of sfun(x)[["mean_ci"]]). It is possible to specify one whisker only, or to suppress all whiskers by setting interval = NULL.

table

(character or NULL)
names of the statistics that will be displayed in the table below the plot. All the statistics indicated in table variable must be present in the object returned by sfun.

mid_type

(string)
controls the type of the mid plot, it can be point ("p"), line ("l"), or point and line ("pl").

mid_point_size

(numeric(1))
font size of the mid plot points.

table_font_size

(numeric(1))
font size of the text in the table.

plot_height

(numeric) optional
vector of length three with c(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 with c(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 the shiny::helpText() elements are useful.

ggplot2_args

(ggplot2_args) optional
object created by teal.widgets::ggplot2_args() with settings for the module plot. For this module, this argument will only accept ggplot2_args object with labs list of following child elements: title, subtitle, caption, y, lty. No other elements would be taken into account. The argument is merged with option teal.ggplot2_args and with default module arguments (hard coded in the module body).

For more details, see the vignette: vignette("custom-ggplot2-arguments", package = "teal.widgets").

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 lists of teal_transform_module) optional, decorator for tables or plots included in the module output reported. The decorators are applied to the respective output objects.

See section "Decorating Module" below for more details.

Value

a teal_module object.

Decorating Module

This module generates the following objects, which can be modified in place using decorators:

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_lineplot(
   ..., # arguments for module
   decorators = list(
     plot = teal_transform_module(...) # applied only to `plot` output
   )
)

For additional details and examples of decorators, refer to the vignette vignette("decorate-module-output", package = "teal.modules.clinical").

To learn more please refer to the vignette vignette("transform-module-output", package = "teal") or the teal::teal_transform_module() documentation.

Examples in Shinylive

example-1

Open in Shinylive

See Also

The TLG Catalog where additional example apps implementing this module can be found.

Examples

library(nestcolor)
library(dplyr)
library(forcats)

data <- teal_data()
data <- within(data, {
  ADSL <- tmc_ex_adsl
  ADLB <- tmc_ex_adlb %>%
    mutate(AVISIT == fct_reorder(AVISIT, AVISITN, min))
})
join_keys(data) <- default_cdisc_join_keys[names(data)]

ADSL <- data[["ADSL"]]
ADLB <- data[["ADLB"]]

app <- init(
  data = data,
  modules = modules(
    tm_g_lineplot(
      label = "Line Plot",
      dataname = "ADLB",
      group_var = choices_selected(
        variable_choices(ADSL, c("ARM", "ARMCD", "ACTARMCD")),
        "ARM"
      ),
      y = choices_selected(
        variable_choices(ADLB, c("AVAL", "BASE", "CHG", "PCHG")),
        "AVAL"
      ),
      param = choices_selected(
        value_choices(ADLB, "PARAMCD", "PARAM"),
        "ALT"
      )
    )
  )
)
if (interactive()) {
  shinyApp(app$ui, app$server)
}


teal Module: Patient Profile Adverse Events Table and Plot

Description

This module produces an adverse events table and ggplot2::ggplot() type plot using ADaM datasets.

Usage

tm_g_pp_adverse_events(
  label,
  dataname = "ADAE",
  parentname = "ADSL",
  patient_col = "USUBJID",
  aeterm = NULL,
  tox_grade = NULL,
  causality = NULL,
  outcome = NULL,
  action = NULL,
  time = NULL,
  decod = NULL,
  font_size = c(12L, 12L, 25L),
  plot_height = c(700L, 200L, 2000L),
  plot_width = NULL,
  pre_output = NULL,
  post_output = NULL,
  ggplot2_args = teal.widgets::ggplot2_args(),
  transformators = list(),
  decorators = list()
)

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 to ADSL.

patient_col

(character)
name of patient ID variable.

aeterm

(teal.transform::choices_selected())
object with all available choices and preselected option for the AETERM variable from dataname.

tox_grade

(teal.transform::choices_selected())
object with all available choices and preselected option for the AETOXGR variable from dataname.

causality

(teal.transform::choices_selected())
object with all available choices and preselected option for the AEREL variable from dataname.

outcome

(teal.transform::choices_selected())
object with all available choices and preselected option for the AEOUT variable from dataname.

action

(teal.transform::choices_selected())
object with all available choices and preselected option for the AEACN variable from dataname.

time

(teal.transform::choices_selected())
object with all available choices and preselected option for the ASTDY variable from dataname.

decod

(teal.transform::choices_selected())
object with all available choices and preselected option for the AEDECOD variable from dataname.

font_size

(numeric)
numeric vector of length 3 of current, minimum and maximum font size values.

plot_height

(numeric) optional
vector of length three with c(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 with c(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 the shiny::helpText() elements are useful.

ggplot2_args

(ggplot2_args) optional
object created by teal.widgets::ggplot2_args() with settings for the module plot. The argument is merged with option teal.ggplot2_args and with default module arguments (hard coded in the module body). For more details, see the vignette: vignette("custom-ggplot2-arguments", package = "teal.widgets").

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 lists of teal_transform_module) optional, decorator for tables or plots included in the module output reported. The decorators are applied to the respective output objects.

See section "Decorating Module" below for more details.

Value

a teal_module object.

Decorating Module

This module generates the following objects, which can be modified in place using decorators::

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_pp_adverse_events(
   ..., # arguments for module
   decorators = list(
     plot = teal_transform_module(...), # applied only to `plot` output
     table = teal_transform_module(...) # applied only to `table` output
   )
)

For additional details and examples of decorators, refer to the vignette vignette("decorate-module-output", package = "teal.modules.clinical").

To learn more please refer to the vignette vignette("transform-module-output", package = "teal") or the teal::teal_transform_module() documentation.

Examples in Shinylive

example-1

Open in Shinylive

Examples

library(nestcolor)
library(dplyr)

data <- teal_data()
data <- within(data, {
  ADAE <- tmc_ex_adae
  ADSL <- tmc_ex_adsl %>%
    filter(USUBJID %in% ADAE$USUBJID)
})
join_keys(data) <- default_cdisc_join_keys[names(data)]

ADSL <- data[["ADSL"]]
ADAE <- data[["ADAE"]]

app <- init(
  data = data,
  modules = modules(
    tm_g_pp_adverse_events(
      label = "Adverse Events",
      dataname = "ADAE",
      parentname = "ADSL",
      patient_col = "USUBJID",
      plot_height = c(600L, 200L, 2000L),
      aeterm = choices_selected(
        choices = variable_choices(ADAE, "AETERM"),
        selected = "AETERM"
      ),
      tox_grade = choices_selected(
        choices = variable_choices(ADAE, "AETOXGR"),
        selected = "AETOXGR"
      ),
      causality = choices_selected(
        choices = variable_choices(ADAE, "AEREL"),
        selected = "AEREL"
      ),
      outcome = choices_selected(
        choices = variable_choices(ADAE, "AEOUT"),
        selected = "AEOUT"
      ),
      action = choices_selected(
        choices = variable_choices(ADAE, "AEACN"),
        selected = "AEACN"
      ),
      time = choices_selected(
        choices = variable_choices(ADAE, "ASTDY"),
        selected = "ASTDY"
      ),
      decod = NULL
    )
  )
)
if (interactive()) {
  shinyApp(app$ui, app$server)
}


teal Module: Patient Profile Timeline Plot

Description

This module produces a patient profile timeline ggplot2::ggplot() type plot using ADaM datasets.

Usage

tm_g_pp_patient_timeline(
  label,
  dataname_adcm = "ADCM",
  dataname_adae = "ADAE",
  parentname = "ADSL",
  patient_col = "USUBJID",
  aeterm = NULL,
  cmdecod = NULL,
  aetime_start = NULL,
  aetime_end = NULL,
  dstime_start = NULL,
  dstime_end = NULL,
  aerelday_start = NULL,
  aerelday_end = NULL,
  dsrelday_start = NULL,
  dsrelday_end = NULL,
  font_size = c(12L, 12L, 25L),
  plot_height = c(700L, 200L, 2000L),
  plot_width = NULL,
  pre_output = NULL,
  post_output = NULL,
  ggplot2_args = teal.widgets::ggplot2_args(),
  transformators = list(),
  decorators = list()
)

Arguments

label

(character)
menu item label of the module in the teal app.

dataname_adcm

(character)
name of ADCM dataset or equivalent.

dataname_adae

(character)
name of ADAE dataset or equivalent.

parentname

(character)
parent analysis data used in teal module, usually this refers to ADSL.

patient_col

(character)
name of patient ID variable.

aeterm

(teal.transform::choices_selected())
object with all available choices and preselected option for the AETERM variable from dataname.

cmdecod

(teal.transform::choices_selected())
object with all available choices and preselected option for the CMDECOD variable from dataname_adcm.

aetime_start

(teal.transform::choices_selected())
object with all available choices and preselected option for the ASTDTM variable from dataname_adae.

aetime_end

(teal.transform::choices_selected())
object with all available choices and preselected option for the AENDTM variable from dataname_adae.

dstime_start

(teal.transform::choices_selected())
object with all available choices and preselected option for the CMASTDTM variable from dataname_adcm.

dstime_end

(teal.transform::choices_selected())
object with all available choices and preselected option for the CMAENDTM variable from dataname_adcm.

aerelday_start

(teal.transform::choices_selected())
object with all available choices and preselected option for the ASTDY variable from dataname_adae.

aerelday_end

(teal.transform::choices_selected())
object with all available choices and preselected option for the AENDY variable from dataname_adae.

dsrelday_start

(teal.transform::choices_selected())
object with all available choices and preselected option for the ASTDY variable from dataname_adcm.

dsrelday_end

(teal.transform::choices_selected())
object with all available choices and preselected option for the AENDY variable from dataname_adcm.

font_size

(numeric)
numeric vector of length 3 of current, minimum and maximum font size values.

plot_height

(numeric) optional
vector of length three with c(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 with c(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 the shiny::helpText() elements are useful.

ggplot2_args

(ggplot2_args) optional
object created by teal.widgets::ggplot2_args() with settings for the module plot. The argument is merged with option teal.ggplot2_args and with default module arguments (hard coded in the module body). For more details, see the vignette: vignette("custom-ggplot2-arguments", package = "teal.widgets").

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 lists of teal_transform_module) optional, decorator for tables or plots included in the module output reported. The decorators are applied to the respective output objects.

See section "Decorating Module" below for more details.

Value

a teal_module object.

Decorating Module

This module generates the following objects, which can be modified in place using decorators:

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_pp_patient_timeline(
   ..., # arguments for module
   decorators = list(
     plot = teal_transform_module(...) # applied only to `plot` output
   )
)

For additional details and examples of decorators, refer to the vignette vignette("decorate-module-output", package = "teal.modules.clinical").

To learn more please refer to the vignette vignette("transform-module-output", package = "teal") or the teal::teal_transform_module() documentation.

Examples in Shinylive

example-1

Open in Shinylive

Examples

library(nestcolor)
library(dplyr)

data <- teal_data()
data <- within(data, {
  ADAE <- tmc_ex_adae
  ADSL <- tmc_ex_adsl %>%
    filter(USUBJID %in% ADAE$USUBJID)
  ADCM <- tmc_ex_adcm %>%
    mutate(
      CMSTDY = case_when(
        CMCAT == "medcl B" ~ 20,
        CMCAT == "medcl C" ~ 150,
        TRUE ~ 1
      ) %>% with_label("Study Day of Start of Medication"),
      CMENDY = case_when(
        CMCAT == "medcl B" ~ 700,
        CMCAT == "medcl C" ~ 1000,
        TRUE ~ 500
      ) %>% with_label("Study Day of End of Medication"),
      CMASTDTM = ASTDTM,
      CMAENDTM = AENDTM
    )
})

join_keys(data) <- default_cdisc_join_keys[c("ADSL", "ADAE", "ADCM")]
adcm_keys <- c("STUDYID", "USUBJID", "ASTDTM", "CMSEQ", "ATC1", "ATC2", "ATC3", "ATC4")
join_keys(data)["ADCM", "ADCM"] <- adcm_keys
join_keys(data)["ADAE", "ADCM"] <- c("STUDYID", "USUBJID")

app <- init(
  data = data,
  modules = modules(
    tm_g_pp_patient_timeline(
      label = "Patient Timeline",
      dataname_adae = "ADAE",
      dataname_adcm = "ADCM",
      parentname = "ADSL",
      patient_col = "USUBJID",
      plot_height = c(600L, 200L, 2000L),
      cmdecod = choices_selected(
        choices = variable_choices(data[["ADCM"]], "CMDECOD"),
        selected = "CMDECOD",
      ),
      aeterm = choices_selected(
        choices = variable_choices(data[["ADAE"]], "AETERM"),
        selected = c("AETERM")
      ),
      aetime_start = choices_selected(
        choices = variable_choices(data[["ADAE"]], "ASTDTM"),
        selected = c("ASTDTM")
      ),
      aetime_end = choices_selected(
        choices = variable_choices(data[["ADAE"]], "AENDTM"),
        selected = c("AENDTM")
      ),
      dstime_start = choices_selected(
        choices = variable_choices(data[["ADCM"]], "CMASTDTM"),
        selected = c("CMASTDTM")
      ),
      dstime_end = choices_selected(
        choices = variable_choices(data[["ADCM"]], "CMAENDTM"),
        selected = c("CMAENDTM")
      ),
      aerelday_start = choices_selected(
        choices = variable_choices(data[["ADAE"]], "ASTDY"),
        selected = c("ASTDY")
      ),
      aerelday_end = choices_selected(
        choices = variable_choices(data[["ADAE"]], "AENDY"),
        selected = c("AENDY")
      ),
      dsrelday_start = choices_selected(
        choices = variable_choices(data[["ADCM"]], "ASTDY"),
        selected = c("ASTDY")
      ),
      dsrelday_end = choices_selected(
        choices = variable_choices(data[["ADCM"]], "AENDY"),
        selected = c("AENDY")
      )
    )
  )
)
if (interactive()) {
  shinyApp(app$ui, app$server)
}


teal Module: Patient Profile Therapy Table and Plot

Description

This module produces a patient profile therapy table and ggplot2::ggplot() type plot using ADaM datasets.

Usage

tm_g_pp_therapy(
  label,
  dataname = "ADCM",
  parentname = "ADSL",
  patient_col = "USUBJID",
  atirel = NULL,
  cmdecod = NULL,
  cmindc = NULL,
  cmdose = NULL,
  cmtrt = NULL,
  cmdosu = NULL,
  cmroute = NULL,
  cmdosfrq = NULL,
  cmstdy = NULL,
  cmendy = NULL,
  font_size = c(12L, 12L, 25L),
  plot_height = c(700L, 200L, 2000L),
  plot_width = NULL,
  pre_output = NULL,
  post_output = NULL,
  ggplot2_args = teal.widgets::ggplot2_args(),
  transformators = list(),
  decorators = list()
)

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 to ADSL.

patient_col

(character)
name of patient ID variable.

atirel

(teal.transform::choices_selected())
object with all available choices and preselected option for the ATIREL variable from dataname.

cmdecod

(teal.transform::choices_selected())
object with all available choices and preselected option for the CMDECOD variable from dataname.

cmindc

(teal.transform::choices_selected())
object with all available choices and preselected option for the CMINDC variable from dataname.

cmdose

(teal.transform::choices_selected())
object with all available choices and preselected option for the CMDOSE variable from dataname.

cmtrt

(teal.transform::choices_selected())
object with all available choices and preselected option for the CMTRT variable from dataname.

cmdosu

(teal.transform::choices_selected())
object with all available choices and preselected option for the CMDOSU variable from dataname.

cmroute

(teal.transform::choices_selected())
object with all available choices and preselected option for the CMROUTE variable from dataname.

cmdosfrq

(teal.transform::choices_selected())
object with all available choices and preselected option for the CMDOSFRQ variable from dataname.

cmstdy

(teal.transform::choices_selected())
object with all available choices and preselected option for the CMSTDY variable from dataname.

cmendy

(teal.transform::choices_selected())
object with all available choices and preselected option for the CMENDY variable from dataname.

font_size

(numeric)
numeric vector of length 3 of current, minimum and maximum font size values.

plot_height

(numeric) optional
vector of length three with c(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 with c(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 the shiny::helpText() elements are useful.

ggplot2_args

(ggplot2_args) optional
object created by teal.widgets::ggplot2_args() with settings for the module plot. The argument is merged with option teal.ggplot2_args and with default module arguments (hard coded in the module body). For more details, see the vignette: vignette("custom-ggplot2-arguments", package = "teal.widgets").

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 lists of teal_transform_module) optional, decorator for tables or plots included in the module output reported. The decorators are applied to the respective output objects.

See section "Decorating Module" below for more details.

Value

a teal_module object.

Decorating Module

This module generates the following objects, which can be modified in place using decorators::

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_pp_therapy(
   ..., # arguments for module
   decorators = list(
     plot = teal_transform_module(...), # applied only to `plot` output
     table = teal_transform_module(...) # applied only to `table` output
   )
)

For additional details and examples of decorators, refer to the vignette vignette("decorate-module-output", package = "teal.modules.clinical").

To learn more please refer to the vignette vignette("transform-module-output", package = "teal") or the teal::teal_transform_module() documentation.

Examples in Shinylive

example-1

Open in Shinylive

Examples

library(nestcolor)
library(dplyr)

data <- teal_data()
data <- within(data, {
  ADCM <- tmc_ex_adcm
  ADSL <- tmc_ex_adsl %>% filter(USUBJID %in% ADCM$USUBJID)
  ADCM$CMASTDTM <- ADCM$ASTDTM
  ADCM$CMAENDTM <- ADCM$AENDTM
})

join_keys(data) <- default_cdisc_join_keys[c("ADSL", "ADCM")]
adcm_keys <- c("STUDYID", "USUBJID", "ASTDTM", "CMSEQ", "ATC1", "ATC2", "ATC3", "ATC4")
join_keys(data)["ADCM", "ADCM"] <- adcm_keys

ADSL <- data[["ADSL"]]
ADCM <- data[["ADCM"]]

app <- init(
  data = data,
  modules = modules(
    tm_g_pp_therapy(
      label = "Therapy",
      dataname = "ADCM",
      parentname = "ADSL",
      patient_col = "USUBJID",
      plot_height = c(600L, 200L, 2000L),
      atirel = choices_selected(
        choices = variable_choices(ADCM, "ATIREL"),
        selected = c("ATIREL")
      ),
      cmdecod = choices_selected(
        choices = variable_choices(ADCM, "CMDECOD"),
        selected = "CMDECOD"
      ),
      cmindc = choices_selected(
        choices = variable_choices(ADCM, "CMINDC"),
        selected = "CMINDC"
      ),
      cmdose = choices_selected(
        choices = variable_choices(ADCM, "CMDOSE"),
        selected = "CMDOSE"
      ),
      cmtrt = choices_selected(
        choices = variable_choices(ADCM, "CMTRT"),
        selected = "CMTRT"
      ),
      cmdosu = choices_selected(
        choices = variable_choices(ADCM, "CMDOSU"),
        selected = c("CMDOSU")
      ),
      cmroute = choices_selected(
        choices = variable_choices(ADCM, "CMROUTE"),
        selected = "CMROUTE"
      ),
      cmdosfrq = choices_selected(
        choices = variable_choices(ADCM, "CMDOSFRQ"),
        selected = "CMDOSFRQ"
      ),
      cmstdy = choices_selected(
        choices = variable_choices(ADCM, "ASTDY"),
        selected = "ASTDY"
      ),
      cmendy = choices_selected(
        choices = variable_choices(ADCM, "AENDY"),
        selected = "AENDY"
      )
    )
  )
)
if (interactive()) {
  shinyApp(app$ui, app$server)
}


teal Module: Patient Profile Vitals Plot

Description

This module produces a patient profile vitals ggplot2::ggplot() type plot using ADaM datasets.

Usage

tm_g_pp_vitals(
  label,
  dataname = "ADVS",
  parentname = "ADSL",
  patient_col = "USUBJID",
  paramcd = NULL,
  aval = lifecycle::deprecated(),
  aval_var = NULL,
  xaxis = NULL,
  font_size = c(12L, 12L, 25L),
  plot_height = c(700L, 200L, 2000L),
  plot_width = NULL,
  pre_output = NULL,
  post_output = NULL,
  ggplot2_args = teal.widgets::ggplot2_args(),
  transformators = list(),
  decorators = list()
)

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 to ADSL.

patient_col

(character)
name of patient ID variable.

paramcd

(teal.transform::choices_selected())
object with all available choices and preselected option for the parameter code variable from dataname.

aval

[Deprecated] Please use the aval_var argument instead.

aval_var

(teal.transform::choices_selected())
object with all available choices and pre-selected option for the analysis variable.

xaxis

(teal.transform::choices_selected())
object with all available choices and preselected option for the time variable from dataname to be put on the plot x-axis.

font_size

(numeric)
numeric vector of length 3 of current, minimum and maximum font size values.

plot_height

(numeric) optional
vector of length three with c(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 with c(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 the shiny::helpText() elements are useful.

ggplot2_args

(ggplot2_args) optional
object created by teal.widgets::ggplot2_args() with settings for the module plot. The argument is merged with option teal.ggplot2_args and with default module arguments (hard coded in the module body). For more details, see the vignette: vignette("custom-ggplot2-arguments", package = "teal.widgets").

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 lists of teal_transform_module) optional, decorator for tables or plots included in the module output reported. The decorators are applied to the respective output objects.

See section "Decorating Module" below for more details.

Details

This plot supports horizontal lines for the following 6 PARAMCD levels when they are present in dataname: "SYSBP", "DIABP", "TEMP", "RESP", "OXYSAT".

Value

a teal_module object.

Decorating Module

This module generates the following objects, which can be modified in place using decorators:

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_pp_vitals(
   ..., # arguments for module
   decorators = list(
     plot = teal_transform_module(...) # applied only to `plot` output
   )
)

For additional details and examples of decorators, refer to the vignette vignette("decorate-module-output", package = "teal.modules.clinical").

To learn more please refer to the vignette vignette("transform-module-output", package = "teal") or the teal::teal_transform_module() documentation.

Examples in Shinylive

example-1

Open in Shinylive

Examples

library(nestcolor)

data <- teal_data()
data <- within(data, {
  ADSL <- tmc_ex_adsl
  ADVS <- tmc_ex_advs
})
join_keys(data) <- default_cdisc_join_keys[names(data)]

ADSL <- data[["ADSL"]]
ADVS <- data[["ADVS"]]

app <- init(
  data = data,
  modules = modules(
    tm_g_pp_vitals(
      label = "Vitals",
      dataname = "ADVS",
      parentname = "ADSL",
      patient_col = "USUBJID",
      plot_height = c(600L, 200L, 2000L),
      paramcd = choices_selected(
        choices = variable_choices(ADVS, "PARAMCD"),
        selected = "PARAMCD"
      ),
      xaxis = choices_selected(
        choices = variable_choices(ADVS, "ADY"),
        selected = "ADY"
      ),
      aval_var = choices_selected(
        choices = variable_choices(ADVS, "AVAL"),
        selected = "AVAL"
      )
    )
  )
)
if (interactive()) {
  shinyApp(app$ui, app$server)
}


teal Module: Abnormality Summary Table

Description

This module produces a table to summarize abnormality.

Usage

tm_t_abnormality(
  label,
  dataname,
  parentname = ifelse(inherits(arm_var, "data_extract_spec"),
    teal.transform::datanames_input(arm_var), "ADSL"),
  arm_var,
  by_vars,
  grade,
  abnormal = list(low = c("LOW", "LOW LOW"), high = c("HIGH", "HIGH HIGH")),
  id_var = teal.transform::choices_selected(teal.transform::variable_choices(dataname,
    subset = "USUBJID"), selected = "USUBJID", fixed = TRUE),
  baseline_var =
    teal.transform::choices_selected(teal.transform::variable_choices(dataname, subset =
    "BNRIND"), selected = "BNRIND", fixed = TRUE),
  treatment_flag_var =
    teal.transform::choices_selected(teal.transform::variable_choices(dataname, subset =
    "ONTRTFL"), selected = "ONTRTFL", fixed = TRUE),
  treatment_flag = teal.transform::choices_selected("Y"),
  add_total = TRUE,
  total_label = default_total_label(),
  exclude_base_abn = FALSE,
  drop_arm_levels = TRUE,
  pre_output = NULL,
  post_output = NULL,
  na_level = default_na_str(),
  basic_table_args = teal.widgets::basic_table_args(),
  transformators = list(),
  decorators = list()
)

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 to ADSL.

arm_var

(teal.transform::choices_selected())
object with all available choices and preselected option for variable names that can be used as arm_var. It defines the grouping variable in the results table.

by_vars

(teal.transform::choices_selected())
object with all available choices and preselected option for variable names used to split the summary by rows.

grade

(teal.transform::choices_selected())
object with all available choices and preselected option for variable names that can be used to specify the abnormality grade. Variable must be factor.

abnormal

(⁠named list⁠)
defined by user to indicate what abnormalities are to be displayed.

id_var

(teal.transform::choices_selected())
object specifying the variable name for subject id.

baseline_var

(teal.transform::choices_selected())
variable for baseline abnormality grade.

treatment_flag_var

(teal.transform::choices_selected())
on treatment flag variable.

treatment_flag

(teal.transform::choices_selected())
value indicating on treatment records in treatment_flag_var.

add_total

(logical)
whether to include column with total number of patients.

total_label

(string)
string to display as total column/row label if column/row is enabled (see add_total). Defaults to "All Patients". To set a new default total_label to apply in all modules, run set_default_total_label("new_default").

exclude_base_abn

(logical)
whether to exclude patients who had abnormal values at baseline.

drop_arm_levels

(logical)
whether to drop unused levels of arm_var. If TRUE, arm_var levels are set to those used in the dataname dataset. If FALSE, arm_var levels are set to those used in the parentname dataset. If dataname and parentname are the same, then drop_arm_levels is set to TRUE and user input for this parameter is ignored.

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 the shiny::helpText() elements are useful.

na_level

(character)
the NA level in the input dataset, default to "<Missing>".

basic_table_args

(basic_table_args) optional
object created by teal.widgets::basic_table_args() with settings for the module table. The argument is merged with option teal.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").

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 lists of teal_transform_module) optional, decorator for tables or plots included in the module output reported. The decorators are applied to the respective output objects.

See section "Decorating Module" below for more details.

Value

a teal_module object.

Decorating Module

This module generates the following objects, which can be modified in place using decorators:

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_t_abnormality(
   ..., # arguments for module
   decorators = list(
     table = teal_transform_module(...) # applied only to `table` output
   )
)

For additional details and examples of decorators, refer to the vignette vignette("decorate-module-output", package = "teal.modules.clinical").

To learn more please refer to the vignette vignette("transform-module-output", package = "teal") or the teal::teal_transform_module() documentation.

Examples in Shinylive

example-1

Open in Shinylive

Note

Patients with the same abnormality at baseline as on the treatment visit can be excluded in accordance with GDSR specifications by using exclude_base_abn.

See Also

The TLG Catalog where additional example apps implementing this module can be found.

Examples

library(dplyr)

data <- teal_data()
data <- within(data, {
  ADSL <- tmc_ex_adsl
  ADLB <- tmc_ex_adlb %>%
    mutate(
      ONTRTFL = case_when(
        AVISIT %in% c("SCREENING", "BASELINE") ~ "",
        TRUE ~ "Y"
      ) %>% with_label("On Treatment Record Flag")
    )
})
join_keys(data) <- default_cdisc_join_keys[names(data)]

ADSL <- data[["ADSL"]]
ADLB <- data[["ADLB"]]

app <- init(
  data = data,
  modules = modules(
    tm_t_abnormality(
      label = "Abnormality Table",
      dataname = "ADLB",
      arm_var = choices_selected(
        choices = variable_choices(ADSL, subset = c("ARM", "ARMCD")),
        selected = "ARM"
      ),
      add_total = FALSE,
      by_vars = choices_selected(
        choices = variable_choices(ADLB, subset = c("LBCAT", "PARAM", "AVISIT")),
        selected = c("LBCAT", "PARAM"),
        keep_order = TRUE
      ),
      baseline_var = choices_selected(
        variable_choices(ADLB, subset = "BNRIND"),
        selected = "BNRIND", fixed = TRUE
      ),
      grade = choices_selected(
        choices = variable_choices(ADLB, subset = "ANRIND"),
        selected = "ANRIND",
        fixed = TRUE
      ),
      abnormal = list(low = "LOW", high = "HIGH"),
      exclude_base_abn = FALSE
    )
  )
)
if (interactive()) {
  shinyApp(app$ui, app$server)
}


teal Module: Laboratory test results with highest grade post-baseline

Description

This module produces a table to summarize laboratory test results with highest grade post-baseline

Usage

tm_t_abnormality_by_worst_grade(
  label,
  dataname,
  parentname = ifelse(inherits(arm_var, "data_extract_spec"),
    teal.transform::datanames_input(arm_var), "ADSL"),
  arm_var,
  id_var = teal.transform::choices_selected(teal.transform::variable_choices(dataname,
    subset = "USUBJID"), selected = "USUBJID", fixed = TRUE),
  paramcd,
  atoxgr_var =
    teal.transform::choices_selected(teal.transform::variable_choices(dataname, subset =
    "ATOXGR"), selected = "ATOXGR", fixed = TRUE),
  worst_high_flag_var =
    teal.transform::choices_selected(teal.transform::variable_choices(dataname, subset =
    "WGRHIFL"), selected = "WGRHIFL", fixed = TRUE),
  worst_low_flag_var =
    teal.transform::choices_selected(teal.transform::variable_choices(dataname, subset =
    "WGRLOFL"), selected = "WGRLOFL", fixed = TRUE),
  worst_flag_indicator = teal.transform::choices_selected("Y"),
  add_total = TRUE,
  total_label = default_total_label(),
  drop_arm_levels = TRUE,
  pre_output = NULL,
  post_output = NULL,
  basic_table_args = teal.widgets::basic_table_args(),
  transformators = list(),
  decorators = list()
)

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 to ADSL.

arm_var

(teal.transform::choices_selected())
object with all available choices and preselected option for variable names that can be used as arm_var. It defines the grouping variable in the results table.

id_var

(teal.transform::choices_selected())
object specifying the variable name for subject id.

paramcd

(teal.transform::choices_selected())
object with all available choices and preselected option for the parameter code variable from dataname.

atoxgr_var

(teal.transform::choices_selected())
object with all available choices and preselected option for variable names that can be used as Analysis Toxicity Grade.

worst_high_flag_var

(teal.transform::choices_selected())
object with all available choices and preselected option for variable names that can be used as Worst High Grade flag.

worst_low_flag_var

(teal.transform::choices_selected())
object with all available choices and preselected option for variable names that can be used as Worst Low Grade flag.

worst_flag_indicator

(teal.transform::choices_selected())
value indicating worst grade.

add_total

(logical)
whether to include column with total number of patients.

total_label

(string)
string to display as total column/row label if column/row is enabled (see add_total). Defaults to "All Patients". To set a new default total_label to apply in all modules, run set_default_total_label("new_default").

drop_arm_levels

(logical)
whether to drop unused levels of arm_var. If TRUE, arm_var levels are set to those used in the dataname dataset. If FALSE, arm_var levels are set to those used in the parentname dataset. If dataname and parentname are the same, then drop_arm_levels is set to TRUE and user input for this parameter is ignored.

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 the shiny::helpText() elements are useful.

basic_table_args

(basic_table_args) optional
object created by teal.widgets::basic_table_args() with settings for the module table. The argument is merged with option teal.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").

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 lists of teal_transform_module) optional, decorator for tables or plots included in the module output reported. The decorators are applied to the respective output objects.

See section "Decorating Module" below for more details.

Value

a teal_module object.

Decorating Module

This module generates the following objects, which can be modified in place using decorators:

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_t_abnormality_by_worst_grade(
   ..., # arguments for module
   decorators = list(
     table = teal_transform_module(...) # applied only to `table` output
   )
)

For additional details and examples of decorators, refer to the vignette vignette("decorate-module-output", package = "teal.modules.clinical").

To learn more please refer to the vignette vignette("transform-module-output", package = "teal") or the teal::teal_transform_module() documentation.

Examples in Shinylive

example-1

Open in Shinylive

See Also

The TLG Catalog where additional example apps implementing this module can be found.

Examples

library(dplyr)

data <- teal_data()
data <- within(data, {
  ADSL <- tmc_ex_adsl
  ADLB <- tmc_ex_adlb %>%
    filter(!AVISIT %in% c("SCREENING", "BASELINE"))
})
join_keys(data) <- default_cdisc_join_keys[names(data)]

ADSL <- data[["ADSL"]]
ADLB <- data[["ADLB"]]

app <- init(
  data = data,
  modules = modules(
    tm_t_abnormality_by_worst_grade(
      label = "Laboratory Test Results with Highest Grade Post-Baseline",
      dataname = "ADLB",
      arm_var = choices_selected(
        choices = variable_choices(ADSL, subset = c("ARM", "ARMCD")),
        selected = "ARM"
      ),
      paramcd = choices_selected(
        choices = value_choices(ADLB, "PARAMCD", "PARAM"),
        selected = c("ALT", "CRP", "IGA")
      ),
      add_total = FALSE
    )
  ),
  filter = teal_slices(
    teal_slice("ADSL", "SAFFL", selected = "Y"),
    teal_slice("ADLB", "ONTRTFL", selected = "Y")
  )
)
if (interactive()) {
  shinyApp(app$ui, app$server)
}


teal Module: ANCOVA Summary

Description

This module produces a table to summarize analysis of variance, consistent with the TLG Catalog template for AOVT01 available here when multiple endpoints are selected.

Usage

tm_t_ancova(
  label,
  dataname,
  parentname = ifelse(inherits(arm_var, "data_extract_spec"),
    teal.transform::datanames_input(arm_var), "ADSL"),
  arm_var,
  arm_ref_comp = NULL,
  aval_var,
  cov_var,
  include_interact = FALSE,
  interact_var = NULL,
  interact_y = FALSE,
  avisit,
  paramcd,
  conf_level = teal.transform::choices_selected(c(0.95, 0.9, 0.8), 0.95, keep_order =
    TRUE),
  pre_output = NULL,
  post_output = NULL,
  basic_table_args = teal.widgets::basic_table_args(),
  transformators = list(),
  decorators = list()
)

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 to ADSL.

arm_var

(teal.transform::choices_selected())
object with all available choices and preselected option for variable names that can be used as arm_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 in ADSL and the element must be another list (possibly with delayed teal.transform::variable_choices() or delayed teal.transform::value_choices() with the elements named ref and comp that the defined the default reference and comparison arms when the arm variable is changed.

aval_var

(teal.transform::choices_selected())
object with all available choices and pre-selected option for the analysis variable.

cov_var

(teal.transform::choices_selected())
object with all available choices and preselected option for the covariates variables.

include_interact

(logical)
whether an interaction term should be included in the model.

interact_var

(character)
name of the variable that should have interactions with arm. If the interaction is not needed, the default option is NULL.

interact_y

(character)
a selected item from the interact_var column which will be used to select the specific ANCOVA results when interact_var is discrete. If the interaction is not needed, the default option is FALSE.

avisit

(teal.transform::choices_selected())
value of analysis visit AVISIT of interest.

paramcd

(teal.transform::choices_selected())
object with all available choices and preselected option for the parameter code variable from dataname.

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).

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 the shiny::helpText() elements are useful.

basic_table_args

(basic_table_args) optional
object created by teal.widgets::basic_table_args() with settings for the module table. The argument is merged with option teal.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").

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 lists of teal_transform_module) optional, decorator for tables or plots included in the module output reported. The decorators are applied to the respective output objects.

See section "Decorating Module" below for more details.

Details

When a single endpoint is selected, both unadjusted and adjusted comparison are provided. This modules expects that the analysis data has the following variables:

Value

a teal_module object.

Decorating Module

This module generates the following objects, which can be modified in place using decorators:

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_t_ancova(
   ..., # arguments for module
   decorators = list(
     table = teal_transform_module(...) # applied only to `table` output
   )
)

For additional details and examples of decorators, refer to the vignette vignette("decorate-module-output", package = "teal.modules.clinical").

To learn more please refer to the vignette vignette("transform-module-output", package = "teal") or the teal::teal_transform_module() documentation.

Examples in Shinylive

example-1

Open in Shinylive

See Also

The TLG Catalog where additional example apps implementing this module can be found.

Examples

data <- teal_data()
data <- within(data, {
  ADSL <- tmc_ex_adsl
  ADQS <- tmc_ex_adqs
})
join_keys(data) <- default_cdisc_join_keys[names(data)]

ADSL <- data[["ADSL"]]
ADQS <- data[["ADQS"]]

arm_ref_comp <- list(
  ARM = list(
    ref = "B: Placebo",
    comp = c("A: Drug X", "C: Combination")
  ),
  ACTARMCD = list(
    ref = "ARM B",
    comp = c("ARM A", "ARM C")
  )
)

app <- init(
  data = data,
  modules = modules(
    tm_t_ancova(
      label = "ANCOVA Table",
      dataname = "ADQS",
      avisit = choices_selected(
        choices = value_choices(ADQS, "AVISIT"),
        selected = "WEEK 1 DAY 8"
      ),
      arm_var = choices_selected(
        choices = variable_choices(ADSL, c("ARM", "ACTARMCD", "ARMCD")),
        selected = "ARMCD"
      ),
      arm_ref_comp = arm_ref_comp,
      aval_var = choices_selected(
        choices = variable_choices(ADQS, c("CHG", "AVAL")),
        selected = "CHG"
      ),
      cov_var = choices_selected(
        choices = variable_choices(ADQS, c("BASE", "STRATA1", "SEX")),
        selected = "STRATA1"
      ),
      paramcd = choices_selected(
        choices = value_choices(ADQS, "PARAMCD", "PARAM"),
        selected = "FKSI-FWB"
      ),
      interact_var = choices_selected(
        choices = variable_choices(ADQS, c("BASE", "STRATA1", "SEX")),
        selected = "STRATA1"
      )
    )
  )
)
if (interactive()) {
  shinyApp(app$ui, app$server)
}


teal Module: Binary Outcome Table

Description

This module produces a binary outcome response summary table, with the option to match the template for response table RSPT01 available in the TLG Catalog here.

Usage

tm_t_binary_outcome(
  label,
  dataname,
  parentname = ifelse(test = inherits(arm_var, "data_extract_spec"), yes =
    teal.transform::datanames_input(arm_var), no = "ADSL"),
  arm_var,
  arm_ref_comp = NULL,
  paramcd,
  strata_var,
  aval_var = teal.transform::choices_selected(choices =
    teal.transform::variable_choices(dataname, c("AVALC", "SEX")), selected = "AVALC",
    fixed = FALSE),
  conf_level = teal.transform::choices_selected(c(0.95, 0.9, 0.8), 0.95, keep_order =
    TRUE),
  default_responses = c("CR", "PR", "Y", "Complete Response (CR)",
    "Partial Response (PR)", "M"),
  rsp_table = FALSE,
  control = list(global = list(method = ifelse(rsp_table, "clopper-pearson", "waldcc"),
    conf_level = 0.95), unstrat = list(method_ci = ifelse(rsp_table, "wald", "waldcc"),
    method_test = "schouten", odds = TRUE), strat = list(method_ci = "cmh", method_test =
    "cmh")),
  add_total = FALSE,
  total_label = default_total_label(),
  na_level = default_na_str(),
  pre_output = NULL,
  post_output = NULL,
  basic_table_args = teal.widgets::basic_table_args(),
  transformators = list(),
  decorators = list()
)

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 to ADSL.

arm_var

(teal.transform::choices_selected())
object with all available choices and preselected option for variable names that can be used as arm_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 in ADSL and the element must be another list (possibly with delayed teal.transform::variable_choices() or delayed teal.transform::value_choices() with the elements named ref and comp 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 from dataname.

strata_var

(teal.transform::choices_selected())
names of the variables for stratified analysis.

aval_var

(teal.transform::choices_selected())
object with all available choices and pre-selected option for the analysis 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).

default_responses

(list or character)
defines the default codes for the response variable in the module per value of paramcd. A passed vector is transmitted for all paramcd values. A passed list must be named and contain arrays, each name corresponding to a single value of paramcd. Each array may contain default response values or named arrays rsp of default selected response values and levels of default level choices.

rsp_table

(logical)
whether the initial set-up of the module should match RSPT01. Defaults to FALSE.

control

(named list)
named list containing 3 named lists as follows:

add_total

(logical)
whether to include column with total number of patients.

total_label

(string)
string to display as total column/row label if column/row is enabled (see add_total). Defaults to "All Patients". To set a new default total_label to apply in all modules, run set_default_total_label("new_default").

na_level

(string)
used to replace all NA or empty values in character or factor variables in the data. Defaults to "<Missing>". To set a default na_level to apply in all modules, run set_default_na_str("new_default").

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 the shiny::helpText() elements are useful.

basic_table_args

(basic_table_args) optional
object created by teal.widgets::basic_table_args() with settings for the module table. The argument is merged with option teal.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").

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 lists of teal_transform_module) optional, decorator for tables or plots included in the module output reported. The decorators are applied to the respective output objects.

See section "Decorating Module" below for more details.

Details

Value

a teal_module object.

Decorating Module

This module generates the following objects, which can be modified in place using decorators:

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_t_binary_outcome(
   ..., # arguments for module
   decorators = list(
     table = teal_transform_module(...) # applied only to `table` output
   )
)

For additional details and examples of decorators, refer to the vignette vignette("decorate-module-output", package = "teal.modules.clinical").

To learn more please refer to the vignette vignette("transform-module-output", package = "teal") or the teal::teal_transform_module() documentation.

Examples in Shinylive

example-1

Open in Shinylive

See Also

The TLG Catalog where additional example apps implementing this module can be found.

Examples

library(dplyr)

data <- teal_data()
data <- within(data, {
  ADSL <- tmc_ex_adsl
  ADRS <- tmc_ex_adrs %>%
    mutate(
      AVALC = d_onco_rsp_label(AVALC) %>%
        with_label("Character Result/Finding")
    ) %>%
    filter(PARAMCD != "OVRINV" | AVISIT == "FOLLOW UP")
})
join_keys(data) <- default_cdisc_join_keys[names(data)]

ADSL <- data[["ADSL"]]
ADRS <- data[["ADRS"]]

arm_ref_comp <- list(
  ARMCD = 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_t_binary_outcome(
      label = "Responders",
      dataname = "ADRS",
      paramcd = choices_selected(
        choices = value_choices(ADRS, "PARAMCD", "PARAM"),
        selected = "BESRSPI"
      ),
      arm_var = choices_selected(
        choices = variable_choices(ADRS, c("ARM", "ARMCD", "ACTARMCD")),
        selected = "ARM"
      ),
      arm_ref_comp = arm_ref_comp,
      strata_var = choices_selected(
        choices = variable_choices(ADRS, c("SEX", "BMRKR2", "RACE")),
        selected = "RACE"
      ),
      default_responses = list(
        BESRSPI = list(
          rsp = c("Complete Response (CR)", "Partial Response (PR)"),
          levels = c(
            "Complete Response (CR)", "Partial Response (PR)",
            "Stable Disease (SD)", "Progressive Disease (PD)"
          )
        ),
        INVET = list(
          rsp = c("Stable Disease (SD)", "Not Evaluable (NE)"),
          levels = c(
            "Complete Response (CR)", "Not Evaluable (NE)", "Partial Response (PR)",
            "Progressive Disease (PD)", "Stable Disease (SD)"
          )
        ),
        OVRINV = list(
          rsp = c("Progressive Disease (PD)", "Stable Disease (SD)"),
          levels = c("Progressive Disease (PD)", "Stable Disease (SD)", "Not Evaluable (NE)")
        )
      )
    )
  )
)
if (interactive()) {
  shinyApp(app$ui, app$server)
}


teal Module: Cox Regression Model

Description

This module fits Cox univariable or multi-variable models, consistent with the TLG Catalog templates for Cox regression tables COXT01 and COXT02, respectively. See the TLG Catalog entries for COXT01 here and COXT02 here.

Usage

tm_t_coxreg(
  label,
  dataname,
  parentname = ifelse(inherits(arm_var, "data_extract_spec"),
    teal.transform::datanames_input(arm_var), "ADSL"),
  arm_var,
  arm_ref_comp = NULL,
  paramcd,
  cov_var,
  strata_var,
  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),
  multivariate = TRUE,
  na_level = default_na_str(),
  conf_level = teal.transform::choices_selected(c(0.95, 0.9, 0.8), 0.95, keep_order =
    TRUE),
  pre_output = NULL,
  post_output = NULL,
  basic_table_args = teal.widgets::basic_table_args(),
  transformators = list(),
  decorators = list()
)

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 to ADSL.

arm_var

(teal.transform::choices_selected())
object with all available choices and preselected option for variable names that can be used as arm_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 in ADSL and the element must be another list (possibly with delayed teal.transform::variable_choices() or delayed teal.transform::value_choices() with the elements named ref and comp 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 from dataname.

cov_var

(teal.transform::choices_selected())
object with all available choices and preselected option for the covariates variables.

strata_var

(teal.transform::choices_selected())
names of the variables for stratified analysis.

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.

multivariate

(logical)
if FALSE, the univariable approach is used instead of the multi-variable model.

na_level

(string)
used to replace all NA or empty values in character or factor variables in the data. Defaults to "<Missing>". To set a default na_level to apply in all modules, run set_default_na_str("new_default").

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).

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 the shiny::helpText() elements are useful.

basic_table_args

(basic_table_args) optional
object created by teal.widgets::basic_table_args() with settings for the module table. The argument is merged with option teal.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").

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 lists of teal_transform_module) optional, decorator for tables or plots included in the module output reported. The decorators are applied to the respective output objects.

See section "Decorating Module" below for more details.

Details

The Cox Proportional Hazards (PH) model is the most commonly used method to estimate the magnitude of the effect in survival analysis. It assumes proportional hazards: the ratio of the hazards between groups (e.g., two arms) is constant over time. This ratio is referred to as the "hazard ratio" (HR) and is one of the most commonly reported metrics to describe the effect size in survival analysis.

This modules expects that the analysis data has the following variables:

The arm variables and stratification/covariate variables are taken from the ADSL data.

Value

a teal_module object.

Decorating Module

This module generates the following objects, which can be modified in place using decorators:

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_t_coxreg(
   ..., # arguments for module
   decorators = list(
     table = teal_transform_module(...) # applied only to `table` output
   )
)

For additional details and examples of decorators, refer to the vignette vignette("decorate-module-output", package = "teal.modules.clinical").

To learn more please refer to the vignette vignette("transform-module-output", package = "teal") or the teal::teal_transform_module() documentation.

Examples in Shinylive

example-1

Open in Shinylive

example-2

Open in Shinylive

Note

See Also

The TLG Catalog where additional example apps implementing this module can be found.

Examples

## First example
## =============
## The example below is based on the usual approach involving creation of
## a random CDISC dataset and then running the application.

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")
  )
)

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"]]

app <- init(
  data = data,
  modules = modules(
    tm_t_coxreg(
      label = "Cox Reg.",
      dataname = "ADTTE",
      arm_var = choices_selected(c("ARM", "ARMCD", "ACTARMCD"), "ARM"),
      arm_ref_comp = arm_ref_comp,
      paramcd = choices_selected(
        value_choices(ADTTE, "PARAMCD", "PARAM"), "OS"
      ),
      strata_var = choices_selected(
        c("COUNTRY", "STRATA1", "STRATA2"), "STRATA1"
      ),
      cov_var = choices_selected(
        c("AGE", "BMRKR1", "BMRKR2", "REGION1"), "AGE"
      ),
      multivariate = TRUE
    )
  )
)
if (interactive()) {
  shinyApp(app$ui, app$server)
}

## Second example
## ==============
## This time, a synthetic pair of ADTTE/ADSL data is fabricated for Cox regression
## where ties and pval_method matter.
library(dplyr)

data <- teal_data()
data <- within(data, {
  ADTTE <- data.frame(
    STUDYID = "LUNG",
    AVAL = c(4, 3, 1, 1, 2, 2, 3, 1, 2),
    CNSR = c(1, 1, 1, 0, 1, 1, 0, 0, 0),
    ARMCD = factor(
      c(0, 1, 1, 1, 1, 0, 0, 0, 0),
      labels = c("ARM A", "ARM B")
    ),
    SEX = factor(
      c(0, 0, 0, 0, 1, 1, 1, 1, 1),
      labels = c("F", "M")
    ),
    INST = factor(c("A", "A", "B", "B", "A", "B", "A", "B", "A")),
    stringsAsFactors = FALSE
  )
  ADTTE <- rbind(ADTTE, ADTTE, ADTTE, ADTTE)
  ADTTE <- as_tibble(ADTTE)
  set.seed(1)
  ADTTE$INST <- sample(ADTTE$INST)
  ADTTE$AGE <- sample(seq(5, 75, 5), size = nrow(ADTTE), replace = TRUE)
  ADTTE$USUBJID <- paste("sub", 1:nrow(ADTTE), ADTTE$INST, sep = "-")
  ADTTE$PARAM <- ADTTE$PARAMCD <- "OS"
  ADSL <- subset(
    ADTTE,
    select = c("USUBJID", "STUDYID", "ARMCD", "SEX", "INST", "AGE")
  )
})

join_keys(data) <- default_cdisc_join_keys[names(data)]

ADSL <- data[["ADSL"]]
ADTTE <- data[["ADTTE"]]

## `teal` application
## ----------------
## Note that the R code exported by `Show R Code` does not include the data
## pre-processing. You will need to create the dataset as above before
## running the exported R code.

arm_ref_comp <- list(ARMCD = list(ref = "ARM A", comp = c("ARM B")))

app <- init(
  data = data,
  modules = modules(
    tm_t_coxreg(
      label = "Cox Reg.",
      dataname = "ADTTE",
      arm_var = choices_selected(c("ARMCD"), "ARMCD"),
      arm_ref_comp = arm_ref_comp,
      paramcd = choices_selected(
        value_choices(ADTTE, "PARAMCD", "PARAM"), "OS"
      ),
      strata_var = choices_selected(c("INST"), NULL),
      cov_var = choices_selected(c("SEX", "AGE"), "SEX"),
      multivariate = TRUE
    )
  )
)
if (interactive()) {
  shinyApp(app$ui, app$server)
}


teal Module: Events by Term

Description

This module produces a table of events by term.

Usage

tm_t_events(
  label,
  dataname,
  parentname = ifelse(inherits(arm_var, "data_extract_spec"),
    teal.transform::datanames_input(arm_var), "ADSL"),
  arm_var,
  hlt,
  llt,
  add_total = TRUE,
  total_label = default_total_label(),
  na_level = default_na_str(),
  event_type = "event",
  sort_criteria = c("freq_desc", "alpha"),
  sort_freq_col = total_label,
  prune_freq = 0,
  prune_diff = 0,
  drop_arm_levels = TRUE,
  incl_overall_sum = TRUE,
  pre_output = NULL,
  post_output = NULL,
  basic_table_args = teal.widgets::basic_table_args(),
  transformators = list(),
  decorators = list()
)

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 to ADSL.

arm_var

(teal.transform::choices_selected())
object with all available choices and preselected option for variable names that can be used as arm_var. It defines the grouping variable(s) in the results table. If there are two elements selected for arm_var, second variable will be nested under the first variable.

hlt

(teal.transform::choices_selected())
name of the variable with high level term for events.

llt

(teal.transform::choices_selected())
name of the variable with low level term for events.

add_total

(logical)
whether to include column with total number of patients.

total_label

(string)
string to display as total column/row label if column/row is enabled (see add_total). Defaults to "All Patients". To set a new default total_label to apply in all modules, run set_default_total_label("new_default").

na_level

(string)
used to replace all NA or empty values in character or factor variables in the data. Defaults to "<Missing>". To set a default na_level to apply in all modules, run set_default_na_str("new_default").

event_type

(character)
type of event that is summarized (e.g. adverse event, treatment). Default is "event".

sort_criteria

(character)
how to sort the final table. Default option freq_desc sorts on column sort_freq_col by decreasing number of patients with event. Alternative option alpha sorts events alphabetically.

sort_freq_col

(character)
column to sort by frequency on if sort_criteria is set to freq_desc.

prune_freq

(number)
threshold to use for trimming table using event incidence rate in any column.

prune_diff

(number)
threshold to use for trimming table using as criteria difference in rates between any two columns.

drop_arm_levels

(logical)
whether to drop unused levels of arm_var. If TRUE, arm_var levels are set to those used in the dataname dataset. If FALSE, arm_var levels are set to those used in the parentname dataset. If dataname and parentname are the same, then drop_arm_levels is set to TRUE and user input for this parameter is ignored.

incl_overall_sum

(flag)
whether two rows which summarize the overall number of adverse events should be included at the top of the table.

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 the shiny::helpText() elements are useful.

basic_table_args

(basic_table_args) optional
object created by teal.widgets::basic_table_args() with settings for the module table. The argument is merged with option teal.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").

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 lists of teal_transform_module) optional, decorator for tables or plots included in the module output reported. The decorators are applied to the respective output objects.

See section "Decorating Module" below for more details.

Value

a teal_module object.

Decorating Module

This module generates the following objects, which can be modified in place using decorators:

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_t_events(
   ..., # arguments for module
   decorators = list(
     table = teal_transform_module(...) # applied only to `table` output
   )
)

For additional details and examples of decorators, refer to the vignette vignette("decorate-module-output", package = "teal.modules.clinical").

To learn more please refer to the vignette vignette("transform-module-output", package = "teal") or the teal::teal_transform_module() documentation.

Examples in Shinylive

example-1

Open in Shinylive

See Also

The TLG Catalog where additional example apps implementing this module can be found.

Examples

data <- teal_data()
data <- within(data, {
  ADSL <- tmc_ex_adsl
  ADAE <- tmc_ex_adae
})
join_keys(data) <- default_cdisc_join_keys[names(data)]

ADSL <- data[["ADSL"]]
ADAE <- data[["ADAE"]]

app <- init(
  data = data,
  modules = modules(
    tm_t_events(
      label = "Adverse Event Table",
      dataname = "ADAE",
      arm_var = choices_selected(c("ARM", "ARMCD"), "ARM"),
      llt = choices_selected(
        choices = variable_choices(ADAE, c("AETERM", "AEDECOD")),
        selected = c("AEDECOD")
      ),
      hlt = choices_selected(
        choices = variable_choices(ADAE, c("AEBODSYS", "AESOC")),
        selected = "AEBODSYS"
      ),
      add_total = TRUE,
      event_type = "adverse event"
    )
  )
)
if (interactive()) {
  shinyApp(app$ui, app$server)
}


teal Module: Events by Grade

Description

This module produces a table to summarize events by grade.

Usage

tm_t_events_by_grade(
  label,
  dataname,
  parentname = ifelse(inherits(arm_var, "data_extract_spec"),
    teal.transform::datanames_input(arm_var), "ADSL"),
  arm_var,
  hlt,
  llt,
  grade,
  grading_groups = list(`Any Grade (%)` = c("1", "2", "3", "4", "5"), `Grade 1-2 (%)` =
    c("1", "2"), `Grade 3-4 (%)` = c("3", "4"), `Grade 5 (%)` = "5"),
  col_by_grade = FALSE,
  prune_freq = 0,
  prune_diff = 0,
  add_total = TRUE,
  total_label = default_total_label(),
  na_level = default_na_str(),
  drop_arm_levels = TRUE,
  pre_output = NULL,
  post_output = NULL,
  basic_table_args = teal.widgets::basic_table_args(),
  transformators = list(),
  decorators = list()
)

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 to ADSL.

arm_var

(teal.transform::choices_selected())
object with all available choices and preselected option for variable names that can be used as arm_var. It defines the grouping variable in the results table.

hlt

(teal.transform::choices_selected())
name of the variable with high level term for events.

llt

(teal.transform::choices_selected())
name of the variable with low level term for events.

grade

(character)
name of the severity level variable.

grading_groups

(list)
named list of grading groups used when col_by_grade = TRUE.

col_by_grade

(logical)
whether to display the grading groups in nested columns.

prune_freq

(number)
threshold to use for trimming table using event incidence rate in any column.

prune_diff

(number)
threshold to use for trimming table using as criteria difference in rates between any two columns.

add_total

(logical)
whether to include column with total number of patients.

total_label

(string)
string to display as total column/row label if column/row is enabled (see add_total). Defaults to "All Patients". To set a new default total_label to apply in all modules, run set_default_total_label("new_default").

na_level

(string)
used to replace all NA or empty values in character or factor variables in the data. Defaults to "<Missing>". To set a default na_level to apply in all modules, run set_default_na_str("new_default").

drop_arm_levels

(logical)
whether to drop unused levels of arm_var. If TRUE, arm_var levels are set to those used in the dataname dataset. If FALSE, arm_var levels are set to those used in the parentname dataset. If dataname and parentname are the same, then drop_arm_levels is set to TRUE and user input for this parameter is ignored.

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 the shiny::helpText() elements are useful.

basic_table_args

(basic_table_args) optional
object created by teal.widgets::basic_table_args() with settings for the module table. The argument is merged with option teal.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").

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 lists of teal_transform_module) optional, decorator for tables or plots included in the module output reported. The decorators are applied to the respective output objects.

See section "Decorating Module" below for more details.

Value

a teal_module object.

Decorating Module

This module generates the following objects, which can be modified in place using decorators:

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_t_events_by_grade(
   ..., # arguments for module
   decorators = list(
     table = teal_transform_module(...) # applied only to `table` output
   )
)

For additional details and examples of decorators, refer to the vignette vignette("decorate-module-output", package = "teal.modules.clinical").

To learn more please refer to the vignette vignette("transform-module-output", package = "teal") or the teal::teal_transform_module() documentation.

Examples in Shinylive

example-1

Open in Shinylive

See Also

The TLG Catalog where additional example apps implementing this module can be found.

Examples

library(dplyr)
data <- teal_data()
data <- within(data, {
  ADSL <- tmc_ex_adsl
  .lbls_adae <- col_labels(tmc_ex_adae)
  ADAE <- tmc_ex_adae %>%
    mutate_if(is.character, as.factor) #' be certain of having factors
  col_labels(ADAE) <- .lbls_adae
})
join_keys(data) <- default_cdisc_join_keys[names(data)]

ADSL <- data[["ADSL"]]
ADAE <- data[["ADAE"]]

app <- init(
  data = data,
  modules = modules(
    tm_t_events_by_grade(
      label = "Adverse Events by Grade Table",
      dataname = "ADAE",
      arm_var = choices_selected(c("ARM", "ARMCD"), "ARM"),
      llt = choices_selected(
        choices = variable_choices(ADAE, c("AETERM", "AEDECOD")),
        selected = c("AEDECOD")
      ),
      hlt = choices_selected(
        choices = variable_choices(ADAE, c("AEBODSYS", "AESOC")),
        selected = "AEBODSYS"
      ),
      grade = choices_selected(
        choices = variable_choices(ADAE, c("AETOXGR", "AESEV")),
        selected = "AETOXGR"
      )
    )
  )
)
if (interactive()) {
  shinyApp(app$ui, app$server)
}


teal Module: Event Rates Adjusted for Patient-Years

Description

This module produces a table of event rates adjusted for patient-years.

Usage

tm_t_events_patyear(
  label,
  dataname,
  parentname = ifelse(inherits(arm_var, "data_extract_spec"),
    teal.transform::datanames_input(arm_var), "ADSL"),
  arm_var,
  events_var,
  paramcd,
  aval_var = teal.transform::choices_selected(teal.transform::variable_choices(dataname,
    "AVAL"), "AVAL", fixed = TRUE),
  avalu_var = teal.transform::choices_selected(teal.transform::variable_choices(dataname,
    "AVALU"), "AVALU", fixed = TRUE),
  add_total = TRUE,
  total_label = default_total_label(),
  na_level = default_na_str(),
  conf_level = teal.transform::choices_selected(c(0.95, 0.9, 0.8), 0.95, keep_order =
    TRUE),
  drop_arm_levels = TRUE,
  pre_output = NULL,
  post_output = NULL,
  basic_table_args = teal.widgets::basic_table_args(),
  transformators = list(),
  decorators = list()
)

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 to ADSL.

arm_var

(teal.transform::choices_selected())
object with all available choices and preselected option for variable names that can be used as arm_var. It defines the grouping variable(s) in the results table. If there are two elements selected for arm_var, second variable will be nested under the first variable.

events_var

(teal.transform::choices_selected())
object with all available choices and preselected option for the variable with all event counts.

paramcd

(teal.transform::choices_selected())
object with all available choices and preselected option for the parameter code variable from dataname.

aval_var

(teal.transform::choices_selected())
object with all available choices and pre-selected option for the analysis variable.

avalu_var

(teal.transform::choices_selected())
object with all available choices and preselected option for the analysis unit variable.

add_total

(logical)
whether to include column with total number of patients.

total_label

(string)
string to display as total column/row label if column/row is enabled (see add_total). Defaults to "All Patients". To set a new default total_label to apply in all modules, run set_default_total_label("new_default").

na_level

(string)
used to replace all NA or empty values in character or factor variables in the data. Defaults to "<Missing>". To set a default na_level to apply in all modules, run set_default_na_str("new_default").

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).

drop_arm_levels

(logical)
whether to drop unused levels of arm_var. If TRUE, arm_var levels are set to those used in the dataname dataset. If FALSE, arm_var levels are set to those used in the parentname dataset. If dataname and parentname are the same, then drop_arm_levels is set to TRUE and user input for this parameter is ignored.

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 the shiny::helpText() elements are useful.

basic_table_args

(basic_table_args) optional
object created by teal.widgets::basic_table_args() with settings for the module table. The argument is merged with option teal.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").

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 lists of teal_transform_module) optional, decorator for tables or plots included in the module output reported. The decorators are applied to the respective output objects.

See section "Decorating Module" below for more details.

Value

a teal_module object.

Decorating Module

This module generates the following objects, which can be modified in place using decorators:

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_t_events_patyear(
   ..., # arguments for module
   decorators = list(
     table = teal_transform_module(...) # applied only to `table` output
   )
)

For additional details and examples of decorators, refer to the vignette vignette("decorate-module-output", package = "teal.modules.clinical").

To learn more please refer to the vignette vignette("transform-module-output", package = "teal") or the teal::teal_transform_module() documentation.

Examples in Shinylive

example-1

Open in Shinylive

example-2

Open in Shinylive

See Also

The TLG Catalog where additional example apps implementing this module can be found.

Examples

library(dplyr)

data <- teal_data()
data <- within(data, {
  ADSL <- tmc_ex_adsl
  ADAETTE <- tmc_ex_adaette %>%
    filter(PARAMCD %in% c("AETTE1", "AETTE2", "AETTE3")) %>%
    mutate(is_event = CNSR == 0) %>%
    mutate(n_events = as.integer(is_event))
})
join_keys(data) <- default_cdisc_join_keys[names(data)]

ADSL <- data[["ADSL"]]
ADAETTE <- data[["ADAETTE"]]

# 1. Basic Example

app <- init(
  data = data,
  modules = modules(
    tm_t_events_patyear(
      label = "AE Rate Adjusted for Patient-Years At Risk Table",
      dataname = "ADAETTE",
      arm_var = choices_selected(
        choices = variable_choices(ADSL, c("ARM", "ARMCD")),
        selected = "ARMCD"
      ),
      add_total = TRUE,
      events_var = choices_selected(
        choices = variable_choices(ADAETTE, "n_events"),
        selected = "n_events",
        fixed = TRUE
      ),
      paramcd = choices_selected(
        choices = value_choices(ADAETTE, "PARAMCD", "PARAM"),
        selected = "AETTE1"
      )
    )
  )
)
if (interactive()) {
  shinyApp(app$ui, app$server)
}

# 2. Example with table split on 2 arm_var variables

app <- init(
  data = data,
  modules = modules(
    tm_t_events_patyear(
      label = "AE Rate Adjusted for Patient-Years At Risk Table",
      dataname = "ADAETTE",
      arm_var = choices_selected(
        choices = variable_choices(ADSL, c("ARM", "ARMCD", "SEX")),
        selected = c("ARM", "SEX")
      ),
      add_total = TRUE,
      events_var = choices_selected(
        choices = variable_choices(ADAETTE, "n_events"),
        selected = "n_events",
        fixed = TRUE
      ),
      paramcd = choices_selected(
        choices = value_choices(ADAETTE, "PARAMCD", "PARAM"),
        selected = "AETTE1"
      )
    )
  )
)
if (interactive()) {
  shinyApp(app$ui, app$server)
}


teal Module: Adverse Events Summary

Description

This module produces an adverse events summary table.

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,
  total_label = default_total_label(),
  na_level = default_na_str(),
  count_dth = TRUE,
  count_wd = TRUE,
  count_subj = TRUE,
  count_pt = TRUE,
  count_events = TRUE,
  pre_output = NULL,
  post_output = NULL,
  basic_table_args = teal.widgets::basic_table_args(),
  transformators = list(),
  decorators = list()
)

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 to ADSL.

arm_var

(teal.transform::choices_selected())
object with all available choices and preselected option for variable names that can be used as arm_var. It defines the grouping variable(s) in the results table. If there are two elements selected for arm_var, second variable will be nested under the first variable.

flag_var_anl

(teal.transform::choices_selected() or NULL)
vector with names of flag variables from dataset 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() or NULL)
vector with names of flag variables from dataset used to count adverse event special interest groups. All flag variables must be of type logical. Variable labels are used as table row names if they exist.

dthfl_var

(teal.transform::choices_selected())
object with all available choices and preselected option for variable names that can be used as death flag variable. Records with '"Y"“ are summarized in the table row for "Total number of deaths".

dcsreas_var

(teal.transform::choices_selected())
object with all available choices and preselected option for variable names that can be used as study discontinuation reason variable. Records with "ADVERSE EVENTS" are summarized in the table row for "Total number of patients withdrawn from study due to an AE".

llt

(teal.transform::choices_selected())
name of the variable with low level term for events.

aeseq_var

(teal.transform::choices_selected())
variable for adverse events sequence number from dataset. Used for counting total number of events.

add_total

(logical)
whether to include column with total number of patients.

total_label

(string)
string to display as total column/row label if column/row is enabled (see add_total). Defaults to "All Patients". To set a new default total_label to apply in all modules, run set_default_total_label("new_default").

na_level

(string)
used to replace all NA or empty values in character or factor variables in the data. Defaults to "<Missing>". To set a default na_level to apply in all modules, run set_default_na_str("new_default").

count_dth

(logical)
whether to show count of total deaths (based on dthfl_var). Defaults to TRUE.

count_wd

(logical)
whether to show count of patients withdrawn from study due to an adverse event (based on dcsreas_var). Defaults to TRUE.

count_subj

(logical)
whether to show count of unique subjects (based on USUBJID). Only applies if event flag variables are provided.

count_pt

(logical)
whether to show count of unique preferred terms (based on llt). Only applies if event flag variables are provided.

count_events

(logical)
whether to show count of events (based on aeseq_var). Only applies if event flag variables are provided.

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 the shiny::helpText() elements are useful.

basic_table_args

(basic_table_args) optional
object created by teal.widgets::basic_table_args() with settings for the module table. The argument is merged with option teal.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").

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 lists of teal_transform_module) optional, decorator for tables or plots included in the module output reported. The decorators are applied to the respective output objects.

See section "Decorating Module" below for more details.

Value

a teal_module object.

Decorating Module

This module generates the following objects, which can be modified in place using decorators:

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_t_events_summary(
   ..., # arguments for module
   decorators = list(
     table = teal_transform_module(...) # applied only to `table` output
   )
)

For additional details and examples of decorators, refer to the vignette vignette("decorate-module-output", package = "teal.modules.clinical").

To learn more please refer to the vignette vignette("transform-module-output", package = "teal") or the teal::teal_transform_module() documentation.

Examples in Shinylive

example-1

Open in Shinylive

See Also

The TLG Catalog where additional example apps implementing this module can be found.

Examples

library(dplyr)

data <- teal_data()
data <- within(data, {
  ADSL <- tmc_ex_adsl %>%
    mutate(
      DTHFL = case_when(
        !is.na(DTHDT) ~ "Y",
        TRUE ~ ""
      ) %>% with_label("Subject Death Flag")
    )
  ADAE <- tmc_ex_adae

  .add_event_flags <- function(dat) {
    dat <- dat %>%
      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"]])
    )
    col_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_")]
})
join_keys(data) <- default_cdisc_join_keys[names(data)]

app <- init(
  data = data,
  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", data[[".ae_anl_vars"]]),
        selected = data[[".ae_anl_vars"]][1],
        keep_order = TRUE,
        fixed = FALSE
      ),
      flag_var_aesi = choices_selected(
        choices = variable_choices("ADAE", data[[".aesi_vars"]]),
        selected = data[[".aesi_vars"]][1],
        keep_order = TRUE,
        fixed = FALSE
      ),
      add_total = TRUE
    )
  )
)
if (interactive()) {
  shinyApp(app$ui, app$server)
}


teal Module: Exposure Table for Risk management plan

Description

The module produces an exposure table for risk management plan.

Usage

tm_t_exposure(
  label,
  dataname,
  parentname = ifelse(inherits(col_by_var, "data_extract_spec"),
    teal.transform::datanames_input(col_by_var), "ADSL"),
  row_by_var,
  col_by_var,
  paramcd = teal.transform::choices_selected(choices =
    teal.transform::value_choices(dataname, "PARAMCD", "PARAM"), selected = "TDURD"),
  paramcd_label = "PARAM",
  id_var = teal.transform::choices_selected(teal.transform::variable_choices(dataname,
    subset = "USUBJID"), selected = "USUBJID", fixed = TRUE),
  parcat,
  aval_var = teal.transform::choices_selected(teal.transform::variable_choices(dataname,
    subset = "AVAL"), selected = "AVAL", fixed = TRUE),
  avalu_var = teal.transform::choices_selected(teal.transform::variable_choices(dataname,
    subset = "AVALU"), selected = "AVALU", fixed = TRUE),
  add_total,
  total_label = default_total_label(),
  add_total_row = TRUE,
  total_row_label = "Total number of patients and patient time*",
  na_level = default_na_str(),
  pre_output = NULL,
  post_output = NULL,
  basic_table_args = teal.widgets::basic_table_args(),
  transformators = list(),
  decorators = list()
)

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 to ADSL.

row_by_var

(teal.transform::choices_selected())
object with all available choices and preselected option for variable names that can be used to split rows.

col_by_var

(teal.transform::choices_selected())
object with all available choices and preselected option for variable names that can be used to split columns.

paramcd

(teal.transform::choices_selected())
object with all available choices and preselected option for the parameter code variable from dataname.

paramcd_label

(character)
the column from the dataset where the value will be used to label the argument paramcd.

id_var

(teal.transform::choices_selected())
object specifying the variable name for subject id.

parcat

(teal.transform::choices_selected())
object with all available choices and preselected option for parameter category values.

aval_var

(teal.transform::choices_selected())
object with all available choices and pre-selected option for the analysis variable.

avalu_var

(teal.transform::choices_selected())
object with all available choices and preselected option for the analysis unit variable.

add_total

(logical)
whether to include column with total number of patients.

total_label

(string)
string to display as total column/row label if column/row is enabled (see add_total). Defaults to "All Patients". To set a new default total_label to apply in all modules, run set_default_total_label("new_default").

add_total_row

(flag)
whether a "total" level should be added after the others which includes all the levels that constitute the split. A custom label can be set for this level via the total_row_label argument.

total_row_label

(character)
string to display as total row label if row is enabled (see add_total_row).

na_level

(string)
used to replace all NA or empty values in character or factor variables in the data. Defaults to "<Missing>". To set a default na_level to apply in all modules, run set_default_na_str("new_default").

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 the shiny::helpText() elements are useful.

basic_table_args

(basic_table_args) optional
object created by teal.widgets::basic_table_args() with settings for the module table. The argument is merged with option teal.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").

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 lists of teal_transform_module) optional, decorator for tables or plots included in the module output reported. The decorators are applied to the respective output objects.

See section "Decorating Module" below for more details.

Value

a teal_module object.

Decorating Module

This module generates the following objects, which can be modified in place using decorators:

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_t_exposure(
   ..., # arguments for module
   decorators = list(
     table = teal_transform_module(...) # applied only to `table` output
   )
)

For additional details and examples of decorators, refer to the vignette vignette("decorate-module-output", package = "teal.modules.clinical").

To learn more please refer to the vignette vignette("transform-module-output", package = "teal") or the teal::teal_transform_module() documentation.

Examples in Shinylive

example-1

Open in Shinylive

See Also

The TLG Catalog where additional example apps implementing this module can be found.

Examples

library(dplyr)

data <- teal_data()
data <- within(data, {
  ADSL <- tmc_ex_adsl
  ADEX <- tmc_ex_adex

  set.seed(1, kind = "Mersenne-Twister")
  .labels <- col_labels(ADEX, fill = FALSE)
  ADEX <- ADEX %>%
    distinct(USUBJID, .keep_all = TRUE) %>%
    mutate(
      PARAMCD = "TDURD",
      PARAM = "Overall duration (days)",
      AVAL = sample(x = seq(1, 200), size = n(), replace = TRUE),
      AVALU = "Days"
    ) %>%
    bind_rows(ADEX)
  col_labels(ADEX) <- .labels
})
join_keys(data) <- default_cdisc_join_keys[names(data)]

app <- init(
  data = data,
  modules = modules(
    tm_t_exposure(
      label = "Duration of Exposure Table",
      dataname = "ADEX",
      paramcd = choices_selected(
        choices = value_choices(data[["ADEX"]], "PARAMCD", "PARAM"),
        selected = "TDURD"
      ),
      col_by_var = choices_selected(
        choices = variable_choices(data[["ADEX"]], subset = c("SEX", "ARM")),
        selected = "SEX"
      ),
      row_by_var = choices_selected(
        choices = variable_choices(data[["ADEX"]], subset = c("RACE", "REGION1", "STRATA1", "SEX")),
        selected = "RACE"
      ),
      parcat = choices_selected(
        choices = value_choices(data[["ADEX"]], "PARCAT2"),
        selected = "Drug A"
      ),
      add_total = FALSE
    )
  ),
  filter = teal_slices(teal_slice("ADSL", "SAFFL", selected = "Y"))
)
if (interactive()) {
  shinyApp(app$ui, app$server)
}


teal Module: Logistic Regression

Description

This module produces a multi-variable logistic regression table consistent with the TLG Catalog template LGRT02 available here.

Usage

tm_t_logistic(
  label,
  dataname,
  parentname = ifelse(inherits(arm_var, "data_extract_spec"),
    teal.transform::datanames_input(arm_var), "ADSL"),
  arm_var = NULL,
  arm_ref_comp = NULL,
  paramcd,
  cov_var = NULL,
  avalc_var = teal.transform::choices_selected(teal.transform::variable_choices(dataname,
    "AVALC"), "AVALC", fixed = TRUE),
  conf_level = teal.transform::choices_selected(c(0.95, 0.9, 0.8), 0.95, keep_order =
    TRUE),
  pre_output = NULL,
  post_output = NULL,
  basic_table_args = teal.widgets::basic_table_args(),
  transformators = list(),
  decorators = list()
)

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 to ADSL.

arm_var

(teal.transform::choices_selected() or NULL)
object with all available choices and preselected option for variable names that can be used as arm_var. This defines the grouping variable(s) in the results table. If there are two elements selected for arm_var, the second variable will be nested under the first variable. If NULL, no arm/treatment variable is included in the logistic model.

arm_ref_comp

(list) optional,
if specified it must be a named list with each element corresponding to an arm variable in ADSL and the element must be another list (possibly with delayed teal.transform::variable_choices() or delayed teal.transform::value_choices() with the elements named ref and comp 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 from dataname.

cov_var

(teal.transform::choices_selected())
object with all available choices and preselected option for the covariates variables.

avalc_var

(teal.transform::choices_selected())
object with all available choices and preselected option for the analysis variable (categorical).

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).

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 the shiny::helpText() elements are useful.

basic_table_args

(basic_table_args) optional
object created by teal.widgets::basic_table_args() with settings for the module table. The argument is merged with option teal.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").

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 lists of teal_transform_module) optional, decorator for tables or plots included in the module output reported. The decorators are applied to the respective output objects.

See section "Decorating Module" below for more details.

Value

a teal_module object.

Decorating Module

This module generates the following objects, which can be modified in place using decorators:

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_t_logistic(
   ..., # arguments for module
   decorators = list(
     table = teal_transform_module(...) # applied only to `table` output
   )
)

For additional details and examples of decorators, refer to the vignette vignette("decorate-module-output", package = "teal.modules.clinical").

To learn more please refer to the vignette vignette("transform-module-output", package = "teal") or the teal::teal_transform_module() documentation.

Examples in Shinylive

example-1

Open in Shinylive

See Also

The TLG Catalog where additional example apps implementing this module can be found.

Examples

library(dplyr)

data <- teal_data()
data <- within(data, {
  ADSL <- tmc_ex_adsl
  ADRS <- tmc_ex_adrs %>%
    filter(PARAMCD %in% c("BESRSPI", "INVET"))
})
join_keys(data) <- default_cdisc_join_keys[names(data)]

ADSL <- data[["ADSL"]]
ADRS <- data[["ADRS"]]

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_t_logistic(
      label = "Logistic Regression",
      dataname = "ADRS",
      arm_var = choices_selected(
        choices = variable_choices(ADRS, c("ARM", "ARMCD")),
        selected = "ARM"
      ),
      arm_ref_comp = arm_ref_comp,
      paramcd = choices_selected(
        choices = value_choices(ADRS, "PARAMCD", "PARAM"),
        selected = "BESRSPI"
      ),
      cov_var = choices_selected(
        choices = c("SEX", "AGE", "BMRKR1", "BMRKR2"),
        selected = "SEX"
      )
    )
  )
)
if (interactive()) {
  shinyApp(app$ui, app$server)
}


teal Module: Multiple Events by Term

Description

This module produces a table of multiple events by term.

Usage

tm_t_mult_events(
  label,
  dataname,
  parentname = ifelse(inherits(arm_var, "data_extract_spec"),
    teal.transform::datanames_input(arm_var), "ADSL"),
  arm_var,
  seq_var,
  hlt,
  llt,
  add_total = TRUE,
  total_label = default_total_label(),
  na_level = default_na_str(),
  event_type = "event",
  title_text = "Concomitant Medications",
  drop_arm_levels = TRUE,
  pre_output = NULL,
  post_output = NULL,
  basic_table_args = teal.widgets::basic_table_args(),
  transformators = list(),
  decorators = list()
)

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 to ADSL.

arm_var

(teal.transform::choices_selected())
object with all available choices and preselected option for variable names that can be used as arm_var. It defines the grouping variable in the results table.

seq_var

(teal.transform::choices_selected())
object with all available choices and preselected option for variable names that can be used as analysis sequence number variable. Used for counting the unique number of events.

hlt

(teal.transform::choices_selected())
name of the variable with high level term for events.

llt

(teal.transform::choices_selected())
name of the variable with low level term for events.

add_total

(logical)
whether to include column with total number of patients.

total_label

(string)
string to display as total column/row label if column/row is enabled (see add_total). Defaults to "All Patients". To set a new default total_label to apply in all modules, run set_default_total_label("new_default").

na_level

(string)
used to replace all NA or empty values in character or factor variables in the data. Defaults to "<Missing>". To set a default na_level to apply in all modules, run set_default_na_str("new_default").

event_type

(character)
type of event that is summarized (e.g. adverse event, treatment). Default is "event".

title_text

(string)
text to display as the first part of the dynamic table title. The table title is constructed as follows: "title_text by hlt and llt". Defaults to "Concomitant Medications".

drop_arm_levels

(logical)
whether to drop unused levels of arm_var. If TRUE, arm_var levels are set to those used in the dataname dataset. If FALSE, arm_var levels are set to those used in the parentname dataset. If dataname and parentname are the same, then drop_arm_levels is set to TRUE and user input for this parameter is ignored.

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 the shiny::helpText() elements are useful.

basic_table_args

(basic_table_args) optional
object created by teal.widgets::basic_table_args() with settings for the module table. The argument is merged with option teal.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").

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 lists of teal_transform_module) optional, decorator for tables or plots included in the module output reported. The decorators are applied to the respective output objects.

See section "Decorating Module" below for more details.

Value

a teal_module object.

Decorating Module

This module generates the following objects, which can be modified in place using decorators:

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_t_mult_events(
   ..., # arguments for module
   decorators = list(
     table = teal_transform_module(...) # applied only to `table` output
   )
)

For additional details and examples of decorators, refer to the vignette vignette("decorate-module-output", package = "teal.modules.clinical").

To learn more please refer to the vignette vignette("transform-module-output", package = "teal") or the teal::teal_transform_module() documentation.

Examples in Shinylive

example-1

Open in Shinylive

See Also

The TLG Catalog where additional example apps implementing this module can be found.

Examples

data <- teal_data()
data <- within(data, {
  ADSL <- tmc_ex_adsl
  ADCM <- tmc_ex_adcm
})
join_keys(data) <- default_cdisc_join_keys[names(data)]
adcm_keys <- c("STUDYID", "USUBJID", "ASTDTM", "CMSEQ", "ATC1", "ATC2", "ATC3", "ATC4")
join_keys(data)["ADCM", "ADCM"] <- adcm_keys

ADSL <- data[["ADSL"]]
ADCM <- data[["ADCM"]]

app <- init(
  data = data,
  modules = modules(
    tm_t_mult_events(
      label = "Concomitant Medications by Medication Class and Preferred Name",
      dataname = "ADCM",
      arm_var = choices_selected(c("ARM", "ARMCD"), "ARM"),
      seq_var = choices_selected("CMSEQ", selected = "CMSEQ", fixed = TRUE),
      hlt = choices_selected(
        choices = variable_choices(ADCM, c("ATC1", "ATC2", "ATC3", "ATC4")),
        selected = c("ATC1", "ATC2", "ATC3", "ATC4")
      ),
      llt = choices_selected(
        choices = variable_choices(ADCM, c("CMDECOD")),
        selected = c("CMDECOD")
      ),
      add_total = TRUE,
      event_type = "treatment"
    )
  )
)
if (interactive()) {
  shinyApp(app$ui, app$server)
}


teal Module: Patient Profile Basic Info

Description

This module produces a patient profile basic info report using ADaM datasets.

Usage

tm_t_pp_basic_info(
  label,
  dataname = "ADSL",
  patient_col = "USUBJID",
  vars = NULL,
  pre_output = NULL,
  post_output = NULL,
  transformators = list(),
  decorators = list()
)

Arguments

label

(character)
menu item label of the module in the teal app.

dataname

(character)
analysis data used in teal module.

patient_col

(character)
name of patient ID variable.

vars

(teal.transform::choices_selected())
object with all available choices and preselected option for variables from dataname to show in the table.

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 the shiny::helpText() elements are useful.

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 lists of teal_transform_module) optional, decorator for tables or plots included in the module output reported. The decorators are applied to the respective output objects.

See section "Decorating Module" below for more details.

Value

a teal_module object.

Decorating Module

This module generates the following objects, which can be modified in place using decorators:

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_t_pp_basic_info(
   ..., # arguments for module
   decorators = list(
     table = teal_transform_module(...) # applied only to `table` output
   )
)

For additional details and examples of decorators, refer to the vignette vignette("decorate-module-output", package = "teal.modules.clinical").

To learn more please refer to the vignette vignette("transform-module-output", package = "teal") or the teal::teal_transform_module() documentation.

Examples in Shinylive

example-1

Open in Shinylive

Examples

data <- teal_data()
data <- within(data, {
  ADSL <- tmc_ex_adsl
})
join_keys(data) <- default_cdisc_join_keys[names(data)]

ADSL <- data[["ADSL"]]

app <- init(
  data = data,
  modules = modules(
    tm_t_pp_basic_info(
      label = "Basic Info",
      dataname = "ADSL",
      patient_col = "USUBJID",
      vars = choices_selected(
        choices = variable_choices(ADSL),
        selected = c("ARM", "AGE", "SEX", "COUNTRY", "RACE", "EOSSTT")
      )
    )
  )
)
if (interactive()) {
  shinyApp(app$ui, app$server)
}


teal Module: Patient Profile Laboratory Table

Description

This module produces a patient profile laboratory table using ADaM datasets.

Usage

tm_t_pp_laboratory(
  label,
  dataname = "ADLB",
  parentname = "ADSL",
  patient_col = "USUBJID",
  timepoints = NULL,
  aval = lifecycle::deprecated(),
  aval_var = NULL,
  avalu = lifecycle::deprecated(),
  avalu_var = NULL,
  param = NULL,
  paramcd = NULL,
  anrind = NULL,
  pre_output = NULL,
  post_output = NULL,
  transformators = list(),
  decorators = list()
)

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 to ADSL.

patient_col

(character)
name of patient ID variable.

timepoints

(teal.transform::choices_selected())
object with all available choices and preselected option for the time variable from dataname.

aval

[Deprecated] Please use the aval_var argument instead.

aval_var

(teal.transform::choices_selected())
object with all available choices and pre-selected option for the analysis variable.

avalu

[Deprecated] Please use the avalu_var argument instead.

avalu_var

(teal.transform::choices_selected())
object with all available choices and preselected option for the analysis unit variable.

param

(teal.transform::choices_selected())
object with all available choices and preselected option for the PARAM variable from dataname.

paramcd

(teal.transform::choices_selected())
object with all available choices and preselected option for the parameter code variable from dataname.

anrind

(teal.transform::choices_selected())
object with all available choices and preselected option for the ANRIND variable from dataname. Variable should have the following 3 levels: "HIGH", "LOW", and "NORMAL".

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 the shiny::helpText() elements are useful.

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 lists of teal_transform_module) optional, decorator for tables or plots included in the module output reported. The decorators are applied to the respective output objects.

See section "Decorating Module" below for more details.

Value

a teal_module object.

Decorating Module

This module generates the following objects, which can be modified in place using decorators:

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_t_pp_laboratory(
   ..., # arguments for module
   decorators = list(
     table = teal_transform_module(...) # applied only to `table` output
   )
)

For additional details and examples of decorators, refer to the vignette vignette("decorate-module-output", package = "teal.modules.clinical").

To learn more please refer to the vignette vignette("transform-module-output", package = "teal") or the teal::teal_transform_module() documentation.

Examples in Shinylive

example-1

Open in Shinylive

Examples

data <- teal_data()
data <- within(data, {
  ADSL <- tmc_ex_adsl
  ADLB <- tmc_ex_adlb
})
join_keys(data) <- default_cdisc_join_keys[names(data)]

ADSL <- data[["ADSL"]]
ADLB <- data[["ADLB"]]

app <- init(
  data = data,
  modules = modules(
    tm_t_pp_laboratory(
      label = "Vitals",
      dataname = "ADLB",
      patient_col = "USUBJID",
      paramcd = choices_selected(
        choices = variable_choices(ADLB, "PARAMCD"),
        selected = "PARAMCD"
      ),
      param = choices_selected(
        choices = variable_choices(ADLB, "PARAM"),
        selected = "PARAM"
      ),
      timepoints = choices_selected(
        choices = variable_choices(ADLB, "ADY"),
        selected = "ADY"
      ),
      anrind = choices_selected(
        choices = variable_choices(ADLB, "ANRIND"),
        selected = "ANRIND"
      ),
      aval_var = choices_selected(
        choices = variable_choices(ADLB, "AVAL"),
        selected = "AVAL"
      ),
      avalu_var = choices_selected(
        choices = variable_choices(ADLB, "AVALU"),
        selected = "AVALU"
      )
    )
  )
)
if (interactive()) {
  shinyApp(app$ui, app$server)
}


teal Module: Patient Profile Medical History

Description

This module produces a patient profile medical history report using ADaM datasets.

Usage

tm_t_pp_medical_history(
  label,
  dataname = "ADMH",
  parentname = "ADSL",
  patient_col = "USUBJID",
  mhterm = NULL,
  mhbodsys = NULL,
  mhdistat = NULL,
  pre_output = NULL,
  post_output = NULL,
  transformators = list(),
  decorators = list()
)

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 to ADSL.

patient_col

(character)
name of patient ID variable.

mhterm

(teal.transform::choices_selected())
object with all available choices and preselected option for the MHTERM variable from dataname.

mhbodsys

(teal.transform::choices_selected())
object with all available choices and preselected option for the MHBODSYS variable from dataname.

mhdistat

(teal.transform::choices_selected())
object with all available choices and preselected option for the MHDISTAT variable from dataname.

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 the shiny::helpText() elements are useful.

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 lists of teal_transform_module) optional, decorator for tables or plots included in the module output reported. The decorators are applied to the respective output objects.

See section "Decorating Module" below for more details.

Value

a teal_module object.

Decorating Module

This module generates the following objects, which can be modified in place using decorators:

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_t_pp_medical_history(
   ..., # arguments for module
   decorators = list(
     table = teal_transform_module(...) # applied only to `table` output
   )
)

For additional details and examples of decorators, refer to the vignette vignette("decorate-module-output", package = "teal.modules.clinical").

To learn more please refer to the vignette vignette("transform-module-output", package = "teal") or the teal::teal_transform_module() documentation.

Examples in Shinylive

example-1

Open in Shinylive

Examples

data <- teal_data()
data <- within(data, {
  ADSL <- tmc_ex_adsl
  ADMH <- tmc_ex_admh
})
join_keys(data) <- default_cdisc_join_keys[names(data)]

ADSL <- data[["ADSL"]]
ADMH <- data[["ADMH"]]

app <- init(
  data = data,
  modules = modules(
    tm_t_pp_medical_history(
      label = "Medical History",
      dataname = "ADMH",
      parentname = "ADSL",
      patient_col = "USUBJID",
      mhterm = choices_selected(
        choices = variable_choices(ADMH, c("MHTERM")),
        selected = "MHTERM"
      ),
      mhbodsys = choices_selected(
        choices = variable_choices(ADMH, "MHBODSYS"),
        selected = "MHBODSYS"
      ),
      mhdistat = choices_selected(
        choices = variable_choices(ADMH, "MHDISTAT"),
        selected = "MHDISTAT"
      )
    )
  )
)
if (interactive()) {
  shinyApp(app$ui, app$server)
}


teal Module: Patient Profile Prior Medication

Description

This module produces a patient profile prior medication report using ADaM datasets.

Usage

tm_t_pp_prior_medication(
  label,
  dataname = "ADCM",
  parentname = "ADSL",
  patient_col = "USUBJID",
  atirel = NULL,
  cmdecod = NULL,
  cmindc = NULL,
  cmstdy = NULL,
  pre_output = NULL,
  post_output = NULL,
  transformators = list(),
  decorators = list()
)

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 to ADSL.

patient_col

(character)
name of patient ID variable.

atirel

(teal.transform::choices_selected())
object with all available choices and preselected option for the ATIREL variable from dataname.

cmdecod

(teal.transform::choices_selected())
object with all available choices and preselected option for the CMDECOD variable from dataname.

cmindc

(teal.transform::choices_selected())
object with all available choices and preselected option for the CMINDC variable from dataname.

cmstdy

(teal.transform::choices_selected())
object with all available choices and preselected option for the CMSTDY variable from dataname.

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 the shiny::helpText() elements are useful.

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 lists of teal_transform_module) optional, decorator for tables or plots included in the module output reported. The decorators are applied to the respective output objects.

See section "Decorating Module" below for more details.

Value

a teal_module object.

Decorating Module

This module generates the following objects, which can be modified in place using decorators:

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_t_pp_prior_medication(
   ..., # arguments for module
   decorators = list(
     table = teal_transform_module(...) # applied only to `table` output
   )
)

For additional details and examples of decorators, refer to the vignette vignette("decorate-module-output", package = "teal.modules.clinical").

To learn more please refer to the vignette vignette("transform-module-output", package = "teal") or the teal::teal_transform_module() documentation.

Examples in Shinylive

example-1

Open in Shinylive

Examples

library(dplyr)
data <- teal_data()
data <- within(data, {
  ADCM <- tmc_ex_adcm
  ADSL <- tmc_ex_adsl %>% filter(USUBJID %in% ADCM$USUBJID)
  ADCM$CMASTDTM <- ADCM$ASTDTM
  ADCM$CMAENDTM <- ADCM$AENDTM
})
join_keys(data) <- default_cdisc_join_keys[names(data)]
adcm_keys <- c("STUDYID", "USUBJID", "ASTDTM", "CMSEQ", "ATC1", "ATC2", "ATC3", "ATC4")
join_keys(data)["ADCM", "ADCM"] <- adcm_keys

ADSL <- data[["ADSL"]]
ADCM <- data[["ADCM"]]

app <- init(
  data = data,
  modules = modules(
    tm_t_pp_prior_medication(
      label = "Prior Medication",
      dataname = "ADCM",
      parentname = "ADSL",
      patient_col = "USUBJID",
      atirel = choices_selected(
        choices = variable_choices(ADCM, "ATIREL"),
        selected = "ATIREL"
      ),
      cmdecod = choices_selected(
        choices = variable_choices(ADCM, "CMDECOD"),
        selected = "CMDECOD"
      ),
      cmindc = choices_selected(
        choices = variable_choices(ADCM, "CMINDC"),
        selected = "CMINDC"
      ),
      cmstdy = choices_selected(
        choices = variable_choices(ADCM, "ASTDY"),
        selected = "ASTDY"
      )
    )
  )
)
if (interactive()) {
  shinyApp(app$ui, app$server)
}


teal Module: Shift by Arm

Description

This module produces a summary table of analysis indicator levels by arm.

Usage

tm_t_shift_by_arm(
  label,
  dataname,
  parentname = ifelse(inherits(arm_var, "data_extract_spec"),
    teal.transform::datanames_input(arm_var), "ADSL"),
  arm_var,
  paramcd,
  visit_var,
  aval_var,
  base_var = lifecycle::deprecated(),
  baseline_var,
  treatment_flag_var =
    teal.transform::choices_selected(teal.transform::variable_choices(dataname, subset =
    "ONTRTFL"), selected = "ONTRTFL"),
  treatment_flag = teal.transform::choices_selected("Y"),
  useNA = c("ifany", "no"),
  na_level = default_na_str(),
  add_total = FALSE,
  total_label = default_total_label(),
  pre_output = NULL,
  post_output = NULL,
  basic_table_args = teal.widgets::basic_table_args(),
  transformators = list(),
  decorators = list()
)

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 to ADSL.

arm_var

(teal.transform::choices_selected())
object with all available choices and preselected option for variable names that can be used as arm_var. It defines the grouping variable in the results table.

paramcd

(teal.transform::choices_selected())
object with all available choices and preselected option for the parameter code variable from dataname.

visit_var

(teal.transform::choices_selected())
object with all available choices and preselected option for variable names that can be used as visit variable. Must be a factor in dataname.

aval_var

(teal.transform::choices_selected())
object with all available choices and pre-selected option for the analysis variable.

base_var

[Deprecated] Please use the baseline_var argument instead.

baseline_var

(teal.transform::choices_selected())
object with all available choices and preselected option for variable values that can be used as baseline_var.

treatment_flag_var

(teal.transform::choices_selected())
on treatment flag variable.

treatment_flag

(teal.transform::choices_selected())
value indicating on treatment records in treatment_flag_var.

useNA

(character)
whether missing data (NA) should be displayed as a level.

na_level

(string)
used to replace all NA or empty values in character or factor variables in the data. Defaults to "<Missing>". To set a default na_level to apply in all modules, run set_default_na_str("new_default").

add_total

(logical)
whether to include row with total number of patients.

total_label

(string)
string to display as total column/row label if column/row is enabled (see add_total). Defaults to "All Patients". To set a new default total_label to apply in all modules, run set_default_total_label("new_default").

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 the shiny::helpText() elements are useful.

basic_table_args

(basic_table_args) optional
object created by teal.widgets::basic_table_args() with settings for the module table. The argument is merged with option teal.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").

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 lists of teal_transform_module) optional, decorator for tables or plots included in the module output reported. The decorators are applied to the respective output objects.

See section "Decorating Module" below for more details.

Value

a teal_module object.

Decorating Module

This module generates the following objects, which can be modified in place using decorators:

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_t_shift_by_arm(
   ..., # arguments for module
   decorators = list(
     table = teal_transform_module(...) # applied only to `table` output
   )
)

For additional details and examples of decorators, refer to the vignette vignette("decorate-module-output", package = "teal.modules.clinical").

To learn more please refer to the vignette vignette("transform-module-output", package = "teal") or the teal::teal_transform_module() documentation.

Examples in Shinylive

example-1

Open in Shinylive

See Also

The TLG Catalog where additional example apps implementing this module can be found.

Examples

data <- teal_data()
data <- within(data, {
  ADSL <- tmc_ex_adsl
  ADEG <- tmc_ex_adeg
})
join_keys(data) <- default_cdisc_join_keys[names(data)]

ADSL <- data[["ADSL"]]
ADEG <- data[["ADEG"]]

app <- init(
  data = data,
  modules = modules(
    tm_t_shift_by_arm(
      label = "Shift by Arm Table",
      dataname = "ADEG",
      arm_var = choices_selected(
        variable_choices(ADSL, subset = c("ARM", "ARMCD")),
        selected = "ARM"
      ),
      paramcd = choices_selected(
        value_choices(ADEG, "PARAMCD"),
        selected = "HR"
      ),
      visit_var = choices_selected(
        value_choices(ADEG, "AVISIT"),
        selected = "POST-BASELINE MINIMUM"
      ),
      aval_var = choices_selected(
        variable_choices(ADEG, subset = "ANRIND"),
        selected = "ANRIND",
        fixed = TRUE
      ),
      baseline_var = choices_selected(
        variable_choices(ADEG, subset = "BNRIND"),
        selected = "BNRIND",
        fixed = TRUE
      ),
      useNA = "ifany"
    )
  )
)
if (interactive()) {
  shinyApp(app$ui, app$server)
}


teal Module: Shift by Arm by Worst Analysis Indicator Level

Description

This module produces a summary table of worst analysis indicator variable level per subject by arm.

Usage

tm_t_shift_by_arm_by_worst(
  label,
  dataname,
  parentname = ifelse(inherits(arm_var, "data_extract_spec"),
    teal.transform::datanames_input(arm_var), "ADSL"),
  arm_var,
  paramcd,
  aval_var,
  base_var = lifecycle::deprecated(),
  baseline_var,
  worst_flag_var,
  worst_flag,
  treatment_flag_var = teal.transform::choices_selected(choices =
    teal.transform::variable_choices(dataname, subset = "ONTRTFL"), selected = "ONTRTFL"),
  treatment_flag = teal.transform::choices_selected("Y"),
  useNA = c("ifany", "no"),
  na_level = default_na_str(),
  add_total = FALSE,
  total_label = default_total_label(),
  pre_output = NULL,
  post_output = NULL,
  basic_table_args = teal.widgets::basic_table_args(),
  transformators = list(),
  decorators = list()
)

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 to ADSL.

arm_var

(teal.transform::choices_selected())
object with all available choices and preselected option for variable names that can be used as arm_var. It defines the grouping variable in the results table.

paramcd

(teal.transform::choices_selected())
object with all available choices and preselected option for the parameter code variable from dataname.

aval_var

(teal.transform::choices_selected())
object with all available choices and pre-selected option for the analysis variable.

base_var

[Deprecated] Please use the baseline_var argument instead.

baseline_var

(teal.transform::choices_selected())
object with all available choices and preselected option for variable values that can be used as baseline_var.

worst_flag_var

(teal.transform::choices_selected())
object with all available choices and preselected option for variable names that can be used as worst flag variable.

worst_flag

(character)
value indicating worst analysis indicator level.

treatment_flag_var

(teal.transform::choices_selected())
on treatment flag variable.

treatment_flag

(teal.transform::choices_selected())
value indicating on treatment records in treatment_flag_var.

useNA

(character)
whether missing data (NA) should be displayed as a level.

na_level

(string)
used to replace all NA or empty values in character or factor variables in the data. Defaults to "<Missing>". To set a default na_level to apply in all modules, run set_default_na_str("new_default").

add_total

(logical)
whether to include row with total number of patients.

total_label

(string)
string to display as total column/row label if column/row is enabled (see add_total). Defaults to "All Patients". To set a new default total_label to apply in all modules, run set_default_total_label("new_default").

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 the shiny::helpText() elements are useful.

basic_table_args

(basic_table_args) optional
object created by teal.widgets::basic_table_args() with settings for the module table. The argument is merged with option teal.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").

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 lists of teal_transform_module) optional, decorator for tables or plots included in the module output reported. The decorators are applied to the respective output objects.

See section "Decorating Module" below for more details.

Value

a teal_module object.

Decorating Module

This module generates the following objects, which can be modified in place using decorators:

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_t_shift_by_arm_by_worst(
   ..., # arguments for module
   decorators = list(
     table = teal_transform_module(...) # applied only to `table` output
   )
)

For additional details and examples of decorators, refer to the vignette vignette("decorate-module-output", package = "teal.modules.clinical").

To learn more please refer to the vignette vignette("transform-module-output", package = "teal") or the teal::teal_transform_module() documentation.

Examples in Shinylive

example-1

Open in Shinylive

Examples

data <- teal_data()
data <- within(data, {
  ADSL <- tmc_ex_adsl
  ADEG <- tmc_ex_adeg
})
join_keys(data) <- default_cdisc_join_keys[names(data)]

ADSL <- data[["ADSL"]]
ADEG <- data[["ADEG"]]

app <- init(
  data = data,
  modules = modules(
    tm_t_shift_by_arm_by_worst(
      label = "Shift by Arm Table",
      dataname = "ADEG",
      arm_var = choices_selected(
        variable_choices(ADSL, subset = c("ARM", "ARMCD")),
        selected = "ARM"
      ),
      paramcd = choices_selected(
        value_choices(ADEG, "PARAMCD"),
        selected = "ECGINTP"
      ),
      worst_flag_var = choices_selected(
        variable_choices(ADEG, c("WORS02FL", "WORS01FL")),
        selected = "WORS02FL"
      ),
      worst_flag = choices_selected(
        value_choices(ADEG, "WORS02FL"),
        selected = "Y",
        fixed = TRUE
      ),
      aval_var = choices_selected(
        variable_choices(ADEG, c("AVALC", "ANRIND")),
        selected = "AVALC"
      ),
      baseline_var = choices_selected(
        variable_choices(ADEG, c("BASEC", "BNRIND")),
        selected = "BASEC"
      ),
      useNA = "ifany"
    )
  )
)
if (interactive()) {
  shinyApp(app$ui, app$server)
}


teal Module: Grade Summary Table

Description

This module produces a summary table of worst grades per subject by visit and parameter.

Usage

tm_t_shift_by_grade(
  label,
  dataname,
  parentname = ifelse(inherits(arm_var, "data_extract_spec"),
    teal.transform::datanames_input(arm_var), "ADSL"),
  arm_var,
  visit_var = teal.transform::choices_selected(teal.transform::variable_choices(dataname,
    subset = "AVISIT"), selected = "AVISIT", fixed = TRUE),
  paramcd,
  worst_flag_var =
    teal.transform::choices_selected(teal.transform::variable_choices(dataname, subset =
    c("WGRLOVFL", "WGRLOFL", "WGRHIVFL", "WGRHIFL")), selected = "WGRLOVFL"),
  worst_flag_indicator =
    teal.transform::choices_selected(teal.transform::value_choices(dataname, "WGRLOVFL"),
    selected = "Y", fixed = TRUE),
  anl_toxgrade_var =
    teal.transform::choices_selected(teal.transform::variable_choices(dataname, subset =
    c("ATOXGR")), selected = c("ATOXGR"), fixed = TRUE),
  base_toxgrade_var =
    teal.transform::choices_selected(teal.transform::variable_choices(dataname, subset =
    c("BTOXGR")), selected = c("BTOXGR"), fixed = TRUE),
  id_var = teal.transform::choices_selected(teal.transform::variable_choices(dataname,
    subset = "USUBJID"), selected = "USUBJID", fixed = TRUE),
  add_total = FALSE,
  total_label = default_total_label(),
  drop_arm_levels = TRUE,
  pre_output = NULL,
  post_output = NULL,
  na_level = default_na_str(),
  code_missing_baseline = FALSE,
  basic_table_args = teal.widgets::basic_table_args(),
  transformators = list(),
  decorators = list()
)

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 to ADSL.

arm_var

(teal.transform::choices_selected())
object with all available choices and preselected option for variable names that can be used as arm_var. It defines the grouping variable in the results table.

visit_var

(teal.transform::choices_selected())
object with all available choices and preselected option for variable names that can be used as visit variable. Must be a factor in dataname.

paramcd

(teal.transform::choices_selected())
object with all available choices and preselected option for the parameter code variable from dataname.

worst_flag_var

(teal.transform::choices_selected())
object with all available choices and preselected option for variable names that can be used as worst flag variable.

worst_flag_indicator

(teal.transform::choices_selected())
value indicating worst grade.

anl_toxgrade_var

(teal.transform::choices_selected())
variable for analysis toxicity grade.

base_toxgrade_var

(teal.transform::choices_selected())
variable for baseline toxicity grade.

id_var

(teal.transform::choices_selected())
object specifying the variable name for subject id.

add_total

(logical)
whether to include column with total number of patients.

total_label

(string)
string to display as total column/row label if column/row is enabled (see add_total). Defaults to "All Patients". To set a new default total_label to apply in all modules, run set_default_total_label("new_default").

drop_arm_levels

(logical)
whether to drop unused levels of arm_var. If TRUE, arm_var levels are set to those used in the dataname dataset. If FALSE, arm_var levels are set to those used in the parentname dataset. If dataname and parentname are the same, then drop_arm_levels is set to TRUE and user input for this parameter is ignored.

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 the shiny::helpText() elements are useful.

na_level

(string)
used to replace all NA or empty values in character or factor variables in the data. Defaults to "<Missing>". To set a default na_level to apply in all modules, run set_default_na_str("new_default").

code_missing_baseline

(logical)
whether missing baseline grades should be counted as grade 0.

basic_table_args

(basic_table_args) optional
object created by teal.widgets::basic_table_args() with settings for the module table. The argument is merged with option teal.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").

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 lists of teal_transform_module) optional, decorator for tables or plots included in the module output reported. The decorators are applied to the respective output objects.

See section "Decorating Module" below for more details.

Value

a teal_module object.

Decorating Module

This module generates the following objects, which can be modified in place using decorators:

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_t_shift_by_grade(
   ..., # arguments for module
   decorators = list(
     table = teal_transform_module(...) # applied only to `table` output
   )
)

For additional details and examples of decorators, refer to the vignette vignette("decorate-module-output", package = "teal.modules.clinical").

To learn more please refer to the vignette vignette("transform-module-output", package = "teal") or the teal::teal_transform_module() documentation.

Examples in Shinylive

example-1

Open in Shinylive

See Also

The TLG Catalog where additional example apps implementing this module can be found.

Examples

data <- teal_data()
data <- within(data, {
  ADSL <- tmc_ex_adsl
  ADLB <- tmc_ex_adlb
})
join_keys(data) <- default_cdisc_join_keys[names(data)]

ADSL <- data[["ADSL"]]
ADLB <- data[["ADLB"]]

app <- init(
  data = data,
  modules = modules(
    tm_t_shift_by_grade(
      label = "Grade Laboratory Abnormality Table",
      dataname = "ADLB",
      arm_var = choices_selected(
        choices = variable_choices(ADSL, subset = c("ARM", "ARMCD")),
        selected = "ARM"
      ),
      paramcd = choices_selected(
        choices = value_choices(ADLB, "PARAMCD", "PARAM"),
        selected = "ALT"
      ),
      worst_flag_var = choices_selected(
        choices = variable_choices(ADLB, subset = c("WGRLOVFL", "WGRLOFL", "WGRHIVFL", "WGRHIFL")),
        selected = c("WGRLOVFL")
      ),
      worst_flag_indicator = choices_selected(
        value_choices(ADLB, "WGRLOVFL"),
        selected = "Y", fixed = TRUE
      ),
      anl_toxgrade_var = choices_selected(
        choices = variable_choices(ADLB, subset = c("ATOXGR")),
        selected = c("ATOXGR"),
        fixed = TRUE
      ),
      base_toxgrade_var = choices_selected(
        choices = variable_choices(ADLB, subset = c("BTOXGR")),
        selected = c("BTOXGR"),
        fixed = TRUE
      ),
      add_total = FALSE
    )
  ),
  filter = teal_slices(teal_slice("ADSL", "SAFFL", selected = "Y"))
)
if (interactive()) {
  shinyApp(app$ui, app$server)
}


teal Module: Adverse Events Table by Standardized MedDRA Query

Description

This module produces an adverse events table by Standardized MedDRA Query.

Usage

tm_t_smq(
  label,
  dataname,
  parentname = ifelse(inherits(arm_var, "data_extract_spec"),
    teal.transform::datanames_input(arm_var), "ADSL"),
  arm_var,
  id_var = teal.transform::choices_selected(teal.transform::variable_choices(dataname,
    subset = "USUBJID"), selected = "USUBJID", fixed = TRUE),
  llt,
  add_total = TRUE,
  total_label = default_total_label(),
  sort_criteria = c("freq_desc", "alpha"),
  drop_arm_levels = TRUE,
  na_level = default_na_str(),
  smq_varlabel = "Standardized MedDRA Query",
  baskets,
  scopes,
  pre_output = NULL,
  post_output = NULL,
  basic_table_args = teal.widgets::basic_table_args(),
  transformators = list(),
  decorators = list()
)

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 to ADSL.

arm_var

(teal.transform::choices_selected())
object with all available choices and preselected option for variable names that can be used as arm_var. It defines the grouping variable(s) in the results table. If there are two elements selected for arm_var, second variable will be nested under the first variable.

id_var

(teal.transform::choices_selected())
object specifying the variable name for subject id.

llt

(teal.transform::choices_selected())
name of the variable with low level term for events.

add_total

(logical)
whether to include column with total number of patients.

total_label

(string)
string to display as total column/row label if column/row is enabled (see add_total). Defaults to "All Patients". To set a new default total_label to apply in all modules, run set_default_total_label("new_default").

sort_criteria

(character)
how to sort the final table. Default option freq_desc sorts on column sort_freq_col by decreasing number of patients with event. Alternative option alpha sorts events alphabetically.

drop_arm_levels

(logical)
whether to drop unused levels of arm_var. If TRUE, arm_var levels are set to those used in the dataname dataset. If FALSE, arm_var levels are set to those used in the parentname dataset. If dataname and parentname are the same, then drop_arm_levels is set to TRUE and user input for this parameter is ignored.

na_level

(string)
used to replace all NA or empty values in character or factor variables in the data. Defaults to "<Missing>". To set a default na_level to apply in all modules, run set_default_na_str("new_default").

smq_varlabel

(character)
label to use for new column SMQ created by tern::h_stack_by_baskets().

baskets

(teal.transform::choices_selected())
object with all available choices and preselected options for standardized/customized queries.

scopes

(teal.transform::choices_selected())
object with all available choices for the scopes of standardized queries.

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 the shiny::helpText() elements are useful.

basic_table_args

(basic_table_args) optional
object created by teal.widgets::basic_table_args() with settings for the module table. The argument is merged with option teal.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").

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 lists of teal_transform_module) optional, decorator for tables or plots included in the module output reported. The decorators are applied to the respective output objects.

See section "Decorating Module" below for more details.

Value

a teal_module object.

Decorating Module

This module generates the following objects, which can be modified in place using decorators:

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_t_smq(
   ..., # arguments for module
   decorators = list(
     table = teal_transform_module(...) # applied only to `table` output
   )
)

For additional details and examples of decorators, refer to the vignette vignette("decorate-module-output", package = "teal.modules.clinical").

To learn more please refer to the vignette vignette("transform-module-output", package = "teal") or the teal::teal_transform_module() documentation.

Examples in Shinylive

example-1

Open in Shinylive

See Also

The TLG Catalog where additional example apps implementing this module can be found.

Examples

data <- teal_data()
data <- within(data, {
  ADSL <- tmc_ex_adsl
  ADAE <- tmc_ex_adae

  .names_baskets <- grep("^(SMQ|CQ).*NAM$", names(ADAE), value = TRUE)
  .names_scopes <- grep("^SMQ.*SC$", names(ADAE), value = TRUE)

  .cs_baskets <- choices_selected(
    choices = variable_choices(ADAE, subset = .names_baskets),
    selected = .names_baskets
  )

  .cs_scopes <- choices_selected(
    choices = variable_choices(ADAE, subset = .names_scopes),
    selected = .names_scopes,
    fixed = TRUE
  )
})
join_keys(data) <- default_cdisc_join_keys[names(data)]

app <- init(
  data = data,
  modules = modules(
    tm_t_smq(
      label = "Adverse Events by SMQ Table",
      dataname = "ADAE",
      arm_var = choices_selected(
        choices = variable_choices(data[["ADSL"]], subset = c("ARM", "SEX")),
        selected = "ARM"
      ),
      add_total = FALSE,
      baskets = data[[".cs_baskets"]],
      scopes = data[[".cs_scopes"]],
      llt = choices_selected(
        choices = variable_choices(data[["ADAE"]], subset = c("AEDECOD")),
        selected = "AEDECOD"
      )
    )
  )
)
if (interactive()) {
  shinyApp(app$ui, app$server)
}


teal Module: Summary of Variables

Description

This module produces a table to summarize variables.

Usage

tm_t_summary(
  label,
  dataname,
  parentname = ifelse(inherits(arm_var, "data_extract_spec"),
    teal.transform::datanames_input(arm_var), "ADSL"),
  arm_var,
  summarize_vars,
  add_total = TRUE,
  total_label = default_total_label(),
  show_arm_var_labels = TRUE,
  useNA = c("ifany", "no"),
  na_level = default_na_str(),
  numeric_stats = c("n", "mean_sd", "mean_ci", "median", "median_ci", "quantiles",
    "range", "geom_mean"),
  denominator = c("N", "n", "omit"),
  drop_arm_levels = TRUE,
  pre_output = NULL,
  post_output = NULL,
  basic_table_args = teal.widgets::basic_table_args(),
  transformators = list(),
  decorators = list()
)

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 to ADSL.

arm_var

(teal.transform::choices_selected())
object with all available choices and preselected option for variable names that can be used as arm_var. It defines the grouping variable(s) in the results table. If there are two elements selected for arm_var, second variable will be nested under the first variable.

summarize_vars

(teal.transform::choices_selected())
names of the variables that should be summarized.

add_total

(logical)
whether to include column with total number of patients.

total_label

(string)
string to display as total column/row label if column/row is enabled (see add_total). Defaults to "All Patients". To set a new default total_label to apply in all modules, run set_default_total_label("new_default").

show_arm_var_labels

(flag)
whether arm variable label(s) should be displayed. Defaults to TRUE.

useNA

(character)
whether missing data (NA) should be displayed as a level.

na_level

(string)
used to replace all NA or empty values in character or factor variables in the data. Defaults to "<Missing>". To set a default na_level to apply in all modules, run set_default_na_str("new_default").

numeric_stats

(character)
names of statistics to display for numeric summary variables. Available statistics are n, mean_sd, mean_ci, median, median_ci, quantiles, range, and geom_mean.

denominator

(character)
chooses how percentages are calculated. With option N, the reference population from the column total is used as the denominator. With option n, the number of non-missing records in this row and column intersection is used as the denominator. If omit is chosen, then the percentage is omitted.

drop_arm_levels

(logical)
whether to drop unused levels of arm_var. If TRUE, arm_var levels are set to those used in the dataname dataset. If FALSE, arm_var levels are set to those used in the parentname dataset. If dataname and parentname are the same, then drop_arm_levels is set to TRUE and user input for this parameter is ignored.

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 the shiny::helpText() elements are useful.

basic_table_args

(basic_table_args) optional
object created by teal.widgets::basic_table_args() with settings for the module table. The argument is merged with option teal.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").

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 lists of teal_transform_module) optional, decorator for tables or plots included in the module output reported. The decorators are applied to the respective output objects.

See section "Decorating Module" below for more details.

Value

a teal_module object.

Decorating Module

This module generates the following objects, which can be modified in place using decorators:

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_t_summary(
   ..., # arguments for module
   decorators = list(
     table = teal_transform_module(...) # applied only to `table` output
   )
)

For additional details and examples of decorators, refer to the vignette vignette("decorate-module-output", package = "teal.modules.clinical").

To learn more please refer to the vignette vignette("transform-module-output", package = "teal") or the teal::teal_transform_module() documentation.

Examples in Shinylive

example-1

Open in Shinylive

See Also

The TLG Catalog where additional example apps implementing this module can be found.

Examples

# Preparation of the test case - use `EOSDY` and `DCSREAS` variables to demonstrate missing data.
data <- teal_data()
data <- within(data, {
  ADSL <- tmc_ex_adsl
  ADSL$EOSDY[1] <- NA_integer_
})
join_keys(data) <- default_cdisc_join_keys[names(data)]

ADSL <- data[["ADSL"]]

app <- init(
  data = data,
  modules = modules(
    tm_t_summary(
      label = "Demographic Table",
      dataname = "ADSL",
      arm_var = choices_selected(c("ARM", "ARMCD"), "ARM"),
      add_total = TRUE,
      summarize_vars = choices_selected(
        c("SEX", "RACE", "BMRKR2", "EOSDY", "DCSREAS", "AGE"),
        c("SEX", "RACE")
      ),
      useNA = "ifany"
    )
  )
)
if (interactive()) {
  shinyApp(app$ui, app$server)
}


teal Module: Summarize Variables by Row Groups

Description

This module produces a table to summarize variables by row groups.

Usage

tm_t_summary_by(
  label,
  dataname,
  parentname = ifelse(inherits(arm_var, "data_extract_spec"),
    teal.transform::datanames_input(arm_var), "ADSL"),
  arm_var,
  by_vars,
  summarize_vars,
  id_var = teal.transform::choices_selected(teal.transform::variable_choices(dataname,
    subset = "USUBJID"), selected = "USUBJID", fixed = TRUE),
  paramcd = NULL,
  add_total = TRUE,
  total_label = default_total_label(),
  parallel_vars = FALSE,
  row_groups = FALSE,
  useNA = c("ifany", "no"),
  na_level = default_na_str(),
  numeric_stats = c("n", "mean_sd", "median", "range"),
  denominator = teal.transform::choices_selected(c("n", "N", "omit"), "omit", fixed =
    TRUE),
  drop_arm_levels = TRUE,
  drop_zero_levels = TRUE,
  pre_output = NULL,
  post_output = NULL,
  basic_table_args = teal.widgets::basic_table_args(),
  transformators = list(),
  decorators = list()
)

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 to ADSL.

arm_var

(teal.transform::choices_selected())
object with all available choices and preselected option for variable names that can be used as arm_var. It defines the grouping variable(s) in the results table. If there are two elements selected for arm_var, second variable will be nested under the first variable.

by_vars

(teal.transform::choices_selected())
object with all available choices and preselected option for variable names used to split the summary by rows.

summarize_vars

(teal.transform::choices_selected())
names of the variables that should be summarized.

id_var

(teal.transform::choices_selected())
object specifying the variable name for subject id.

paramcd

(teal.transform::choices_selected())
object with all available choices and preselected option for the parameter code variable from dataname.

add_total

(logical)
whether to include column with total number of patients.

total_label

(string)
string to display as total column/row label if column/row is enabled (see add_total). Defaults to "All Patients". To set a new default total_label to apply in all modules, run set_default_total_label("new_default").

parallel_vars

(logical)
whether summarized variables should be arranged in columns. Can only be set to TRUE if all chosen analysis variables are numeric.

row_groups

(logical)
whether summarized variables should be arranged in row groups.

useNA

(character)
whether missing data (NA) should be displayed as a level.

na_level

(string)
used to replace all NA or empty values in character or factor variables in the data. Defaults to "<Missing>". To set a default na_level to apply in all modules, run set_default_na_str("new_default").

numeric_stats

(character)
names of statistics to display for numeric summary variables. Available statistics are n, mean_sd, mean_ci, median, median_ci, quantiles, range, and geom_mean.

denominator

(character)
chooses how percentages are calculated. With option N, the reference population from the column total is used as the denominator. With option n, the number of non-missing records in this row and column intersection is used as the denominator. If omit is chosen, then the percentage is omitted.

drop_arm_levels

(logical)
whether to drop unused levels of arm_var. If TRUE, arm_var levels are set to those used in the dataname dataset. If FALSE, arm_var levels are set to those used in the parentname dataset. If dataname and parentname are the same, then drop_arm_levels is set to TRUE and user input for this parameter is ignored.

drop_zero_levels

(logical)
whether rows with zero counts in all columns should be removed from the table.

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 the shiny::helpText() elements are useful.

basic_table_args

(basic_table_args) optional
object created by teal.widgets::basic_table_args() with settings for the module table. The argument is merged with option teal.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").

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 lists of teal_transform_module) optional, decorator for tables or plots included in the module output reported. The decorators are applied to the respective output objects.

See section "Decorating Module" below for more details.

Value

a teal_module object.

Decorating Module

This module generates the following objects, which can be modified in place using decorators:

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_t_summary_by(
   ..., # arguments for module
   decorators = list(
     table = teal_transform_module(...) # applied only to `table` output
   )
)

For additional details and examples of decorators, refer to the vignette vignette("decorate-module-output", package = "teal.modules.clinical").

To learn more please refer to the vignette vignette("transform-module-output", package = "teal") or the teal::teal_transform_module() documentation.

Examples in Shinylive

example-1

Open in Shinylive

See Also

The TLG Catalog where additional example apps implementing this module can be found.

Examples

data <- teal_data()
data <- within(data, {
  ADSL <- tmc_ex_adsl
  ADLB <- tmc_ex_adlb
})
join_keys(data) <- default_cdisc_join_keys[names(data)]

ADSL <- data[["ADSL"]]
ADLB <- data[["ADLB"]]

app <- init(
  data = data,
  modules = modules(
    tm_t_summary_by(
      label = "Summary by Row Groups Table",
      dataname = "ADLB",
      arm_var = choices_selected(
        choices = variable_choices(ADSL, c("ARM", "ARMCD")),
        selected = "ARM"
      ),
      add_total = TRUE,
      by_vars = choices_selected(
        choices = variable_choices(ADLB, c("PARAM", "AVISIT")),
        selected = c("AVISIT")
      ),
      summarize_vars = choices_selected(
        choices = variable_choices(ADLB, c("AVAL", "CHG")),
        selected = c("AVAL")
      ),
      useNA = "ifany",
      paramcd = choices_selected(
        choices = value_choices(ADLB, "PARAMCD", "PARAM"),
        selected = "ALT"
      )
    )
  )
)
if (interactive()) {
  shinyApp(app$ui, app$server)
}


teal Module: Time-To-Event Table

Description

This module produces a time-to-event analysis summary table, consistent with the TLG Catalog template for TTET01 available here.

Usage

tm_t_tte(
  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,
  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_coxph = teal.transform::choices_selected(c(0.95, 0.9, 0.8), 0.95, keep_order
    = TRUE),
  conf_level_survfit = teal.transform::choices_selected(c(0.95, 0.9, 0.8), 0.95,
    keep_order = TRUE),
  time_points,
  time_unit_var =
    teal.transform::choices_selected(teal.transform::variable_choices(dataname, "AVALU"),
    "AVALU", fixed = TRUE),
  event_desc_var = teal.transform::choices_selected("EVNTDESC", "EVNTDESC", fixed = TRUE),
  add_total = FALSE,
  total_label = default_total_label(),
  na_level = default_na_str(),
  pre_output = NULL,
  post_output = NULL,
  basic_table_args = teal.widgets::basic_table_args(),
  transformators = list(),
  decorators = list()
)

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 to ADSL.

arm_var

(teal.transform::choices_selected())
object with all available choices and preselected option for variable names that can be used as arm_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 in ADSL and the element must be another list (possibly with delayed teal.transform::variable_choices() or delayed teal.transform::value_choices() with the elements named ref and comp 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 from dataname.

strata_var

(teal.transform::choices_selected())
names of the variables for stratified analysis.

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_coxph

(teal.transform::choices_selected())
object with all available choices and pre-selected option for confidence level, each within range of (0, 1).

conf_level_survfit

(teal.transform::choices_selected())
object with all available choices and pre-selected option for confidence level, each within range of (0, 1).

time_points

(teal.transform::choices_selected())
object with all available choices and preselected option for time points that can be used in tern::surv_timepoint().

time_unit_var

(teal.transform::choices_selected())
object with all available choices and pre-selected option for the time unit variable.

event_desc_var

(character or teal.transform::data_extract_spec())
variable name with the event description information, optional.

add_total

(logical)
whether to include column with total number of patients.

total_label

(string)
string to display as total column/row label if column/row is enabled (see add_total). Defaults to "All Patients". To set a new default total_label to apply in all modules, run set_default_total_label("new_default").

na_level

(string)
used to replace all NA or empty values in character or factor variables in the data. Defaults to "<Missing>". To set a default na_level to apply in all modules, run set_default_na_str("new_default").

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 the shiny::helpText() elements are useful.

basic_table_args

(basic_table_args) optional
object created by teal.widgets::basic_table_args() with settings for the module table. The argument is merged with option teal.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").

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 lists of teal_transform_module) optional, decorator for tables or plots included in the module output reported. The decorators are applied to the respective output objects.

See section "Decorating Module" below for more details.

Details

Value

a teal_module object.

Decorating Module

This module generates the following objects, which can be modified in place using decorators:

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_t_tte(
   ..., # arguments for module
   decorators = list(
     table = teal_transform_module(...) # applied only to `table` output
   )
)

For additional details and examples of decorators, refer to the vignette vignette("decorate-module-output", package = "teal.modules.clinical").

To learn more please refer to the vignette vignette("transform-module-output", package = "teal") or the teal::teal_transform_module() documentation.

Examples in Shinylive

example-1

Open in Shinylive

See Also

The TLG Catalog where additional example apps implementing this module can be found.

Examples

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_t_tte(
      label = "Time To Event Table",
      dataname = "ADTTE",
      arm_var = choices_selected(
        variable_choices(ADSL, c("ARM", "ARMCD", "ACTARMCD")),
        "ARM"
      ),
      arm_ref_comp = arm_ref_comp,
      paramcd = choices_selected(
        value_choices(ADTTE, "PARAMCD", "PARAM"),
        "OS"
      ),
      strata_var = choices_selected(
        variable_choices(ADSL, c("SEX", "BMRKR2")),
        "SEX"
      ),
      time_points = choices_selected(c(182, 243), 182),
      event_desc_var = choices_selected(
        variable_choices(ADTTE, "EVNTDESC"),
        "EVNTDESC",
        fixed = TRUE
      )
    )
  )
)
if (interactive()) {
  shinyApp(app$ui, app$server)
}


Check if vector is valid as to be used as a treatment arm variable

Description

Check if vector is valid as to be used as a treatment arm variable

Usage

validate_arm(arm_vec)

Arguments

arm_vec

vector to be validated

Details

A validate error is returned if the vector is not a factor with a more detailed error message if any of the entries are empty strings


Validate standard input values for a teal module

Description

[Stable]

Usage

validate_standard_inputs(
  adsl,
  adslvars = character(0),
  anl,
  anlvars = character(0),
  need_arm = TRUE,
  arm_var,
  ref_arm,
  comp_arm,
  min_n_levels_armvar = 1L,
  max_n_levels_armvar = 100L,
  min_nrow = 1
)

Arguments

adsl

data.frame with subject-level data

adslvars

required variables from ADSL

anl

data.frame with analysis data

anlvars

required variables from ANL

need_arm

flag indicating whether grouping variable arm_var is required or can be optionally NULL.

arm_var

character with name of grouping variable, typically arm

ref_arm

character with name of reference level in arm_var

comp_arm

character with name for comparison level in arm_var

min_n_levels_armvar

minimum number of levels in grouping variable arm_var. Defaults to 1, NULL for no minimum.

max_n_levels_armvar

maximum number of levels in grouping variable arm_var. Use NULL for no maximum.

min_nrow

minimum number of observations in ADSL and ANL