library(teal.modules.clinical)
library(nestcolor)
ADSL <- tmc_ex_adsl
ADAE <- tmc_ex_adae
app <- init(
data = cdisc_data(
ADSL = ADSL,
ADAE = ADAE,
code = "
ADSL <- tmc_ex_adsl
ADAE <- tmc_ex_adae
"
),
modules = list(
tm_g_barchart_simple(
label = "ADAE Analysis",
x = data_extract_spec(
dataname = "ADAE",
select = select_spec(
choices = variable_choices(
ADAE,
c(
"ARM", "ACTARM", "SEX",
"RACE", "SAFFL", "STRATA2"
)
),
selected = "ACTARM",
multiple = FALSE
)
)
)
)
)
Try it out in Shinylive
Open
in Shinylive
Consider consulting the documentation and examples of each module
(e.g. ?tm_g_barchart_simple
). In many, you can also find
useful links to the TLG
Catalog where additional example apps can be found.
teal.modules.clinical
exports modules and needs support
from other libraries to run a teal
app and flesh out its
functionality. In the example above, tm_g_barchart_simple()
is the only function from teal.modules.clinical
whereas
init()
is a teal
function,
data_extract_spec()
, select_spec()
, and
variable_choices()
are teal.transform
functions, and cdisc_data()
is a teal.data
function.
Let’s break the above app down into pieces:
library(teal.modules.clinical)
library(nestcolor)
The above lines load the libraries used in this example. We will use
the example data provided in the teal.modules.clinical
package:
ADSL <- tmc_ex_adsl
ADAE <- tmc_ex_adae
nestcolor
is an optional package that can be loaded in
to apply the standardized NEST color palette to all module plots.
There is no need to load teal
as
teal.modules.clinical
already depends on it.
In the next step, we use teal
to create
shiny
UI and server functions that we can launch using
shiny
. The data
argument tells
teal
about the input data - the ADaM datasets
ADSL
and ADAE
- and the modules
argument indicates the modules included in the application. Here, we
include only one module: tm_g_barchart_simple()
.
app <- init(
data = cdisc_data(
ADSL = ADSL,
ADAE = ADAE,
code = "
ADSL <- tmc_ex_adsl
ADAE <- tmc_ex_adae
"
),
modules = list(
tm_g_barchart_simple(
label = "ADAE Analysis",
x = data_extract_spec(
dataname = "ADAE",
select = select_spec(
choices = variable_choices(
ADAE,
c(
"ARM", "ACTARM", "SEX",
"RACE", "SAFFL", "STRATA2"
)
),
selected = "ACTARM",
multiple = FALSE
)
)
)
)
)
Finally, we use shiny
to launch the application:
if (interactive()) shinyApp(app$ui, app$server)
Some teal.modules.clinical
modules allow for the
specification of arguments using
teal.transform::choices_selected()
, such as the
tm_t_summary()
module in the following example.
ADSL <- tmc_ex_adsl
app <- init(
data = cdisc_data(ADSL = ADSL, code = "ADSL <- tmc_ex_adsl"),
modules = list(
tm_t_summary(
label = "Demographic Table",
dataname = "ADSL",
arm_var = choices_selected(choices = c("ARM", "ARMCD"), selected = "ARM"),
summarize_vars = choices_selected(
choices = c("SEX", "RACE", "BMRKR2", "EOSDY", "DCSREAS", "AGE"),
selected = c("SEX", "RACE")
)
)
)
)
if (interactive()) shinyApp(app$ui, app$server)
Please refer to the API
reference of specific modules for more examples and information on
the customization options available.