This is teal module that generates a swimlane plot (bar plot with markers) for ADaM data
Usage
tm_g_swimlane(
label,
dataname,
bar_var,
bar_color_var = NULL,
sort_var = NULL,
marker_pos_var = NULL,
marker_shape_var = NULL,
marker_shape_opt = NULL,
marker_color_var = NULL,
marker_color_opt = NULL,
anno_txt_var = NULL,
vref_line = NULL,
plot_height = c(1200L, 400L, 5000L),
plot_width = NULL,
pre_output = NULL,
post_output = NULL,
x_label = "Time from First Treatment (Day)"
)
Arguments
- label
(
character(1)
)
menu item label of the module in the teal app.- dataname
analysis data used for plotting, needs to be available in the list passed to the
data
argument ofinit
. If no markers are to be plotted in the module, "ADSL" should be the input. If markers are to be plotted, data name for the marker data should be the input- bar_var
(
choices_selected
) subject-level numeric variable from dataset to plot as the bar length- bar_color_var
(
choices_selected
) color by variable (subject-level)- sort_var
(
choices_selected
) sort by variable (subject-level)- marker_pos_var
(
choices_selected
) variable for marker position from marker data (Note: make sure that marker position has the same relative start day as bar length variablebar_var
)- marker_shape_var
(
choices_selected
) marker shape variable from marker data- marker_shape_opt
aesthetic values to map shape values (named vector to map shape values to each name). If not
NULL
, please make sure this contains all possible values formarker_shape_var
values, otherwise shape will be assigned byggplot
default- marker_color_var
marker color variable from marker data
- marker_color_opt
aesthetic values to map color values (named vector to map color values to each name). If not
NULL
, please make sure this contains all possible values formarker_color_var
values, otherwise color will be assigned byggplot
default- anno_txt_var
character vector with subject-level variable names that are selected as annotation
- vref_line
vertical reference lines
- 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.- x_label
the label of the x axis
Value
the teal::module()
object.
Author
Ting Qi (qit3) qit3@gene.com
Examples
# Example using stream (ADaM) dataset
library(dplyr)
ADSL <- rADSL
ADRS <- rADRS
ADRS <- ADRS %>%
dplyr::filter(PARAMCD == "LSTASDI" & DCSREAS == "Death") %>%
mutate(AVALC = DCSREAS, ADY = EOSDY) %>%
base::rbind(ADRS %>% dplyr::filter(PARAMCD == "OVRINV" & AVALC != "NE")) %>%
arrange(USUBJID)
x <- init(
data = cdisc_data(
cdisc_dataset("ADSL", ADSL, code = "ADSL <- rADSL"),
cdisc_dataset("ADRS", ADRS,
code = "ADRS <- rADRS
ADRS <- ADRS %>% dplyr::filter(PARAMCD == 'LSTASDI' & DCSREAS == 'Death') %>%
mutate(AVALC = DCSREAS, ADY = EOSDY) %>%
rbind(ADRS %>% dplyr::filter(PARAMCD == 'OVRINV' & AVALC != 'NE')) %>%
arrange(USUBJID)"
),
check = TRUE
),
modules = modules(
tm_g_swimlane(
label = "Swimlane Plot",
dataname = "ADRS",
bar_var = choices_selected(selected = "TRTDURD", choices = c("TRTDURD", "EOSDY")),
bar_color_var = choices_selected(
selected = "EOSSTT",
choices = c("EOSSTT", "ARM", "ARMCD", "ACTARM", "ACTARMCD", "AGEGR1", "SEX")
),
sort_var = choices_selected(
selected = "ACTARMCD",
choices = c("USUBJID", "SITEID", "ACTARMCD", "TRTDURD")
),
marker_pos_var = choices_selected(selected = "ADY", choices = c("ADY")),
marker_shape_var = choices_selected(selected = "AVALC", c("AVALC", "AVISIT")),
marker_shape_opt = c("CR" = 16, "PR" = 17, "SD" = 18, "PD" = 15, "Death" = 8),
marker_color_var = choices_selected(
selected = "AVALC",
choices = c("AVALC", "AVISIT")
),
marker_color_opt = c(
"CR" = "green", "PR" = "blue", "SD" = "goldenrod",
"PD" = "red", "Death" = "black"
),
vref_line = c(30, 60),
anno_txt_var = choices_selected(
selected = c("ACTARM", "SEX"),
choices = c(
"ARM", "ARMCD", "ACTARM", "ACTARMCD", "AGEGR1",
"SEX", "RACE", "COUNTRY", "DCSREAS", "DCSREASP"
)
)
)
)
)
#> [INFO] 2022-06-17 09:56:31.6196 pid:1163 token:[] teal.osprey Initializing tm_g_swimlane
if (FALSE) {
shinyApp(x$ui, x$server)
}