-
-
Notifications
You must be signed in to change notification settings - Fork 18
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
Incrementally initializing the test apps so it becomes easier to review the tests. #1132
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
app_driver_tm_g_ipp <- function() { | ||
data <- teal_data() %>% | ||
within({ | ||
library(nestcolor) | ||
library(dplyr) | ||
ADSL <- tmc_ex_adsl %>% | ||
slice(1:20) %>% | ||
df_explicit_na() | ||
ADLB <- tmc_ex_adlb %>% | ||
filter(USUBJID %in% ADSL$USUBJID) %>% | ||
df_explicit_na() %>% | ||
filter(AVISIT != "SCREENING") | ||
}) | ||
|
||
datanames <- c("ADSL", "ADLB") | ||
teal.data::datanames(data) <- datanames | ||
teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[datanames] | ||
|
||
init_teal_app_driver( | ||
data = data, | ||
modules = teal::modules( | ||
tm_g_ipp( | ||
label = "Individual Patient Plot", | ||
dataname = "ADLB", | ||
arm_var = teal.transform::choices_selected( | ||
teal.transform::value_choices(data[["ADLB"]], "ARMCD"), | ||
"ARM A" | ||
), | ||
paramcd = teal.transform::choices_selected( | ||
teal.transform::value_choices(data[["ADLB"]], "PARAMCD"), | ||
"ALT" | ||
), | ||
aval_var = teal.transform::choices_selected( | ||
teal.transform::variable_choices(data[["ADLB"]], c("AVAL", "CHG")), | ||
"AVAL" | ||
), | ||
avalu_var = teal.transform::choices_selected( | ||
teal.transform::variable_choices(data[["ADLB"]], c("AVALU")), | ||
"AVALU", | ||
fixed = TRUE | ||
), | ||
id_var = teal.transform::choices_selected( | ||
teal.transform::variable_choices(data[["ADLB"]], c("USUBJID")), | ||
"USUBJID", | ||
fixed = TRUE | ||
), | ||
visit_var = teal.transform::choices_selected( | ||
teal.transform::variable_choices(data[["ADLB"]], c("AVISIT")), | ||
"AVISIT" | ||
), | ||
baseline_var = teal.transform::choices_selected( | ||
teal.transform::variable_choices(data[["ADLB"]], c("BASE")), | ||
"BASE", | ||
fixed = TRUE | ||
), | ||
add_baseline_hline = FALSE, | ||
separate_by_obs = FALSE | ||
) | ||
) | ||
) | ||
} | ||
|
||
testthat::test_that("e2e - tm_g_ipp: Module initializes in teal without errors and produces plot output.", { | ||
skip_if_too_deep(5) | ||
app_driver <- app_driver_tm_g_ipp() | ||
app_driver$expect_no_shiny_error() | ||
app_driver$expect_no_validation_error() | ||
|
||
testthat::expect_match( | ||
app_driver$get_attr( | ||
app_driver$active_module_element("myplot-plot_main > img"), | ||
"src" | ||
), | ||
"data:image/png;base64," | ||
) | ||
app_driver$stop() | ||
}) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
app_driver_tm_g_forest_tte <- function() { | ||
data <- teal.data::teal_data() %>% | ||
within({ | ||
library(nestcolor) | ||
library(formatters) | ||
|
||
ADSL <- tmc_ex_adsl | ||
ADTTE <- tmc_ex_adtte | ||
ADSL$RACE <- droplevels(ADSL$RACE) %>% | ||
with_label("Race") | ||
}) | ||
datanames <- c("ADSL", "ADTTE") | ||
teal.data::datanames(data) <- datanames | ||
teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[datanames] | ||
|
||
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") | ||
) | ||
) | ||
|
||
init_teal_app_driver( | ||
data = data, | ||
modules = teal::modules( | ||
tm_g_forest_tte( | ||
label = "Forest Survival", | ||
dataname = "ADTTE", | ||
arm_var = teal.transform::choices_selected( | ||
teal.transform::variable_choices(data[["ADSL"]], c("ARM", "ARMCD")), | ||
"ARMCD" | ||
), | ||
arm_ref_comp = arm_ref_comp, | ||
paramcd = teal.transform::choices_selected( | ||
teal.transform::value_choices(data[["ADTTE"]], "PARAMCD", "PARAM"), | ||
"OS" | ||
), | ||
subgroup_var = teal.transform::choices_selected( | ||
teal.transform::variable_choices(data[["ADSL"]], names(data[["ADSL"]])), | ||
c("BMRKR2", "SEX") | ||
), | ||
strata_var = teal.transform::choices_selected( | ||
teal.transform::variable_choices(data[["ADSL"]], c("STRATA1", "STRATA2")), | ||
"STRATA2" | ||
) | ||
) | ||
) | ||
) | ||
} | ||
|
||
testthat::test_that("e2e - tm_g_forest_tte: Module initializes in teal without errors and produces plot output.", { | ||
skip_if_too_deep(5) | ||
app_driver <- app_driver_tm_g_forest_tte() | ||
app_driver$expect_no_shiny_error() | ||
app_driver$expect_no_validation_error() | ||
|
||
testthat::expect_match( | ||
app_driver$get_attr( | ||
app_driver$active_module_element("myplot-plot_main > img"), | ||
"src" | ||
), | ||
"data:image/png;base64," | ||
) | ||
app_driver$stop() | ||
}) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
app_driver_tm_g_km <- function() { | ||
data <- teal.data::teal_data() %>% | ||
within({ | ||
ADSL <- tmc_ex_adsl | ||
ADTTE <- tmc_ex_adtte | ||
}) | ||
|
||
datanames <- c("ADSL", "ADTTE") | ||
teal.data::datanames(data) <- datanames | ||
teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[datanames] | ||
|
||
arm_ref_comp <- list( | ||
ACTARMCD = list( | ||
ref = "ARM B", | ||
comp = c("ARM A", "ARM C") | ||
), | ||
ARM = list( | ||
ref = "B: Placebo", | ||
comp = c("A: Drug X", "C: Combination") | ||
) | ||
) | ||
|
||
init_teal_app_driver( | ||
data = data, | ||
modules = teal::modules( | ||
tm_g_km( | ||
label = "Kaplan-Meier Plot", | ||
dataname = "ADTTE", | ||
arm_var = teal.transform::choices_selected( | ||
teal.transform::variable_choices(data[["ADSL"]], c("ARM", "ARMCD", "ACTARMCD")), | ||
"ARM" | ||
), | ||
paramcd = teal.transform::choices_selected( | ||
teal.transform::value_choices(data[["ADTTE"]], "PARAMCD", "PARAM"), | ||
"OS" | ||
), | ||
arm_ref_comp = arm_ref_comp, | ||
strata_var = teal.transform::choices_selected( | ||
teal.transform::variable_choices(data[["ADSL"]], c("SEX", "BMRKR2")), | ||
"SEX" | ||
), | ||
facet_var = teal.transform::choices_selected( | ||
teal.transform::variable_choices(data[["ADSL"]], c("SEX", "BMRKR2")), | ||
NULL | ||
) | ||
) | ||
) | ||
) | ||
} | ||
|
||
testthat::test_that("e2e - tm_g_km: Module initializes in teal without errors and produces plot output.", { | ||
skip_if_too_deep(5) | ||
app_driver <- app_driver_tm_g_km() | ||
app_driver$expect_no_shiny_error() | ||
app_driver$expect_no_validation_error() | ||
|
||
testthat::expect_match( | ||
app_driver$get_attr( | ||
app_driver$active_module_element("myplot-plot_main > img"), | ||
"src" | ||
), | ||
"data:image/png;base64," | ||
) | ||
app_driver$stop() | ||
}) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
app_driver_tm_g_lineplot <- function() { | ||
data <- teal.data::teal_data() %>% | ||
within({ | ||
library(dplyr) | ||
library(forcats) | ||
|
||
ADSL <- tmc_ex_adsl | ||
ADLB <- tmc_ex_adlb %>% | ||
mutate(AVISIT == fct_reorder(AVISIT, AVISITN, min)) | ||
}) | ||
|
||
datanames <- c("ADSL", "ADLB") | ||
teal.data::datanames(data) <- datanames | ||
teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[datanames] | ||
|
||
init_teal_app_driver( | ||
data = data, | ||
modules = teal::modules( | ||
tm_g_lineplot( | ||
label = "Line Plot", | ||
dataname = "ADLB", | ||
strata = teal.transform::choices_selected( | ||
teal.transform::variable_choices(data[["ADSL"]], c("ARM", "ARMCD", "ACTARMCD")), | ||
"ARM" | ||
), | ||
y = teal.transform::choices_selected( | ||
teal.transform::variable_choices(data[["ADLB"]], c("AVAL", "BASE", "CHG", "PCHG")), | ||
"AVAL" | ||
), | ||
param = teal.transform::choices_selected( | ||
teal.transform::value_choices(data[["ADLB"]], "PARAMCD", "PARAM"), | ||
"ALT" | ||
) | ||
) | ||
) | ||
) | ||
} | ||
|
||
testthat::test_that("e2e - tm_g_lineplot: Module initializes in teal without errors and produces plot output.", { | ||
skip_if_too_deep(5) | ||
app_driver <- app_driver_tm_g_lineplot() | ||
app_driver$expect_no_shiny_error() | ||
app_driver$expect_no_validation_error() | ||
|
||
testthat::expect_match( | ||
app_driver$get_attr( | ||
app_driver$active_module_element("myplot-plot_main > img"), | ||
"src" | ||
), | ||
"data:image/png;base64," | ||
) | ||
app_driver$stop() | ||
}) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
app_driver_tm_g_pp_adverse_events <- function() { # nolint: object_length | ||
data <- teal.data::teal_data() %>% | ||
within({ | ||
library(dplyr) | ||
ADAE <- tmc_ex_adae | ||
ADSL <- tmc_ex_adsl %>% | ||
filter(USUBJID %in% ADAE$USUBJID) | ||
}) | ||
|
||
datanames <- c("ADSL", "ADAE") | ||
teal.data::datanames(data) <- datanames | ||
teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[datanames] | ||
|
||
init_teal_app_driver( | ||
data = data, | ||
modules = teal::modules( | ||
tm_g_pp_adverse_events( | ||
label = "Adverse Events", | ||
dataname = "ADAE", | ||
parentname = "ADSL", | ||
patient_col = "USUBJID", | ||
plot_height = c(600L, 200L, 2000L), | ||
aeterm = teal.transform::choices_selected( | ||
choices = teal.transform::variable_choices(data[["ADAE"]], "AETERM"), | ||
selected = "AETERM" | ||
), | ||
tox_grade = teal.transform::choices_selected( | ||
choices = teal.transform::variable_choices(data[["ADAE"]], "AETOXGR"), | ||
selected = "AETOXGR" | ||
), | ||
causality = teal.transform::choices_selected( | ||
choices = teal.transform::variable_choices(data[["ADAE"]], "AEREL"), | ||
selected = "AEREL" | ||
), | ||
outcome = teal.transform::choices_selected( | ||
choices = teal.transform::variable_choices(data[["ADAE"]], "AEOUT"), | ||
selected = "AEOUT" | ||
), | ||
action = teal.transform::choices_selected( | ||
choices = teal.transform::variable_choices(data[["ADAE"]], "AEACN"), | ||
selected = "AEACN" | ||
), | ||
time = teal.transform::choices_selected( | ||
choices = teal.transform::variable_choices(data[["ADAE"]], "ASTDY"), | ||
selected = "ASTDY" | ||
), | ||
decod = NULL | ||
) | ||
) | ||
) | ||
} | ||
|
||
testthat::test_that( | ||
"e2e - tm_g_pp_adverse_events: Module initializes in teal without errors and produces plot output.", | ||
{ | ||
skip_if_too_deep(5) | ||
app_driver <- app_driver_tm_g_pp_adverse_events() | ||
app_driver$expect_no_shiny_error() | ||
app_driver$expect_no_validation_error() | ||
|
||
testthat::expect_match( | ||
app_driver$get_attr( | ||
app_driver$active_module_element("myplot-plot_main > img"), | ||
"src" | ||
), | ||
"data:image/png;base64," | ||
) | ||
app_driver$stop() | ||
} | ||
) |
This file contains 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
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,19 @@ | ||||||
app_driver_tm_g_km <- function() { | ||||||
|
||||||
} | ||||||
|
||||||
testthat::test_that("e2e - tm_g_km: Module initializes in teal without errors and produces plot output.", { | ||||||
skip_if_too_deep(5) | ||||||
app_driver <- app_driver_tm_g_km() | ||||||
app_driver$expect_no_shiny_error() | ||||||
app_driver$expect_no_validation_error() | ||||||
|
||||||
testthat::expect_match( | ||||||
app_driver$get_attr( | ||||||
app_driver$active_module_element("myplot-plot_main > img"), | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same reasoning as here https://github.com/insightsengineering/teal.modules.clinical/pull/1132/files#r1576318046 IMHO it would be better if we can go module by module, so we can focus on one module and catch such things.
Suggested change
|
||||||
"src" | ||||||
), | ||||||
"data:image/png;base64," | ||||||
) | ||||||
app_driver$stop() | ||||||
}) |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is stupid but
ui_g_adverse_events
usesteal.widgets::plot_with_settings_ui(id = ns("chart"))
Checkout the discussion about discrepancy in plot namespace name in here : ) insightsengineering/teal#1208 (comment)