Usage
tm_g_butterfly(
label,
dataname,
filter_var = NULL,
right_var,
left_var,
category_var,
color_by_var,
count_by_var,
facet_var = NULL,
sort_by_var = teal.transform::choices_selected(selected = "count", choices = c("count",
"alphabetical")),
legend_on = TRUE,
plot_height = c(600L, 200L, 2000L),
plot_width = NULL,
pre_output = NULL,
post_output = NULL
)
Arguments
- label
(
character(1)
)
menu item label of the module in the teal app.- dataname
(
character(1)
)
analysis data used in the teal module, needs to be available in the list passed to thedata
argument ofteal::init()
.- filter_var
(
choices_selected
) variable name of data filter, please see details regarding expected values, default isNULL
.choices
vector withfilter_var
choices, default isNULL
- right_var
(
choices_selected
) dichotomization variable for right side- left_var
(
choices_selected
) dichotomization variable for left side- category_var
(
choices_selected
) category (y axis) variable- color_by_var
(
choices_selected
) variable defines color blocks within each bar- count_by_var
(
choices_selected
) variable defines how x axis is calculated- facet_var
(
choices_selected
) variable for row facets- sort_by_var
(
choices_selected
) argument for order of class and term elements in table, default here is "count"- legend_on
(
boolean
) value for whether legend is displayed- plot_height
(
numeric(3)
)
vector to indicate default value, minimum and maximum values.- plot_width
(
numeric(3)
)
vector to indicate default value, minimum and maximum values.- 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.
Value
the teal::module()
object.
Details
filter_var
option is designed to work in conjunction with
filtering function provided by teal
(encoding panel on the right
hand side of the shiny app). It can be used as quick access to predefined
subsets of the domain datasets (not subject-level dataset) to be used for
analysis, denoted by an value of "Y". Each variable within the
filter_var_choices
is expected to contain values of either "Y" or
"N". If multiple variables are selected as filter_var
, only
observations with "Y" value in each and every selected variables will be
used for subsequent analysis. Flag variables (from ADaM
datasets) can be
used directly as filter.
Examples
# Example using stream (ADaM) dataset
library(dplyr)
library(nestcolor)
set.seed(23)
ADSL <- osprey::rADSL
ADAE <- osprey::rADAE
ADSL <- mutate(ADSL, DOSE = paste(sample(1:3, n(), replace = TRUE), "UG"))
ADAE <- mutate(
ADAE,
flag1 = ifelse(AETOXGR == 1, 1, 0),
flag2 = ifelse(AETOXGR == 2, 1, 0),
flag3 = ifelse(AETOXGR == 3, 1, 0),
flag1_filt = rep("Y", n())
)
app <- init(
data = cdisc_data(
cdisc_dataset("ADSL", ADSL,
code = "ADSL <- osprey::rADSL
set.seed(23)
ADSL <- mutate(ADSL, DOSE = paste(sample(1:3, n(), replace = TRUE), 'UG'))"
),
cdisc_dataset("ADAE", ADAE,
code = "ADAE <- osprey::rADAE
ADAE <- mutate(ADAE,
flag1 = ifelse(AETOXGR == 1, 1, 0),
flag2 = ifelse(AETOXGR == 2, 1, 0),
flag3 = ifelse(AETOXGR == 3, 1, 0),
flag1_filt = rep('Y', n()))"
),
check = TRUE
),
modules = modules(
tm_g_butterfly(
label = "Butterfly Plot",
dataname = "ADAE",
right_var = teal.transform::choices_selected(
selected = "SEX",
choices = c("SEX", "ARM", "RACE")
),
left_var = teal.transform::choices_selected(
selected = "RACE",
choices = c("SEX", "ARM", "RACE")
),
category_var = teal.transform::choices_selected(
selected = "AEBODSYS",
choices = c("AEDECOD", "AEBODSYS")
),
color_by_var = teal.transform::choices_selected(
selected = "AETOXGR",
choices = c("AETOXGR", "None")
),
count_by_var = teal.transform::choices_selected(
selected = "# of patients",
choices = c("# of patients", "# of AEs")
),
facet_var = teal.transform::choices_selected(
selected = NULL,
choices = c("RACE", "SEX", "ARM")
),
sort_by_var = teal.transform::choices_selected(
selected = "count",
choices = c("count", "alphabetical")
),
legend_on = TRUE,
plot_height = c(600, 200, 2000)
)
)
)
#> [INFO] 2023-08-14 13:53:43.9833 pid:1120 token:[] teal.osprey Initializing tm_g_butterfly
if (interactive()) {
shinyApp(app$ui, app$server)
}