Skip to content
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

370 again integration test failures because of snapshot changes #371

Merged
merged 6 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions R/argument_convention.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#' @param plot_width (`list`)\cr list of integers to set the default, minimum,
#' and maximum plot width.
#' @param filter_panel_api (`FilterPanelAPI`)\cr object describing the actual filter panel API.
#' @param .test (`flag`)\cr whether to display the internal structure of the plot for testing purposes.
#'
#' @name module_arguments
#' @keywords internal
Expand Down
35 changes: 27 additions & 8 deletions R/barplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,29 +34,33 @@ tm_g_barplot <- function(label,
Max = matrixStats::colMaxs
),
pre_output = NULL,
post_output = NULL) {
post_output = NULL,
.test = FALSE) {
message("Initializing tm_g_barplot")
assert_string(label)
assert_string(mae_name)
assert_character(exclude_assays)
assert_summary_funs(summary_funs)
assert_tag(pre_output, null.ok = TRUE)
assert_tag(post_output, null.ok = TRUE)
assert_flag(.test)

module(
label = label,
server = srv_g_barplot,
server_args = list(
mae_name = mae_name,
exclude_assays = exclude_assays,
summary_funs = summary_funs
summary_funs = summary_funs,
.test = .test
),
ui = ui_g_barplot,
ui_args = list(
mae_name = mae_name,
summary_funs = summary_funs,
pre_output = pre_output,
post_output = post_output
post_output = post_output,
.test = .test
),
datanames = mae_name
)
Expand All @@ -69,7 +73,8 @@ ui_g_barplot <- function(id,
mae_name,
summary_funs,
pre_output,
post_output) {
post_output,
.test = FALSE) {
ns <- NS(id)
teal.widgets::standard_layout(
encoding = tags$div(
Expand Down Expand Up @@ -101,7 +106,10 @@ ui_g_barplot <- function(id,
)
)
),
output = teal.widgets::plot_with_settings_ui(ns("plot")),
output = div(
if (.test) verbatimTextOutput(ns("table")) else NULL,
teal.widgets::plot_with_settings_ui(ns("plot"))
),
pre_output = pre_output,
post_output = post_output
)
Expand All @@ -116,11 +124,13 @@ srv_g_barplot <- function(id,
reporter,
mae_name,
exclude_assays,
summary_funs) {
summary_funs,
.test = FALSE) {
with_reporter <- !missing(reporter) && inherits(reporter, "Reporter")
assert_class(filter_panel_api, "FilterPanelAPI")
checkmate::assert_class(data, "reactive")
checkmate::assert_class(shiny::isolate(data()), "teal_data")
assert_flag(.test)
moduleServer(id, function(input, output, session) {
output$experiment_ui <- renderUI({
experimentSpecInput(session$ns("experiment"), data, mae_name)
Expand Down Expand Up @@ -189,6 +199,13 @@ srv_g_barplot <- function(id,
plot_r = plot_r
)

if (.test) {
table_r <- reactive({
str(layer_data(plot_r()))
})
output$table <- renderPrint(table_r())
}

### REPORTER
if (with_reporter) {
card_fun <- function(comment, label) {
Expand Down Expand Up @@ -230,6 +247,7 @@ srv_g_barplot <- function(id,
card$append_text("Comment", "header3")
card$append_text(comment)
}

card
}
teal.reporter::simple_reporter_srv("simple_reporter", reporter = reporter, card_fun = card_fun)
Expand All @@ -246,14 +264,15 @@ srv_g_barplot <- function(id,
#' if (interactive()) {
#' sample_tm_g_barplot()
#' }
sample_tm_g_barplot <- function() {
sample_tm_g_barplot <- function(.test = FALSE) {
data <- teal.data::teal_data(MAE = hermes::multi_assay_experiment)
app <- teal::init(
data = data,
modules = teal::modules(
tm_g_barplot(
label = "barplot",
mae_name = "MAE"
mae_name = "MAE",
.test = .test
)
)
)
Expand Down
33 changes: 25 additions & 8 deletions R/boxplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,29 +35,33 @@ tm_g_boxplot <- function(label,
Max = matrixStats::colMaxs
),
pre_output = NULL,
post_output = NULL) {
post_output = NULL,
.test = FALSE) {
message("Initializing tm_g_boxplot")
assert_string(label)
assert_string(mae_name)
assert_character(exclude_assays, any.missing = FALSE)
assert_summary_funs(summary_funs, null.ok = TRUE)
assert_tag(pre_output, null.ok = TRUE)
assert_tag(post_output, null.ok = TRUE)
assert_flag(.test)

teal::module(
label = label,
server = srv_g_boxplot,
server_args = list(
mae_name = mae_name,
summary_funs = summary_funs,
exclude_assays = exclude_assays
exclude_assays = exclude_assays,
.test = .test
),
ui = ui_g_boxplot,
ui_args = list(
mae_name = mae_name,
summary_funs = summary_funs,
pre_output = pre_output,
post_output = post_output
post_output = post_output,
.test = .test
),
datanames = mae_name
)
Expand All @@ -70,7 +74,8 @@ ui_g_boxplot <- function(id,
mae_name,
summary_funs,
pre_output,
post_output) {
post_output,
.test = FALSE) {
ns <- NS(id)
teal.widgets::standard_layout(
encoding = tags$div(
Expand All @@ -97,7 +102,10 @@ ui_g_boxplot <- function(id,
)
)
),
output = teal.widgets::plot_with_settings_ui(ns("plot")),
output = div(
if (.test) verbatimTextOutput(ns("table")) else NULL,
teal.widgets::plot_with_settings_ui(ns("plot"))
),
pre_output = pre_output,
post_output = post_output
)
Expand All @@ -112,7 +120,8 @@ srv_g_boxplot <- function(id,
reporter,
mae_name,
exclude_assays,
summary_funs) {
summary_funs,
.test = FALSE) {
with_reporter <- !missing(reporter) && inherits(reporter, "Reporter")
assert_class(filter_panel_api, "FilterPanelAPI")
checkmate::assert_class(data, "reactive")
Expand Down Expand Up @@ -184,6 +193,13 @@ srv_g_boxplot <- function(id,
plot_r = plot_r
)

if (.test) {
table_r <- reactive({
str(layer_data(plot_r()))
})
output$table <- renderPrint(table_r())
}

### REPORTER
if (with_reporter) {
card_fun <- function(comment, label) {
Expand Down Expand Up @@ -247,14 +263,15 @@ srv_g_boxplot <- function(id,
#' if (interactive()) {
#' sample_tm_g_boxplot()
#' }
sample_tm_g_boxplot <- function() {
sample_tm_g_boxplot <- function(.test = FALSE) {
data <- teal.data::teal_data(MAE = hermes::multi_assay_experiment)
app <- teal::init(
data = data,
modules = teal::modules(
tm_g_boxplot(
label = "boxplot",
mae_name = "MAE"
mae_name = "MAE",
.test = .test
)
)
)
Expand Down
37 changes: 27 additions & 10 deletions R/forestplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ tm_g_forest_tte <- function(label,
pre_output = NULL,
post_output = NULL,
plot_height = c(600L, 200L, 2000L),
plot_width = c(1360L, 500L, 2000L)) {
plot_width = c(1360L, 500L, 2000L),
.test = FALSE) {
message("Initializing tm_g_forest_tte")
assert_string(label)
assert_string(adtte_name)
Expand All @@ -63,6 +64,7 @@ tm_g_forest_tte <- function(label,
assert_summary_funs(summary_funs)
assert_tag(pre_output, null.ok = TRUE)
assert_tag(post_output, null.ok = TRUE)
assert_flag(.test)

teal::module(
label = label,
Expand All @@ -74,15 +76,17 @@ tm_g_forest_tte <- function(label,
exclude_assays = exclude_assays,
summary_funs = summary_funs,
plot_height = plot_height,
plot_width = plot_width
plot_width = plot_width,
.test = .test
),
ui = ui_g_forest_tte,
ui_args = list(
adtte_name = adtte_name,
mae_name = mae_name,
summary_funs = summary_funs,
pre_output = pre_output,
post_output = post_output
post_output = post_output,
.test = .test
),
datanames = c(adtte_name, mae_name)
)
Expand All @@ -96,7 +100,8 @@ ui_g_forest_tte <- function(id,
mae_name,
summary_funs,
pre_output,
post_output) {
post_output,
.test = FALSE) {
ns <- NS(id)
teal.widgets::standard_layout(
encoding = tags$div(
Expand All @@ -120,7 +125,10 @@ ui_g_forest_tte <- function(id,
)
)
),
output = teal.widgets::plot_with_settings_ui(ns("plot")),
output = div(
if (.test) verbatimTextOutput(ns("table")) else NULL,
teal.widgets::plot_with_settings_ui(ns("plot"))
),
pre_output = pre_output,
post_output = post_output
)
Expand All @@ -139,7 +147,8 @@ srv_g_forest_tte <- function(id,
exclude_assays,
summary_funs,
plot_height,
plot_width) {
plot_width,
.test = FALSE) {
with_reporter <- !missing(reporter) && inherits(reporter, "Reporter")
assert_class(filter_panel_api, "FilterPanelAPI")
checkmate::assert_class(data, "reactive")
Expand Down Expand Up @@ -217,8 +226,8 @@ srv_g_forest_tte <- function(id,
})

forest_plot <- reactive({
result <- result()
tern::g_forest(result)
res <- result()
tern::g_forest(res)
})

pws <- teal.widgets::plot_with_settings_srv(
Expand All @@ -228,6 +237,13 @@ srv_g_forest_tte <- function(id,
width = plot_width
)

if (.test) {
table_r <- reactive({
rtables::as_result_df(result())
})
output$table <- renderPrint(table_r())
}

### REPORTER
if (with_reporter) {
card_fun <- function(comment, label) {
Expand Down Expand Up @@ -285,7 +301,7 @@ srv_g_forest_tte <- function(id,
#' if (interactive()) {
#' sample_tm_g_forest_tte()
#' }
sample_tm_g_forest_tte <- function() { # nolint
sample_tm_g_forest_tte <- function(.test = FALSE) { # nolint
data <- teal_data()
data <- within(data, {
ADTTE <- teal.modules.hermes::rADTTE %>% # nolint
Expand All @@ -302,7 +318,8 @@ sample_tm_g_forest_tte <- function() { # nolint
tm_g_forest_tte(
label = "forest",
adtte_name = "ADTTE",
mae_name = "MAE"
mae_name = "MAE",
.test = .test
)
)
)
Expand Down
Loading
Loading