This guide will show you how set of the pharmaverse packages can be used to create a a Shiny APP using demographic module end-to-end, using the {admiral} ADSL data as an input.
The eight packages used with a brief description of their purpose are as follows:
{teal.widgets
: provides various widgets for teal applications.{teal.logger
: provides a unified setup for generating logs using the logger package.{teal.code
: provides tools to store code and an execution environment associated with it.{teal.data
: creates the data needed for teal applications.{teal.slice
: used in the development of teal shiny modules{teal.transform
: contains functions and shiny modules for extracting and merging data within the teal framework.{teal
: is a shiny-based interactive exploration framework for analyzing data{teal.modules.clinical
: contains a set of standard teal modules to be used with CDISC data in order to generate many of the standard outputs used in clinical trialsIn this exmaple it is important to understand {teal.modules.clinical
in order to modify parameters to the teal module: tm_t_summary
.
After installation of packages, the first step is to load our pharmaverse packages and input data.
options(repos = c(
pharmaverse = 'https://pharmaverse.r-universe.dev',
CRAN = 'https://cloud.r-project.org'))
library(admiral)
library(rtables)
library(tern)
library(teal.widgets)
library(teal.logger)
library(teal.code)
library(teal.data)
library(teal.slice)
library(teal.transform)
library(teal)
library(teal.modules.clinical)
library(dplyr)
# Read in input ADaM data
data("admiral_adsl")
In the first step we are going to encode missing entries across groups of categorical variables in a data frame adsl
.
ADSL <- df_explicit_na(admiral_adsl)
Now we will add some pre-processing.
ADSL <- ADSL %>%
mutate(
SEX = factor(case_when(
SEX == "M" ~ "Male",
SEX == "F" ~ "Female",
SEX == "U" ~ "Unknown",
SEX == "UNDIFFERENTIATED" ~ "Undifferentiated"
))
)
Now we create the Shiny APP based on the module: tm_t_summary
. Please note that the above two pre-processing steps are included in the code section below to allow reproducibility of the code.
app <- init(
data = cdisc_data(
cdisc_dataset("ADSL", ADSL),
code = 'data("admiral_adsl")
ADSL <- df_explicit_na(admiral_adsl)
ADSL <- ADSL %>%
mutate(
SEX = factor(case_when(
SEX == "M" ~ "Male",
SEX == "F" ~ "Female",
SEX == "U" ~ "Unknown",
SEX == "UNDIFFERENTIATED" ~ "Undifferentiated"
))
) ',
check = TRUE
),
modules = modules(
tm_t_summary(
label = "Demographic Table",
dataname = "ADSL",
arm_var = choices_selected(c("ARM", "ARMCD"), "ARM"),
summarize_vars = choices_selected(
c("SEX", "RACE", "AGEGR1"),
c("SEX", "RACE")
),
useNA = "ifany"
)
)
)
## [INFO] 2022-08-25 09:53:33.5526 pid:6286 token:[] teal.modules.clinical Initializing tm_t_summary
Now we run the shiny APP. Please note that parameter option is only used to control rendering of the Shiny APP.
shinyApp(app$ui, app$server,
options = list(width = 1200, height= 600))
While this code won’t work, as this website is static - you can see an example here: https://genentech.shinyapps.io/teal_efficacy/