This module produces a ggplot2::ggplot() type line plot, with optional summary table, for standard ADaM data.
Usage
tm_g_lineplot(
label,
dataname,
parentname = "ADSL",
strata = lifecycle::deprecated(),
group_var = teal.picks::variables(choices = c("ARM", "ARMCD", "ACTARMCD"), selected =
"ARM"),
x = teal.picks::variables("AVISIT", "AVISIT"),
y = teal.picks::variables(choices = c("AVAL", "BASE", "CHG", "PCHG"), selected =
"AVAL"),
y_unit = teal.picks::variables("AVALU", "AVALU"),
paramcd = teal.picks::picks(teal.picks::variables("PARAMCD", "PARAMCD", fixed = TRUE),
teal.picks::values(c("ALT", "CRP", "IGA"), "ALT", multiple = FALSE), check_dataset =
FALSE),
conf_level = teal.picks::values(c(0.95, 0.9, 0.8), 0.95),
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 toADSL.- strata
- group_var, x, y, y_unit
(
teal.picks::variables(),teal.picks::picks(), or legacychoices_selected)
encodings; legacy inputs are coerced with a deprecation warning.- paramcd
(
teal.picks::picks()or legacychoices_selectedfromvalue_choices())
parameter code filter: apicks()chain with thePARAMCDvariable and biomarkervalues(); defaults toALT/CRP/IGAwithALTselected.- conf_level
(
teal.picks::values(); legacyteal.transform::choices_selected()is deprecated but still accepted)
available confidence levels and default selection, each in the range (0, 1).- interval
(
characterorNULL)
names of the statistics that will be plotted as intervals. All the statistics indicated inintervalvariable must be present in the object returned bysfun, and be of adoubleornumerictype vector of length two. Setinterval = NULLif intervals should not be added to the plot.- mid
(
characterorNULL)
names of the statistics that will be plotted as midpoints. All the statistics indicated inmidvariable must be present in the object returned bysfun, and be of adoubleornumerictype vector of length one.- whiskers
(
character)
names of the interval whiskers that will be plotted. Names must match names of the list elementintervalthat will be returned bysfun(e.g.mean_ci_lwrelement ofsfun(x)[["mean_ci"]]). It is possible to specify one whisker only, or to suppress all whiskers by settinginterval = NULL.- table
(
characterorNULL)
names of the statistics that will be displayed in the table below the plot. All the statistics indicated intablevariable must be present in the object returned bysfun.- mid_type
(
string)
controls the type of themidplot, it can be point ("p"), line ("l"), or point and line ("pl").- mid_point_size
(
numeric(1))
font size of themidplot points.- table_font_size
(
numeric(1))
font size of the text in the table.- plot_height
(
numeric) optional
vector of length three withc(value, min, max). Specifies the height of the main plot and renders a slider on the plot to interactively adjust the plot height.- plot_width
(
numeric) optional
vector of length three withc(value, min, max). Specifies the width of the main plot and renders a slider on the plot to interactively adjust the plot width.- pre_output
(
shiny.tag) optional,
with text placed before the output to put the output into context. For example a title.- post_output
(
shiny.tag) optional,
with text placed after the output to put the output into context. For example theshiny::helpText()elements are useful.- ggplot2_args
-
(
ggplot2_args) optional
object created byteal.widgets::ggplot2_args()with settings for the module plot. For this module, this argument will only acceptggplot2_argsobject withlabslist of following child elements:title,subtitle,caption,y,lty. No other elements would be taken into account. The argument is merged with optionteal.ggplot2_argsand with default module arguments (hard coded in the module body).For more details, see the vignette:
vignette("custom-ggplot2-arguments", package = "teal.widgets"). - transformators
(
listofteal_transform_module) that will be applied to transform module's data input. To learn more checkvignette("transform-input-data", package = "teal").- decorators
-
(named
listof lists ofteal_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.
Decorating Module
This module generates the following objects, which can be modified in place using decorators:
plot(ggplot)
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.
Reporting
This module returns an object of class teal_module, that contains a server function.
Since the server function returns a teal_report object, this makes this module reportable, which means that
the reporting functionality will be turned on automatically by the teal framework.
For more information on reporting in teal, see the vignettes:
vignette("reportable-shiny-application", package = "teal.reporter")vignette("adding-support-for-reporting-to-custom-modules", package = "teal")
See also
The TLG Catalog where additional example apps implementing this module can be found.
Examples
library(nestcolor)
data <- teal_data()
data <- within(data, {
library(teal.modules.clinical)
library(dplyr)
library(forcats)
ADSL <- tmc_ex_adsl
ADLB <- tmc_ex_adlb %>%
mutate(AVISIT == fct_reorder(AVISIT, AVISITN, min))
})
join_keys(data) <- default_cdisc_join_keys[names(data)]
app <- init(
data = data,
modules = modules(
tm_g_lineplot(
label = "Line Plot",
dataname = "ADLB",
parentname = "ADSL",
group_var = variables(
choices = c("ARM", "ARMCD", "ACTARMCD"),
selected = "ARM",
multiple = FALSE
),
y = variables(
choices = c("AVAL", "BASE", "CHG", "PCHG"),
selected = "AVAL",
multiple = FALSE
),
paramcd = picks(
variables("PARAMCD", fixed = TRUE),
values(selected = "ALT", multiple = FALSE),
check_dataset = FALSE
)
)
)
)
#> Initializing tm_g_lineplot
#> Warning: rlang::dots_list(..., .ignore_empty = "trailing")
#> - Setting explicit `selected` while `choices` are delayed (set using `tidyselect`) doesn't guarantee that `selected` is a subset of `choices`.
if (interactive()) {
shinyApp(app$ui, app$server)
}