-
-
Notifications
You must be signed in to change notification settings - Fork 19
WIP demo app with all modules #1408
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
m7pr
wants to merge
5
commits into
teal_reportable
Choose a base branch
from
demo
base: teal_reportable
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Here are the missing modules:
|
Here's the full "manual" app for part 3: # Load packages
pkgload::load_all("../teal.logger", export_all = FALSE)
pkgload::load_all("../teal.code", export_all = FALSE)
pkgload::load_all("../teal.data", export_all = FALSE)
pkgload::load_all("../teal.widgets", export_all = FALSE)
pkgload::load_all("../teal.slice", export_all = FALSE)
pkgload::load_all("../teal.reporter", export_all = FALSE)
pkgload::load_all("../teal", export_all = FALSE)
pkgload::load_all("../teal.modules.clinical", export_all = FALSE)
# Example below
data <- teal_data()
data <- within(data, {
library(dplyr)
ADSL <- teal.modules.clinical::tmc_ex_adsl
ADQS <- teal.modules.clinical::tmc_ex_adqs %>%
filter(ABLFL != "Y" & ABLFL2 != "Y") %>%
mutate(
AVISIT = as.factor(AVISIT),
AVISITN = rank(AVISITN) %>%
as.factor() %>%
as.numeric() %>%
as.factor(),
AVALBIN = AVAL < 50 # Just as an example to get a binary endpoint.
) %>%
droplevels()
# ci
ADLB <- teal.modules.clinical::tmc_ex_adlb %>%
filter(USUBJID %in% ADSL$USUBJID) %>%
df_explicit_na()
# forest
ADRS <- teal.modules.clinical::tmc_ex_adrs %>%
mutate(AVALC = tern::d_onco_rsp_label(AVALC) %>%
formatters::with_label("Character Result/Finding")) %>%
filter(PARAMCD != "OVRINV" | AVISIT == "FOLLOW UP")
# forest tte
ADTTE <- teal.modules.clinical::tmc_ex_adtte
ADSL$RACE <- droplevels(ADSL$RACE) %>% formatters::with_label("Race")
# patient timeline
ADAE <- teal.modules.clinical::tmc_ex_adae
ADSL <- ADSL %>%
filter(USUBJID %in% ADAE$USUBJID)
ADCM <- teal.modules.clinical::tmc_ex_adcm %>%
mutate(
CMSTDY = case_when(
CMCAT == "medcl B" ~ 20,
CMCAT == "medcl C" ~ 150,
TRUE ~ 1
) %>% with_label("Study Day of Start of Medication"),
CMENDY = case_when(
CMCAT == "medcl B" ~ 700,
CMCAT == "medcl C" ~ 1000,
TRUE ~ 500
) %>% with_label("Study Day of End of Medication"),
CMASTDTM = ASTDTM,
CMAENDTM = AENDTM
)
ADCM$CMASTDTM <- ADCM$ASTDTM
ADCM$CMAENDTM <- ADCM$AENDTM
})
teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)]
ADSL <- data[["ADSL"]]
ADLB <- data[["ADLB"]]
ADRS <- data[["ADRS"]]
ADTTE <- data[["ADTTE"]]
ADQS <- data[["ADQS"]]
ADAE <- data[["ADAE"]]
ADCM <- data[["ADCM"]]
# Define arm reference and comparison
arm_ref_comp <- list(
ARM = list(
ref = "B: Placebo",
comp = c("A: Drug X", "C: Combination")
),
ARMCD = list(
ref = "ARM B",
comp = c("ARM A", "ARM C")
)
)
adcm_keys <- c("STUDYID", "USUBJID", "ASTDTM", "CMSEQ", "ATC1", "ATC2", "ATC3", "ATC4")
join_keys(data)["ADCM", "ADCM"] <- adcm_keys
join_keys(data)["ADAE", "ADCM"] <- c("STUDYID", "USUBJID")
app <- init(
data = data,
modules = modules(
tm_a_gee(
label = "a_gee",
dataname = "ADQS",
aval_var = choices_selected("AVALBIN", fixed = TRUE),
id_var = choices_selected(c("USUBJID", "SUBJID"), "USUBJID"),
arm_var = choices_selected(c("ARM", "ARMCD"), "ARM"),
visit_var = choices_selected(c("AVISIT", "AVISITN"), "AVISIT"),
paramcd = choices_selected(
choices = value_choices(data[["ADQS"]], "PARAMCD", "PARAM"),
selected = "FKSI-FWB"
),
cov_var = choices_selected(c("BASE", "AGE", "SEX", "BASE:AVISIT"), NULL)
),
tm_g_ci(
label = "g_ci",
x_var = data_extract_spec(
dataname = "ADSL",
select = select_spec(
choices = c("ARMCD", "BMRKR2"), selected = c("ARMCD"), multiple = FALSE, fixed = FALSE
)
),
y_var = data_extract_spec(
dataname = "ADLB",
filter = list(
filter_spec(vars = "PARAMCD", choices = levels(ADLB$PARAMCD), selected = levels(ADLB$PARAMCD)[1], multiple = FALSE, label = "Select lab:"),
filter_spec(vars = "AVISIT", choices = levels(ADLB$AVISIT), selected = levels(ADLB$AVISIT)[1], multiple = FALSE, label = "Select visit:")
),
select = select_spec(
label = "Analyzed Value",
choices = c("AVAL", "CHG"),
selected = "AVAL",
multiple = FALSE,
fixed = FALSE
)
),
color = data_extract_spec(
dataname = "ADSL",
select = select_spec(
label = "Color by variable",
choices = c("SEX", "STRATA1", "STRATA2"),
selected = c("STRATA1"),
multiple = FALSE,
fixed = FALSE
)
)
),
tm_g_forest_tte(
label = "g_forest_tte",
dataname = "ADTTE",
arm_var = choices_selected(
variable_choices(ADSL, c("ARM", "ARMCD")),
"ARMCD"
),
arm_ref_comp = arm_ref_comp,
paramcd = choices_selected(
value_choices(ADTTE, "PARAMCD", "PARAM"),
"OS"
),
subgroup_var = choices_selected(
variable_choices(ADSL, names(ADSL)),
c("BMRKR2", "SEX")
),
strata_var = choices_selected(
variable_choices(ADSL, c("STRATA1", "STRATA2")),
"STRATA2"
)
),
tm_g_forest_rsp(
label = "g_forest_rsp",
dataname = "ADRS",
arm_var = choices_selected(
variable_choices(ADSL, c("ARM", "ARMCD")),
"ARMCD"
),
arm_ref_comp = arm_ref_comp,
paramcd = choices_selected(
value_choices(ADRS, "PARAMCD", "PARAM"),
"INVET"
),
subgroup_var = choices_selected(
variable_choices(ADSL, names(ADSL)),
c("BMRKR2", "SEX")
),
strata_var = choices_selected(
variable_choices(ADSL, c("STRATA1", "STRATA2")),
"STRATA2"
),
plot_height = c(600L, 200L, 2000L),
default_responses = list(
BESRSPI = list(
rsp = c("Stable Disease (SD)", "Not Evaluable (NE)"),
levels = c(
"Complete Response (CR)", "Partial Response (PR)", "Stable Disease (SD)",
"Progressive Disease (PD)", "Not Evaluable (NE)"
)
),
INVET = list(
rsp = c("Complete Response (CR)", "Partial Response (PR)"),
levels = c(
"Complete Response (CR)", "Not Evaluable (NE)", "Partial Response (PR)",
"Progressive Disease (PD)", "Stable Disease (SD)"
)
),
OVRINV = list(
rsp = c("Progressive Disease (PD)", "Stable Disease (SD)"),
levels = c("Progressive Disease (PD)", "Stable Disease (SD)", "Not Evaluable (NE)")
)
)
),
tm_g_ipp(
label = "g_ipp",
dataname = "ADLB",
arm_var = choices_selected(
value_choices(ADLB, "ARMCD"),
"ARM A"
),
paramcd = choices_selected(
value_choices(ADLB, "PARAMCD"),
"ALT"
),
aval_var = choices_selected(
variable_choices(ADLB, c("AVAL", "CHG")),
"AVAL"
),
avalu_var = choices_selected(
variable_choices(ADLB, c("AVALU")),
"AVALU",
fixed = TRUE
),
id_var = choices_selected(
variable_choices(ADLB, c("USUBJID")),
"USUBJID",
fixed = TRUE
),
visit_var = choices_selected(
variable_choices(ADLB, c("AVISIT")),
"AVISIT"
),
baseline_var = choices_selected(
variable_choices(ADLB, c("BASE")),
"BASE",
fixed = TRUE
),
add_baseline_hline = FALSE,
separate_by_obs = FALSE
),
tm_g_pp_patient_timeline(
label = "pp_patient_timeline",
dataname_adae = "ADAE",
dataname_adcm = "ADCM",
parentname = "ADSL",
patient_col = "USUBJID",
plot_height = c(600L, 200L, 2000L),
cmdecod = choices_selected(
choices = variable_choices(data[["ADCM"]], "CMDECOD"),
selected = "CMDECOD",
),
aeterm = choices_selected(
choices = variable_choices(data[["ADAE"]], "AETERM"),
selected = c("AETERM")
),
aetime_start = choices_selected(
choices = variable_choices(data[["ADAE"]], "ASTDTM"),
selected = c("ASTDTM")
),
aetime_end = choices_selected(
choices = variable_choices(data[["ADAE"]], "AENDTM"),
selected = c("AENDTM")
),
dstime_start = choices_selected(
choices = variable_choices(data[["ADCM"]], "CMASTDTM"),
selected = c("CMASTDTM")
),
dstime_end = choices_selected(
choices = variable_choices(data[["ADCM"]], "CMAENDTM"),
selected = c("CMAENDTM")
),
aerelday_start = choices_selected(
choices = variable_choices(data[["ADAE"]], "ASTDY"),
selected = c("ASTDY")
),
aerelday_end = choices_selected(
choices = variable_choices(data[["ADAE"]], "AENDY"),
selected = c("AENDY")
),
dsrelday_start = choices_selected(
choices = variable_choices(data[["ADCM"]], "ASTDY"),
selected = c("ASTDY")
),
dsrelday_end = choices_selected(
choices = variable_choices(data[["ADCM"]], "AENDY"),
selected = c("AENDY")
)
),
tm_g_pp_therapy(
label = "g_pp_therapy",
dataname = "ADCM",
parentname = "ADSL",
patient_col = "USUBJID",
plot_height = c(600L, 200L, 2000L),
atirel = choices_selected(
choices = variable_choices(ADCM, "ATIREL"),
selected = c("ATIREL")
),
cmdecod = choices_selected(
choices = variable_choices(ADCM, "CMDECOD"),
selected = "CMDECOD"
),
cmindc = choices_selected(
choices = variable_choices(ADCM, "CMINDC"),
selected = "CMINDC"
),
cmdose = choices_selected(
choices = variable_choices(ADCM, "CMDOSE"),
selected = "CMDOSE"
),
cmtrt = choices_selected(
choices = variable_choices(ADCM, "CMTRT"),
selected = "CMTRT"
),
cmdosu = choices_selected(
choices = variable_choices(ADCM, "CMDOSU"),
selected = c("CMDOSU")
),
cmroute = choices_selected(
choices = variable_choices(ADCM, "CMROUTE"),
selected = "CMROUTE"
),
cmdosfrq = choices_selected(
choices = variable_choices(ADCM, "CMDOSFRQ"),
selected = "CMDOSFRQ"
),
cmstdy = choices_selected(
choices = variable_choices(ADCM, "ASTDY"),
selected = "ASTDY"
),
cmendy = choices_selected(
choices = variable_choices(ADCM, "AENDY"),
selected = "AENDY"
)
),
tm_t_abnormality_by_worst_grade(
label = "t_abnormality_by_worst_grade",
dataname = "ADLB",
arm_var = choices_selected(
choices = variable_choices(ADSL, subset = c("ARM", "ARMCD")),
selected = "ARM"
),
paramcd = choices_selected(
choices = value_choices(ADLB, "PARAMCD", "PARAM"),
selected = c("ALT", "CRP", "IGA")
),
add_total = FALSE
),
tm_t_ancova(
label = "t_ancova",
dataname = "ADQS",
avisit = choices_selected(
choices = value_choices(ADQS, "AVISIT"),
selected = "WEEK 1 DAY 8"
),
arm_var = choices_selected(
choices = variable_choices(ADSL, c("ARM", "ACTARMCD", "ARMCD")),
selected = "ARMCD"
),
arm_ref_comp = arm_ref_comp,
aval_var = choices_selected(
choices = variable_choices(ADQS, c("CHG", "AVAL")),
selected = "CHG"
),
cov_var = choices_selected(
choices = variable_choices(ADQS, c("BASE", "STRATA1", "SEX")),
selected = "STRATA1"
),
paramcd = choices_selected(
choices = value_choices(ADQS, "PARAMCD", "PARAM"),
selected = "FKSI-FWB"
),
interact_var = choices_selected(
choices = variable_choices(ADQS, c("BASE", "STRATA1", "SEX")),
selected = "STRATA1"
)
),
tm_t_glm_counts(
label = "t_glm_counts",
dataname = "ADTTE",
arm_var = choices_selected(
variable_choices(ADTTE, c("ARM", "ARMCD", "ACTARMCD")),
"ARMCD"
),
arm_ref_comp = arm_ref_comp,
aval_var = choices_selected(
variable_choices(ADTTE, "AVAL"),
"AVAL"
),
strata_var = choices_selected(
variable_choices(ADSL, "SEX"),
NULL
),
offset_var = choices_selected(
variable_choices(ADSL, "AGE"),
NULL
),
cov_var = choices_selected(
variable_choices(ADTTE, "SITEID"),
NULL
)
),
tm_t_tte(
label = "t_tte",
dataname = "ADTTE",
arm_var = choices_selected(
variable_choices(ADSL, c("ARM", "ARMCD", "ACTARMCD")),
"ARM"
),
arm_ref_comp = arm_ref_comp,
paramcd = choices_selected(
value_choices(ADTTE, "PARAMCD", "PARAM"),
"OS"
),
strata_var = choices_selected(
variable_choices(ADSL, c("SEX", "BMRKR2")),
"SEX"
),
time_points = choices_selected(c(182, 243), 182),
event_desc_var = choices_selected(
variable_choices(ADTTE, "EVNTDESC"),
"EVNTDESC",
fixed = TRUE
)
)
),
filter = teal_slices(
teal_slice("ADSL", "SAFFL", selected = "Y", id = "ts1"),
teal_slice("ADLB", "ONTRTFL", selected = "Y", id = "ts2"),
teal_slice("ADLB", "AVISIT", selected = c("BASELINE", "WEEK 1 DAY 8", "WEEK 2 DAY 15", "WEEK 3 DAY 22"), id = "ts3"),
module_specific = TRUE,
mapping = list(
"g_ipp" = "ts3",
"t_abnormality_by_worst_grade" = c("ts1", "ts2")
)
)
) |> shiny::runApp() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
WIP