From 145b115d8424565deb437e4562dc0bebcfb5f609 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dawid=20Ka=C5=82=C4=99dkowski?= <6959016+gogonzo@users.noreply.github.com> Date: Fri, 24 Nov 2023 14:01:59 +0100 Subject: [PATCH 01/28] fix `tm_g_pp_vitals` (#896) closes #895 --- DESCRIPTION | 1 - NEWS.md | 2 +- R/tm_g_pp_vitals.R | 222 ++++++++++++++++++++++++--------------------- 3 files changed, 122 insertions(+), 103 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 8cbc216356..abc6b92a99 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -69,7 +69,6 @@ Suggests: knitr, lubridate, nestcolor (>= 0.1.0), - teal.data (>= 0.3.0.9010), testthat (>= 3.0) VignetteBuilder: knitr diff --git a/NEWS.md b/NEWS.md index 69be7beb4b..589deddd45 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# teal.modules.clinical 0.8.16.9011 +# teal.modules.clinical 0.8.16.9012 ### Enhancements * Updated the documentation and vignettes to demonstrate method to pass `teal_data` object to `teal::init()`. diff --git a/R/tm_g_pp_vitals.R b/R/tm_g_pp_vitals.R index dcd7f64605..e82af1c4f0 100644 --- a/R/tm_g_pp_vitals.R +++ b/R/tm_g_pp_vitals.R @@ -64,108 +64,128 @@ template_vitals <- function(dataname = "ANL", vital_plot <- add_expr( list(), - substitute(expr = { - vitals <- - dataname %>% - dplyr::group_by(paramcd, xaxis) %>% - dplyr::filter(paramcd %in% paramcd_levels_chars) %>% - dplyr::summarise(AVAL = max(aval, na.rm = TRUE)) %>% - dplyr::mutate(AVAL = ifelse(is.infinite(AVAL), NA, AVAL)) - - max_day <- max(vitals[[xaxis_char]], na.rm = TRUE) - max_aval <- max(vitals[[aval_char]], na.rm = TRUE) - max_aval_seq <- seq(0, max_aval, 10) - - full_vita <- levels(dataname[[paramcd_char]]) - provided_vita <- paramcd_levels_chars - known_vita <- c("SYSBP", "DIABP", "TEMP", "RESP", "OXYSAT", "PULSE") - - paramcd_levels_e <- known_vita[stats::na.omit(match(provided_vita, known_vita))] - len_paramcd_levels_e <- length(paramcd_levels_e) - - all_colors <- stats::setNames(nestcolor::color_palette(length(full_vita), "stream"), full_vita) - vars_colors <- all_colors[provided_vita] - names(vars_colors) <- provided_vita - - base_stats <- stats::setNames(c(140, 90, 38, 20, 94, 100), known_vita) - paramcd_stats_e <- base_stats[paramcd_levels_e] - - base_labels <- stats::setNames(c("140mmHg", "90mmHg", "38\u00B0 C", "20/min", "94%", "100bpm"), known_vita) - paramcd_labels_e <- base_labels[paramcd_levels_e] - - base_stats_df <- data.frame( - x = rep(1, len_paramcd_levels_e), - y = paramcd_stats_e, - label = paramcd_labels_e, - color = paramcd_levels_e - ) + substitute_names( + names = list( + dataname = as.name(dataname), + paramcd = as.name(paramcd), + xaxis = as.name(xaxis), + aval = as.name(aval) + ), + others = list(paramcd_levels = paramcd_levels), + expr = { + vitals <- + dataname %>% + dplyr::group_by(paramcd, xaxis) %>% + dplyr::filter(paramcd %in% paramcd_levels) %>% + dplyr::summarise(aval = max(aval, na.rm = TRUE)) %>% + dplyr::mutate( + aval = ifelse(is.infinite(aval), NA, aval), + xaxis = as.numeric(xaxis) # difftime fails ggplot2::scale_x_continuous + ) + } + ) + ) - result_plot <- ggplot2::ggplot(data = vitals, mapping = ggplot2::aes(x = xaxis)) + # replaced VSDY - ggplot2::geom_line( - data = vitals, - mapping = ggplot2::aes(y = aval, color = paramcd), - size = 1.5, - alpha = 0.5 - ) + - ggplot2::scale_color_manual( - values = vars_colors, - ) + - ggplot2::geom_text( - data = base_stats_df, - ggplot2::aes(x = x, y = y, label = label, color = color), - alpha = 1, - nudge_y = 2.2, - size = font_size_var / 3.5, - show.legend = FALSE - ) + - ggplot2::geom_hline( - data = base_stats_df, - ggplot2::aes(yintercept = y, color = color), - linetype = 2, - alpha = 0.5, - size = 1, - show.legend = FALSE - ) + - ggplot2::scale_y_continuous( - breaks = seq(0, max(vitals[[xaxis_char]], na.rm = TRUE), 50), - minor_breaks = seq(0, max(vitals[[aval_char]], na.rm = TRUE), 10) - ) + - ggplot2::geom_text( - data = data.frame( - x = rep(max_day, length(max_aval_seq)), - y = max_aval_seq, - l = as.character(max_aval_seq) - ), - ggplot2::aes( - x = x, - y = y, - label = l - ), - color = "black", - alpha = 1, - nudge_y = 2.2, - size = font_size_var / 3.5 - ) + - labs + - ggthemes + - themes - - print(result_plot) - }, env = list( - dataname = as.name(dataname), - paramcd = as.name(paramcd), - paramcd_char = paramcd, - paramcd_levels_chars = paramcd_levels, - xaxis = as.name(xaxis), - xaxis_char = xaxis, - aval = as.name(aval), - aval_char = aval, - patient_id = patient_id, - font_size_var = font_size, - labs = parsed_ggplot2_args$labs, - ggthemes = parsed_ggplot2_args$ggtheme, - themes = parsed_ggplot2_args$theme - )) + vital_plot <- add_expr( + vital_plot, + substitute( + expr = { + max_day <- max(vitals[[xaxis_char]], na.rm = TRUE) + max_aval <- max(vitals[[aval_char]], na.rm = TRUE) + max_aval_seq <- seq(0, max_aval, 10) + + full_vita <- levels(dataname[[paramcd_char]]) + provided_vita <- paramcd_levels + known_vita <- c("SYSBP", "DIABP", "TEMP", "RESP", "OXYSAT", "PULSE") + + paramcd_levels_e <- known_vita[stats::na.omit(match(provided_vita, known_vita))] + len_paramcd_levels_e <- length(paramcd_levels_e) + + all_colors <- stats::setNames(nestcolor::color_palette(length(full_vita), "stream"), full_vita) + vars_colors <- all_colors[provided_vita] + names(vars_colors) <- provided_vita + + base_stats <- stats::setNames(c(140, 90, 38, 20, 94, 100), known_vita) + paramcd_stats_e <- base_stats[paramcd_levels_e] + + base_labels <- stats::setNames(c("140mmHg", "90mmHg", "38\u00B0 C", "20/min", "94%", "100bpm"), known_vita) + paramcd_labels_e <- base_labels[paramcd_levels_e] + + base_stats_df <- data.frame( + x = rep(1, len_paramcd_levels_e), + y = paramcd_stats_e, + label = paramcd_labels_e, + color = paramcd_levels_e + ) + + result_plot <- ggplot2::ggplot(data = vitals, mapping = ggplot2::aes(x = xaxis)) + # replaced VSDY + ggplot2::geom_line( + data = vitals, + mapping = ggplot2::aes(y = aval, color = paramcd), + size = 1.5, + alpha = 0.5 + ) + + ggplot2::scale_color_manual( + values = vars_colors + ) + + ggplot2::geom_text( + data = base_stats_df, + ggplot2::aes(x = x, y = y, label = label, color = color), + alpha = 1, + nudge_y = 2.2, + size = font_size_var / 3.5, + show.legend = FALSE + ) + + ggplot2::geom_hline( + data = base_stats_df, + ggplot2::aes(yintercept = y, color = color), + linetype = 2, + alpha = 0.5, + size = 1, + show.legend = FALSE + ) + + ggplot2::scale_y_continuous( + breaks = seq(0, max(vitals[[xaxis_char]], na.rm = TRUE), 50), + minor_breaks = seq(0, max(vitals[[aval_char]], na.rm = TRUE), 10) + ) + + ggplot2::geom_text( + data = data.frame( + x = rep(max_day, length(max_aval_seq)), + y = max_aval_seq, + l = as.character(max_aval_seq) + ), + ggplot2::aes( + x = x, + y = y, + label = l + ), + color = "black", + alpha = 1, + nudge_y = 2.2, + size = font_size_var / 3.5 + ) + + labs + + ggthemes + + themes + + print(result_plot) + }, + env = list( + dataname = as.name(dataname), + paramcd = as.name(paramcd), + paramcd_char = paramcd, + paramcd_levels = paramcd_levels, + xaxis = as.name(xaxis), + xaxis_char = xaxis, + aval = as.name(aval), + aval_char = aval, + patient_id = patient_id, + font_size_var = font_size, + labs = parsed_ggplot2_args$labs, + ggthemes = parsed_ggplot2_args$ggtheme, + themes = parsed_ggplot2_args$theme + ) + ) ) y$plot <- bracket_expr(vital_plot) From 17f205caa9c4767137f2739b5d10d78616f30296 Mon Sep 17 00:00:00 2001 From: gogonzo Date: Fri, 24 Nov 2023 13:02:50 +0000 Subject: [PATCH 02/28] [skip actions] Bump version to 0.8.16.9013 --- DESCRIPTION | 4 ++-- NEWS.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index abc6b92a99..061dd30764 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: teal.modules.clinical Title: Teal Modules for Standard Clinical Outputs -Version: 0.8.16.9012 -Date: 2023-11-20 +Version: 0.8.16.9013 +Date: 2023-11-24 Authors@R: c( person("Joe", "Zhu", , "joe.zhu@roche.com", role = c("aut", "cre")), person("Jana", "Stoilova", , "jana.stoilova@roche.com", role = "aut"), diff --git a/NEWS.md b/NEWS.md index 589deddd45..5e1a7a22ce 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# teal.modules.clinical 0.8.16.9012 +# teal.modules.clinical 0.8.16.9013 ### Enhancements * Updated the documentation and vignettes to demonstrate method to pass `teal_data` object to `teal::init()`. From 1ca9af3da76be7b9eebf1fc7207896d5eebf18e3 Mon Sep 17 00:00:00 2001 From: Marcin <133694481+m7pr@users.noreply.github.com> Date: Fri, 1 Dec 2023 07:27:34 +0100 Subject: [PATCH 03/28] Update `tern` version (#901) Close #900 Signed-off-by: Marcin <133694481+m7pr@users.noreply.github.com> --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 061dd30764..5df50e8aee 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -27,7 +27,7 @@ BugReports: Depends: R (>= 4.0), teal (>= 0.14.0.9019), - tern (>= 0.8.2) + tern (>= 0.9.2.9017) Imports: assertthat, broom, From 6642b7a80cbbafc831f3efe9c3d1f93222f5ade7 Mon Sep 17 00:00:00 2001 From: shajoezhu Date: Fri, 1 Dec 2023 06:28:33 +0000 Subject: [PATCH 04/28] [skip actions] Bump version to 0.8.16.9014 --- DESCRIPTION | 4 ++-- NEWS.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 5df50e8aee..28aa5f0a9a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: teal.modules.clinical Title: Teal Modules for Standard Clinical Outputs -Version: 0.8.16.9013 -Date: 2023-11-24 +Version: 0.8.16.9014 +Date: 2023-12-01 Authors@R: c( person("Joe", "Zhu", , "joe.zhu@roche.com", role = c("aut", "cre")), person("Jana", "Stoilova", , "jana.stoilova@roche.com", role = "aut"), diff --git a/NEWS.md b/NEWS.md index 5e1a7a22ce..38edec21ce 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# teal.modules.clinical 0.8.16.9013 +# teal.modules.clinical 0.8.16.9014 ### Enhancements * Updated the documentation and vignettes to demonstrate method to pass `teal_data` object to `teal::init()`. From 9a94a2925a7c43c9e9d46f3899d8403e08e20e92 Mon Sep 17 00:00:00 2001 From: Aleksander Chlebowski <114988527+chlebowa@users.noreply.github.com> Date: Fri, 1 Dec 2023 11:23:14 +0100 Subject: [PATCH 05/28] bump `teal.reporter` dep version (#903) fixes #902 --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 28aa5f0a9a..497cad0f39 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -56,7 +56,7 @@ Imports: teal.code (>= 0.4.0), teal.data (>= 0.3.0.9010), teal.logger (>= 0.1.1), - teal.reporter (>= 0.2.0), + teal.reporter (>= 0.2.1), teal.transform (>= 0.4.0.9007), teal.widgets (>= 0.4.0), tern.gee (>= 0.1.0), From 98c7490d6ec508eb42bb6c6f5764e944fc8c0e64 Mon Sep 17 00:00:00 2001 From: chlebowa Date: Fri, 1 Dec 2023 10:24:13 +0000 Subject: [PATCH 06/28] [skip actions] Bump version to 0.8.16.9015 --- DESCRIPTION | 2 +- NEWS.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 497cad0f39..b9ef9537ad 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: teal.modules.clinical Title: Teal Modules for Standard Clinical Outputs -Version: 0.8.16.9014 +Version: 0.8.16.9015 Date: 2023-12-01 Authors@R: c( person("Joe", "Zhu", , "joe.zhu@roche.com", role = c("aut", "cre")), diff --git a/NEWS.md b/NEWS.md index 38edec21ce..c1ea0d442a 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# teal.modules.clinical 0.8.16.9014 +# teal.modules.clinical 0.8.16.9015 ### Enhancements * Updated the documentation and vignettes to demonstrate method to pass `teal_data` object to `teal::init()`. From 38d7395423c1e7efb6be4f786ae919f470845e68 Mon Sep 17 00:00:00 2001 From: Emily de la Rua <59304861+edelarua@users.noreply.github.com> Date: Fri, 1 Dec 2023 10:54:01 -0500 Subject: [PATCH 07/28] Fix bug forcing `tm_g_lineplot` to initialize with a table (#899) Fixes #823 --- NEWS.md | 3 +++ R/tm_g_lineplot.R | 4 ++-- man/tm_g_lineplot.Rd | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/NEWS.md b/NEWS.md index c1ea0d442a..ff112f3c16 100644 --- a/NEWS.md +++ b/NEWS.md @@ -3,6 +3,9 @@ ### Enhancements * Updated the documentation and vignettes to demonstrate method to pass `teal_data` object to `teal::init()`. +### Bug fixes +* Fixed bug in `tm_g_lineplot` forcing module to initialize with a table. + # teal.modules.clinical 0.8.16.9010 ### Enhancements diff --git a/R/tm_g_lineplot.R b/R/tm_g_lineplot.R index 1e4d4e6e8a..0efd44860e 100644 --- a/R/tm_g_lineplot.R +++ b/R/tm_g_lineplot.R @@ -285,7 +285,7 @@ tm_g_lineplot <- function(label, interval = "mean_ci", mid = "mean", whiskers = c("mean_ci_lwr", "mean_ci_upr"), - table = NULL, + table = c("n", "mean_sd", "median", "range"), mid_type = "pl", mid_point_size = c(2, 1, 5), table_font_size = c(4, 2, 6), @@ -488,7 +488,7 @@ ui_g_lineplot <- function(id, ...) { "25% and 75%-ile" = "quantiles", "Min - Max" = "range" ), - selected = c("n", "mean_sd", "median", "range"), + selected = a$table, ) ) ) diff --git a/man/tm_g_lineplot.Rd b/man/tm_g_lineplot.Rd index 2cd5994f18..4b51f2d0a5 100644 --- a/man/tm_g_lineplot.Rd +++ b/man/tm_g_lineplot.Rd @@ -26,7 +26,7 @@ tm_g_lineplot( interval = "mean_ci", mid = "mean", whiskers = c("mean_ci_lwr", "mean_ci_upr"), - table = NULL, + table = c("n", "mean_sd", "median", "range"), mid_type = "pl", mid_point_size = c(2, 1, 5), table_font_size = c(4, 2, 6), From 9a0c3e9503a5bcd1d150073f82dd3ac2aa2e0a13 Mon Sep 17 00:00:00 2001 From: edelarua Date: Fri, 1 Dec 2023 15:54:59 +0000 Subject: [PATCH 08/28] [skip actions] Bump version to 0.8.16.9016 --- DESCRIPTION | 2 +- NEWS.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index b9ef9537ad..28ca54ae45 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: teal.modules.clinical Title: Teal Modules for Standard Clinical Outputs -Version: 0.8.16.9015 +Version: 0.8.16.9016 Date: 2023-12-01 Authors@R: c( person("Joe", "Zhu", , "joe.zhu@roche.com", role = c("aut", "cre")), diff --git a/NEWS.md b/NEWS.md index ff112f3c16..a3c7319979 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# teal.modules.clinical 0.8.16.9015 +# teal.modules.clinical 0.8.16.9016 ### Enhancements * Updated the documentation and vignettes to demonstrate method to pass `teal_data` object to `teal::init()`. From 96a0d9ffd4dbedadb31530277defc6e7621b435b Mon Sep 17 00:00:00 2001 From: Emily de la Rua <59304861+edelarua@users.noreply.github.com> Date: Fri, 1 Dec 2023 12:22:59 -0500 Subject: [PATCH 09/28] Add options to `tm_t_events` for sorting and overall rows (#851) Closes #844 #849 --------- Signed-off-by: Emily de la Rua <59304861+edelarua@users.noreply.github.com> --- NEWS.md | 12 ++---- R/tm_t_events.R | 57 ++++++++++++++++++++-------- man/template_events.Rd | 9 ++++- man/tm_t_events.Rd | 9 ++++- tests/testthat/_snaps/tm_t_events.md | 18 +++++++-- 5 files changed, 75 insertions(+), 30 deletions(-) diff --git a/NEWS.md b/NEWS.md index a3c7319979..bd615bdd8c 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,13 +1,5 @@ # teal.modules.clinical 0.8.16.9016 -### Enhancements -* Updated the documentation and vignettes to demonstrate method to pass `teal_data` object to `teal::init()`. - -### Bug fixes -* Fixed bug in `tm_g_lineplot` forcing module to initialize with a table. - -# teal.modules.clinical 0.8.16.9010 - ### Enhancements * Added more informative error message when grade mapping error occurs in `tm_t_abnormality_by_worst_grade`. * Fixed label indentation in `tm_t_abnormality_by_worst_grade`. @@ -22,9 +14,13 @@ * Updated `tm_t_pp_basic_info`, `tm_g_pp_therapy`, `tm_g_pp_adverse_events`, and `tm_t_pp_laboratory` to use `rlistings` to print data neatly in reports. * Updated `tm_g_lineplot` to allow user to remove interval from plot. * Updated the documentation and vignettes to demonstrate method to pass `teal_data` object to `teal::init()`. +* Added parameter `sort_freq_col` to `tm_t_events` to allow the user to select column to use when sorting by decreasing frequency. +* Added parameter `incl_overall_sum` to `tm_t_events` to allow the user to choose whether overall summary rows are included at the top of the table. +* Updated the documentation and vignettes to demonstrate method to pass `teal_data` object to `teal::init()`. ### Bug fixes * Fixed bug in `tm_t_coxreg` preventing table from being displayed when no covariates are selected. +* Fixed bug in `tm_g_lineplot` forcing module to initialize with a table. ### Miscellaneous * Updated `control_incidence_rate` parameter names in `tm_t_events_patyear` from `time_unit_input` and `time_unit_output` to `input_time_unit` and `num_pt_year`, respectively, after parameter names were changed in `tern`. diff --git a/R/tm_t_events.R b/R/tm_t_events.R index 955df7a834..4eba9fddcd 100644 --- a/R/tm_t_events.R +++ b/R/tm_t_events.R @@ -8,8 +8,11 @@ #' @param event_type (`character`)\cr type of event that is summarized (e.g. adverse event, treatment). #' Default is "event". #' @param sort_criteria (`character`)\cr how to sort the final table. Default option `freq_desc` sorts -#' by decreasing total number of patients with event. Alternative option `alpha` sorts events +#' on column `sort_freq_col` by decreasing number of patients with event. Alternative option `alpha` sorts events #' alphabetically. +#' @param sort_freq_col (`character`)\cr column to sort by frequency on if `sort_criteria` is set to `freq_desc`. +#' @param incl_overall_sum (`flag`)\cr whether two rows which summarize the overall number of adverse events +#' should be included at the top of the table. #' #' @seealso [tm_t_events()] #' @keywords internal @@ -25,9 +28,11 @@ template_events <- function(dataname, total_label = "All Patients", event_type = "event", sort_criteria = c("freq_desc", "alpha"), + sort_freq_col = total_label, prune_freq = 0, prune_diff = 0, drop_arm_levels = TRUE, + incl_overall_sum = TRUE, basic_table_args = teal.widgets::basic_table_args()) { assertthat::assert_that( assertthat::is.string(dataname), @@ -189,20 +194,23 @@ template_events <- function(dataname, unique_label <- paste0("Total number of patients with at least one ", event_type) nonunique_label <- paste0("Overall total number of ", event_type, "s") - layout_list <- add_expr( - layout_list, - substitute( - summarize_num_patients( - var = "USUBJID", - .stats = c("unique", "nonunique"), - .labels = c( - unique = unique_label, - nonunique = nonunique_label - ) - ), - env = list(unique_label = unique_label, nonunique_label = nonunique_label) + if (incl_overall_sum) { + layout_list <- add_expr( + layout_list, + substitute( + summarize_num_patients( + var = "USUBJID", + .stats = c("unique", "nonunique"), + .labels = c( + unique = unique_label, + nonunique = nonunique_label + ) + ), + env = list(unique_label = unique_label, nonunique_label = nonunique_label) + ) ) - ) + } + one_term <- is.null(hlt) || is.null(llt) @@ -362,10 +370,17 @@ template_events <- function(dataname, } } else { # Sort by decreasing frequency. + sort_list <- add_expr( + sort_list, + substitute( + expr = idx_split_col <- which(sapply(col_paths(result), tail, 1) == sort_freq_col), + env = list(sort_freq_col = sort_freq_col) + ) + ) # When the "All Patients" column is present we only use that for scoring. scorefun_hlt <- if (add_total) { - quote(cont_n_onecol(ncol(result))) + quote(cont_n_onecol(idx_split_col)) } else { quote(cont_n_allcols) } @@ -495,9 +510,11 @@ tm_t_events <- function(label, total_label = "All Patients", event_type = "event", sort_criteria = c("freq_desc", "alpha"), + sort_freq_col = total_label, prune_freq = 0, prune_diff = 0, drop_arm_levels = TRUE, + incl_overall_sum = TRUE, pre_output = NULL, post_output = NULL, basic_table_args = teal.widgets::basic_table_args()) { @@ -508,9 +525,11 @@ tm_t_events <- function(label, checkmate::assert_string(event_type) checkmate::assert_flag(add_total) checkmate::assert_string(total_label) + checkmate::assert_string(sort_freq_col) checkmate::assert_scalar(prune_freq) checkmate::assert_scalar(prune_diff) checkmate::assert_flag(drop_arm_levels) + checkmate::assert_flag(incl_overall_sum) sort_criteria <- match.arg(sort_criteria) checkmate::assert_class(pre_output, classes = "shiny.tag", null.ok = TRUE) checkmate::assert_class(post_output, classes = "shiny.tag", null.ok = TRUE) @@ -537,6 +556,8 @@ tm_t_events <- function(label, event_type = event_type, label = label, total_label = total_label, + sort_freq_col = sort_freq_col, + incl_overall_sum = incl_overall_sum, basic_table_args = basic_table_args ) ), @@ -596,7 +617,7 @@ ui_t_events_byterm <- function(id, ...) { selected = a$sort_criteria, multiple = FALSE ), - shiny::helpText("Pruning Options"), + shiny::helpText(shiny::strong("Pruning Options:")), shiny::numericInput( inputId = ns("prune_freq"), label = "Minimum Incidence Rate(%) in any of the treatment groups", @@ -638,8 +659,10 @@ srv_t_events_byterm <- function(id, hlt, llt, drop_arm_levels, + incl_overall_sum, label, total_label, + sort_freq_col, basic_table_args) { with_reporter <- !missing(reporter) && inherits(reporter, "Reporter") with_filter <- !missing(filter_panel_api) && inherits(filter_panel_api, "FilterPanelAPI") @@ -761,9 +784,11 @@ srv_t_events_byterm <- function(id, total_label = total_label, event_type = event_type, sort_criteria = input$sort_criteria, + sort_freq_col = sort_freq_col, prune_freq = input$prune_freq / 100, prune_diff = input$prune_diff / 100, drop_arm_levels = input$drop_arm_levels, + incl_overall_sum = incl_overall_sum, basic_table_args = basic_table_args ) diff --git a/man/template_events.Rd b/man/template_events.Rd index 0300fbbb67..6c7d1d3089 100644 --- a/man/template_events.Rd +++ b/man/template_events.Rd @@ -16,9 +16,11 @@ template_events( total_label = "All Patients", event_type = "event", sort_criteria = c("freq_desc", "alpha"), + sort_freq_col = total_label, prune_freq = 0, prune_diff = 0, drop_arm_levels = TRUE, + incl_overall_sum = TRUE, basic_table_args = teal.widgets::basic_table_args() ) } @@ -51,9 +53,11 @@ whether to include column with total number of patients.} Default is "event".} \item{sort_criteria}{(\code{character})\cr how to sort the final table. Default option \code{freq_desc} sorts -by decreasing total number of patients with event. Alternative option \code{alpha} sorts events +on column \code{sort_freq_col} by decreasing number of patients with event. Alternative option \code{alpha} sorts events alphabetically.} +\item{sort_freq_col}{(\code{character})\cr column to sort by frequency on if \code{sort_criteria} is set to \code{freq_desc}.} + \item{prune_freq}{(\code{number})\cr threshold to use for trimming table using event incidence rate in any column.} \item{prune_diff}{(\code{number})\cr threshold to use for trimming table using as criteria difference in @@ -63,6 +67,9 @@ rates between any two columns.} When \code{TRUE}, \code{arm_var} levels are set to those used in the \code{dataname} dataset. When \code{FALSE}, \code{arm_var} levels are set to those used in the \code{parantname} dataset.} +\item{incl_overall_sum}{(\code{flag})\cr whether two rows which summarize the overall number of adverse events +should be included at the top of the table.} + \item{basic_table_args}{optional, (\code{basic_table_args})\cr object created by \code{\link[teal.widgets:basic_table_args]{teal.widgets::basic_table_args()}} with settings for the module table. The argument is merged with option \code{teal.basic_table_args} and with default module arguments diff --git a/man/tm_t_events.Rd b/man/tm_t_events.Rd index 231f8bf68a..edb18ff64c 100644 --- a/man/tm_t_events.Rd +++ b/man/tm_t_events.Rd @@ -16,9 +16,11 @@ tm_t_events( total_label = "All Patients", event_type = "event", sort_criteria = c("freq_desc", "alpha"), + sort_freq_col = total_label, prune_freq = 0, prune_diff = 0, drop_arm_levels = TRUE, + incl_overall_sum = TRUE, pre_output = NULL, post_output = NULL, basic_table_args = teal.widgets::basic_table_args() @@ -57,9 +59,11 @@ enabled (see \code{add_total}).} Default is "event".} \item{sort_criteria}{(\code{character})\cr how to sort the final table. Default option \code{freq_desc} sorts -by decreasing total number of patients with event. Alternative option \code{alpha} sorts events +on column \code{sort_freq_col} by decreasing number of patients with event. Alternative option \code{alpha} sorts events alphabetically.} +\item{sort_freq_col}{(\code{character})\cr column to sort by frequency on if \code{sort_criteria} is set to \code{freq_desc}.} + \item{prune_freq}{(\code{number})\cr threshold to use for trimming table using event incidence rate in any column.} \item{prune_diff}{(\code{number})\cr threshold to use for trimming table using as criteria difference in @@ -69,6 +73,9 @@ rates between any two columns.} When \code{TRUE}, \code{arm_var} levels are set to those used in the \code{dataname} dataset. When \code{FALSE}, \code{arm_var} levels are set to those used in the \code{parantname} dataset.} +\item{incl_overall_sum}{(\code{flag})\cr whether two rows which summarize the overall number of adverse events +should be included at the top of the table.} + \item{pre_output}{optional, (\code{shiny.tag})\cr with text placed before the output to put the output into context. For example a title.} diff --git a/tests/testthat/_snaps/tm_t_events.md b/tests/testthat/_snaps/tm_t_events.md index 403dbf5b19..da2b5299c4 100644 --- a/tests/testthat/_snaps/tm_t_events.md +++ b/tests/testthat/_snaps/tm_t_events.md @@ -42,8 +42,10 @@ $sort { + idx_split_col <- which(sapply(col_paths(result), tail, 1) == + "All Patients") pruned_and_sorted_result <- pruned_result %>% sort_at_path(path = c("AEBODSYS"), - scorefun = cont_n_onecol(ncol(result))) %>% sort_at_path(path = c("AEBODSYS", + scorefun = cont_n_onecol(idx_split_col)) %>% sort_at_path(path = c("AEBODSYS", "*", "AEDECOD"), scorefun = score_occurrences_cols(col_indices = seq(1, ncol(result)))) pruned_and_sorted_result @@ -99,8 +101,10 @@ $sort { + idx_split_col <- which(sapply(col_paths(result), tail, 1) == + "All Patients") pruned_and_sorted_result <- pruned_result %>% sort_at_path(path = c("AEBODSYS"), - scorefun = cont_n_onecol(ncol(result))) %>% sort_at_path(path = c("AEBODSYS", + scorefun = cont_n_onecol(idx_split_col)) %>% sort_at_path(path = c("AEBODSYS", "*", "AEDECOD"), scorefun = score_occurrences_cols(col_indices = seq(1, ncol(result)))) pruned_and_sorted_result @@ -142,6 +146,8 @@ $sort { + idx_split_col <- which(sapply(col_paths(result), tail, 1) == + "All Patients") pruned_and_sorted_result <- pruned_result %>% sort_at_path(path = c("CMDECOD"), scorefun = score_occurrences) pruned_and_sorted_result @@ -247,8 +253,10 @@ $sort { + idx_split_col <- which(sapply(col_paths(result), tail, 1) == + "All Patients") pruned_and_sorted_result <- pruned_result %>% sort_at_path(path = c("AEBODSYS"), - scorefun = cont_n_onecol(ncol(result))) %>% sort_at_path(path = c("AEBODSYS", + scorefun = cont_n_onecol(idx_split_col)) %>% sort_at_path(path = c("AEBODSYS", "*", "AEDECOD"), scorefun = score_occurrences_cols(col_indices = seq(1, ncol(result)))) criteria_fun <- function(tr) { @@ -313,8 +321,10 @@ $sort { + idx_split_col <- which(sapply(col_paths(result), tail, 1) == + "All Patients") pruned_and_sorted_result <- pruned_result %>% sort_at_path(path = c("AEBODSYS"), - scorefun = cont_n_onecol(ncol(result))) %>% sort_at_path(path = c("AEBODSYS", + scorefun = cont_n_onecol(idx_split_col)) %>% sort_at_path(path = c("AEBODSYS", "*", "AEDECOD"), scorefun = score_occurrences_cols(col_indices = seq(1, ncol(result)))) criteria_fun <- function(tr) { From d4726d5033c30bcf510ad7580082994ed75b60c6 Mon Sep 17 00:00:00 2001 From: edelarua Date: Fri, 1 Dec 2023 17:23:51 +0000 Subject: [PATCH 10/28] [skip actions] Bump version to 0.8.16.9017 --- DESCRIPTION | 2 +- NEWS.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 28ca54ae45..6842a2bb0f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: teal.modules.clinical Title: Teal Modules for Standard Clinical Outputs -Version: 0.8.16.9016 +Version: 0.8.16.9017 Date: 2023-12-01 Authors@R: c( person("Joe", "Zhu", , "joe.zhu@roche.com", role = c("aut", "cre")), diff --git a/NEWS.md b/NEWS.md index bd615bdd8c..871d8ef2c6 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# teal.modules.clinical 0.8.16.9016 +# teal.modules.clinical 0.8.16.9017 ### Enhancements * Added more informative error message when grade mapping error occurs in `tm_t_abnormality_by_worst_grade`. From 3a35c7f5060037b8d8b4c864c3d8a088fa1cce3e Mon Sep 17 00:00:00 2001 From: Emily de la Rua <59304861+edelarua@users.noreply.github.com> Date: Tue, 5 Dec 2023 13:06:58 -0500 Subject: [PATCH 11/28] Remove unused `table_names` argument from `surv_timepoint` (#905) Fixes #904 --- R/tm_t_tte.R | 3 +-- tests/testthat/_snaps/tm_t_tte.md | 8 ++++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/R/tm_t_tte.R b/R/tm_t_tte.R index f73461eeaf..8608320b3d 100644 --- a/R/tm_t_tte.R +++ b/R/tm_t_tte.R @@ -324,8 +324,7 @@ template_tte <- function(dataname = "ANL", conf_level = conf_level, conf_type = conf_type ), - .indent_mods = indents, - table_names = "time_points" + .indent_mods = indents ), env = list( aval_var = aval_var, diff --git a/tests/testthat/_snaps/tm_t_tte.md b/tests/testthat/_snaps/tm_t_tte.md index 1a19c722a5..3c0116bba9 100644 --- a/tests/testthat/_snaps/tm_t_tte.md +++ b/tests/testthat/_snaps/tm_t_tte.md @@ -33,7 +33,7 @@ surv_timepoint(vars = "AVAL", var_labels = as.character(anl$AVALU[1]), is_event = "is_event", time_point = c(183, 365, 548), method = "surv", control = control_surv_timepoint(conf_level = 0.95, - conf_type = "plain"), .indent_mods = NULL, table_names = "time_points") + conf_type = "plain"), .indent_mods = NULL) $table { @@ -77,7 +77,7 @@ surv_timepoint(vars = "AVAL", var_labels = as.character(anl$AVALU[1]), is_event = "is_event", time_point = c(183, 365, 548), method = "surv", control = control_surv_timepoint(conf_level = 0.95, - conf_type = "plain"), .indent_mods = NULL, table_names = "time_points") + conf_type = "plain"), .indent_mods = NULL) $table { @@ -135,7 +135,7 @@ method = "both", control = control_surv_timepoint(conf_level = 0.95, conf_type = "plain"), .indent_mods = c(pt_at_risk = 0L, event_free_rate = 0L, rate_ci = 0L, rate_diff = 1L, - rate_diff_ci = 1L, ztest_pval = 1L), table_names = "time_points") + rate_diff_ci = 1L, ztest_pval = 1L)) $table { @@ -189,7 +189,7 @@ method = "both", control = control_surv_timepoint(conf_level = 0.95, conf_type = "plain"), .indent_mods = c(pt_at_risk = 0L, event_free_rate = 0L, rate_ci = 0L, rate_diff = 1L, - rate_diff_ci = 1L, ztest_pval = 1L), table_names = "time_points") + rate_diff_ci = 1L, ztest_pval = 1L)) $table { From a2172bf6f6a0da7773a5fda04b8918c5d2e57a07 Mon Sep 17 00:00:00 2001 From: edelarua Date: Tue, 5 Dec 2023 18:07:58 +0000 Subject: [PATCH 12/28] [skip actions] Bump version to 0.8.16.9018 --- DESCRIPTION | 4 ++-- NEWS.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 6842a2bb0f..0f9c5fa0c2 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: teal.modules.clinical Title: Teal Modules for Standard Clinical Outputs -Version: 0.8.16.9017 -Date: 2023-12-01 +Version: 0.8.16.9018 +Date: 2023-12-05 Authors@R: c( person("Joe", "Zhu", , "joe.zhu@roche.com", role = c("aut", "cre")), person("Jana", "Stoilova", , "jana.stoilova@roche.com", role = "aut"), diff --git a/NEWS.md b/NEWS.md index 871d8ef2c6..2159c1c1f6 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# teal.modules.clinical 0.8.16.9017 +# teal.modules.clinical 0.8.16.9018 ### Enhancements * Added more informative error message when grade mapping error occurs in `tm_t_abnormality_by_worst_grade`. From 029c1cc3b8e9a3be96af8406960546d6d64c6229 Mon Sep 17 00:00:00 2001 From: Aleksander Chlebowski <114988527+chlebowa@users.noreply.github.com> Date: Fri, 8 Dec 2023 14:39:38 +0100 Subject: [PATCH 13/28] `tdata` to `teal_data` (#855) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --------- Signed-off-by: Aleksander Chlebowski <114988527+chlebowa@users.noreply.github.com> Signed-off-by: Vedha Viyash <49812166+vedhav@users.noreply.github.com> Co-authored-by: go_gonzo Co-authored-by: 27856297+dependabot-preview[bot]@users.noreply.github.com <27856297+dependabot-preview[bot]@users.noreply.github.com> Co-authored-by: unknown Co-authored-by: Vedha Viyash <49812166+vedhav@users.noreply.github.com> Co-authored-by: André Veríssimo <211358+averissimo@users.noreply.github.com> Co-authored-by: vedhav --- DESCRIPTION | 8 +-- NEWS.md | 18 ++++-- R/tm_a_gee.R | 17 +++--- R/tm_a_mmrm.R | 15 +++-- R/tm_g_barchart_simple.R | 87 +++++++++++++++-------------- R/tm_g_ci.R | 21 ++++--- R/tm_g_forest_rsp.R | 31 +++++----- R/tm_g_forest_tte.R | 25 ++++----- R/tm_g_ipp.R | 24 ++++---- R/tm_g_km.R | 24 ++++---- R/tm_g_lineplot.R | 8 +-- R/tm_g_pp_adverse_events.R | 25 ++++----- R/tm_g_pp_patient_timeline.R | 10 ++-- R/tm_g_pp_therapy.R | 10 ++-- R/tm_g_pp_vitals.R | 10 ++-- R/tm_t_abnormality.R | 9 ++- R/tm_t_abnormality_by_worst_grade.R | 9 ++- R/tm_t_ancova.R | 13 ++--- R/tm_t_binary_outcome.R | 17 +++--- R/tm_t_coxreg.R | 10 ++-- R/tm_t_events.R | 11 ++-- R/tm_t_events_by_grade.R | 9 ++- R/tm_t_events_patyear.R | 13 ++--- R/tm_t_events_summary.R | 9 ++- R/tm_t_exposure.R | 9 ++- R/tm_t_logistic.R | 11 ++-- R/tm_t_mult_events.R | 21 ++++--- R/tm_t_pp_basic_info.R | 10 ++-- R/tm_t_pp_laboratory.R | 12 ++-- R/tm_t_pp_medical_history.R | 10 ++-- R/tm_t_pp_prior_medication.R | 30 +++++----- R/tm_t_shift_by_arm.R | 9 ++- R/tm_t_shift_by_arm_by_worst.R | 9 ++- R/tm_t_shift_by_grade.R | 9 ++- R/tm_t_smq.R | 9 ++- R/tm_t_summary.R | 13 ++--- R/tm_t_summary_by.R | 9 ++- R/tm_t_tte.R | 17 +++--- man/tm_a_gee.Rd | 2 +- 39 files changed, 297 insertions(+), 316 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 0f9c5fa0c2..2fdc8567f2 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -26,7 +26,7 @@ BugReports: https://github.com/insightsengineering/teal.modules.clinical/issues Depends: R (>= 4.0), - teal (>= 0.14.0.9019), + teal (>= 0.14.0.9027), tern (>= 0.9.2.9017) Imports: assertthat, @@ -53,11 +53,11 @@ Imports: shinyWidgets, stats, styler, - teal.code (>= 0.4.0), - teal.data (>= 0.3.0.9010), + teal.code(>= 0.4.1.9009), + teal.data (>= 0.3.0.9018), teal.logger (>= 0.1.1), teal.reporter (>= 0.2.1), - teal.transform (>= 0.4.0.9007), + teal.transform (>= 0.4.0.9011), teal.widgets (>= 0.4.0), tern.gee (>= 0.1.0), tern.mmrm (>= 0.2.1), diff --git a/NEWS.md b/NEWS.md index 2159c1c1f6..ec72100e20 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,19 @@ # teal.modules.clinical 0.8.16.9018 +### Breaking Changes ++ Adapted all modules to use `teal_data` objects. + +### Enhancements +* Updated the documentation and vignettes to demonstrate method to pass `teal_data` object to `teal::init()`. +* Added parameter `sort_freq_col` to `tm_t_events` to allow the user to select column to use when sorting by decreasing frequency. +* Added parameter `incl_overall_sum` to `tm_t_events` to allow the user to choose whether overall summary rows are included at the top of the table. +* Updated the documentation and vignettes to demonstrate method to pass `teal_data` object to `teal::init()`. + +### Bug fixes +* Fixed bug in `tm_g_lineplot` forcing module to initialize with a table. + +# teal.modules.clinical 0.8.16.9010 + ### Enhancements * Added more informative error message when grade mapping error occurs in `tm_t_abnormality_by_worst_grade`. * Fixed label indentation in `tm_t_abnormality_by_worst_grade`. @@ -14,13 +28,9 @@ * Updated `tm_t_pp_basic_info`, `tm_g_pp_therapy`, `tm_g_pp_adverse_events`, and `tm_t_pp_laboratory` to use `rlistings` to print data neatly in reports. * Updated `tm_g_lineplot` to allow user to remove interval from plot. * Updated the documentation and vignettes to demonstrate method to pass `teal_data` object to `teal::init()`. -* Added parameter `sort_freq_col` to `tm_t_events` to allow the user to select column to use when sorting by decreasing frequency. -* Added parameter `incl_overall_sum` to `tm_t_events` to allow the user to choose whether overall summary rows are included at the top of the table. -* Updated the documentation and vignettes to demonstrate method to pass `teal_data` object to `teal::init()`. ### Bug fixes * Fixed bug in `tm_t_coxreg` preventing table from being displayed when no covariates are selected. -* Fixed bug in `tm_g_lineplot` forcing module to initialize with a table. ### Miscellaneous * Updated `control_incidence_rate` parameter names in `tm_t_events_patyear` from `time_unit_input` and `time_unit_output` to `input_time_unit` and `num_pt_year`, respectively, after parameter names were changed in `tern`. diff --git a/R/tm_a_gee.R b/R/tm_a_gee.R index f6ac605e65..57c2106eb2 100644 --- a/R/tm_a_gee.R +++ b/R/tm_a_gee.R @@ -139,7 +139,7 @@ template_a_gee <- function(output_table, #' as.factor() %>% #' as.numeric() %>% #' as.factor(), -#' AVALBIN = AVAL < 50 #' Just as an example to get a binary endpoint. +#' AVALBIN = AVAL < 50 # Just as an example to get a binary endpoint. #' ) %>% #' droplevels() #' }) @@ -369,7 +369,8 @@ srv_gee <- function(id, basic_table_args) { with_reporter <- !missing(reporter) && inherits(reporter, "Reporter") with_filter <- !missing(filter_panel_api) && inherits(filter_panel_api, "FilterPanelAPI") - checkmate::assert_class(data, "tdata") + checkmate::assert_class(data, "reactive") + checkmate::assert_class(shiny::isolate(data()), "teal_data") shiny::moduleServer(id, function(input, output, session) { ## split_covariates ---- @@ -401,7 +402,7 @@ srv_gee <- function(id, input, output, id_arm_var = extract_input("arm_var", parentname), - data = data[[parentname]], + data = shiny::reactive(data()[[parentname]]), arm_ref_comp = arm_ref_comp, module = "tm_a_gee" ) @@ -446,19 +447,17 @@ srv_gee <- function(id, anl_inputs <- teal.transform::merge_expression_srv( datasets = data, selector_list = selector_list, - merge_function = "dplyr::inner_join", - join_keys = teal.data::join_keys(data) + merge_function = "dplyr::inner_join" ) adsl_inputs <- teal.transform::merge_expression_module( datasets = data, data_extract = list(arm_var = arm_var), - anl_name = "ANL_ADSL", - join_keys = teal.data::join_keys(data) + anl_name = "ANL_ADSL" ) anl_q <- shiny::reactive({ - teal.code::new_qenv(tdata2env(data), code = get_code_tdata(data)) %>% + data() %>% teal.code::eval_code(as.expression(anl_inputs()$expr)) %>% teal.code::eval_code(as.expression(adsl_inputs()$expr)) }) @@ -570,7 +569,7 @@ srv_gee <- function(id, card$append_text("Comment", "header3") card$append_text(comment) } - card$append_src(paste(teal.code::get_code(table_q()), collapse = "\n")) + card$append_src(teal.code::get_code(table_q())) card } teal.reporter::simple_reporter_srv("simple_reporter", reporter = reporter, card_fun = card_fun) diff --git a/R/tm_a_mmrm.R b/R/tm_a_mmrm.R index f7a2f2ed4b..2db02c2006 100644 --- a/R/tm_a_mmrm.R +++ b/R/tm_a_mmrm.R @@ -824,7 +824,8 @@ srv_mmrm <- function(id, ggplot2_args) { with_reporter <- !missing(reporter) && inherits(reporter, "Reporter") with_filter <- !missing(filter_panel_api) && inherits(filter_panel_api, "FilterPanelAPI") - checkmate::assert_class(data, "tdata") + checkmate::assert_class(data, "reactive") + checkmate::assert_class(shiny::isolate(data()), "teal_data") shiny::moduleServer(id, function(input, output, session) { # Reactive responsible for sending a disable/enable signal @@ -853,7 +854,7 @@ srv_mmrm <- function(id, input, output, id_arm_var = extract_input("arm_var", parentname), # From UI. - data = data[[parentname]], + data = shiny::reactive(data()[[parentname]]), arm_ref_comp = arm_ref_comp, module = "tm_mmrm" ) @@ -920,21 +921,19 @@ srv_mmrm <- function(id, anl_inputs <- teal.transform::merge_expression_srv( datasets = data, selector_list = selector_list_without_cov, - join_keys = teal.data::join_keys(data), merge_function = "dplyr::inner_join" ) adsl_merge_inputs <- teal.transform::merge_expression_module( datasets = data, data_extract = list(arm_var = arm_var), - join_keys = teal.data::join_keys(data), anl_name = "ANL_ADSL" ) anl_q <- shiny::reactive({ - qenv <- teal.code::new_qenv(tdata2env(data), code = get_code_tdata(data)) - qenv2 <- teal.code::eval_code(qenv, as.expression(anl_inputs()$expr)) - teal.code::eval_code(qenv2, as.expression(adsl_merge_inputs()$expr)) + data() %>% + teal.code::eval_code(code = as.expression(anl_inputs()$expr)) %>% + teal.code::eval_code(code = as.expression(adsl_merge_inputs()$expr)) }) # Initially hide the output title because there is no output yet. @@ -1457,7 +1456,7 @@ srv_mmrm <- function(id, card$append_text("Comment", "header3") card$append_text(comment) } - card$append_src(paste(teal.code::get_code(all_q()), collapse = "\n")) + card$append_src(teal.code::get_code(all_q())) card } teal.reporter::simple_reporter_srv("simple_reporter", reporter = reporter, card_fun = card_fun) diff --git a/R/tm_g_barchart_simple.R b/R/tm_g_barchart_simple.R index 08604c82e4..b29fa9ee7a 100644 --- a/R/tm_g_barchart_simple.R +++ b/R/tm_g_barchart_simple.R @@ -329,7 +329,8 @@ srv_g_barchart_simple <- function(id, ggplot2_args) { with_reporter <- !missing(reporter) && inherits(reporter, "Reporter") with_filter <- !missing(filter_panel_api) && inherits(filter_panel_api, "FilterPanelAPI") - checkmate::assert_class(data, "tdata") + checkmate::assert_class(data, "reactive") + checkmate::assert_class(shiny::isolate(data()), "teal_data") shiny::moduleServer(id, function(input, output, session) { rule_dupl <- function(others) { @@ -381,19 +382,17 @@ srv_g_barchart_simple <- function(id, anl_inputs <- teal.transform::merge_expression_srv( datasets = data, - join_keys = teal.data::join_keys(data), selector_list = selector_list ) anl_q <- shiny::reactive({ - qenv <- teal.code::new_qenv(tdata2env(data), code = get_code_tdata(data)) - qenv <- teal.code::eval_code(qenv, as.expression(anl_inputs()$expr)) - qenv + data() %>% + teal.code::eval_code(as.expression(anl_inputs()$expr)) }) count_q <- shiny::reactive({ - qenv <- anl_q() - teal::validate_has_data(qenv[["ANL"]], 2) + anl_q <- anl_q() + teal::validate_has_data(anl_q[["ANL"]], 2) groupby_vars <- r_groupby_vars() # count @@ -409,51 +408,46 @@ srv_g_barchart_simple <- function(id, count_str_to_col_exprs <- sapply(groupby_vars[-1], count_str_to_column_expr) count_exprs <- c(count_exprs, count_exprs2, count_str_to_col_exprs) } - qenv2 <- teal.code::eval_code(qenv, code = count_exprs) + + data_list <- sapply(teal.data::datanames(data()), function(x) shiny::reactive(data()[[x]]), + simplify = FALSE + ) + + anl_q <- anl_q %>% + teal.code::eval_code(code = count_exprs) # add label and slice(1) as all patients in the same subgroup have same n_'s - qenv3 <- teal.code::eval_code( - qenv2, - as.expression( - c( - bquote(attr(counts[[.(get_n_name(groupby_vars))]], "label") <- "Count"), - bquote( - counts <- counts %>% - dplyr::group_by_at(.(as.vector(groupby_vars))) %>% - dplyr::slice(1) %>% - dplyr::ungroup() %>% - dplyr::select(.(as.vector(groupby_vars)), dplyr::starts_with("n_")) + anl_q <- anl_q %>% + teal.code::eval_code( + as.expression( + c( + bquote(attr(counts[[.(get_n_name(groupby_vars))]], "label") <- "Count"), + bquote( + counts <- counts %>% + dplyr::group_by_at(.(as.vector(groupby_vars))) %>% + dplyr::slice(1) %>% + dplyr::ungroup() %>% + dplyr::select(.(as.vector(groupby_vars)), dplyr::starts_with("n_")) + ) ) ) ) - ) # dplyr::select loses labels - teal.code::eval_code( - qenv3, - teal.transform::get_anl_relabel_call( - columns_source = anl_inputs()$columns_source, - datasets = data, - anl_name = "counts" + anl_q %>% + teal.code::eval_code( + teal.transform::get_anl_relabel_call( + columns_source = anl_inputs()$columns_source, + datasets = data_list, + anl_name = "counts" + ) ) - ) }) all_q <- shiny::reactive({ teal::validate_inputs(iv_r()) groupby_vars <- as.list(r_groupby_vars()) # so $ access works below - ANL <- count_q()[["ANL"]] # nolint - - qenv2 <- teal.code::eval_code(count_q(), substitute( - env = list(groupby_vars = paste(groupby_vars, collapse = ", ")), - plot_title <- sprintf( - "Number of patients (total N = %s) for each combination of (%s)", - nrow(ANL), - groupby_vars - ) - )) - y_lab <- substitute( column_annotation_label(counts, y_name), list(y_name = get_n_name(groupby_vars)) @@ -487,11 +481,22 @@ srv_g_barchart_simple <- function(id, ggplot2_args = all_ggplot2_args ) - qenv3 <- teal.code::eval_code(qenv2, code = plot_call) + ANL <- count_q()[["ANL"]] # nolint + + all_q <- count_q() %>% + teal.code::eval_code(substitute( + env = list(groupby_vars = paste(groupby_vars, collapse = ", ")), + plot_title <- sprintf( + "Number of patients (total N = %s) for each combination of (%s)", + nrow(ANL), + groupby_vars + ) + )) %>% + teal.code::eval_code(code = plot_call) # explicitly calling print on the plot inside the qenv evaluates # the ggplot call and therefore catches errors - teal.code::eval_code(qenv3, code = quote(print(plot))) + teal.code::eval_code(all_q, code = quote(print(plot))) }) plot_r <- shiny::reactive(all_q()[["plot"]]) @@ -558,7 +563,7 @@ srv_g_barchart_simple <- function(id, card$append_text("Comment", "header3") card$append_text(comment) } - card$append_src(paste(teal.code::get_code(all_q()), collapse = "\n")) + card$append_src(teal.code::get_code(all_q())) card } teal.reporter::simple_reporter_srv("simple_reporter", reporter = reporter, card_fun = card_fun) diff --git a/R/tm_g_ci.R b/R/tm_g_ci.R index 6ed37997bd..fb06f18cce 100644 --- a/R/tm_g_ci.R +++ b/R/tm_g_ci.R @@ -376,7 +376,8 @@ srv_g_ci <- function(id, # nolint ggplot2_args) { with_reporter <- !missing(reporter) && inherits(reporter, "Reporter") with_filter <- !missing(filter_panel_api) && inherits(filter_panel_api, "FilterPanelAPI") - checkmate::assert_class(data, "tdata") + checkmate::assert_class(data, "reactive") + checkmate::assert_class(shiny::isolate(data()), "teal_data") shiny::moduleServer(id, function(input, output, session) { selector_list <- teal.transform::data_extract_multiple_srv( @@ -407,12 +408,10 @@ srv_g_ci <- function(id, # nolint selector_list = selector_list ) - anl_q <- shiny::reactive( - teal.code::eval_code( - object = teal.code::new_qenv(tdata2env(data), code = get_code_tdata(data)), - code = as.expression(anl_inputs()$expr) - ) - ) + anl_q <- shiny::reactive({ + data() %>% + teal.code::eval_code(as.expression(anl_inputs()$expr)) + }) all_q <- shiny::reactive({ teal::validate_inputs(iv_r()) @@ -429,10 +428,10 @@ srv_g_ci <- function(id, # nolint ) ) - x_label <- column_annotation_label(data[[attr(x, "dataname")]](), x) - y_label <- column_annotation_label(data[[attr(y, "dataname")]](), y) + x_label <- column_annotation_label(data()[[attr(x, "dataname")]], x) + y_label <- column_annotation_label(data()[[attr(y, "dataname")]], y) color_label <- if (length(color)) { - column_annotation_label(data[[attr(color, "dataname")]](), color) + column_annotation_label(data()[[attr(color, "dataname")]], color) } else { NULL } @@ -501,7 +500,7 @@ srv_g_ci <- function(id, # nolint card$append_text("Comment", "header3") card$append_text(comment) } - card$append_src(paste(teal.code::get_code(all_q()), collapse = "\n")) + card$append_src(teal.code::get_code(all_q())) card } teal.reporter::simple_reporter_srv("simple_reporter", reporter = reporter, card_fun = card_fun) diff --git a/R/tm_g_forest_rsp.R b/R/tm_g_forest_rsp.R index 8ea397b378..4960f25c8a 100644 --- a/R/tm_g_forest_rsp.R +++ b/R/tm_g_forest_rsp.R @@ -474,7 +474,8 @@ srv_g_forest_rsp <- function(id, ggplot2_args) { with_reporter <- !missing(reporter) && inherits(reporter, "Reporter") with_filter <- !missing(filter_panel_api) && inherits(filter_panel_api, "FilterPanelAPI") - checkmate::assert_class(data, "tdata") + checkmate::assert_class(data, "reactive") + checkmate::assert_class(shiny::isolate(data()), "teal_data") shiny::moduleServer(id, function(input, output, session) { # Setup arm variable selection, default reference arms, and default @@ -484,7 +485,7 @@ srv_g_forest_rsp <- function(id, input, output, id_arm_var = extract_input("arm_var", parentname), - data = data[[parentname]], + data = data()[[parentname]], arm_ref_comp = arm_ref_comp, module = "tm_t_tte" ) @@ -520,21 +521,19 @@ srv_g_forest_rsp <- function(id, anl_inputs <- teal.transform::merge_expression_srv( datasets = data, selector_list = selector_list, - merge_function = "dplyr::inner_join", - join_keys = teal.data::join_keys(data) + merge_function = "dplyr::inner_join" ) adsl_inputs <- teal.transform::merge_expression_module( datasets = data, data_extract = list(arm_var = arm_var, subgroup_var = subgroup_var, strata_var = strata_var), - join_keys = teal.data::join_keys(data), anl_name = "ANL_ADSL" ) anl_q <- shiny::reactive({ - q <- teal.code::new_qenv(tdata2env(data), code = get_code_tdata(data)) - qenv <- teal.code::eval_code(q, as.expression(anl_inputs()$expr)) - teal.code::eval_code(qenv, as.expression(adsl_inputs()$expr)) + data() %>% + teal.code::eval_code(code = as.expression(anl_inputs()$expr)) %>% + teal.code::eval_code(code = as.expression(adsl_inputs()$expr)) }) shiny::observeEvent( @@ -588,10 +587,9 @@ srv_g_forest_rsp <- function(id, validate_checks <- shiny::reactive({ teal::validate_inputs(iv_r()) shiny::req(anl_q()) - qenv <- anl_q() - adsl_filtered <- qenv[[parentname]] - anl_filtered <- qenv[[dataname]] - anl <- qenv[["ANL"]] + adsl_filtered <- anl_q()[[parentname]] + anl_filtered <- anl_q()[[dataname]] + anl <- anl_q()[["ANL"]] anl_m <- anl_inputs() input_arm_var <- as.vector(anl_m$columns_source$arm_var) @@ -615,7 +613,7 @@ srv_g_forest_rsp <- function(id, do.call(what = "validate_standard_inputs", validate_args) - teal::validate_one_row_per_id(qenv[["ANL"]], key = c("USUBJID", "STUDYID", input_paramcd)) + teal::validate_one_row_per_id(anl_q()[["ANL"]], key = c("USUBJID", "STUDYID", input_paramcd)) if (length(input_subgroup_var) > 0) { shiny::validate( @@ -667,14 +665,13 @@ srv_g_forest_rsp <- function(id, ) } - validate_has_data(qenv[["ANL"]], min_nrow = 1) + validate_has_data(anl_q()[["ANL"]], min_nrow = 1) NULL }) # The R-code corresponding to the analysis. all_q <- shiny::reactive({ validate_checks() - qenv <- anl_q() anl_m <- anl_inputs() strata_var <- as.vector(anl_m$columns_source$strata_var) @@ -698,7 +695,7 @@ srv_g_forest_rsp <- function(id, ggplot2_args = ggplot2_args ) - teal.code::eval_code(qenv, as.expression(my_calls)) + teal.code::eval_code(anl_q(), as.expression(my_calls)) }) plot_r <- shiny::reactive(all_q()[["p"]]) @@ -738,7 +735,7 @@ srv_g_forest_rsp <- function(id, card$append_text("Comment", "header3") card$append_text(comment) } - card$append_src(paste(teal.code::get_code(all_q()), collapse = "\n")) + card$append_src(teal.code::get_code(all_q())) card } teal.reporter::simple_reporter_srv("simple_reporter", reporter = reporter, card_fun = card_fun) diff --git a/R/tm_g_forest_tte.R b/R/tm_g_forest_tte.R index 3eeb82bbe8..a50c6e015a 100644 --- a/R/tm_g_forest_tte.R +++ b/R/tm_g_forest_tte.R @@ -475,7 +475,8 @@ srv_g_forest_tte <- function(id, ggplot2_args) { with_reporter <- !missing(reporter) && inherits(reporter, "Reporter") with_filter <- !missing(filter_panel_api) && inherits(filter_panel_api, "FilterPanelAPI") - checkmate::assert_class(data, "tdata") + checkmate::assert_class(data, "reactive") + checkmate::assert_class(shiny::isolate(data()), "teal_data") shiny::moduleServer(id, function(input, output, session) { # Setup arm variable selection, default reference arms, and default @@ -485,7 +486,7 @@ srv_g_forest_tte <- function(id, input, output, id_arm_var = extract_input("arm_var", parentname), - data = data[[parentname]], + data = data()[[parentname]], arm_ref_comp = arm_ref_comp, module = "tm_g_forest_tte" ) @@ -522,30 +523,27 @@ srv_g_forest_tte <- function(id, anl_inputs <- teal.transform::merge_expression_srv( datasets = data, - join_keys = teal.data::join_keys(data), selector_list = selector_list, merge_function = "dplyr::inner_join" ) adsl_inputs <- teal.transform::merge_expression_module( datasets = data, - join_keys = teal.data::join_keys(data), data_extract = list(arm_var = arm_var, subgroup_var = subgroup_var, strata_var = strata_var), anl_name = "ANL_ADSL" ) anl_q <- shiny::reactive({ - q <- teal.code::new_qenv(tdata2env(data), code = get_code_tdata(data)) - qenv <- teal.code::eval_code(q, as.expression(anl_inputs()$expr)) - teal.code::eval_code(qenv, as.expression(adsl_inputs()$expr)) + data() %>% + teal.code::eval_code(as.expression(anl_inputs()$expr)) %>% + teal.code::eval_code(as.expression(adsl_inputs()$expr)) }) validate_checks <- shiny::reactive({ teal::validate_inputs(iv_r()) - qenv <- anl_q() - adsl_filtered <- qenv[[parentname]] - anl_filtered <- qenv[[dataname]] - anl <- qenv[["ANL"]] + adsl_filtered <- anl_q()[[parentname]] + anl_filtered <- anl_q()[[dataname]] + anl <- anl_q()[["ANL"]] anl_m <- anl_inputs() input_arm_var <- as.vector(anl_m$columns_source$arm_var) @@ -605,7 +603,6 @@ srv_g_forest_tte <- function(id, all_q <- shiny::reactive({ validate_checks() - qenv <- anl_q() anl_m <- anl_inputs() strata_var <- as.vector(anl_m$columns_source$strata_var) @@ -629,7 +626,7 @@ srv_g_forest_tte <- function(id, time_unit_var = as.vector(anl_m$columns_source$time_unit_var), ggplot2_args = ggplot2_args ) - teal.code::eval_code(qenv, as.expression(my_calls)) + teal.code::eval_code(anl_q(), as.expression(my_calls)) }) # Outputs to render. @@ -670,7 +667,7 @@ srv_g_forest_tte <- function(id, card$append_text("Comment", "header3") card$append_text(comment) } - card$append_src(paste(teal.code::get_code(all_q()), collapse = "\n")) + card$append_src(teal.code::get_code(all_q())) card } teal.reporter::simple_reporter_srv("simple_reporter", reporter = reporter, card_fun = card_fun) diff --git a/R/tm_g_ipp.R b/R/tm_g_ipp.R index 37dc7875fa..1698b4f048 100644 --- a/R/tm_g_ipp.R +++ b/R/tm_g_ipp.R @@ -463,7 +463,8 @@ srv_g_ipp <- function(id, ggplot2_args) { with_reporter <- !missing(reporter) && inherits(reporter, "Reporter") with_filter <- !missing(filter_panel_api) && inherits(filter_panel_api, "FilterPanelAPI") - checkmate::assert_class(data, "tdata") + checkmate::assert_class(data, "reactive") + checkmate::assert_class(shiny::isolate(data()), "teal_data") shiny::moduleServer(id, function(input, output, session) { selector_list <- teal.transform::data_extract_multiple_srv( @@ -498,8 +499,7 @@ srv_g_ipp <- function(id, anl_inputs <- teal.transform::merge_expression_srv( datasets = data, selector_list = selector_list, - merge_function = "dplyr::inner_join", - join_keys = teal.data::join_keys(data) + merge_function = "dplyr::inner_join" ) adsl_inputs <- teal.transform::merge_expression_module( @@ -510,18 +510,17 @@ srv_g_ipp <- function(id, ) anl_q <- shiny::reactive({ - q <- teal.code::new_qenv(tdata2env(data), code = get_code_tdata(data)) - qenv <- teal.code::eval_code(q, as.expression(anl_inputs()$expr)) - teal.code::eval_code(qenv, as.expression(adsl_inputs()$expr)) + data() %>% + teal.code::eval_code(as.expression(anl_inputs()$expr)) %>% + teal.code::eval_code(as.expression(adsl_inputs()$expr)) }) # Prepare the analysis environment (filter data, check data, populate envir). validate_checks <- shiny::reactive({ teal::validate_inputs(iv_r()) - qenv <- anl_q() - adsl_filtered <- qenv[[parentname]] - anl_filtered <- qenv[[dataname]] + adsl_filtered <- anl_q()[[parentname]] + anl_filtered <- anl_q()[[dataname]] anl_m <- anl_inputs() input_arm_var <- unlist(arm_var$filter)["vars_selected"] @@ -557,10 +556,9 @@ srv_g_ipp <- function(id, # The R-code corresponding to the analysis. all_q <- shiny::reactive({ validate_checks() - qenv <- anl_q() anl_m <- anl_inputs() - ANL <- qenv[["ANL"]] # nolint + ANL <- anl_q()[["ANL"]] # nolint teal::validate_has_data(ANL, 2) arm_var <- unlist(arm_var$filter)["vars_selected"] @@ -589,7 +587,7 @@ srv_g_ipp <- function(id, ggplot2_args = ggplot2_args, add_avalu = input$add_avalu ) - teal.code::eval_code(qenv, as.expression(my_calls)) + teal.code::eval_code(anl_q(), as.expression(my_calls)) }) # Outputs to render. @@ -631,7 +629,7 @@ srv_g_ipp <- function(id, card$append_text("Comment", "header3") card$append_text(comment) } - card$append_src(paste(teal.code::get_code(all_q()), collapse = "\n")) + card$append_src(teal.code::get_code(all_q())) card } teal.reporter::simple_reporter_srv("simple_reporter", reporter = reporter, card_fun = card_fun) diff --git a/R/tm_g_km.R b/R/tm_g_km.R index 1bbf08c4b5..e23b61124a 100644 --- a/R/tm_g_km.R +++ b/R/tm_g_km.R @@ -584,7 +584,8 @@ srv_g_km <- function(id, plot_width) { with_reporter <- !missing(reporter) && inherits(reporter, "Reporter") with_filter <- !missing(filter_panel_api) && inherits(filter_panel_api, "FilterPanelAPI") - checkmate::assert_class(data, "tdata") + checkmate::assert_class(data, "reactive") + checkmate::assert_class(shiny::isolate(data()), "teal_data") shiny::moduleServer(id, function(input, output, session) { # Setup arm variable selection, default reference arms and default @@ -594,7 +595,7 @@ srv_g_km <- function(id, input, output, id_arm_var = extract_input("arm_var", parentname), - data = data[[parentname]], + data = data()[[parentname]], arm_ref_comp = arm_ref_comp, module = "tm_t_tte", on_off = shiny::reactive(input$compare_arms) @@ -656,24 +657,20 @@ srv_g_km <- function(id, anl_inputs <- teal.transform::merge_expression_srv( datasets = data, - join_keys = teal.data::join_keys(data), selector_list = selector_list, merge_function = "dplyr::inner_join" ) anl_q <- shiny::reactive({ - teal.code::eval_code( - teal.code::new_qenv(tdata2env(data), code = get_code_tdata(data)), - code = as.expression(anl_inputs()$expr) - ) + data() %>% + teal.code::eval_code(code = as.expression(anl_inputs()$expr)) }) validate_checks <- shiny::reactive({ teal::validate_inputs(iv_r()) - qenv <- anl_q() - adsl_filtered <- qenv[[parentname]] - anl_filtered <- qenv[[dataname]] + adsl_filtered <- anl_q()[[parentname]] + anl_filtered <- anl_q()[[dataname]] anl_m <- anl_inputs() input_arm_var <- as.vector(anl_m$columns_source$arm_var) @@ -711,10 +708,9 @@ srv_g_km <- function(id, all_q <- shiny::reactive({ validate_checks() - qenv <- anl_q() anl_m <- anl_inputs() - anl <- qenv[["ANL"]] # nolint + anl <- anl_q()[["ANL"]] # nolint teal::validate_has_data(anl, 2) input_xticks <- if (!is.null(input$xticks)) { @@ -749,7 +745,7 @@ srv_g_km <- function(id, ci_ribbon = input$show_ci_ribbon, title = title ) - teal.code::eval_code(qenv, as.expression(my_calls)) + teal.code::eval_code(anl_q(), as.expression(my_calls)) }) plot_r <- shiny::reactive(all_q()[["plot"]]) @@ -791,7 +787,7 @@ srv_g_km <- function(id, card$append_text("Comment", "header3") card$append_text(comment) } - card$append_src(paste(teal.code::get_code(all_q()), collapse = "\n")) + card$append_src(teal.code::get_code(all_q())) card } teal.reporter::simple_reporter_srv("simple_reporter", reporter = reporter, card_fun = card_fun) diff --git a/R/tm_g_lineplot.R b/R/tm_g_lineplot.R index 0efd44860e..f640fdac5d 100644 --- a/R/tm_g_lineplot.R +++ b/R/tm_g_lineplot.R @@ -524,7 +524,8 @@ srv_g_lineplot <- function(id, ggplot2_args) { with_reporter <- !missing(reporter) && inherits(reporter, "Reporter") with_filter <- !missing(filter_panel_api) && inherits(filter_panel_api, "FilterPanelAPI") - checkmate::assert_class(data, "tdata") + checkmate::assert_class(data, "reactive") + checkmate::assert_class(shiny::isolate(data()), "teal_data") shiny::moduleServer(id, function(input, output, session) { selector_list <- teal.transform::data_extract_multiple_srv( @@ -555,13 +556,12 @@ srv_g_lineplot <- function(id, anl_inputs <- teal.transform::merge_expression_srv( datasets = data, - join_keys = teal.data::join_keys(data), selector_list = selector_list, merge_function = "dplyr::inner_join" ) anl_q <- shiny::reactive({ - teal.code::new_qenv(tdata2env(data), code = get_code_tdata(data)) %>% + data() %>% teal.code::eval_code(as.expression(anl_inputs()$expr)) }) @@ -673,7 +673,7 @@ srv_g_lineplot <- function(id, card$append_text("Comment", "header3") card$append_text(comment) } - card$append_src(paste(teal.code::get_code(all_q()), collapse = "\n")) + card$append_src(teal.code::get_code(all_q())) card } teal.reporter::simple_reporter_srv("simple_reporter", reporter = reporter, card_fun = card_fun) diff --git a/R/tm_g_pp_adverse_events.R b/R/tm_g_pp_adverse_events.R index 2772d39963..6b2f33d844 100644 --- a/R/tm_g_pp_adverse_events.R +++ b/R/tm_g_pp_adverse_events.R @@ -431,13 +431,14 @@ srv_g_adverse_events <- function(id, ggplot2_args) { with_reporter <- !missing(reporter) && inherits(reporter, "Reporter") with_filter <- !missing(filter_panel_api) && inherits(filter_panel_api, "FilterPanelAPI") - checkmate::assert_class(data, "tdata") + checkmate::assert_class(data, "reactive") + checkmate::assert_class(shiny::isolate(data()), "teal_data") shiny::moduleServer(id, function(input, output, session) { patient_id <- shiny::reactive(input$patient_id) # Init - patient_data_base <- shiny::reactive(unique(data[[parentname]]()[[patient_col]])) + patient_data_base <- shiny::reactive(unique(data()[[parentname]][[patient_col]])) teal.widgets::updateOptionalSelectInput( session, "patient_id", @@ -495,26 +496,24 @@ srv_g_adverse_events <- function(id, anl_inputs <- teal.transform::merge_expression_srv( datasets = data, - selector_list = selector_list, - join_keys = teal.data::join_keys(data) + selector_list = selector_list ) anl_q <- shiny::reactive( - teal.code::eval_code( - teal.code::new_qenv(tdata2env(data), code = get_code_tdata(data)), as.expression(anl_inputs()$expr) - ) + data() %>% + teal.code::eval_code(as.expression(anl_inputs()$expr)) ) all_q <- shiny::reactive({ teal::validate_inputs(iv_r()) anl_m <- anl_inputs() - qenv <- anl_q() - ANL <- qenv[["ANL"]] # nolint + + ANL <- anl_q()[["ANL"]] # nolint teal::validate_has_data(ANL[ANL[[patient_col]] == input$patient_id, ], min_nrow = 1) - qenv2 <- teal.code::eval_code( - qenv, + anl_q2 <- teal.code::eval_code( + anl_q(), substitute( expr = { pt_id <- patient_id @@ -540,7 +539,7 @@ srv_g_adverse_events <- function(id, ggplot2_args = ggplot2_args ) - teal.code::eval_code(qenv2, as.expression(calls)) + teal.code::eval_code(anl_q2, as.expression(calls)) }) output$title <- shiny::renderText({ @@ -594,7 +593,7 @@ srv_g_adverse_events <- function(id, card$append_text("Comment", "header3") card$append_text(comment) } - card$append_src(paste(teal.code::get_code(all_q()), collapse = "\n")) + card$append_src(teal.code::get_code(all_q())) card } teal.reporter::simple_reporter_srv("simple_reporter", reporter = reporter, card_fun = card_fun) diff --git a/R/tm_g_pp_patient_timeline.R b/R/tm_g_pp_patient_timeline.R index 6bae0dc5eb..9fc20eabc5 100644 --- a/R/tm_g_pp_patient_timeline.R +++ b/R/tm_g_pp_patient_timeline.R @@ -685,13 +685,14 @@ srv_g_patient_timeline <- function(id, ggplot2_args) { with_reporter <- !missing(reporter) && inherits(reporter, "Reporter") with_filter <- !missing(filter_panel_api) && inherits(filter_panel_api, "FilterPanelAPI") - checkmate::assert_class(data, "tdata") + checkmate::assert_class(data, "reactive") + checkmate::assert_class(shiny::isolate(data()), "teal_data") shiny::moduleServer(id, function(input, output, session) { patient_id <- shiny::reactive(input$patient_id) # Init - patient_data_base <- shiny::reactive(unique(data[[parentname]]()[[patient_col]])) + patient_data_base <- shiny::reactive(unique(data()[[parentname]][[patient_col]])) teal.widgets::updateOptionalSelectInput( session, "patient_id", @@ -767,12 +768,11 @@ srv_g_patient_timeline <- function(id, anl_inputs <- teal.transform::merge_expression_srv( datasets = data, - join_keys = teal.data::join_keys(data), selector_list = selector_list ) anl_q <- shiny::reactive({ - teal.code::new_qenv(tdata2env(data), code = get_code_tdata(data)) %>% + data() %>% teal.code::eval_code(as.expression(anl_inputs()$expr)) }) @@ -914,7 +914,7 @@ srv_g_patient_timeline <- function(id, card$append_text("Comment", "header3") card$append_text(comment) } - card$append_src(paste(teal.code::get_code(all_q()), collapse = "\n")) + card$append_src(teal.code::get_code(all_q())) card } teal.reporter::simple_reporter_srv("simple_reporter", reporter = reporter, card_fun = card_fun) diff --git a/R/tm_g_pp_therapy.R b/R/tm_g_pp_therapy.R index a613b0300f..46b801015e 100644 --- a/R/tm_g_pp_therapy.R +++ b/R/tm_g_pp_therapy.R @@ -554,13 +554,14 @@ srv_g_therapy <- function(id, ggplot2_args) { with_reporter <- !missing(reporter) && inherits(reporter, "Reporter") with_filter <- !missing(filter_panel_api) && inherits(filter_panel_api, "FilterPanelAPI") - checkmate::assert_class(data, "tdata") + checkmate::assert_class(data, "reactive") + checkmate::assert_class(shiny::isolate(data()), "teal_data") shiny::moduleServer(id, function(input, output, session) { patient_id <- shiny::reactive(input$patient_id) # Init - patient_data_base <- shiny::reactive(unique(data[[parentname]]()[[patient_col]])) + patient_data_base <- shiny::reactive(unique(data()[[parentname]][[patient_col]])) teal.widgets::updateOptionalSelectInput( session, "patient_id", choices = patient_data_base(), selected = patient_data_base()[1] @@ -612,13 +613,12 @@ srv_g_therapy <- function(id, anl_inputs <- teal.transform::merge_expression_srv( datasets = data, - join_keys = teal.data::join_keys(data), selector_list = selector_list, merge_function = "dplyr::left_join" ) anl_q <- shiny::reactive({ - teal.code::new_qenv(tdata2env(data), code = get_code_tdata(data)) %>% + data() %>% teal.code::eval_code(as.expression(anl_inputs()$expr)) }) @@ -721,7 +721,7 @@ srv_g_therapy <- function(id, card$append_text("Comment", "header3") card$append_text(comment) } - card$append_src(paste(teal.code::get_code(all_q()), collapse = "\n")) + card$append_src(teal.code::get_code(all_q())) card } teal.reporter::simple_reporter_srv("simple_reporter", reporter = reporter, card_fun = card_fun) diff --git a/R/tm_g_pp_vitals.R b/R/tm_g_pp_vitals.R index e82af1c4f0..80e0dfecd7 100644 --- a/R/tm_g_pp_vitals.R +++ b/R/tm_g_pp_vitals.R @@ -388,13 +388,14 @@ srv_g_vitals <- function(id, ggplot2_args) { with_reporter <- !missing(reporter) && inherits(reporter, "Reporter") with_filter <- !missing(filter_panel_api) && inherits(filter_panel_api, "FilterPanelAPI") - checkmate::assert_class(data, "tdata") + checkmate::assert_class(data, "reactive") + checkmate::assert_class(shiny::isolate(data()), "teal_data") shiny::moduleServer(id, function(input, output, session) { patient_id <- shiny::reactive(input$patient_id) # Init - patient_data_base <- shiny::reactive(unique(data[[parentname]]()[[patient_col]])) + patient_data_base <- shiny::reactive(unique(data()[[parentname]][[patient_col]])) teal.widgets::updateOptionalSelectInput( session, "patient_id", @@ -449,13 +450,12 @@ srv_g_vitals <- function(id, anl_inputs <- teal.transform::merge_expression_srv( datasets = data, - join_keys = teal.data::join_keys(data), selector_list = selector_list, merge_function = "dplyr::left_join" ) anl_q <- shiny::reactive({ - teal.code::new_qenv(tdata2env(data), code = get_code_tdata(data)) %>% + data() %>% teal.code::eval_code(as.expression(anl_inputs()$expr)) }) @@ -565,7 +565,7 @@ srv_g_vitals <- function(id, card$append_text("Comment", "header3") card$append_text(comment) } - card$append_src(paste(teal.code::get_code(all_q()), collapse = "\n")) + card$append_src(teal.code::get_code(all_q())) card } teal.reporter::simple_reporter_srv("simple_reporter", reporter = reporter, card_fun = card_fun) diff --git a/R/tm_t_abnormality.R b/R/tm_t_abnormality.R index 4c764f1b9b..993f59819f 100644 --- a/R/tm_t_abnormality.R +++ b/R/tm_t_abnormality.R @@ -497,7 +497,8 @@ srv_t_abnormality <- function(id, basic_table_args) { with_reporter <- !missing(reporter) && inherits(reporter, "Reporter") with_filter <- !missing(filter_panel_api) && inherits(filter_panel_api, "FilterPanelAPI") - checkmate::assert_class(data, "tdata") + checkmate::assert_class(data, "reactive") + checkmate::assert_class(shiny::isolate(data()), "teal_data") shiny::moduleServer(id, function(input, output, session) { selector_list <- teal.transform::data_extract_multiple_srv( @@ -542,20 +543,18 @@ srv_t_abnormality <- function(id, anl_inputs <- teal.transform::merge_expression_srv( datasets = data, - join_keys = teal.data::join_keys(data), selector_list = selector_list, merge_function = "dplyr::inner_join" ) adsl_inputs <- teal.transform::merge_expression_module( datasets = data, - join_keys = teal.data::join_keys(data), data_extract = list(arm_var = arm_var), anl_name = "ANL_ADSL" ) anl_q <- shiny::reactive({ - teal.code::new_qenv(tdata2env(data), code = get_code_tdata(data)) %>% + data() %>% teal.code::eval_code(as.expression(anl_inputs()$expr)) %>% teal.code::eval_code(as.expression(adsl_inputs()$expr)) }) @@ -663,7 +662,7 @@ srv_t_abnormality <- function(id, card$append_text("Comment", "header3") card$append_text(comment) } - card$append_src(paste(teal.code::get_code(all_q()), collapse = "\n")) + card$append_src(teal.code::get_code(all_q())) card } teal.reporter::simple_reporter_srv("simple_reporter", reporter = reporter, card_fun = card_fun) diff --git a/R/tm_t_abnormality_by_worst_grade.R b/R/tm_t_abnormality_by_worst_grade.R index dbe615513b..e899e8f403 100644 --- a/R/tm_t_abnormality_by_worst_grade.R +++ b/R/tm_t_abnormality_by_worst_grade.R @@ -498,7 +498,8 @@ srv_t_abnormality_by_worst_grade <- function(id, # nolint basic_table_args) { with_reporter <- !missing(reporter) && inherits(reporter, "Reporter") with_filter <- !missing(filter_panel_api) && inherits(filter_panel_api, "FilterPanelAPI") - checkmate::assert_class(data, "tdata") + checkmate::assert_class(data, "reactive") + checkmate::assert_class(shiny::isolate(data()), "teal_data") shiny::moduleServer(id, function(input, output, session) { selector_list <- teal.transform::data_extract_multiple_srv( @@ -532,19 +533,17 @@ srv_t_abnormality_by_worst_grade <- function(id, # nolint anl_inputs <- teal.transform::merge_expression_srv( selector_list = selector_list, datasets = data, - join_keys = teal.data::join_keys(data), merge_function = "dplyr::inner_join" ) adsl_inputs <- teal.transform::merge_expression_module( datasets = data, - join_keys = teal.data::join_keys(data), data_extract = list(arm_var = arm_var), anl_name = "ANL_ADSL" ) anl_q <- shiny::reactive({ - teal.code::new_qenv(tdata2env(data), code = get_code_tdata(data)) %>% + data() %>% teal.code::eval_code(as.expression(anl_inputs()$expr)) %>% teal.code::eval_code(as.expression(adsl_inputs()$expr)) }) @@ -681,7 +680,7 @@ srv_t_abnormality_by_worst_grade <- function(id, # nolint card$append_text("Comment", "header3") card$append_text(comment) } - card$append_src(paste(teal.code::get_code(all_q()), collapse = "\n")) + card$append_src(teal.code::get_code(all_q())) card } teal.reporter::simple_reporter_srv("simple_reporter", reporter = reporter, card_fun = card_fun) diff --git a/R/tm_t_ancova.R b/R/tm_t_ancova.R index 52664149a4..3b37ed4e9c 100644 --- a/R/tm_t_ancova.R +++ b/R/tm_t_ancova.R @@ -679,7 +679,8 @@ srv_ancova <- function(id, basic_table_args) { with_reporter <- !missing(reporter) && inherits(reporter, "Reporter") with_filter <- !missing(filter_panel_api) && inherits(filter_panel_api, "FilterPanelAPI") - checkmate::assert_class(data, "tdata") + checkmate::assert_class(data, "reactive") + checkmate::assert_class(shiny::isolate(data()), "teal_data") shiny::moduleServer(id, function(input, output, session) { # Setup arm variable selection, default reference arms, and default @@ -689,7 +690,7 @@ srv_ancova <- function(id, input, output, id_arm_var = extract_input("arm_var", parentname), - data = data[[parentname]], + data = data()[[parentname]], arm_ref_comp = arm_ref_comp, module = "tm_ancova" ) @@ -730,19 +731,17 @@ srv_ancova <- function(id, anl_inputs <- teal.transform::merge_expression_srv( selector_list = selector_list, datasets = data, - join_keys = teal.data::join_keys(data), merge_function = "dplyr::inner_join" ) adsl_inputs <- teal.transform::merge_expression_module( datasets = data, data_extract = list(arm_var = arm_var), - anl_name = "ANL_ADSL", - join_keys = teal.data::join_keys(data) + anl_name = "ANL_ADSL" ) anl_q <- shiny::reactive({ - teal.code::new_qenv(tdata2env(data), code = get_code_tdata(data)) %>% + data() %>% teal.code::eval_code(as.expression(anl_inputs()$expr)) %>% teal.code::eval_code(as.expression(adsl_inputs()$expr)) }) @@ -963,7 +962,7 @@ srv_ancova <- function(id, card$append_text("Comment", "header3") card$append_text(comment) } - card$append_src(paste(teal.code::get_code(table_q()), collapse = "\n")) + card$append_src(teal.code::get_code(table_q())) card } teal.reporter::simple_reporter_srv("simple_reporter", reporter = reporter, card_fun = card_fun) diff --git a/R/tm_t_binary_outcome.R b/R/tm_t_binary_outcome.R index d114ec3846..41e9795cb1 100644 --- a/R/tm_t_binary_outcome.R +++ b/R/tm_t_binary_outcome.R @@ -746,7 +746,8 @@ srv_t_binary_outcome <- function(id, basic_table_args) { with_reporter <- !missing(reporter) && inherits(reporter, "Reporter") with_filter <- !missing(filter_panel_api) && inherits(filter_panel_api, "FilterPanelAPI") - checkmate::assert_class(data, "tdata") + checkmate::assert_class(data, "reactive") + checkmate::assert_class(shiny::isolate(data()), "teal_data") shiny::moduleServer(id, function(input, output, session) { # Setup arm variable selection, default reference arms, and default @@ -756,7 +757,7 @@ srv_t_binary_outcome <- function(id, input, output, id_arm_var = extract_input("arm_var", parentname), - data = data[[parentname]], + data = data()[[parentname]], arm_ref_comp = arm_ref_comp, module = "tm_t_binary_outcome", on_off = shiny::reactive(input$compare_arms) @@ -791,21 +792,19 @@ srv_t_binary_outcome <- function(id, anl_inputs <- teal.transform::merge_expression_srv( datasets = data, selector_list = selector_list, - merge_function = "dplyr::inner_join", - join_keys = teal.data::join_keys(data) + merge_function = "dplyr::inner_join" ) adsl_inputs <- teal.transform::merge_expression_module( datasets = data, data_extract = list(arm_var = arm_var, strata_var = strata_var), - join_keys = teal.data::join_keys(data), anl_name = "ANL_ADSL" ) anl_q <- shiny::reactive({ - q <- teal.code::new_qenv(tdata2env(data), code = get_code_tdata(data)) - qenv <- teal.code::eval_code(q, as.expression(anl_inputs()$expr)) - teal.code::eval_code(qenv, as.expression(adsl_inputs()$expr)) + data() %>% + teal.code::eval_code(as.expression(anl_inputs()$expr)) %>% + teal.code::eval_code(as.expression(adsl_inputs()$expr)) }) shiny::observeEvent( @@ -1030,7 +1029,7 @@ srv_t_binary_outcome <- function(id, card$append_text("Comment", "header3") card$append_text(comment) } - card$append_src(paste(teal.code::get_code(table_q()), collapse = "\n")) + card$append_src(teal.code::get_code(table_q())) card } teal.reporter::simple_reporter_srv("simple_reporter", reporter = reporter, card_fun = card_fun) diff --git a/R/tm_t_coxreg.R b/R/tm_t_coxreg.R index 928e01941b..287d351ccd 100644 --- a/R/tm_t_coxreg.R +++ b/R/tm_t_coxreg.R @@ -688,7 +688,8 @@ srv_t_coxreg <- function(id, basic_table_args) { with_reporter <- !missing(reporter) && inherits(reporter, "Reporter") with_filter <- !missing(filter_panel_api) && inherits(filter_panel_api, "FilterPanelAPI") - checkmate::assert_class(data, "tdata") + checkmate::assert_class(data, "reactive") + checkmate::assert_class(shiny::isolate(data()), "teal_data") shiny::moduleServer(id, function(input, output, session) { # Observer to update reference and comparison arm input options. @@ -697,7 +698,7 @@ srv_t_coxreg <- function(id, input, output, id_arm_var = extract_input("arm_var", parentname), - data = data[[parentname]], + data = shiny::reactive(data()[[parentname]]), arm_ref_comp = arm_ref_comp, module = "tm_t_coxreg" ) @@ -790,13 +791,12 @@ srv_t_coxreg <- function(id, anl_inputs <- teal.transform::merge_expression_srv( datasets = data, - join_keys = teal.data::join_keys(data), selector_list = selector_list, merge_function = "dplyr::inner_join" ) anl_q <- shiny::reactive({ - teal.code::new_qenv(tdata2env(data), code = get_code_tdata(data)) %>% + data() %>% teal.code::eval_code(as.expression(anl_inputs()$expr)) }) @@ -1077,7 +1077,7 @@ srv_t_coxreg <- function(id, card$append_text("Comment", "header3") card$append_text(comment) } - card$append_src(paste(teal.code::get_code(all_q()), collapse = "\n")) + card$append_src(teal.code::get_code(all_q())) card } teal.reporter::simple_reporter_srv("simple_reporter", reporter = reporter, card_fun = card_fun) diff --git a/R/tm_t_events.R b/R/tm_t_events.R index 4eba9fddcd..f697575cc9 100644 --- a/R/tm_t_events.R +++ b/R/tm_t_events.R @@ -666,7 +666,8 @@ srv_t_events_byterm <- function(id, basic_table_args) { with_reporter <- !missing(reporter) && inherits(reporter, "Reporter") with_filter <- !missing(filter_panel_api) && inherits(filter_panel_api, "FilterPanelAPI") - checkmate::assert_class(data, "tdata") + checkmate::assert_class(data, "reactive") + checkmate::assert_class(shiny::isolate(data()), "teal_data") shiny::moduleServer(id, function(input, output, session) { selector_list <- teal.transform::data_extract_multiple_srv( @@ -702,7 +703,6 @@ srv_t_events_byterm <- function(id, anl_inputs <- teal.transform::merge_expression_srv( datasets = data, - join_keys = teal.data::join_keys(data), selector_list = selector_list, merge_function = "dplyr::inner_join" ) @@ -710,12 +710,11 @@ srv_t_events_byterm <- function(id, adsl_inputs <- teal.transform::merge_expression_module( datasets = data, data_extract = list(arm_var = arm_var), - anl_name = "ANL_ADSL", - join_keys = teal.data::join_keys(data) + anl_name = "ANL_ADSL" ) anl_q <- shiny::reactive({ - teal.code::new_qenv(tdata2env(data), code = get_code_tdata(data)) %>% + data() %>% teal.code::eval_code(as.expression(anl_inputs()$expr)) %>% teal.code::eval_code(as.expression(adsl_inputs()$expr)) }) @@ -834,7 +833,7 @@ srv_t_events_byterm <- function(id, card$append_text("Comment", "header3") card$append_text(comment) } - card$append_src(paste(teal.code::get_code(table_q()), collapse = "\n")) + card$append_src(teal.code::get_code(table_q())) card } teal.reporter::simple_reporter_srv("simple_reporter", reporter = reporter, card_fun = card_fun) diff --git a/R/tm_t_events_by_grade.R b/R/tm_t_events_by_grade.R index c1f9758156..921ffe0ea8 100644 --- a/R/tm_t_events_by_grade.R +++ b/R/tm_t_events_by_grade.R @@ -997,7 +997,8 @@ srv_t_events_by_grade <- function(id, basic_table_args) { with_reporter <- !missing(reporter) && inherits(reporter, "Reporter") with_filter <- !missing(filter_panel_api) && inherits(filter_panel_api, "FilterPanelAPI") - checkmate::assert_class(data, "tdata") + checkmate::assert_class(data, "reactive") + checkmate::assert_class(shiny::isolate(data()), "teal_data") shiny::moduleServer(id, function(input, output, session) { selector_list <- teal.transform::data_extract_multiple_srv( @@ -1046,19 +1047,17 @@ srv_t_events_by_grade <- function(id, anl_inputs <- teal.transform::merge_expression_srv( datasets = data, selector_list = selector_list, - join_keys = teal.data::join_keys(data), merge_function = "dplyr::inner_join" ) adsl_inputs <- teal.transform::merge_expression_module( datasets = data, data_extract = list(arm_var = arm_var), - join_keys = teal.data::join_keys(data), anl_name = "ANL_ADSL" ) anl_q <- shiny::reactive({ - teal.code::new_qenv(tdata2env(data), code = get_code_tdata(data)) %>% + data() %>% teal.code::eval_code(as.expression(anl_inputs()$expr)) %>% teal.code::eval_code(as.expression(adsl_inputs()$expr)) }) @@ -1210,7 +1209,7 @@ srv_t_events_by_grade <- function(id, card$append_text("Comment", "header3") card$append_text(comment) } - card$append_src(paste(teal.code::get_code(table_q()), collapse = "\n")) + card$append_src(teal.code::get_code(table_q())) card } teal.reporter::simple_reporter_srv("simple_reporter", reporter = reporter, card_fun = card_fun) diff --git a/R/tm_t_events_patyear.R b/R/tm_t_events_patyear.R index 564ca517cc..ddf5cf7c84 100644 --- a/R/tm_t_events_patyear.R +++ b/R/tm_t_events_patyear.R @@ -386,14 +386,15 @@ srv_events_patyear <- function(id, basic_table_args) { with_reporter <- !missing(reporter) && inherits(reporter, "Reporter") with_filter <- !missing(filter_panel_api) && inherits(filter_panel_api, "FilterPanelAPI") - checkmate::assert_class(data, "tdata") + checkmate::assert_class(data, "reactive") + checkmate::assert_class(shiny::isolate(data()), "teal_data") shiny::moduleServer(id, function(input, output, session) { shiny::observeEvent(anl_q(), { - data <- merged$anl_q()[["ANL"]] + data_anl <- merged$anl_q()[["ANL"]] aval_unit_var <- merged$anl_input_r()$columns_source$avalu_var if (length(aval_unit_var) > 0) { - choices <- stats::na.omit(unique(data[[aval_unit_var]])) + choices <- stats::na.omit(unique(data_anl[[aval_unit_var]])) choices <- gsub("s$", "", tolower(choices)) shiny::updateSelectInput( @@ -443,19 +444,17 @@ srv_events_patyear <- function(id, anl_inputs <- teal.transform::merge_expression_srv( datasets = data, selector_list = selector_list, - join_keys = teal.data::join_keys(data), merge_function = "dplyr::inner_join" ) adsl_inputs <- teal.transform::merge_expression_module( datasets = data, data_extract = list(arm_var = arm_var), - join_keys = teal.data::join_keys(data), anl_name = "ANL_ADSL" ) anl_q <- shiny::reactive({ - teal.code::new_qenv(tdata2env(data), code = get_code_tdata(data)) %>% + data() %>% teal.code::eval_code(as.expression(anl_inputs()$expr)) %>% teal.code::eval_code(as.expression(adsl_inputs()$expr)) }) @@ -575,7 +574,7 @@ srv_events_patyear <- function(id, card$append_text("Comment", "header3") card$append_text(comment) } - card$append_src(paste(teal.code::get_code(table_q()), collapse = "\n")) + card$append_src(teal.code::get_code(table_q())) card } teal.reporter::simple_reporter_srv("simple_reporter", reporter = reporter, card_fun = card_fun) diff --git a/R/tm_t_events_summary.R b/R/tm_t_events_summary.R index 52a77af3ae..bc862c2fba 100644 --- a/R/tm_t_events_summary.R +++ b/R/tm_t_events_summary.R @@ -788,7 +788,8 @@ srv_t_events_summary <- function(id, basic_table_args) { with_reporter <- !missing(reporter) && inherits(reporter, "Reporter") with_filter <- !missing(filter_panel_api) && inherits(filter_panel_api, "FilterPanelAPI") - checkmate::assert_class(data, "tdata") + checkmate::assert_class(data, "reactive") + checkmate::assert_class(shiny::isolate(data()), "teal_data") shiny::moduleServer(id, function(input, output, session) { data_extract_vars <- list( @@ -824,19 +825,17 @@ srv_t_events_summary <- function(id, anl_inputs <- teal.transform::merge_expression_srv( datasets = data, selector_list = selector_list, - join_keys = teal.data::join_keys(data), merge_function = "dplyr::inner_join" ) adsl_inputs <- teal.transform::merge_expression_module( datasets = data, data_extract = Filter(Negate(is.null), list(arm_var = arm_var, dthfl_var = dthfl_var, dcsreas_var = dcsreas_var)), - join_keys = teal.data::join_keys(data), anl_name = "ANL_ADSL" ) anl_q <- shiny::reactive({ - teal.code::new_qenv(tdata2env(data), code = get_code_tdata(data)) %>% + data() %>% teal.code::eval_code(as.expression(anl_inputs()$expr)) %>% teal.code::eval_code(as.expression(adsl_inputs()$expr)) }) @@ -982,7 +981,7 @@ srv_t_events_summary <- function(id, card$append_text("Comment", "header3") card$append_text(comment) } - card$append_src(paste(teal.code::get_code(table_q()), collapse = "\n")) + card$append_src(teal.code::get_code(table_q())) card } teal.reporter::simple_reporter_srv("simple_reporter", reporter = reporter, card_fun = card_fun) diff --git a/R/tm_t_exposure.R b/R/tm_t_exposure.R index a0461d807a..1ce1184fa3 100644 --- a/R/tm_t_exposure.R +++ b/R/tm_t_exposure.R @@ -477,7 +477,8 @@ srv_t_exposure <- function(id, basic_table_args = basic_table_args) { with_reporter <- !missing(reporter) && inherits(reporter, "Reporter") with_filter <- !missing(filter_panel_api) && inherits(filter_panel_api, "FilterPanelAPI") - checkmate::assert_class(data, "tdata") + checkmate::assert_class(data, "reactive") + checkmate::assert_class(shiny::isolate(data()), "teal_data") shiny::moduleServer(id, function(input, output, session) { rule_intersection <- function(other) { function(value) { @@ -526,19 +527,17 @@ srv_t_exposure <- function(id, anl_inputs <- teal.transform::merge_expression_srv( datasets = data, selector_list = selector_list, - join_keys = teal.data::join_keys(data), merge_function = "dplyr::inner_join" ) adsl_inputs <- teal.transform::merge_expression_module( datasets = data, - join_keys = teal.data::join_keys(data), data_extract = list(col_by_var = col_by_var), anl_name = "ANL_ADSL" ) anl_q <- shiny::reactive({ - teal.code::new_qenv(tdata2env(data), code = get_code_tdata(data)) %>% + data() %>% teal.code::eval_code(as.expression(anl_inputs()$expr)) %>% teal.code::eval_code(as.expression(adsl_inputs()$expr)) }) @@ -660,7 +659,7 @@ srv_t_exposure <- function(id, card$append_text("Comment", "header3") card$append_text(comment) } - card$append_src(paste(teal.code::get_code(all_q()), collapse = "\n")) + card$append_src(teal.code::get_code(all_q())) card } teal.reporter::simple_reporter_srv("simple_reporter", reporter = reporter, card_fun = card_fun) diff --git a/R/tm_t_logistic.R b/R/tm_t_logistic.R index b85792f005..0d4d24a941 100644 --- a/R/tm_t_logistic.R +++ b/R/tm_t_logistic.R @@ -454,7 +454,8 @@ srv_t_logistic <- function(id, basic_table_args) { with_reporter <- !missing(reporter) && inherits(reporter, "Reporter") with_filter <- !missing(filter_panel_api) && inherits(filter_panel_api, "FilterPanelAPI") - checkmate::assert_class(data, "tdata") + checkmate::assert_class(data, "reactive") + checkmate::assert_class(shiny::isolate(data()), "teal_data") shiny::moduleServer(id, function(input, output, session) { # Observer to update reference and comparison arm input options. @@ -463,7 +464,7 @@ srv_t_logistic <- function(id, input, output, id_arm_var = extract_input("arm_var", parentname), - data = data[[parentname]], + data = shiny::reactive(data()[[parentname]]), arm_ref_comp = arm_ref_comp, module = "tm_t_logistic" ) @@ -523,19 +524,17 @@ srv_t_logistic <- function(id, anl_inputs <- teal.transform::merge_expression_srv( selector_list = selector_list, datasets = data, - join_keys = teal.data::join_keys(data), merge_function = "dplyr::inner_join" ) adsl_inputs <- teal.transform::merge_expression_module( datasets = data, - join_keys = teal.data::join_keys(data), data_extract = list(arm_var = arm_var), anl_name = "ANL_ADSL" ) anl_q <- shiny::reactive({ - teal.code::new_qenv(tdata2env(data), code = get_code_tdata(data)) %>% + data() %>% teal.code::eval_code(as.expression(anl_inputs()$expr)) %>% teal.code::eval_code(as.expression(adsl_inputs()$expr)) }) @@ -733,7 +732,7 @@ srv_t_logistic <- function(id, card$append_text("Comment", "header3") card$append_text(comment) } - card$append_src(paste(teal.code::get_code(all_q()), collapse = "\n")) + card$append_src(teal.code::get_code(all_q())) card } teal.reporter::simple_reporter_srv("simple_reporter", reporter = reporter, card_fun = card_fun) diff --git a/R/tm_t_mult_events.R b/R/tm_t_mult_events.R index 434e557aef..3ed4ed32c2 100644 --- a/R/tm_t_mult_events.R +++ b/R/tm_t_mult_events.R @@ -462,7 +462,8 @@ srv_t_mult_events_byterm <- function(id, basic_table_args) { with_reporter <- !missing(reporter) && inherits(reporter, "Reporter") with_filter <- !missing(filter_panel_api) && inherits(filter_panel_api, "FilterPanelAPI") - checkmate::assert_class(data, "tdata") + checkmate::assert_class(data, "reactive") + checkmate::assert_class(shiny::isolate(data()), "teal_data") shiny::moduleServer(id, function(input, output, session) { selector_list <- teal.transform::data_extract_multiple_srv( @@ -487,7 +488,6 @@ srv_t_mult_events_byterm <- function(id, anl_merge_inputs <- teal.transform::merge_expression_srv( id = "anl_merge", datasets = data, - join_keys = teal.data::join_keys(data), selector_list = selector_list, merge_function = "dplyr::inner_join" ) @@ -495,15 +495,14 @@ srv_t_mult_events_byterm <- function(id, adsl_merge_inputs <- teal.transform::merge_expression_module( id = "adsl_merge", datasets = data, - join_keys = teal.data::join_keys(data), data_extract = list(arm_var = arm_var), anl_name = "ANL_ADSL" ) anl_q <- shiny::reactive({ - qenv <- teal.code::new_qenv(tdata2env(data), code = get_code_tdata(data)) - qenv2 <- teal.code::eval_code(qenv, as.expression(anl_merge_inputs()$expr)) - teal.code::eval_code(qenv2, as.expression(adsl_merge_inputs()$expr)) + data() %>% + teal.code::eval_code(as.expression(anl_merge_inputs()$expr)) %>% + teal.code::eval_code(as.expression(adsl_merge_inputs()$expr)) }) validate_checks <- shiny::reactive({ @@ -540,14 +539,14 @@ srv_t_mult_events_byterm <- function(id, all_q <- shiny::reactive({ validate_checks() - qenv <- anl_q() + anl_q <- anl_q() anl_m <- anl_merge_inputs() input_hlt <- names(anl_m$columns_source$hlt) input_llt <- names(anl_m$columns_source$llt) - hlt_labels <- mapply(function(x) rtables::obj_label(qenv[["ANL"]][[x]]), input_hlt) - llt_labels <- mapply(function(x) rtables::obj_label(qenv[["ANL"]][[x]]), input_llt) + hlt_labels <- mapply(function(x) rtables::obj_label(anl_q[["ANL"]][[x]]), input_hlt) + llt_labels <- mapply(function(x) rtables::obj_label(anl_q[["ANL"]][[x]]), input_llt) basic_table_args$title <- ifelse( is.null(basic_table_args$title), @@ -573,7 +572,7 @@ srv_t_mult_events_byterm <- function(id, drop_arm_levels = input$drop_arm_levels, basic_table_args = basic_table_args ) - teal.code::eval_code(qenv, as.expression(my_calls)) + teal.code::eval_code(anl_q, as.expression(my_calls)) }) # Outputs to render. @@ -610,7 +609,7 @@ srv_t_mult_events_byterm <- function(id, card$append_text("Comment", "header3") card$append_text(comment) } - card$append_src(paste(teal.code::get_code(all_q()), collapse = "\n")) + card$append_src(teal.code::get_code(all_q())) card } teal.reporter::simple_reporter_srv("simple_reporter", reporter = reporter, card_fun = card_fun) diff --git a/R/tm_t_pp_basic_info.R b/R/tm_t_pp_basic_info.R index 6ea4d5fa74..aff0ec8a79 100644 --- a/R/tm_t_pp_basic_info.R +++ b/R/tm_t_pp_basic_info.R @@ -172,13 +172,14 @@ srv_t_basic_info <- function(id, label) { with_reporter <- !missing(reporter) && inherits(reporter, "Reporter") with_filter <- !missing(filter_panel_api) && inherits(filter_panel_api, "FilterPanelAPI") - checkmate::assert_class(data, "tdata") + checkmate::assert_class(data, "reactive") + checkmate::assert_class(shiny::isolate(data()), "teal_data") shiny::moduleServer(id, function(input, output, session) { patient_id <- shiny::reactive(input$patient_id) # Init - patient_data_base <- shiny::reactive(unique(data[[dataname]]()[[patient_col]])) + patient_data_base <- shiny::reactive(unique(data()[[dataname]][[patient_col]])) teal.widgets::updateOptionalSelectInput( session, "patient_id", @@ -219,13 +220,12 @@ srv_t_basic_info <- function(id, anl_inputs <- teal.transform::merge_expression_srv( datasets = data, - join_keys = teal.data::join_keys(data), selector_list = selector_list, merge_function = "dplyr::left_join" ) anl_q <- shiny::reactive({ - teal.code::new_qenv(tdata2env(data), code = get_code_tdata(data)) %>% + data() %>% teal.code::eval_code(as.expression(anl_inputs()$expr)) }) @@ -293,7 +293,7 @@ srv_t_basic_info <- function(id, card$append_text("Comment", "header3") card$append_text(comment) } - card$append_src(paste(teal.code::get_code(all_q()), collapse = "\n")) + card$append_src(teal.code::get_code(all_q())) card } teal.reporter::simple_reporter_srv("simple_reporter", reporter = reporter, card_fun = card_fun) diff --git a/R/tm_t_pp_laboratory.R b/R/tm_t_pp_laboratory.R index 3e790017a0..c203103dbe 100644 --- a/R/tm_t_pp_laboratory.R +++ b/R/tm_t_pp_laboratory.R @@ -310,13 +310,14 @@ srv_g_laboratory <- function(id, label) { with_reporter <- !missing(reporter) && inherits(reporter, "Reporter") with_filter <- !missing(filter_panel_api) && inherits(filter_panel_api, "FilterPanelAPI") - checkmate::assert_class(data, "tdata") + checkmate::assert_class(data, "reactive") + checkmate::assert_class(shiny::isolate(data()), "teal_data") shiny::moduleServer(id, function(input, output, session) { patient_id <- shiny::reactive(input$patient_id) # Init - patient_data_base <- shiny::reactive(unique(data[[parentname]]()[[patient_col]])) + patient_data_base <- shiny::reactive(unique(data()[[parentname]][[patient_col]])) teal.widgets::updateOptionalSelectInput( session, "patient_id", @@ -341,7 +342,7 @@ srv_g_laboratory <- function(id, ) # Update round_values - aval_values <- data[[dataname]]()[, aval$select$selected] + aval_values <- shiny::isolate(data())[[dataname]][, aval$select$selected] decimal_nums <- aval_values[trunc(aval_values) != aval_values] max_decimal <- max(nchar(gsub("([0-9]+).([0-9]+)", "\\2", decimal_nums))) @@ -381,12 +382,11 @@ srv_g_laboratory <- function(id, anl_inputs <- teal.transform::merge_expression_srv( datasets = data, - join_keys = teal.data::join_keys(data), selector_list = selector_list ) anl_q <- shiny::reactive({ - teal.code::new_qenv(tdata2env(data), code = get_code_tdata(data)) %>% + data() %>% teal.code::eval_code(as.expression(anl_inputs()$expr)) }) @@ -469,7 +469,7 @@ srv_g_laboratory <- function(id, card$append_text("Comment", "header3") card$append_text(comment) } - card$append_src(paste(teal.code::get_code(all_q()), collapse = "\n")) + card$append_src(teal.code::get_code(all_q())) card } teal.reporter::simple_reporter_srv("simple_reporter", reporter = reporter, card_fun = card_fun) diff --git a/R/tm_t_pp_medical_history.R b/R/tm_t_pp_medical_history.R index 66b5a66157..ee974793eb 100644 --- a/R/tm_t_pp_medical_history.R +++ b/R/tm_t_pp_medical_history.R @@ -235,13 +235,14 @@ srv_t_medical_history <- function(id, label) { with_reporter <- !missing(reporter) && inherits(reporter, "Reporter") with_filter <- !missing(filter_panel_api) && inherits(filter_panel_api, "FilterPanelAPI") - checkmate::assert_class(data, "tdata") + checkmate::assert_class(data, "reactive") + checkmate::assert_class(shiny::isolate(data()), "teal_data") shiny::moduleServer(id, function(input, output, session) { patient_id <- shiny::reactive(input$patient_id) # Init - patient_data_base <- shiny::reactive(unique(data[[parentname]]()[[patient_col]])) + patient_data_base <- shiny::reactive(unique(data()[[parentname]][[patient_col]])) teal.widgets::updateOptionalSelectInput( session, "patient_id", choices = patient_data_base(), selected = patient_data_base()[1] @@ -282,13 +283,12 @@ srv_t_medical_history <- function(id, anl_inputs <- teal.transform::merge_expression_srv( datasets = data, - join_keys = teal.data::join_keys(data), selector_list = selector_list, merge_function = "dplyr::left_join" ) anl_q <- shiny::reactive({ - teal.code::new_qenv(tdata2env(data), code = get_code_tdata(data)) %>% + data() %>% teal.code::eval_code(as.expression(anl_inputs()$expr)) }) @@ -359,7 +359,7 @@ srv_t_medical_history <- function(id, card$append_text("Comment", "header3") card$append_text(comment) } - card$append_src(paste(teal.code::get_code(all_q()), collapse = "\n")) + card$append_src(teal.code::get_code(all_q())) card } teal.reporter::simple_reporter_srv("simple_reporter", reporter = reporter, card_fun = card_fun) diff --git a/R/tm_t_pp_prior_medication.R b/R/tm_t_pp_prior_medication.R index 42f27d2e0c..aef6547329 100644 --- a/R/tm_t_pp_prior_medication.R +++ b/R/tm_t_pp_prior_medication.R @@ -241,7 +241,8 @@ srv_t_prior_medication <- function(id, label) { with_reporter <- !missing(reporter) && inherits(reporter, "Reporter") with_filter <- !missing(filter_panel_api) && inherits(filter_panel_api, "FilterPanelAPI") - checkmate::assert_class(data, "tdata") + checkmate::assert_class(data, "reactive") + checkmate::assert_class(shiny::isolate(data()), "teal_data") shiny::moduleServer(id, function(input, output, session) { patient_id <- shiny::reactive(input$patient_id) @@ -269,7 +270,7 @@ srv_t_prior_medication <- function(id, }) # Init - patient_data_base <- shiny::reactive(unique(data[[parentname]]()[[patient_col]])) + patient_data_base <- shiny::reactive(unique(data()[[parentname]][[patient_col]])) teal.widgets::updateOptionalSelectInput( session, "patient_id", @@ -297,12 +298,11 @@ srv_t_prior_medication <- function(id, anl_inputs <- teal.transform::merge_expression_srv( datasets = data, selector_list = selector_list, - join_keys = teal.data::join_keys(data), merge_function = "dplyr::left_join" ) anl_q <- shiny::reactive({ - teal.code::new_qenv(tdata2env(data), code = get_code_tdata(data)) %>% + data() %>% teal.code::eval_code(as.expression(anl_inputs()$expr)) }) @@ -317,17 +317,17 @@ srv_t_prior_medication <- function(id, cmstdy = input[[extract_input("cmstdy", dataname)]] ) - teal.code::eval_code( - anl_q(), - substitute( - expr = { - ANL <- ANL[ANL[[patient_col]] == patient_id, ] # nolint - }, env = list( - patient_col = patient_col, - patient_id = patient_id() + anl_q() %>% + teal.code::eval_code( + substitute( + expr = { + ANL <- ANL[ANL[[patient_col]] == patient_id, ] # nolint + }, env = list( + patient_col = patient_col, + patient_id = patient_id() + ) ) - ) - ) %>% + ) %>% teal.code::eval_code(as.expression(my_calls)) }) @@ -367,7 +367,7 @@ srv_t_prior_medication <- function(id, card$append_text("Comment", "header3") card$append_text(comment) } - card$append_src(paste(teal.code::get_code(all_q()), collapse = "\n")) + card$append_src(teal.code::get_code(all_q())) card } teal.reporter::simple_reporter_srv("simple_reporter", reporter = reporter, card_fun = card_fun) diff --git a/R/tm_t_shift_by_arm.R b/R/tm_t_shift_by_arm.R index a881eda4d9..d3f4ec5d1a 100644 --- a/R/tm_t_shift_by_arm.R +++ b/R/tm_t_shift_by_arm.R @@ -395,7 +395,8 @@ srv_shift_by_arm <- function(id, basic_table_args) { with_reporter <- !missing(reporter) && inherits(reporter, "Reporter") with_filter <- !missing(filter_panel_api) && inherits(filter_panel_api, "FilterPanelAPI") - checkmate::assert_class(data, "tdata") + checkmate::assert_class(data, "reactive") + checkmate::assert_class(shiny::isolate(data()), "teal_data") shiny::moduleServer(id, function(input, output, session) { selector_list <- teal.transform::data_extract_multiple_srv( data_extract = list( @@ -430,20 +431,18 @@ srv_shift_by_arm <- function(id, anl_inputs <- teal.transform::merge_expression_srv( datasets = data, - join_keys = teal.data::join_keys(data), selector_list = selector_list, merge_function = "dplyr::inner_join" ) adsl_inputs <- teal.transform::merge_expression_module( datasets = data, - join_keys = teal.data::join_keys(data), data_extract = list(arm_var = arm_var), anl_name = "ANL_ADSL" ) anl_q <- shiny::reactive({ - teal.code::new_qenv(tdata2env(data), code = get_code_tdata(data)) %>% + data() %>% teal.code::eval_code(as.expression(anl_inputs()$expr)) %>% teal.code::eval_code(as.expression(adsl_inputs()$expr)) }) @@ -545,7 +544,7 @@ srv_shift_by_arm <- function(id, card$append_text("Comment", "header3") card$append_text(comment) } - card$append_src(paste(teal.code::get_code(all_q()), collapse = "\n")) + card$append_src(teal.code::get_code(all_q())) card } teal.reporter::simple_reporter_srv("simple_reporter", reporter = reporter, card_fun = card_fun) diff --git a/R/tm_t_shift_by_arm_by_worst.R b/R/tm_t_shift_by_arm_by_worst.R index 7172783191..9e3c97f546 100644 --- a/R/tm_t_shift_by_arm_by_worst.R +++ b/R/tm_t_shift_by_arm_by_worst.R @@ -418,7 +418,8 @@ srv_shift_by_arm_by_worst <- function(id, basic_table_args) { with_reporter <- !missing(reporter) && inherits(reporter, "Reporter") with_filter <- !missing(filter_panel_api) && inherits(filter_panel_api, "FilterPanelAPI") - checkmate::assert_class(data, "tdata") + checkmate::assert_class(data, "reactive") + checkmate::assert_class(shiny::isolate(data()), "teal_data") shiny::moduleServer(id, function(input, output, session) { selector_list <- teal.transform::data_extract_multiple_srv( data_extract = list( @@ -454,19 +455,17 @@ srv_shift_by_arm_by_worst <- function(id, anl_inputs <- teal.transform::merge_expression_srv( datasets = data, selector_list = selector_list, - join_keys = teal.data::join_keys(data), merge_function = "dplyr::inner_join" ) adsl_inputs <- teal.transform::merge_expression_module( datasets = data, - join_keys = teal.data::join_keys(data), data_extract = list(arm_var = arm_var), anl_name = "ANL_ADSL" ) anl_q <- shiny::reactive({ - teal.code::new_qenv(tdata2env(data), code = get_code_tdata(data)) %>% + data() %>% teal.code::eval_code(as.expression(anl_inputs()$expr)) %>% teal.code::eval_code(as.expression(adsl_inputs()$expr)) }) @@ -583,7 +582,7 @@ srv_shift_by_arm_by_worst <- function(id, card$append_text("Comment", "header3") card$append_text(comment) } - card$append_src(paste(teal.code::get_code(all_q()), collapse = "\n")) + card$append_src(teal.code::get_code(all_q())) card } teal.reporter::simple_reporter_srv("simple_reporter", reporter = reporter, card_fun = card_fun) diff --git a/R/tm_t_shift_by_grade.R b/R/tm_t_shift_by_grade.R index 0dd874cef3..00084eee2c 100644 --- a/R/tm_t_shift_by_grade.R +++ b/R/tm_t_shift_by_grade.R @@ -753,7 +753,8 @@ srv_t_shift_by_grade <- function(id, basic_table_args) { with_reporter <- !missing(reporter) && inherits(reporter, "Reporter") with_filter <- !missing(filter_panel_api) && inherits(filter_panel_api, "FilterPanelAPI") - checkmate::assert_class(data, "tdata") + checkmate::assert_class(data, "reactive") + checkmate::assert_class(shiny::isolate(data()), "teal_data") shiny::moduleServer(id, function(input, output, session) { selector_list <- teal.transform::data_extract_multiple_srv( @@ -788,20 +789,18 @@ srv_t_shift_by_grade <- function(id, anl_inputs <- teal.transform::merge_expression_srv( datasets = data, - join_keys = teal.data::join_keys(data), selector_list = selector_list, merge_function = "dplyr::inner_join" ) adsl_inputs <- teal.transform::merge_expression_module( datasets = data, - join_keys = teal.data::join_keys(data), data_extract = list(arm_var = arm_var), anl_name = "ANL_ADSL" ) anl_q <- shiny::reactive({ - teal.code::new_qenv(tdata2env(data), code = get_code_tdata(data)) %>% + data() %>% teal.code::eval_code(as.expression(anl_inputs()$expr)) %>% teal.code::eval_code(as.expression(adsl_inputs()$expr)) }) @@ -901,7 +900,7 @@ srv_t_shift_by_grade <- function(id, card$append_text("Comment", "header3") card$append_text(comment) } - card$append_src(paste(teal.code::get_code(all_q()), collapse = "\n")) + card$append_src(teal.code::get_code(all_q())) card } teal.reporter::simple_reporter_srv("simple_reporter", reporter = reporter, card_fun = card_fun) diff --git a/R/tm_t_smq.R b/R/tm_t_smq.R index f2aa78f6d1..f4d94c4476 100644 --- a/R/tm_t_smq.R +++ b/R/tm_t_smq.R @@ -539,7 +539,8 @@ srv_t_smq <- function(id, basic_table_args) { with_reporter <- !missing(reporter) && inherits(reporter, "Reporter") with_filter <- !missing(filter_panel_api) && inherits(filter_panel_api, "FilterPanelAPI") - checkmate::assert_class(data, "tdata") + checkmate::assert_class(data, "reactive") + checkmate::assert_class(shiny::isolate(data()), "teal_data") shiny::moduleServer(id, function(input, output, session) { selector_list <- teal.transform::data_extract_multiple_srv( data_extract = list( @@ -570,19 +571,17 @@ srv_t_smq <- function(id, anl_inputs <- teal.transform::merge_expression_srv( datasets = data, selector_list = selector_list, - join_keys = teal.data::join_keys(data), merge_function = "dplyr::inner_join" ) adsl_inputs <- teal.transform::merge_expression_module( datasets = data, - join_keys = teal.data::join_keys(data), data_extract = list(arm_var = arm_var), anl_name = "ANL_ADSL" ) anl_q <- shiny::reactive({ - teal.code::new_qenv(tdata2env(data), code = get_code_tdata(data)) %>% + data() %>% teal.code::eval_code(as.expression(anl_inputs()$expr)) %>% teal.code::eval_code(as.expression(adsl_inputs()$expr)) }) @@ -675,7 +674,7 @@ srv_t_smq <- function(id, card$append_text("Comment", "header3") card$append_text(comment) } - card$append_src(paste(teal.code::get_code(all_q()), collapse = "\n")) + card$append_src(teal.code::get_code(all_q())) card } teal.reporter::simple_reporter_srv("simple_reporter", reporter = reporter, card_fun = card_fun) diff --git a/R/tm_t_summary.R b/R/tm_t_summary.R index 71704fc2e7..b5f2381aff 100644 --- a/R/tm_t_summary.R +++ b/R/tm_t_summary.R @@ -431,7 +431,8 @@ srv_summary <- function(id, basic_table_args) { with_reporter <- !missing(reporter) && inherits(reporter, "Reporter") with_filter <- !missing(filter_panel_api) && inherits(filter_panel_api, "FilterPanelAPI") - checkmate::assert_class(data, "tdata") + checkmate::assert_class(data, "reactive") + checkmate::assert_class(shiny::isolate(data()), "teal_data") shiny::moduleServer(id, function(input, output, session) { selector_list <- teal.transform::data_extract_multiple_srv( data_extract = list(arm_var = arm_var, summarize_vars = summarize_vars), @@ -454,7 +455,6 @@ srv_summary <- function(id, id = "anl_merge", datasets = data, selector_list = selector_list, - join_keys = teal.data::join_keys(data), merge_function = "dplyr::inner_join" ) @@ -462,12 +462,11 @@ srv_summary <- function(id, id = "adsl_merge", datasets = data, data_extract = list(arm_var = arm_var), - join_keys = teal.data::join_keys(data), anl_name = "ANL_ADSL" ) anl_q <- shiny::reactive({ - teal.code::new_qenv(tdata2env(data), code = get_code_tdata(data)) %>% + data() %>% teal.code::eval_code(as.expression(anl_inputs()$expr)) %>% teal.code::eval_code(as.expression(adsl_inputs()$expr)) }) @@ -482,7 +481,7 @@ srv_summary <- function(id, choices_classes <- sapply( names(merged$anl_input_r()$columns_source$summarize_vars), function(x) { - summarize_var_data <- data[[summarize_vars$dataname]]()[[x]] + summarize_var_data <- data()[[summarize_vars$dataname]][[x]] inherits(summarize_var_data, "numeric") | inherits(summarize_var_data, "integer") } @@ -543,7 +542,7 @@ srv_summary <- function(id, validate_checks() summarize_vars <- merged$anl_input_r()$columns_source$summarize_vars - var_labels <- formatters::var_labels(data[[dataname]]()[, summarize_vars, drop = FALSE]) + var_labels <- formatters::var_labels(data()[[dataname]][, summarize_vars, drop = FALSE]) my_calls <- template_summary( dataname = "ANL", parentname = "ANL_ADSL", @@ -597,7 +596,7 @@ srv_summary <- function(id, card$append_text("Comment", "header3") card$append_text(comment) } - card$append_src(paste(teal.code::get_code(all_q()), collapse = "\n")) + card$append_src(teal.code::get_code(all_q())) card } teal.reporter::simple_reporter_srv("simple_reporter", reporter = reporter, card_fun = card_fun) diff --git a/R/tm_t_summary_by.R b/R/tm_t_summary_by.R index 0b07a51130..a49d30cb35 100644 --- a/R/tm_t_summary_by.R +++ b/R/tm_t_summary_by.R @@ -599,7 +599,8 @@ srv_summary_by <- function(id, basic_table_args) { with_reporter <- !missing(reporter) && inherits(reporter, "Reporter") with_filter <- !missing(filter_panel_api) && inherits(filter_panel_api, "FilterPanelAPI") - checkmate::assert_class(data, "tdata") + checkmate::assert_class(data, "reactive") + checkmate::assert_class(shiny::isolate(data()), "teal_data") shiny::moduleServer(id, function(input, output, session) { vars <- list(arm_var = arm_var, id_var = id_var, summarize_vars = summarize_vars, by_vars = by_vars) @@ -630,20 +631,18 @@ srv_summary_by <- function(id, anl_inputs <- teal.transform::merge_expression_srv( selector_list = selector_list, datasets = data, - join_keys = teal.data::join_keys(data), merge_function = "dplyr::inner_join" ) adsl_inputs <- teal.transform::merge_expression_module( id = "adsl_merge", datasets = data, - join_keys = teal.data::join_keys(data), data_extract = list(arm_var = arm_var), anl_name = "ANL_ADSL" ) anl_q <- shiny::reactive({ - teal.code::new_qenv(tdata2env(data), code = get_code_tdata(data)) %>% + data() %>% teal.code::eval_code(as.expression(anl_inputs()$expr)) %>% teal.code::eval_code(as.expression(adsl_inputs()$expr)) }) @@ -750,7 +749,7 @@ srv_summary_by <- function(id, card$append_text("Comment", "header3") card$append_text(comment) } - card$append_src(paste(teal.code::get_code(all_q()), collapse = "\n")) + card$append_src(teal.code::get_code(all_q())) card } teal.reporter::simple_reporter_srv("simple_reporter", reporter = reporter, card_fun = card_fun) diff --git a/R/tm_t_tte.R b/R/tm_t_tte.R index 8608320b3d..ce3c4cb072 100644 --- a/R/tm_t_tte.R +++ b/R/tm_t_tte.R @@ -721,7 +721,8 @@ srv_t_tte <- function(id, basic_table_args) { with_reporter <- !missing(reporter) && inherits(reporter, "Reporter") with_filter <- !missing(filter_panel_api) && inherits(filter_panel_api, "FilterPanelAPI") - checkmate::assert_class(data, "tdata") + checkmate::assert_class(data, "reactive") + checkmate::assert_class(shiny::isolate(data()), "teal_data") shiny::moduleServer(id, function(input, output, session) { # Setup arm variable selection, default reference arms, and default # comparison arms for encoding panel @@ -730,7 +731,7 @@ srv_t_tte <- function(id, input, output, id_arm_var = extract_input("arm_var", parentname), - data = data[[parentname]], + data = shiny::reactive(data()[[parentname]]), arm_ref_comp = arm_ref_comp, module = "tm_t_tte", on_off = shiny::reactive(input$compare_arms) @@ -795,7 +796,6 @@ srv_t_tte <- function(id, anl_merge_inputs <- teal.transform::merge_expression_srv( datasets = data, selector_list = selector_list, - join_keys = teal.data::join_keys(data), merge_function = "dplyr::inner_join" ) @@ -807,9 +807,9 @@ srv_t_tte <- function(id, ) anl_q <- shiny::reactive({ - qenv <- teal.code::new_qenv(tdata2env(data), code = get_code_tdata(data)) - qenv1 <- teal.code::eval_code(qenv, as.expression(anl_merge_inputs()$expr)) - teal.code::eval_code(qenv1, as.expression(adsl_merge_inputs()$expr)) + data() %>% + teal.code::eval_code(as.expression(anl_merge_inputs()$expr)) %>% + teal.code::eval_code(as.expression(adsl_merge_inputs()$expr)) }) # Prepare the analysis environment (filter data, check data, populate envir). @@ -868,7 +868,6 @@ srv_t_tte <- function(id, validate_checks() anl_m <- anl_merge_inputs() - qenv <- anl_q() strata_var <- as.vector(anl_m$columns_source$strata_var) @@ -908,7 +907,7 @@ srv_t_tte <- function(id, basic_table_args = basic_table_args ) - teal.code::eval_code(qenv, as.expression(my_calls)) + anl_q() %>% teal.code::eval_code(as.expression(my_calls)) }) table_r <- shiny::reactive(all_q()[["table"]]) @@ -943,7 +942,7 @@ srv_t_tte <- function(id, card$append_text("Comment", "header3") card$append_text(comment) } - card$append_src(paste(teal.code::get_code(all_q()), collapse = "\n")) + card$append_src(teal.code::get_code(all_q())) card } teal.reporter::simple_reporter_srv("simple_reporter", reporter = reporter, card_fun = card_fun) diff --git a/man/tm_a_gee.Rd b/man/tm_a_gee.Rd index b0a994055c..fe1658275c 100644 --- a/man/tm_a_gee.Rd +++ b/man/tm_a_gee.Rd @@ -100,7 +100,7 @@ data <- within(data, { as.factor() \%>\% as.numeric() \%>\% as.factor(), - AVALBIN = AVAL < 50 #' Just as an example to get a binary endpoint. + AVALBIN = AVAL < 50 # Just as an example to get a binary endpoint. ) \%>\% droplevels() }) From 13c31198d422c15bbf7a18b2dbf3c64c099c5ce3 Mon Sep 17 00:00:00 2001 From: gogonzo Date: Fri, 8 Dec 2023 13:40:31 +0000 Subject: [PATCH 14/28] [skip actions] Bump version to 0.8.16.9019 --- DESCRIPTION | 4 ++-- NEWS.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 2fdc8567f2..f67ba373a9 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: teal.modules.clinical Title: Teal Modules for Standard Clinical Outputs -Version: 0.8.16.9018 -Date: 2023-12-05 +Version: 0.8.16.9019 +Date: 2023-12-08 Authors@R: c( person("Joe", "Zhu", , "joe.zhu@roche.com", role = c("aut", "cre")), person("Jana", "Stoilova", , "jana.stoilova@roche.com", role = "aut"), diff --git a/NEWS.md b/NEWS.md index ec72100e20..32ae7c5e5b 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# teal.modules.clinical 0.8.16.9018 +# teal.modules.clinical 0.8.16.9019 ### Breaking Changes + Adapted all modules to use `teal_data` objects. From b83236e63397a372c40c24395bc48a8471679318 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dawid=20Ka=C5=82=C4=99dkowski?= <6959016+gogonzo@users.noreply.github.com> Date: Wed, 13 Dec 2023 13:48:37 +0100 Subject: [PATCH 15/28] fix resolve_delayed (#909) part of https://github.com/insightsengineering/teal.transform/issues/111 --- DESCRIPTION | 2 +- NAMESPACE | 1 + R/teal.modules.clinical.R | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index f67ba373a9..d5a05a02a0 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -27,6 +27,7 @@ BugReports: Depends: R (>= 4.0), teal (>= 0.14.0.9027), + teal.transform (>= 0.4.0.9011), tern (>= 0.9.2.9017) Imports: assertthat, @@ -57,7 +58,6 @@ Imports: teal.data (>= 0.3.0.9018), teal.logger (>= 0.1.1), teal.reporter (>= 0.2.1), - teal.transform (>= 0.4.0.9011), teal.widgets (>= 0.4.0), tern.gee (>= 0.1.0), tern.mmrm (>= 0.2.1), diff --git a/NAMESPACE b/NAMESPACE index 14061c6ebd..d6c1090a49 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -66,6 +66,7 @@ export(tm_t_summary_by) export(tm_t_tte) import(assertthat) import(teal) +import(teal.transform) import(tern) importFrom(magrittr,"%>%") importFrom(methods,is) diff --git a/R/teal.modules.clinical.R b/R/teal.modules.clinical.R index 9b9be6f503..40056dbe29 100644 --- a/R/teal.modules.clinical.R +++ b/R/teal.modules.clinical.R @@ -4,6 +4,7 @@ #' The teal modules add an encoding panel to interactively change the encodings within teal. #' #' @import teal +#' @import teal.transform #' @import tern #' @importFrom magrittr %>% #' @importFrom methods is From c0370e97aede3d2b0a919320eba7eb7c1298b9fb Mon Sep 17 00:00:00 2001 From: gogonzo Date: Wed, 13 Dec 2023 12:49:32 +0000 Subject: [PATCH 16/28] [skip actions] Bump version to 0.8.16.9020 --- DESCRIPTION | 4 ++-- NEWS.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index d5a05a02a0..83209256a9 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: teal.modules.clinical Title: Teal Modules for Standard Clinical Outputs -Version: 0.8.16.9019 -Date: 2023-12-08 +Version: 0.8.16.9020 +Date: 2023-12-13 Authors@R: c( person("Joe", "Zhu", , "joe.zhu@roche.com", role = c("aut", "cre")), person("Jana", "Stoilova", , "jana.stoilova@roche.com", role = "aut"), diff --git a/NEWS.md b/NEWS.md index 32ae7c5e5b..16d3192935 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# teal.modules.clinical 0.8.16.9019 +# teal.modules.clinical 0.8.16.9020 ### Breaking Changes + Adapted all modules to use `teal_data` objects. From 62d3491e664cd64471f539e2c3c88f4925be0974 Mon Sep 17 00:00:00 2001 From: walkowif <59475134+walkowif@users.noreply.github.com> Date: Wed, 13 Dec 2023 14:08:53 +0100 Subject: [PATCH 17/28] Workflow propagation (#908) --- .Rbuildignore | 1 + .github/ISSUE_TEMPLATE/cran-release.yaml | 124 +++++++++++++++++++++++ .github/ISSUE_TEMPLATE/release.yaml | 99 ++++++++++-------- .github/workflows/check.yaml | 1 + .github/workflows/release.yaml | 1 + .pre-commit-config.yaml | 8 +- 6 files changed, 188 insertions(+), 46 deletions(-) create mode 100644 .github/ISSUE_TEMPLATE/cran-release.yaml diff --git a/.Rbuildignore b/.Rbuildignore index 460bf7b7d1..b01e512c78 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -43,3 +43,4 @@ SECURITY.md ^\.pre-commit-config\.yaml$ ^LICENSE\.md$ coverage.* +^pkgdown$ diff --git a/.github/ISSUE_TEMPLATE/cran-release.yaml b/.github/ISSUE_TEMPLATE/cran-release.yaml new file mode 100644 index 0000000000..bab34fcff5 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/cran-release.yaml @@ -0,0 +1,124 @@ +--- +name: 🎉 CRAN Release +description: Template for release to CRAN +title: "[Release]: " +labels: ["release"] +assignees: + - KlaudiaBB + - cicdguy + - shajoezhu +body: + - type: markdown + attributes: + value: | + ⚠️ Please do not link or mention any internal references in this issue. This includes internal URLs, intellectual property and references. + - type: textarea + id: blocked-by + attributes: + label: Blocked by + description: Any PRs or issues that this release is blocked by. + placeholder: Add a list of blocking PRs or issues here. + value: | + ### PRs + + - [ ] PR 1 + + ### Issues + + - [ ] Issue 1 + validations: + required: true + - type: textarea + id: pre-release + attributes: + label: Pre-release + description: Pre-requisites that must be fulfilled before initiating the release process. + placeholder: Add your list of pre-requisites here. + value: | + - [ ] Make sure you adhere to CRAN submission policy: https://cran.r-project.org/web/packages/submission_checklist.html; https://cran.r-project.org/web/packages/policies.html. + - [ ] Make sure that high priority bugs (label "priority" + "bug") have been resolved before going into the release. + - [ ] Review old/hanging PRs before going into the release (Optional). + - [ ] Revisit R-package's lifecycle badges (Optional). + - [ ] Make sure that all upstream dependencies of this package that need to be submitted to CRAN were accepted before going into release activities. + - [ ] Make sure integration tests are green 2-3 days before the release. Look carefully through logs (check for warnings and notes). + - [ ] Decide what gets merged in before starting release activities. + - type: textarea + id: release + attributes: + label: Release + description: The steps to be taken in order to create a release. + placeholder: Steps to create a release. + value: | + ### Prepare the release + + - [ ] Create a new release candidate branch + `git checkout -b release-candidate-vX.Y.Z` + - [ ] Update NEWS.md file: make sure it reflects a holistic summary of what has changed in the package. + - [ ] Remove the additional fields (`Remotes`) from the DESCRIPTION file where applicable. + - [ ] Make sure that the minimum dependency versions are updated in the DESCRIPTION file for the package and its reverse dependencies (Optional). + - [ ] Increase versioned dependency on {package name} to >=X.Y.Z (Optional). + - [ ] Commit your changes and create the PR on GitHub (add "[skip vbump]" in the PR title). Add all updates, commit, and push changes: + `# Make the necessary modifications to your files + # Stage the changes + git add + # Commit the changes + git commit -m "[skip vbump] " + git push origin release-candidate-vX.Y.Z` + + ### Test the release + + - [ ] Execute the manual tests on Shiny apps that are deployed on various hosting providers (Posit connect and shinyapps.io) - track the results in GitHub issue (Applicable only for frameworks that use Shiny). + - [ ] Monitor integration tests, if integration fails, create priority issues on the board. + - [ ] Execute UAT tests (Optional). + + ### CRAN submission + + - [ ] Tag the update(s) as a release candidate vX.Y.Z-rc (e.g. v0.5.3-rc1) on the release candidate branch (release-candidate-vX.Y.Z). + `# Create rc tag for submission for internal validation + git tag vX.Y.Z-rc + git push origin vX.Y.Z-rc` + - [ ] Build the package locally using the command:`R CMD build .` which will generate a .tar.gz file necessary for the CRAN submission. + - [ ] Submit the package to https://win-builder.r-project.org/upload.aspx for testing, for more details please see "Building and checking R source packages for Windows": https://win-builder.r-project.org/. + - [ ] Once tested, send the package that was built in the previous steps to CRAN via this form: https://cran.r-project.org/submit.html. + - [ ] Address CRAN feedback, tag the package vX.Y.Z-rc(n+1) and repeat the submission to CRAN whenever necessary. + - [ ] Get the package accepted and published on CRAN. + + ### Tag the release + + - [ ] If the additional fields were removed, add them back in a separate PR, and then merge the PR back to main (add "[skip vbump]" in the PR title). If nothing was removed just merge the PR you created in the "Prepare the release" section to 'main'. Note the commit hash of the merged commit. **Note:** additional commits might be added to the `main` branch by a bot or an automation - we do **NOT** want to tag this commit. + + ### Make sure of the following before continuing + + - [ ] CI checks are passing in GH before releasing the package. + - [ ] Shiny apps are deployable and there are no errors/warnings (Applicable only for frameworks that use Shiny). + + - [ ] Create a git tag with the final version set to vX.Y.Z on the main branch. In order to do this: + 1. Checkout the commit hash. + `git checkout ` + 2. Tag the hash with the release version (vX.Y.Z). + `git tag vX.Y.Z` + 3. Push the tag to make the final release. + `git push origin vX.Y.Z` + - [ ] Update downstream package dependencies to (>=X.Y.Z) in {package name}. + Note: Once the release tag is created, the package is automatically published to internal repositories. + - type: textarea + id: post-release + attributes: + label: Post-release + description: The list of activities to be completed after the release. + placeholder: The steps that must be taken after the release. + value: | + - [ ] Ensure that CRAN checks are passing for the package. + - [ ] Make sure that the package is published to internal repositories. + - [ ] Make sure internal documentation is up to date. + - [ ] Review and update installation instructions for the package wherever needed (Optional). + - [ ] Update all integration tests to reference the new release. + - [ ] Announce the release on ________. + - type: textarea + id: decision-tree + attributes: + label: Decision tree + description: Any decision tree(s) that would aid release management + placeholder: Any decision tree(s) that would aid release management. + value: | + Click [here](https://github.com/insightsengineering/.github/blob/main/.github/ISSUE_TEMPLATE/RELEASE_DECISION_TREE.md) to see the release decision tree. diff --git a/.github/ISSUE_TEMPLATE/release.yaml b/.github/ISSUE_TEMPLATE/release.yaml index 1d97dff5a3..73bb11dc88 100644 --- a/.github/ISSUE_TEMPLATE/release.yaml +++ b/.github/ISSUE_TEMPLATE/release.yaml @@ -28,72 +28,87 @@ body: validations: required: true - type: textarea - id: pre-requisites + id: pre-release attributes: - label: Pre-requisites + label: Pre-release description: Pre-requisites that must be fulfilled before initiating the release process. placeholder: Add your list of pre-requisites here. value: | - [ ] Make sure that high priority bugs (label "priority" + "bug") have been resolved before going into the release. - [ ] Review old/hanging PRs before going into the release. - [ ] Revisit R-package's lifecycle badges (Optional). - - [ ] Discuss package dependencies before going into release activities. - - [ ] Create a plan to sequentially close release activities and submit groups of packages for internal validation (Applicable only for regulatory release). + - [ ] Release Manager: Discuss package dependencies, create a plan to sequentially close release activities and submit groups of packages for internal validation (Applicable only for regulatory release). + - [ ] Check Validation Pipeline dry-run results for the package. - [ ] Make sure all relevant integration tests are green 2-3 days before the release. Look carefully through logs (check for warnings and notes). - - [ ] Check if a package is installable on our supported internal systems (Optional). - [ ] Inform about the soft code freeze, decide what gets merged in before starting release activities. - type: textarea - id: release-checklist + id: release attributes: - label: Release Checklist + label: Release description: The steps to be taken in order to create a release. placeholder: Steps to create a release. value: | - - [ ] Recurring tasks: Execute the manual tests on Shiny apps that are deployed on various hosting providers (Posit connect and shinyapps.io) - track the results in GitHub issue (Applicable only for frameworks that use Shiny). - - [ ] Recurring tasks: Monitor integration tests, if integration fails, create priority issues on the board. - - [ ] Sanity checks for Shiny applications e.g. checking if Shiny apps are deployable and making sure there are no errors/warnings. + ### Prepare the release + + - [ ] Create a new release candidate branch + `git checkout -b release-candidate-vX.Y.Z` - [ ] Update NEWS.md file: make sure it reflects a holistic summary of what has changed in the package, check README. - - [ ] Remove the additional fields (`Remotes` and `Config/Needs/*`) from the DESCRIPTION file where applicable. + - [ ] Remove the additional fields (`Remotes`) from the DESCRIPTION file where applicable. - [ ] Make sure that the minimum dependency versions are updated in the DESCRIPTION file for the package. - - [ ] Increase versioned dependency on {package name} to >=X.X.X. - - [ ] Create a pull request to make necessary bug fixes/changes (add "[skip vbump]" in the PR title), and after merging the PR, tag the update(s) as a release candidate v < intended release version > -rc < release candidate iteration > on the main branch. Note that tags are created in GitHub and synchronized with GitLab automatically. - - [ ] The package is submitted for internal validation by Release Coordinator (Applicable only for regulatory release). - - [ ] Address any feedback (internal validation/user testing), retag the package as a release candidate vX.X.X-rc(n+1). Repeat the submission for internal validation if necessary. - - [ ] Get the package validated (Applicable only for regulatory release). - - [ ] If the additional fields were removed, add them back in a separate PR, and then merge the PR back to main (add "[skip vbump]" in the PR title). - - [ ] Create a git tag with the final version set to X.X.X on the main branch. - - [ ] Update downstream package dependencies to (>=X.X.X) in {package name}. - - type: textarea - id: testing - attributes: - label: Testing - description: Summary of testing activities - integration tests, UAT, other. - placeholder: Tests results - value: | - - [ ] Integration tests results - accepted. - - [ ] UAT results - accepted. - - [ ] Shiny apps test results - accepted (Applicable only for Shiny apps). - - [ ] Necessary testing on target environment - performed (up to ETL). - - type: textarea - id: feedback - attributes: - label: Release Feedback - description: Feedback received from internal validation/UAT testers. - placeholder: Feedback to be implemented after submission for internal validation/testing. - value: | - - [ ] Fix 1 - - [ ] Enhancement 1 - - [ ] Defect 1 + - [ ] Increase versioned dependency on {package name} to >=X.Y.Z. + - [ ] Commit your changes and create the PR on GitHub (add "[skip vbump]" in the PR title). Add all updates, commit, and push changes: + `# Make the necessary modifications to your files + # Stage the changes + git add + # Commit the changes + git commit -m "[skip vbump] " + git push origin release-candidate-vX.Y.Z` + + ### Test the release + + - [ ] Execute the manual tests on Shiny apps that are deployed on various hosting providers (Posit connect and shinyapps.io) - track the results in GitHub issue (Applicable only for frameworks that use Shiny). + - [ ] Monitor integration tests, if integration fails, create priority issues on the board. + - [ ] Execute UAT tests (Optional). + + ### Validation loop + + Note: This section is applicable only for regulatory packages. + + - [ ] Tag the update(s) as a release candidate vX.Y.Z-rc (e.g. v0.5.3-rc1) on the release candidate branch (release-candidate-vX.Y.Z). + `# Create rc tag for submission for internal validation + git tag vX.Y.Z-rc + git push origin vX.Y.Z-rc` + - [ ] Submit the package for internal validation. + - [ ] Address any feedback (internal validation/user testing), retag the package as a release candidate vX.Y.Z-rc(n+1). Repeat the submission for internal validation if necessary. + - [ ] Get the package validated. + + ### Tag the release + + - [ ] If the additional fields were removed, add them back in a separate PR, and then merge the PR back to main (add "[skip vbump]" in the PR title). If nothing was removed just merge the PR you created in the "Prepare the release" section to `main`. Note the commit hash of the merged commit. **Note:** additional commits might be added to the `main` branch by a bot or an automation - we do **NOT** want to tag this commit. + + #### Make sure of the following before continuing with the release: + + - [ ] CI checks are passing in GH. + - [ ] Shiny apps are deployable and there are no errors/warnings (Applicable only for frameworks that use Shiny). + + - [ ] Create a git tag with the final version set to vX.Y.Z on the main branch. In order to do this: + 1. Checkout the commit hash. + `git checkout ` + 2. Tag the hash with the release version (vX.Y.Z). + `git tag vX.Y.Z` + 3. Push the tag to make the final release. + `git push origin vX.Y.Z` + - [ ] Update downstream package dependencies to (>=X.Y.Z) in {package name}. + Note: Once the release tag is created, the package is automatically published to internal repositories. - type: textarea id: post-release attributes: - label: Post-release Checklist + label: Post-release description: The list of activities to be completed after the release. placeholder: The steps that must be taken after the release. value: | - [ ] Make sure that the package is published to internal repositories (Validated and/or Non-Validated repository). - [ ] Review and update installation instructions for the package if needed. - - [ ] Verify if a new dev version (.9XXX) has been added to the NEWS.md file and DESCRIPTION file as a placeholder for release notes by automation. - [ ] Make sure internal documentation/documentation catalogs are up to date. - [ ] Notify the IDR team to start post-release/clean-up activities. - [ ] Announce the release on ________. diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml index 0c8f904fb0..cc21eb858a 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/check.yaml @@ -37,6 +37,7 @@ jobs: checking S3 generic/method consistency .* NOTE checking Rd .usage sections .* NOTE checking for unstated dependencies in vignettes .* NOTE + checking top-level files .* NOTE unit-test-report-brand: >- https://raw.githubusercontent.com/insightsengineering/hex-stickers/main/thumbs/teal.png coverage: diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index a742d6ab7f..0fa4a06c8f 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -52,6 +52,7 @@ jobs: checking R code for possible problems .* NOTE checking examples .* NOTE checking Rd line widths .* NOTE + checking top-level files .* NOTE unit-test-report-brand: >- https://raw.githubusercontent.com/insightsengineering/hex-stickers/main/thumbs/teal.png coverage: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d7f7c94ffa..9ff0944acc 100755 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -52,9 +52,9 @@ repos: .*\.sh| .*\.svg| .*\.xml| - (.*/|)\_pkgdown.y[a]ml| + (.*/|)\_pkgdown.y[a]?ml| (.*/|)\.gitignore| - (.*/|)\.gitlab-ci\.yml| + (.*/|)\.gitlab-ci\.y[a]?ml| (.*/|)\.lintr| (.*/|)\.pre-commit-.*| (.*/|)\.Rbuildignore| @@ -64,8 +64,8 @@ repos: (.*/|)DESCRIPTION| (.*/|)LICENSE| (.*/|)NAMESPACE| - (.*/|)staged_dependencies\.yaml| + (.*/|)staged_dependencies\.y[a]?ml| (.*/|)WORDLIST| - \.github/.*\.yaml| + \.github/.*\.y[a]?ml| data/.* )$ From e8ebbfdfa171c0e067b19464b5515980053d287d Mon Sep 17 00:00:00 2001 From: walkowif Date: Wed, 13 Dec 2023 13:09:52 +0000 Subject: [PATCH 18/28] [skip actions] Bump version to 0.8.16.9021 --- DESCRIPTION | 2 +- NEWS.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 83209256a9..97d8188c91 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: teal.modules.clinical Title: Teal Modules for Standard Clinical Outputs -Version: 0.8.16.9020 +Version: 0.8.16.9021 Date: 2023-12-13 Authors@R: c( person("Joe", "Zhu", , "joe.zhu@roche.com", role = c("aut", "cre")), diff --git a/NEWS.md b/NEWS.md index 16d3192935..325c8b1430 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# teal.modules.clinical 0.8.16.9020 +# teal.modules.clinical 0.8.16.9021 ### Breaking Changes + Adapted all modules to use `teal_data` objects. From 34e7b72287e56d80920eef7e4e1713021fe4b9c2 Mon Sep 17 00:00:00 2001 From: Aleksander Chlebowski <114988527+chlebowa@users.noreply.github.com> Date: Mon, 18 Dec 2023 02:46:17 +0100 Subject: [PATCH 19/28] 906 update dependency versions (#907) Fixes #906 --------- Signed-off-by: Aleksander Chlebowski <114988527+chlebowa@users.noreply.github.com> Signed-off-by: Joe Zhu Co-authored-by: Joe Zhu --- DESCRIPTION | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 97d8188c91..4befa4c9f9 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -28,14 +28,14 @@ Depends: R (>= 4.0), teal (>= 0.14.0.9027), teal.transform (>= 0.4.0.9011), - tern (>= 0.9.2.9017) + tern (>= 0.9.3) Imports: assertthat, broom, checkmate, dplyr, DT, - formatters (>= 0.5.0), + formatters (>= 0.5.5), ggplot2 (>= 3.4.0), ggrepel, grid, @@ -46,7 +46,7 @@ Imports: rlang, rlistings (>= 0.2.4), rmarkdown, - rtables (>= 0.6.1), + rtables (>= 0.6.6), scales, shiny, shinyjs, @@ -59,8 +59,8 @@ Imports: teal.logger (>= 0.1.1), teal.reporter (>= 0.2.1), teal.widgets (>= 0.4.0), - tern.gee (>= 0.1.0), - tern.mmrm (>= 0.2.1), + tern.gee (>= 0.1.3), + tern.mmrm (>= 0.3.0), tidyr, utils, vistime From 2fb20afa07675d73ef1e58805c72616f5d11aef9 Mon Sep 17 00:00:00 2001 From: shajoezhu Date: Mon, 18 Dec 2023 01:47:09 +0000 Subject: [PATCH 20/28] [skip actions] Bump version to 0.8.16.9022 --- DESCRIPTION | 4 ++-- NEWS.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 4befa4c9f9..d97a85dad5 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: teal.modules.clinical Title: Teal Modules for Standard Clinical Outputs -Version: 0.8.16.9021 -Date: 2023-12-13 +Version: 0.8.16.9022 +Date: 2023-12-18 Authors@R: c( person("Joe", "Zhu", , "joe.zhu@roche.com", role = c("aut", "cre")), person("Jana", "Stoilova", , "jana.stoilova@roche.com", role = "aut"), diff --git a/NEWS.md b/NEWS.md index 325c8b1430..2e579bb199 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# teal.modules.clinical 0.8.16.9021 +# teal.modules.clinical 0.8.16.9022 ### Breaking Changes + Adapted all modules to use `teal_data` objects. From 53759f205ae0cd5fefbd4ded79a28fb1a0d4b654 Mon Sep 17 00:00:00 2001 From: kartikeya kirar Date: Fri, 22 Dec 2023 11:34:37 +0530 Subject: [PATCH 21/28] 231 remove get_labels function (#914) part of https://github.com/insightsengineering/teal.data/issues/231 --- R/tm_g_pp_adverse_events.R | 2 +- R/tm_g_pp_therapy.R | 4 ++-- R/tm_t_pp_basic_info.R | 2 +- R/tm_t_pp_prior_medication.R | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/R/tm_g_pp_adverse_events.R b/R/tm_g_pp_adverse_events.R index 6b2f33d844..af33960e69 100644 --- a/R/tm_g_pp_adverse_events.R +++ b/R/tm_g_pp_adverse_events.R @@ -52,7 +52,7 @@ template_adverse_events <- function(dataname = "ANL", aeterm, tox_grade, causality, outcome, action, time, decod ) %>% dplyr::arrange(dplyr::desc(tox_grade)) %>% - `colnames<-`(get_labels(dataname)$column_labels[vars]) + `colnames<-`(col_labels(dataname, fill = TRUE)[vars]) table <- rlistings::as_listing( table, diff --git a/R/tm_g_pp_therapy.R b/R/tm_g_pp_therapy.R index 46b801015e..a3a695371d 100644 --- a/R/tm_g_pp_therapy.R +++ b/R/tm_g_pp_therapy.R @@ -84,8 +84,8 @@ template_therapy <- function(dataname = "ANL", dplyr::arrange(cmindc, cmdecod, cmstdy) %>% dplyr::distinct() %>% `colnames<-`(c( - get_labels(dataname)$column_labels[c(cmindc_char, cmdecod_char)], "Dosage", - get_labels(dataname)$column_labels[c(cmstdy_char, cmendy_char)] + col_labels(dataname, fill = TRUE)[c(cmindc_char, cmdecod_char)], "Dosage", + col_labels(dataname, fill = TRUE)[c(cmstdy_char, cmendy_char)] )) therapy_table <- rlistings::as_listing( diff --git a/R/tm_t_pp_basic_info.R b/R/tm_t_pp_basic_info.R index aff0ec8a79..bafdd7f11b 100644 --- a/R/tm_t_pp_basic_info.R +++ b/R/tm_t_pp_basic_info.R @@ -26,7 +26,7 @@ template_basic_info <- function(dataname = "ANL", utils::head(1) %>% t() - key <- get_labels(dataname)$column_labels[rownames(values)] + key <- col_labels(dataname, fill = TRUE)[rownames(values)] result <- data.frame(var = rownames(values), key = key, value = values) %>% diff --git a/R/tm_t_pp_prior_medication.R b/R/tm_t_pp_prior_medication.R index aef6547329..380c5b6e99 100644 --- a/R/tm_t_pp_prior_medication.R +++ b/R/tm_t_pp_prior_medication.R @@ -34,7 +34,7 @@ template_prior_medication <- function(dataname = "ANL", dplyr::select(cmindc, cmdecod, cmstdy) %>% dplyr::filter(!is.na(cmdecod)) %>% dplyr::distinct() %>% - `colnames<-`(get_labels(dataname)$column_labels[c(cmindc_char, cmdecod_char, cmstdy_char)]) + `colnames<-`(col_labels(dataname, fill = TRUE)[c(cmindc_char, cmdecod_char, cmstdy_char)]) result }, env = list( dataname = as.name(dataname), From 3839434f24f9e319cd2c20d7c815b1d952fee5fa Mon Sep 17 00:00:00 2001 From: kartikeyakirar Date: Fri, 22 Dec 2023 06:05:33 +0000 Subject: [PATCH 22/28] [skip actions] Bump version to 0.8.16.9023 --- DESCRIPTION | 4 ++-- NEWS.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index d97a85dad5..8ecbee0e96 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: teal.modules.clinical Title: Teal Modules for Standard Clinical Outputs -Version: 0.8.16.9022 -Date: 2023-12-18 +Version: 0.8.16.9023 +Date: 2023-12-22 Authors@R: c( person("Joe", "Zhu", , "joe.zhu@roche.com", role = c("aut", "cre")), person("Jana", "Stoilova", , "jana.stoilova@roche.com", role = "aut"), diff --git a/NEWS.md b/NEWS.md index 2e579bb199..3333a5faa6 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# teal.modules.clinical 0.8.16.9022 +# teal.modules.clinical 0.8.16.9023 ### Breaking Changes + Adapted all modules to use `teal_data` objects. From 3339d5163e3cb47f803bdf04255e9ced2dcc1359 Mon Sep 17 00:00:00 2001 From: Emily de la Rua <59304861+edelarua@users.noreply.github.com> Date: Wed, 3 Jan 2024 00:36:22 -0500 Subject: [PATCH 23/28] Update forest plots following refactor of `g_forest` (#911) # Pull Request Fixes #910 --------- Signed-off-by: Joe Zhu Co-authored-by: Joe Zhu Co-authored-by: Davide Garolini --- DESCRIPTION | 5 +- NEWS.md | 1 + R/tm_g_forest_rsp.R | 87 +++++++++++++++------ R/tm_g_forest_tte.R | 96 ++++++++++++++++-------- man/template_forest_rsp.Rd | 7 ++ man/template_forest_tte.Rd | 7 ++ man/tm_g_forest_rsp.Rd | 11 ++- man/tm_g_forest_tte.Rd | 14 +++- tests/testthat/_snaps/tm_g_forest_rsp.md | 16 ++-- tests/testthat/_snaps/tm_g_forest_tte.md | 16 ++-- 10 files changed, 185 insertions(+), 75 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 8ecbee0e96..144de05588 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -28,11 +28,12 @@ Depends: R (>= 4.0), teal (>= 0.14.0.9027), teal.transform (>= 0.4.0.9011), - tern (>= 0.9.3) + tern (>= 0.9.3.9002) Imports: assertthat, broom, checkmate, + cowplot (>= 0.7.0), dplyr, DT, formatters (>= 0.5.5), @@ -44,7 +45,7 @@ Imports: magrittr, methods, rlang, - rlistings (>= 0.2.4), + rlistings (>= 0.2.7), rmarkdown, rtables (>= 0.6.6), scales, diff --git a/NEWS.md b/NEWS.md index 3333a5faa6..e06dbae27d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -8,6 +8,7 @@ * Added parameter `sort_freq_col` to `tm_t_events` to allow the user to select column to use when sorting by decreasing frequency. * Added parameter `incl_overall_sum` to `tm_t_events` to allow the user to choose whether overall summary rows are included at the top of the table. * Updated the documentation and vignettes to demonstrate method to pass `teal_data` object to `teal::init()`. +* Updated `tm_g_forest_rsp` and `tm_g_forest_tte` to use refactored version of `g_forest`. Plots are now displayed as `ggplot` objects instead of `grob` objects. Added parameters `font_size` and `rel_width_forest` to control font size and width of plot relative to table, respectively. ### Bug fixes * Fixed bug in `tm_g_lineplot` forcing module to initialize with a table. diff --git a/R/tm_g_forest_rsp.R b/R/tm_g_forest_rsp.R index 4960f25c8a..354faf6708 100644 --- a/R/tm_g_forest_rsp.R +++ b/R/tm_g_forest_rsp.R @@ -2,6 +2,7 @@ #' #' Creates a valid expression for response forest plot. #' +#' @inheritParams tern::g_forest #' @inheritParams template_arguments #' @param obj_var_name (`character`)\cr additional text string append to output title. #' @param responders (`character`)\cr values of `aval_var` that are considered to be responders. @@ -34,6 +35,8 @@ template_forest_rsp <- function(dataname = "ANL", strata_var = NULL, conf_level = 0.95, col_symbol_size = NULL, + rel_width_forest = 0.25, + font_size = 15, ggplot2_args = teal.widgets::ggplot2_args()) { assertthat::assert_that( assertthat::is.string(dataname), @@ -43,6 +46,8 @@ template_forest_rsp <- function(dataname = "ANL", assertthat::is.string(obj_var_name), is.null(subgroup_var) || is.character(subgroup_var) ) + checkmate::assert_number(rel_width_forest, lower = 0, upper = 1) + checkmate::assert_number(font_size) y <- list() ref_arm_val <- paste(ref_arm, collapse = "/") @@ -160,34 +165,55 @@ template_forest_rsp <- function(dataname = "ANL", all_ggplot2_args <- teal.widgets::resolve_ggplot2_args( user_plot = ggplot2_args, module_plot = teal.widgets::ggplot2_args( - labs = list(title = paste0("Forest plot of best overall response for ", obj_var_name), caption = "") + labs = list( + title = paste("Forest Plot of Best Overall Response for", obj_var_name), + caption = "" + ) ) ) - plot_call <- substitute( - expr = g_forest( - tbl = result, - col_symbol_size = col_s_size - ), - env = list(col_s_size = col_symbol_size) - ) + plot_list <- list() - plot_call <- substitute( - decorate_grob(p, titles = title, footnotes = caption, gp_footnotes = grid::gpar(fontsize = 12)), - env = list(title = all_ggplot2_args$labs$title, caption = all_ggplot2_args$labs$caption, p = plot_call) + plot_list <- add_expr( + plot_list, + substitute( + expr = { + f <- g_forest( + tbl = result, + col_symbol_size = col_s_size, + font_size = font_size, + as_list = TRUE + ) + }, + env = list( + col_s_size = col_symbol_size, + font_size = font_size + ) + ) ) - plot_call <- substitute( - expr = { - p <- plot_call - grid::grid.newpage() - grid::grid.draw(p) - }, - env = list(plot_call = plot_call) + plot_list <- add_expr( + plot_list, + substitute( + expr = { + p <- cowplot::plot_grid( + f[["table"]] + ggplot2::labs(title = ggplot2_args_title), + f[["plot"]] + ggplot2::labs(caption = ggplot2_args_caption), + align = "h", + axis = "tblr", + rel_widths = c(1 - rel_width_forest, rel_width_forest) + ) + }, + env = list( + rel_width_forest = rel_width_forest, + ggplot2_args_title = all_ggplot2_args$labs$title, + ggplot2_args_caption = all_ggplot2_args$labs$caption + ) + ) ) # Plot output. - y$plot <- plot_call + y$plot <- plot_list y } @@ -196,6 +222,7 @@ template_forest_rsp <- function(dataname = "ANL", #' #' This teal module produces a grid style Forest plot for response data with `ADaM` structure. #' +#' @inheritParams tern::g_forest #' @inheritParams module_arguments #' @inheritParams tm_t_binary_outcome #' @param fixed_symbol_size (`logical`)\cr @@ -314,8 +341,10 @@ tm_g_forest_rsp <- function(label, fixed_symbol_size = TRUE, conf_level = teal.transform::choices_selected(c(0.95, 0.9, 0.8), 0.95, keep_order = TRUE), default_responses = c("CR", "PR", "Y", "Complete Response (CR)", "Partial Response (PR)"), - plot_height = c(700L, 200L, 2000L), - plot_width = c(1200L, 800L, 3000L), + plot_height = c(500L, 200L, 2000L), + plot_width = c(1500L, 800L, 3000L), + rel_width_forest = c(25L, 0L, 100L), + font_size = c(15L, 1L, 30L), pre_output = NULL, post_output = NULL, ggplot2_args = teal.widgets::ggplot2_args()) { @@ -442,7 +471,19 @@ ui_g_forest_rsp <- function(id, ...) { multiple = FALSE, fixed = a$conf_level$fixed ), - shiny::checkboxInput(ns("fixed_symbol_size"), "Fixed symbol size", value = TRUE) + shiny::checkboxInput(ns("fixed_symbol_size"), "Fixed symbol size", value = TRUE), + teal.widgets::optionalSliderInputValMinMax( + ns("rel_width_forest"), + "Relative Width of Forest Plot (%)", + a$rel_width_forest, + ticks = FALSE, step = 1 + ), + teal.widgets::optionalSliderInputValMinMax( + ns("font_size"), + "Table Font Size", + a$font_size, + ticks = FALSE, step = 1 + ) ) ) ), @@ -692,6 +733,8 @@ srv_g_forest_rsp <- function(id, strata_var = if (length(strata_var) != 0) strata_var else NULL, conf_level = as.numeric(input$conf_level), col_symbol_size = `if`(input$fixed_symbol_size, NULL, 1), + rel_width_forest = input$rel_width_forest / 100, + font_size = input$font_size, ggplot2_args = ggplot2_args ) diff --git a/R/tm_g_forest_tte.R b/R/tm_g_forest_tte.R index a50c6e015a..311240ef41 100644 --- a/R/tm_g_forest_tte.R +++ b/R/tm_g_forest_tte.R @@ -29,6 +29,8 @@ template_forest_tte <- function(dataname = "ANL", conf_level = 0.95, col_symbol_size = NULL, time_unit_var = "AVALU", + rel_width_forest = 0.25, + font_size = 15, ggplot2_args = teal.widgets::ggplot2_args()) { assertthat::assert_that( assertthat::is.string(dataname), @@ -36,6 +38,8 @@ template_forest_tte <- function(dataname = "ANL", assertthat::is.string(obj_var_name), is.character(subgroup_var) || is.null(subgroup_var) ) + checkmate::assert_number(rel_width_forest, lower = 0, upper = 1) + checkmate::assert_number(font_size) y <- list() ref_arm_val <- paste(ref_arm, collapse = "/") @@ -162,45 +166,59 @@ template_forest_tte <- function(dataname = "ANL", user_plot = ggplot2_args, module_plot = teal.widgets::ggplot2_args( labs = list( - title = paste("Forest Plot of Survival Duration for", obj_var_name), - subtitle = ifelse(is.null(strata_var), "", paste("Stratified by", paste(strata_var, collapse = " and "))), + title = paste( + paste("Forest Plot of Survival Duration for", obj_var_name), + ifelse(is.null(strata_var), "", paste("Stratified by", paste(strata_var, collapse = " and "))), + sep = "\n" + ), caption = "" ) ) ) - plot_call <- substitute( - expr = g_forest( - tbl = result, - col_symbol_size = col_s_size - ), - env = list(col_s_size = col_symbol_size) - ) + plot_list <- list() - plot_call <- substitute( - decorate_grob(p, titles = title, footnotes = caption, gp_footnotes = grid::gpar(fontsize = 12)), - env = list( - title = `if`( - all_ggplot2_args$labs$subtitle == "", - all_ggplot2_args$labs$title, - c(all_ggplot2_args$labs$title, all_ggplot2_args$labs$subtitle) - ), - caption = all_ggplot2_args$labs$caption, - p = plot_call + plot_list <- add_expr( + plot_list, + substitute( + expr = { + f <- g_forest( + tbl = result, + col_symbol_size = col_s_size, + font_size = font_size, + as_list = TRUE + ) + }, + env = list( + col_s_size = col_symbol_size, + font_size = font_size + ) ) ) - plot_call <- substitute( - env = list(plot_call = plot_call), - expr = { - p <- plot_call - grid::grid.newpage() - grid::grid.draw(p) - } + plot_list <- add_expr( + plot_list, + substitute( + expr = { + p <- cowplot::plot_grid( + f[["table"]] + ggplot2::labs(title = ggplot2_args_title, subtitle = ggplot2_args_subtitle), + f[["plot"]] + ggplot2::labs(caption = ggplot2_args_caption), + align = "h", + axis = "tblr", + rel_widths = c(1 - rel_width_forest, rel_width_forest) + ) + }, + env = list( + rel_width_forest = rel_width_forest, + ggplot2_args_title = all_ggplot2_args$labs$title, + ggplot2_args_subtitle = all_ggplot2_args$labs$subtitle, + ggplot2_args_caption = all_ggplot2_args$labs$caption + ) + ) ) # Plot output. - y$plot <- plot_call + y$plot <- plot_list y } @@ -210,6 +228,7 @@ template_forest_tte <- function(dataname = "ANL", #' This teal module produces a grid style Forest plot for time-to-event data #' with `ADaM` structure #' +#' @inheritParams tern::g_forest #' @inheritParams module_arguments #' @inheritParams tm_g_forest_rsp #' @param ggplot2_args optional, (`ggplot2_args`)\cr @@ -271,8 +290,7 @@ template_forest_tte <- function(dataname = "ANL", #' strata_var = choices_selected( #' variable_choices(ADSL, c("STRATA1", "STRATA2")), #' "STRATA2" -#' ), -#' plot_height = c(600, 200, 2000) +#' ) #' ) #' ) #' ) @@ -306,8 +324,10 @@ tm_g_forest_tte <- function(label, fixed = TRUE ), fixed_symbol_size = TRUE, - plot_height = c(700L, 200L, 2000L), - plot_width = c(1200L, 800L, 3000L), + plot_height = c(500L, 200L, 2000L), + plot_width = c(1500L, 800L, 3000L), + rel_width_forest = c(25L, 0L, 100L), + font_size = c(15L, 1L, 30L), pre_output = NULL, post_output = NULL, ggplot2_args = teal.widgets::ggplot2_args()) { @@ -443,6 +463,18 @@ ui_g_forest_tte <- function(id, ...) { label = "Time Unit Variable", data_extract_spec = a$time_unit_var, is_single_dataset = is_single_dataset_value + ), + teal.widgets::optionalSliderInputValMinMax( + ns("rel_width_forest"), + "Relative Width of Forest Plot (%)", + a$rel_width_forest, + ticks = FALSE, step = 1 + ), + teal.widgets::optionalSliderInputValMinMax( + ns("font_size"), + "Table Font Size", + a$font_size, + ticks = FALSE, step = 1 ) ) ) @@ -624,6 +656,8 @@ srv_g_forest_tte <- function(id, conf_level = as.numeric(input$conf_level), col_symbol_size = if (!input$fixed_symbol_size) 1, time_unit_var = as.vector(anl_m$columns_source$time_unit_var), + rel_width_forest = input$rel_width_forest / 100, + font_size = input$font_size, ggplot2_args = ggplot2_args ) teal.code::eval_code(anl_q(), as.expression(my_calls)) diff --git a/man/template_forest_rsp.Rd b/man/template_forest_rsp.Rd index db9ec80358..55b3bb6207 100644 --- a/man/template_forest_rsp.Rd +++ b/man/template_forest_rsp.Rd @@ -17,6 +17,8 @@ template_forest_rsp( strata_var = NULL, conf_level = 0.95, col_symbol_size = NULL, + rel_width_forest = 0.25, + font_size = 15, ggplot2_args = teal.widgets::ggplot2_args() ) } @@ -55,6 +57,11 @@ value for the confidence level within the range of (0, 1).} estimator plot symbol. Typically, the symbol size is proportional to the sample size used to calculate the estimator. If \code{NULL}, the same symbol size is used for all subgroups.} +\item{rel_width_forest}{(\code{proportion})\cr proportion of total width to allocate to the forest plot. Relative +width of table is then \code{1 - rel_width_forest}. If \code{as_list = TRUE}, this parameter is ignored.} + +\item{font_size}{(\code{numeric})\cr font size.} + \item{ggplot2_args}{optional, (\code{ggplot2_args})\cr object created by \code{\link[teal.widgets:ggplot2_args]{teal.widgets::ggplot2_args()}} with settings for the module plot. For this module, this argument will only accept \code{ggplot2_args} object with \code{labs} list of following child elements: diff --git a/man/template_forest_tte.Rd b/man/template_forest_tte.Rd index 49ec9db8f9..fa1483434e 100644 --- a/man/template_forest_tte.Rd +++ b/man/template_forest_tte.Rd @@ -18,6 +18,8 @@ template_forest_tte( conf_level = 0.95, col_symbol_size = NULL, time_unit_var = "AVALU", + rel_width_forest = 0.25, + font_size = 15, ggplot2_args = teal.widgets::ggplot2_args() ) } @@ -60,6 +62,11 @@ to calculate the estimator. If \code{NULL}, the same symbol size is used for all \item{time_unit_var}{(\code{character})\cr name of the variable representing time units.} +\item{rel_width_forest}{(\code{proportion})\cr proportion of total width to allocate to the forest plot. Relative +width of table is then \code{1 - rel_width_forest}. If \code{as_list = TRUE}, this parameter is ignored.} + +\item{font_size}{(\code{numeric})\cr font size.} + \item{ggplot2_args}{optional, (\code{ggplot2_args})\cr object created by \code{\link[teal.widgets:ggplot2_args]{teal.widgets::ggplot2_args()}} with settings for the module plot. For this module, this argument will only accept \code{ggplot2_args} object with \code{labs} list of following child elements: diff --git a/man/tm_g_forest_rsp.Rd b/man/tm_g_forest_rsp.Rd index 805fa239c7..647156d746 100644 --- a/man/tm_g_forest_rsp.Rd +++ b/man/tm_g_forest_rsp.Rd @@ -21,8 +21,10 @@ tm_g_forest_rsp( TRUE), default_responses = c("CR", "PR", "Y", "Complete Response (CR)", "Partial Response (PR)"), - plot_height = c(700L, 200L, 2000L), - plot_width = c(1200L, 800L, 3000L), + plot_height = c(500L, 200L, 2000L), + plot_width = c(1500L, 800L, 3000L), + rel_width_forest = c(25L, 0L, 100L), + font_size = c(15L, 1L, 30L), pre_output = NULL, post_output = NULL, ggplot2_args = teal.widgets::ggplot2_args() @@ -91,6 +93,11 @@ a vector of length three with \code{c(value, min, max)}. Specifies the width of the main plot and renders a slider on the plot to interactively adjust the plot width.} +\item{rel_width_forest}{(\code{proportion})\cr proportion of total width to allocate to the forest plot. Relative +width of table is then \code{1 - rel_width_forest}. If \code{as_list = TRUE}, this parameter is ignored.} + +\item{font_size}{(\code{numeric})\cr font size.} + \item{pre_output}{optional, (\code{shiny.tag})\cr with text placed before the output to put the output into context. For example a title.} diff --git a/man/tm_g_forest_tte.Rd b/man/tm_g_forest_tte.Rd index 8d6b408dba..25dfd59f01 100644 --- a/man/tm_g_forest_tte.Rd +++ b/man/tm_g_forest_tte.Rd @@ -24,8 +24,10 @@ tm_g_forest_tte( teal.transform::choices_selected(teal.transform::variable_choices(dataname, "AVALU"), "AVALU", fixed = TRUE), fixed_symbol_size = TRUE, - plot_height = c(700L, 200L, 2000L), - plot_width = c(1200L, 800L, 3000L), + plot_height = c(500L, 200L, 2000L), + plot_width = c(1500L, 800L, 3000L), + rel_width_forest = c(25L, 0L, 100L), + font_size = c(15L, 1L, 30L), pre_output = NULL, post_output = NULL, ggplot2_args = teal.widgets::ggplot2_args() @@ -95,6 +97,11 @@ a vector of length three with \code{c(value, min, max)}. Specifies the width of the main plot and renders a slider on the plot to interactively adjust the plot width.} +\item{rel_width_forest}{(\code{proportion})\cr proportion of total width to allocate to the forest plot. Relative +width of table is then \code{1 - rel_width_forest}. If \code{as_list = TRUE}, this parameter is ignored.} + +\item{font_size}{(\code{numeric})\cr font size.} + \item{pre_output}{optional, (\code{shiny.tag})\cr with text placed before the output to put the output into context. For example a title.} @@ -164,8 +171,7 @@ app <- init( strata_var = choices_selected( variable_choices(ADSL, c("STRATA1", "STRATA2")), "STRATA2" - ), - plot_height = c(600, 200, 2000) + ) ) ) ) diff --git a/tests/testthat/_snaps/tm_g_forest_rsp.md b/tests/testthat/_snaps/tm_g_forest_rsp.md index ed77908703..d11b6d169e 100644 --- a/tests/testthat/_snaps/tm_g_forest_rsp.md +++ b/tests/testthat/_snaps/tm_g_forest_rsp.md @@ -30,12 +30,14 @@ vars = c("n_tot", "n", "n_rsp", "prop", "or", "ci")) $plot - { - p <- decorate_grob(g_forest(tbl = result, col_symbol_size = NULL), - titles = "Forest plot of best overall response for ", - footnotes = "", gp_footnotes = grid::gpar(fontsize = 12)) - grid::grid.newpage() - grid::grid.draw(p) - } + $plot[[1]] + f <- g_forest(tbl = result, col_symbol_size = NULL, font_size = 15, + as_list = TRUE) + + $plot[[2]] + p <- cowplot::plot_grid(f[["table"]] + ggplot2::labs(title = "Forest Plot of Best Overall Response for "), + f[["plot"]] + ggplot2::labs(caption = ""), align = "h", axis = "tblr", + rel_widths = c(1 - 0.25, 0.25)) + diff --git a/tests/testthat/_snaps/tm_g_forest_tte.md b/tests/testthat/_snaps/tm_g_forest_tte.md index f2d83461b2..8a3e7130a8 100644 --- a/tests/testthat/_snaps/tm_g_forest_tte.md +++ b/tests/testthat/_snaps/tm_g_forest_tte.md @@ -33,12 +33,14 @@ } $plot - { - p <- decorate_grob(g_forest(tbl = result, col_symbol_size = NULL), - titles = c("Forest Plot of Survival Duration for ", "Stratified by STRATA2" - ), footnotes = "", gp_footnotes = grid::gpar(fontsize = 12)) - grid::grid.newpage() - grid::grid.draw(p) - } + $plot[[1]] + f <- g_forest(tbl = result, col_symbol_size = NULL, font_size = 15, + as_list = TRUE) + + $plot[[2]] + p <- cowplot::plot_grid(f[["table"]] + ggplot2::labs(title = "Forest Plot of Survival Duration for \nStratified by STRATA2", + subtitle = NULL), f[["plot"]] + ggplot2::labs(caption = ""), + align = "h", axis = "tblr", rel_widths = c(1 - 0.25, 0.25)) + From 90e3e445176bf56f689bb8f93a01870d4e9d2f53 Mon Sep 17 00:00:00 2001 From: shajoezhu Date: Wed, 3 Jan 2024 05:37:24 +0000 Subject: [PATCH 24/28] [skip actions] Bump version to 0.8.16.9024 --- DESCRIPTION | 4 ++-- NEWS.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 144de05588..5b14b21ab2 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: teal.modules.clinical Title: Teal Modules for Standard Clinical Outputs -Version: 0.8.16.9023 -Date: 2023-12-22 +Version: 0.8.16.9024 +Date: 2024-01-03 Authors@R: c( person("Joe", "Zhu", , "joe.zhu@roche.com", role = c("aut", "cre")), person("Jana", "Stoilova", , "jana.stoilova@roche.com", role = "aut"), diff --git a/NEWS.md b/NEWS.md index e06dbae27d..1bd6446e3b 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# teal.modules.clinical 0.8.16.9023 +# teal.modules.clinical 0.8.16.9024 ### Breaking Changes + Adapted all modules to use `teal_data` objects. From 836b970a0df653f71953a782346b9c973fa451fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dawid=20Ka=C5=82=C4=99dkowski?= <6959016+gogonzo@users.noreply.github.com> Date: Fri, 12 Jan 2024 11:33:02 +0100 Subject: [PATCH 25/28] Two arm vars (#916) Two arms --- R/tm_t_summary.R | 64 +++++++------------ R/tm_t_summary_by.R | 80 ++++++++++++------------ tests/testthat/_snaps/tm_t_summary.md | 49 ++++++++------- tests/testthat/_snaps/tm_t_summary_by.md | 59 ++++++++--------- 4 files changed, 119 insertions(+), 133 deletions(-) diff --git a/R/tm_t_summary.R b/R/tm_t_summary.R index b5f2381aff..33c7242d97 100644 --- a/R/tm_t_summary.R +++ b/R/tm_t_summary.R @@ -29,7 +29,6 @@ template_summary <- function(dataname, assertthat::assert_that( assertthat::is.string(dataname), assertthat::is.string(parentname), - is.character(arm_var), is.character(sum_vars), assertthat::is.flag(add_total), assertthat::is.string(total_label), @@ -38,6 +37,7 @@ template_summary <- function(dataname, assertthat::is.string(na_level), assertthat::is.flag(drop_arm_levels) ) + checkmate::assert_character(arm_var, min.len = 1, max.len = 2) checkmate::assert_character(numeric_stats, min.len = 1) checkmate::assert_subset( numeric_stats, @@ -48,7 +48,9 @@ template_summary <- function(dataname, y <- list() + # Data processing data_list <- list() + data_list <- add_expr( data_list, substitute( @@ -62,27 +64,15 @@ template_summary <- function(dataname, ) ) - - data_list <- add_expr( - data_list, + prepare_arm_levels_call <- lapply(arm_var, function(x) { prepare_arm_levels( dataname = "anl", parentname = parentname, - arm_var = arm_var[[1]], + arm_var = x, drop_arm_levels = drop_arm_levels ) - ) - if (length(arm_var) == 2) { - data_list <- add_expr( - data_list, - prepare_arm_levels( - dataname = "anl", - parentname = parentname, - arm_var = arm_var[[2]], - drop_arm_levels = drop_arm_levels - ) - ) - } + }) + data_list <- Reduce(add_expr, prepare_arm_levels_call, init = data_list) data_list <- add_expr( data_list, @@ -109,29 +99,23 @@ template_summary <- function(dataname, layout_list, parsed_basic_table_args ) - layout_list <- add_expr( - layout_list, - substitute( - expr = rtables::split_cols_by(arm_var), - env = list(arm_var = arm_var[[1]]) - ) - ) - if (length(arm_var) == 2) { - layout_list <- add_expr( - layout_list, - if (drop_arm_levels) { - substitute( - expr = rtables::split_cols_by(nested_col, split_fun = drop_split_levels), - env = list(nested_col = arm_var[[2]]) - ) - } else { - substitute( - expr = rtables::split_cols_by(nested_col), - env = list(nested_col = arm_var[[2]]) - ) - } - ) - } + + # Build layout + split_cols_call <- lapply(arm_var, function(x) { + if (drop_arm_levels) { + substitute( + expr = rtables::split_cols_by(x, split_fun = drop_split_levels), + env = list(x = x) + ) + } else { + substitute( + expr = rtables::split_cols_by(x), + env = list(x = x) + ) + } + }) + layout_list <- Reduce(add_expr, split_cols_call, init = layout_list) + if (add_total) { layout_list <- add_expr( layout_list, diff --git a/R/tm_t_summary_by.R b/R/tm_t_summary_by.R index a49d30cb35..083b3558ee 100644 --- a/R/tm_t_summary_by.R +++ b/R/tm_t_summary_by.R @@ -36,7 +36,6 @@ template_summary_by <- function(parentname, assertthat::assert_that( assertthat::is.string(parentname), assertthat::is.string(dataname), - assertthat::is.string(arm_var), assertthat::is.string(id_var), is.character(sum_vars), is.character(by_vars), @@ -51,6 +50,7 @@ template_summary_by <- function(parentname, is.character(numeric_stats), assertthat::is.flag(drop_zero_levels) ) + checkmate::assert_character(arm_var, min.len = 1, max.len = 2) denominator <- match.arg(denominator) y <- list() @@ -72,15 +72,15 @@ template_summary_by <- function(parentname, ) ) - data_list <- add_expr( - data_list, + prepare_arm_levels_call <- lapply(arm_var, function(x) { prepare_arm_levels( dataname = "anl", parentname = parentname, - arm_var = arm_var, + arm_var = x, drop_arm_levels = drop_arm_levels ) - ) + }) + data_list <- Reduce(add_expr, prepare_arm_levels_call, init = data_list) data_list <- add_expr( data_list, @@ -106,7 +106,6 @@ template_summary_by <- function(parentname, ) } - layout_list <- list() table_title <- paste("Summary Table for", paste(sum_vars, collapse = ", "), "by", paste(by_vars, collapse = ", ")) @@ -117,56 +116,53 @@ template_summary_by <- function(parentname, ) ) + layout_list <- list() layout_list <- add_expr( layout_list, parsed_basic_table_args ) - layout_list <- add_expr( - layout_list, - if (add_total) { + split_cols_call <- lapply(arm_var, function(x) { + if (drop_arm_levels) { substitute( - expr = rtables::split_cols_by( - arm_var, - split_fun = add_overall_level(total_label, first = FALSE) - ), - env = list( - arm_var = arm_var, - total_label = total_label - ) + expr = rtables::split_cols_by(x, split_fun = drop_split_levels), + env = list(x = x) ) } else { substitute( - expr = rtables::split_cols_by(arm_var), - env = list(arm_var = arm_var) + expr = rtables::split_cols_by(x), + env = list(x = x) ) } - ) + }) + layout_list <- Reduce(add_expr, split_cols_call, init = layout_list) + + if (add_total) { + layout_list <- add_expr( + layout_list, + substitute( + expr = rtables::add_overall_col(total_label), + env = list(total_label = total_label) + ) + ) + } layout_list <- add_expr( layout_list, quote(rtables::add_colcounts()) ) - if (denominator == "omit") { - env_vars <- list( - sum_vars = sum_vars, - sum_var_labels = var_labels[sum_vars], - na.rm = na.rm, - na_level = na_level, - denom = ifelse(denominator == "n", "n", "N_col"), - stats = c(numeric_stats, "count") - ) - } else { - env_vars <- list( - sum_vars = sum_vars, - sum_var_labels = var_labels[sum_vars], - na.rm = na.rm, - na_level = na_level, - denom = ifelse(denominator == "n", "n", "N_col"), - stats = c(numeric_stats, "count_fraction") + env_vars <- list( + sum_vars = sum_vars, + sum_var_labels = var_labels[sum_vars], + na.rm = na.rm, + na_level = na_level, + denom = ifelse(denominator == "n", "n", "N_col"), + stats = c( + numeric_stats, + ifelse(denominator == "omit", "count", "count_fraction") ) - } + ) for (by_var in by_vars) { split_label <- substitute( @@ -425,7 +421,7 @@ tm_t_summary_by <- function(label, args <- c(as.list(environment())) data_extract_list <- list( - arm_var = cs_to_des_select(arm_var, dataname = parentname), + arm_var = cs_to_des_select(arm_var, dataname = parentname, multiple = TRUE, ordered = TRUE), id_var = cs_to_des_select(id_var, dataname = dataname), paramcd = `if`( is.null(paramcd), @@ -610,7 +606,9 @@ srv_summary_by <- function(id, } validation_rules <- list( - arm_var = shinyvalidate::sv_required("Please select a treatment variable."), + arm_var = ~ if (length(.) != 1 && length(.) != 2) { + "Please select 1 or 2 column variables" + }, id_var = shinyvalidate::sv_required("Please select a subject identifier."), summarize_vars = shinyvalidate::sv_required("Please select a summarize variable.") ) @@ -671,7 +669,7 @@ srv_summary_by <- function(id, adslvars = c("USUBJID", "STUDYID", input_arm_var), anl = anl_filtered, anlvars = c("USUBJID", "STUDYID", input_paramcd, input_by_vars, input_summarize_vars, input_id_var), - arm_var = input_arm_var + arm_var = input_arm_var[[1]] ) if (input$parallel_vars) { diff --git a/tests/testthat/_snaps/tm_t_summary.md b/tests/testthat/_snaps/tm_t_summary.md index cd9a0558df..6c82e195e8 100644 --- a/tests/testthat/_snaps/tm_t_summary.md +++ b/tests/testthat/_snaps/tm_t_summary.md @@ -16,11 +16,12 @@ $layout lyt <- rtables::basic_table(main_footer = "n represents the number of unique subject IDs such that the variable has non-NA values.") %>% - rtables::split_cols_by("ARM") %>% rtables::add_colcounts() %>% - summarize_vars(vars = c("RACE", "COUNTRY", "AGE"), show_labels = "visible", - na.rm = FALSE, na_level = "", denom = "N_col", - .stats = c("n", "mean_sd", "mean_ci", "median", "median_ci", - "quantiles", "range", "geom_mean", "count_fraction")) + rtables::split_cols_by("ARM", split_fun = drop_split_levels) %>% + rtables::add_colcounts() %>% summarize_vars(vars = c("RACE", + "COUNTRY", "AGE"), show_labels = "visible", na.rm = FALSE, + na_level = "", denom = "N_col", .stats = c("n", + "mean_sd", "mean_ci", "median", "median_ci", "quantiles", + "range", "geom_mean", "count_fraction")) $table { @@ -82,12 +83,13 @@ $layout lyt <- rtables::basic_table(main_footer = "n represents the number of unique subject IDs such that the variable has non-NA values.") %>% - rtables::split_cols_by("ARM") %>% rtables::split_cols_by("STRATA1", - split_fun = drop_split_levels) %>% rtables::add_colcounts() %>% - summarize_vars(vars = c("RACE", "COUNTRY", "AGE"), show_labels = "visible", - na.rm = FALSE, na_level = "", denom = "N_col", - .stats = c("n", "mean_sd", "mean_ci", "median", "median_ci", - "quantiles", "range", "geom_mean", "count_fraction")) + rtables::split_cols_by("ARM", split_fun = drop_split_levels) %>% + rtables::split_cols_by("STRATA1", split_fun = drop_split_levels) %>% + rtables::add_colcounts() %>% summarize_vars(vars = c("RACE", + "COUNTRY", "AGE"), show_labels = "visible", na.rm = FALSE, + na_level = "", denom = "N_col", .stats = c("n", + "mean_sd", "mean_ci", "median", "median_ci", "quantiles", + "range", "geom_mean", "count_fraction")) $table { @@ -118,13 +120,13 @@ $layout lyt <- rtables::basic_table(main_footer = "n represents the number of unique subject IDs such that the variable has non-NA values.") %>% - rtables::split_cols_by("ARM") %>% rtables::split_cols_by("STRATA1", - split_fun = drop_split_levels) %>% rtables::add_overall_col("All Patients") %>% - rtables::add_colcounts() %>% summarize_vars(vars = c("RACE", - "COUNTRY", "AGE"), show_labels = "visible", na.rm = FALSE, - na_level = "", denom = "N_col", .stats = c("n", - "mean_sd", "mean_ci", "median", "median_ci", "quantiles", - "range", "geom_mean", "count_fraction")) + rtables::split_cols_by("ARM", split_fun = drop_split_levels) %>% + rtables::split_cols_by("STRATA1", split_fun = drop_split_levels) %>% + rtables::add_overall_col("All Patients") %>% rtables::add_colcounts() %>% + summarize_vars(vars = c("RACE", "COUNTRY", "AGE"), show_labels = "visible", + na.rm = FALSE, na_level = "", denom = "N_col", + .stats = c("n", "mean_sd", "mean_ci", "median", "median_ci", + "quantiles", "range", "geom_mean", "count_fraction")) $table { @@ -155,11 +157,12 @@ $layout lyt <- rtables::basic_table(main_footer = "n represents the number of unique subject IDs such that the variable has non-NA values.") %>% - rtables::split_cols_by("ARM") %>% rtables::split_cols_by("STRATA1", - split_fun = drop_split_levels) %>% rtables::add_colcounts() %>% - summarize_vars(vars = c("RACE", "COUNTRY", "AGE"), show_labels = "visible", - na.rm = FALSE, na_level = "", denom = "N_col", - .stats = c("n", "count_fraction")) + rtables::split_cols_by("ARM", split_fun = drop_split_levels) %>% + rtables::split_cols_by("STRATA1", split_fun = drop_split_levels) %>% + rtables::add_colcounts() %>% summarize_vars(vars = c("RACE", + "COUNTRY", "AGE"), show_labels = "visible", na.rm = FALSE, + na_level = "", denom = "N_col", .stats = c("n", + "count_fraction")) $table { diff --git a/tests/testthat/_snaps/tm_t_summary_by.md b/tests/testthat/_snaps/tm_t_summary_by.md index 3b6c11b5da..f7520f07b0 100644 --- a/tests/testthat/_snaps/tm_t_summary_by.md +++ b/tests/testthat/_snaps/tm_t_summary_by.md @@ -19,13 +19,13 @@ $layout lyt <- rtables::basic_table(title = "Summary Table for AVAL by AVISIT") %>% - rtables::split_cols_by("ARM", split_fun = add_overall_level("All Patients", - first = FALSE)) %>% rtables::add_colcounts() %>% rtables::split_rows_by("AVISIT", - split_label = formatters::var_labels(adlb, fill = FALSE)[["AVISIT"]], - split_fun = split_fun, label_pos = "topleft") %>% summarize_vars(vars = "AVAL", - na.rm = FALSE, na_level = "", denom = "N_col", .stats = c("n", - "mean_sd", "mean_ci", "median", "median_ci", "quantiles", - "range", "count_fraction")) + rtables::split_cols_by("ARM", split_fun = drop_split_levels) %>% + rtables::add_overall_col("All Patients") %>% rtables::add_colcounts() %>% + rtables::split_rows_by("AVISIT", split_label = formatters::var_labels(adlb, + fill = FALSE)[["AVISIT"]], split_fun = split_fun, label_pos = "topleft") %>% + summarize_vars(vars = "AVAL", na.rm = FALSE, na_level = "", + denom = "N_col", .stats = c("n", "mean_sd", "mean_ci", + "median", "median_ci", "quantiles", "range", "count_fraction")) $table { @@ -54,8 +54,8 @@ $layout lyt <- rtables::basic_table(title = "Summary Table for AVAL, CHG by AVISIT") %>% - rtables::split_cols_by("ARM", split_fun = add_overall_level("All Patients", - first = FALSE)) %>% rtables::add_colcounts() %>% rtables::split_rows_by("AVISIT", + rtables::split_cols_by("ARM") %>% rtables::add_overall_col("All Patients") %>% + rtables::add_colcounts() %>% rtables::split_rows_by("AVISIT", split_label = formatters::var_labels(adlb, fill = FALSE)[["AVISIT"]], split_fun = split_fun, label_pos = "topleft") %>% split_cols_by_multivar(vars = c("AVAL", "CHG")) %>% summarize_colvars(vars = c("AVAL", "CHG"), na.rm = FALSE, @@ -96,13 +96,14 @@ $layout lyt <- rtables::basic_table(title = "Summary Table for AVAL by SEX, COUNTRY") %>% - rtables::split_cols_by("ARM") %>% rtables::add_colcounts() %>% - rtables::split_rows_by("SEX", split_label = formatters::var_labels(adsl, - fill = FALSE)[["SEX"]], split_fun = split_fun, label_pos = "topleft") %>% - rtables::summarize_row_groups(var = "USUBJID", cfun = cfun_unique) %>% - rtables::split_rows_by("COUNTRY", split_label = formatters::var_labels(adsl, - fill = FALSE)[["COUNTRY"]], split_fun = split_fun, label_pos = "topleft") %>% - rtables::summarize_row_groups(var = "USUBJID", cfun = cfun_unique) + rtables::split_cols_by("ARM", split_fun = drop_split_levels) %>% + rtables::add_colcounts() %>% rtables::split_rows_by("SEX", + split_label = formatters::var_labels(adsl, fill = FALSE)[["SEX"]], + split_fun = split_fun, label_pos = "topleft") %>% rtables::summarize_row_groups(var = "USUBJID", + cfun = cfun_unique) %>% rtables::split_rows_by("COUNTRY", + split_label = formatters::var_labels(adsl, fill = FALSE)[["COUNTRY"]], + split_fun = split_fun, label_pos = "topleft") %>% rtables::summarize_row_groups(var = "USUBJID", + cfun = cfun_unique) $table { @@ -132,12 +133,12 @@ $layout lyt <- rtables::basic_table(title = "Summary Table for AVAL by AVISIT") %>% - rtables::split_cols_by("ARM", split_fun = add_overall_level("All Patients", - first = FALSE)) %>% rtables::add_colcounts() %>% rtables::split_rows_by("AVISIT", - split_label = formatters::var_labels(adlb, fill = FALSE)[["AVISIT"]], - split_fun = split_fun, label_pos = "topleft") %>% summarize_vars(vars = "AVAL", - na.rm = FALSE, na_level = "", denom = "N_col", .stats = c("n", - "count_fraction")) + rtables::split_cols_by("ARM", split_fun = drop_split_levels) %>% + rtables::add_overall_col("All Patients") %>% rtables::add_colcounts() %>% + rtables::split_rows_by("AVISIT", split_label = formatters::var_labels(adlb, + fill = FALSE)[["AVISIT"]], split_fun = split_fun, label_pos = "topleft") %>% + summarize_vars(vars = "AVAL", na.rm = FALSE, na_level = "", + denom = "N_col", .stats = c("n", "count_fraction")) $table { @@ -167,13 +168,13 @@ $layout lyt <- rtables::basic_table(title = "Summary Table for AVAL by AVISIT") %>% - rtables::split_cols_by("ARM", split_fun = add_overall_level("All Patients", - first = FALSE)) %>% rtables::add_colcounts() %>% rtables::split_rows_by("AVISIT", - split_label = formatters::var_labels(adlb, fill = FALSE)[["AVISIT"]], - split_fun = split_fun, label_pos = "topleft") %>% summarize_vars(vars = "AVAL", - na.rm = FALSE, na_level = "", denom = "N_col", .stats = c("n", - "mean_sd", "mean_ci", "median", "median_ci", "quantiles", - "range", "count_fraction")) + rtables::split_cols_by("ARM", split_fun = drop_split_levels) %>% + rtables::add_overall_col("All Patients") %>% rtables::add_colcounts() %>% + rtables::split_rows_by("AVISIT", split_label = formatters::var_labels(adlb, + fill = FALSE)[["AVISIT"]], split_fun = split_fun, label_pos = "topleft") %>% + summarize_vars(vars = "AVAL", na.rm = FALSE, na_level = "", + denom = "N_col", .stats = c("n", "mean_sd", "mean_ci", + "median", "median_ci", "quantiles", "range", "count_fraction")) $table { From da53aefcfb13a8221f0ad3bc6271b15518dbe1b8 Mon Sep 17 00:00:00 2001 From: gogonzo Date: Fri, 12 Jan 2024 10:34:05 +0000 Subject: [PATCH 26/28] [skip actions] Bump version to 0.8.16.9025 --- DESCRIPTION | 4 ++-- NEWS.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 5b14b21ab2..73d7fd1bb1 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: teal.modules.clinical Title: Teal Modules for Standard Clinical Outputs -Version: 0.8.16.9024 -Date: 2024-01-03 +Version: 0.8.16.9025 +Date: 2024-01-12 Authors@R: c( person("Joe", "Zhu", , "joe.zhu@roche.com", role = c("aut", "cre")), person("Jana", "Stoilova", , "jana.stoilova@roche.com", role = "aut"), diff --git a/NEWS.md b/NEWS.md index 1bd6446e3b..5b37229445 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# teal.modules.clinical 0.8.16.9024 +# teal.modules.clinical 0.8.16.9025 ### Breaking Changes + Adapted all modules to use `teal_data` objects. From 157c8cf719db2c543d035f785f9d70b520356abc Mon Sep 17 00:00:00 2001 From: Emily de la Rua <59304861+edelarua@users.noreply.github.com> Date: Thu, 18 Jan 2024 11:51:28 -0500 Subject: [PATCH 27/28] Fix TMC to work with tern v0.9.3 (#922) Fixes #921 --- .github/workflows/check.yaml | 4 +- .github/workflows/docs.yaml | 2 +- DESCRIPTION | 3 +- NEWS.md | 1 - R/tm_g_forest_rsp.R | 87 ++++++--------------- R/tm_g_forest_tte.R | 96 ++++++++---------------- man/template_forest_rsp.Rd | 7 -- man/template_forest_tte.Rd | 7 -- man/tm_g_forest_rsp.Rd | 11 +-- man/tm_g_forest_tte.Rd | 14 +--- tests/testthat/_snaps/tm_g_forest_rsp.md | 16 ++-- tests/testthat/_snaps/tm_g_forest_tte.md | 16 ++-- 12 files changed, 77 insertions(+), 187 deletions(-) diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml index cc21eb858a..60df82d00d 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/check.yaml @@ -21,7 +21,7 @@ jobs: uses: insightsengineering/r.pkg.template/.github/workflows/audit.yaml@main r-cmd: name: R CMD Check 🧬 - uses: insightsengineering/r.pkg.template/.github/workflows/build-check-install.yaml@main + uses: insightsengineering/r.pkg.template/.github/workflows/build-check-install.yaml@install-tern-from-cran secrets: REPO_GITHUB_TOKEN: ${{ secrets.REPO_GITHUB_TOKEN }} with: @@ -51,7 +51,7 @@ jobs: uses: insightsengineering/r.pkg.template/.github/workflows/linter.yaml@main roxygen: name: Roxygen 🅾 - uses: insightsengineering/r.pkg.template/.github/workflows/roxygen.yaml@main + uses: insightsengineering/r.pkg.template/.github/workflows/roxygen.yaml@install-tern-from-cran secrets: REPO_GITHUB_TOKEN: ${{ secrets.REPO_GITHUB_TOKEN }} with: diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index 9b7a7e54ec..1b2e49ef7a 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -36,7 +36,7 @@ on: jobs: docs: name: Pkgdown Docs 📚 - uses: insightsengineering/r.pkg.template/.github/workflows/pkgdown.yaml@main + uses: insightsengineering/r.pkg.template/.github/workflows/pkgdown.yaml@install-tern-from-cran secrets: REPO_GITHUB_TOKEN: ${{ secrets.REPO_GITHUB_TOKEN }} with: diff --git a/DESCRIPTION b/DESCRIPTION index 73d7fd1bb1..b6f8631d95 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -28,12 +28,11 @@ Depends: R (>= 4.0), teal (>= 0.14.0.9027), teal.transform (>= 0.4.0.9011), - tern (>= 0.9.3.9002) + tern (== 0.9.3) Imports: assertthat, broom, checkmate, - cowplot (>= 0.7.0), dplyr, DT, formatters (>= 0.5.5), diff --git a/NEWS.md b/NEWS.md index 5b37229445..e7cf6af45d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -8,7 +8,6 @@ * Added parameter `sort_freq_col` to `tm_t_events` to allow the user to select column to use when sorting by decreasing frequency. * Added parameter `incl_overall_sum` to `tm_t_events` to allow the user to choose whether overall summary rows are included at the top of the table. * Updated the documentation and vignettes to demonstrate method to pass `teal_data` object to `teal::init()`. -* Updated `tm_g_forest_rsp` and `tm_g_forest_tte` to use refactored version of `g_forest`. Plots are now displayed as `ggplot` objects instead of `grob` objects. Added parameters `font_size` and `rel_width_forest` to control font size and width of plot relative to table, respectively. ### Bug fixes * Fixed bug in `tm_g_lineplot` forcing module to initialize with a table. diff --git a/R/tm_g_forest_rsp.R b/R/tm_g_forest_rsp.R index 354faf6708..4960f25c8a 100644 --- a/R/tm_g_forest_rsp.R +++ b/R/tm_g_forest_rsp.R @@ -2,7 +2,6 @@ #' #' Creates a valid expression for response forest plot. #' -#' @inheritParams tern::g_forest #' @inheritParams template_arguments #' @param obj_var_name (`character`)\cr additional text string append to output title. #' @param responders (`character`)\cr values of `aval_var` that are considered to be responders. @@ -35,8 +34,6 @@ template_forest_rsp <- function(dataname = "ANL", strata_var = NULL, conf_level = 0.95, col_symbol_size = NULL, - rel_width_forest = 0.25, - font_size = 15, ggplot2_args = teal.widgets::ggplot2_args()) { assertthat::assert_that( assertthat::is.string(dataname), @@ -46,8 +43,6 @@ template_forest_rsp <- function(dataname = "ANL", assertthat::is.string(obj_var_name), is.null(subgroup_var) || is.character(subgroup_var) ) - checkmate::assert_number(rel_width_forest, lower = 0, upper = 1) - checkmate::assert_number(font_size) y <- list() ref_arm_val <- paste(ref_arm, collapse = "/") @@ -165,55 +160,34 @@ template_forest_rsp <- function(dataname = "ANL", all_ggplot2_args <- teal.widgets::resolve_ggplot2_args( user_plot = ggplot2_args, module_plot = teal.widgets::ggplot2_args( - labs = list( - title = paste("Forest Plot of Best Overall Response for", obj_var_name), - caption = "" - ) + labs = list(title = paste0("Forest plot of best overall response for ", obj_var_name), caption = "") ) ) - plot_list <- list() + plot_call <- substitute( + expr = g_forest( + tbl = result, + col_symbol_size = col_s_size + ), + env = list(col_s_size = col_symbol_size) + ) - plot_list <- add_expr( - plot_list, - substitute( - expr = { - f <- g_forest( - tbl = result, - col_symbol_size = col_s_size, - font_size = font_size, - as_list = TRUE - ) - }, - env = list( - col_s_size = col_symbol_size, - font_size = font_size - ) - ) + plot_call <- substitute( + decorate_grob(p, titles = title, footnotes = caption, gp_footnotes = grid::gpar(fontsize = 12)), + env = list(title = all_ggplot2_args$labs$title, caption = all_ggplot2_args$labs$caption, p = plot_call) ) - plot_list <- add_expr( - plot_list, - substitute( - expr = { - p <- cowplot::plot_grid( - f[["table"]] + ggplot2::labs(title = ggplot2_args_title), - f[["plot"]] + ggplot2::labs(caption = ggplot2_args_caption), - align = "h", - axis = "tblr", - rel_widths = c(1 - rel_width_forest, rel_width_forest) - ) - }, - env = list( - rel_width_forest = rel_width_forest, - ggplot2_args_title = all_ggplot2_args$labs$title, - ggplot2_args_caption = all_ggplot2_args$labs$caption - ) - ) + plot_call <- substitute( + expr = { + p <- plot_call + grid::grid.newpage() + grid::grid.draw(p) + }, + env = list(plot_call = plot_call) ) # Plot output. - y$plot <- plot_list + y$plot <- plot_call y } @@ -222,7 +196,6 @@ template_forest_rsp <- function(dataname = "ANL", #' #' This teal module produces a grid style Forest plot for response data with `ADaM` structure. #' -#' @inheritParams tern::g_forest #' @inheritParams module_arguments #' @inheritParams tm_t_binary_outcome #' @param fixed_symbol_size (`logical`)\cr @@ -341,10 +314,8 @@ tm_g_forest_rsp <- function(label, fixed_symbol_size = TRUE, conf_level = teal.transform::choices_selected(c(0.95, 0.9, 0.8), 0.95, keep_order = TRUE), default_responses = c("CR", "PR", "Y", "Complete Response (CR)", "Partial Response (PR)"), - plot_height = c(500L, 200L, 2000L), - plot_width = c(1500L, 800L, 3000L), - rel_width_forest = c(25L, 0L, 100L), - font_size = c(15L, 1L, 30L), + plot_height = c(700L, 200L, 2000L), + plot_width = c(1200L, 800L, 3000L), pre_output = NULL, post_output = NULL, ggplot2_args = teal.widgets::ggplot2_args()) { @@ -471,19 +442,7 @@ ui_g_forest_rsp <- function(id, ...) { multiple = FALSE, fixed = a$conf_level$fixed ), - shiny::checkboxInput(ns("fixed_symbol_size"), "Fixed symbol size", value = TRUE), - teal.widgets::optionalSliderInputValMinMax( - ns("rel_width_forest"), - "Relative Width of Forest Plot (%)", - a$rel_width_forest, - ticks = FALSE, step = 1 - ), - teal.widgets::optionalSliderInputValMinMax( - ns("font_size"), - "Table Font Size", - a$font_size, - ticks = FALSE, step = 1 - ) + shiny::checkboxInput(ns("fixed_symbol_size"), "Fixed symbol size", value = TRUE) ) ) ), @@ -733,8 +692,6 @@ srv_g_forest_rsp <- function(id, strata_var = if (length(strata_var) != 0) strata_var else NULL, conf_level = as.numeric(input$conf_level), col_symbol_size = `if`(input$fixed_symbol_size, NULL, 1), - rel_width_forest = input$rel_width_forest / 100, - font_size = input$font_size, ggplot2_args = ggplot2_args ) diff --git a/R/tm_g_forest_tte.R b/R/tm_g_forest_tte.R index 311240ef41..a50c6e015a 100644 --- a/R/tm_g_forest_tte.R +++ b/R/tm_g_forest_tte.R @@ -29,8 +29,6 @@ template_forest_tte <- function(dataname = "ANL", conf_level = 0.95, col_symbol_size = NULL, time_unit_var = "AVALU", - rel_width_forest = 0.25, - font_size = 15, ggplot2_args = teal.widgets::ggplot2_args()) { assertthat::assert_that( assertthat::is.string(dataname), @@ -38,8 +36,6 @@ template_forest_tte <- function(dataname = "ANL", assertthat::is.string(obj_var_name), is.character(subgroup_var) || is.null(subgroup_var) ) - checkmate::assert_number(rel_width_forest, lower = 0, upper = 1) - checkmate::assert_number(font_size) y <- list() ref_arm_val <- paste(ref_arm, collapse = "/") @@ -166,59 +162,45 @@ template_forest_tte <- function(dataname = "ANL", user_plot = ggplot2_args, module_plot = teal.widgets::ggplot2_args( labs = list( - title = paste( - paste("Forest Plot of Survival Duration for", obj_var_name), - ifelse(is.null(strata_var), "", paste("Stratified by", paste(strata_var, collapse = " and "))), - sep = "\n" - ), + title = paste("Forest Plot of Survival Duration for", obj_var_name), + subtitle = ifelse(is.null(strata_var), "", paste("Stratified by", paste(strata_var, collapse = " and "))), caption = "" ) ) ) - plot_list <- list() + plot_call <- substitute( + expr = g_forest( + tbl = result, + col_symbol_size = col_s_size + ), + env = list(col_s_size = col_symbol_size) + ) - plot_list <- add_expr( - plot_list, - substitute( - expr = { - f <- g_forest( - tbl = result, - col_symbol_size = col_s_size, - font_size = font_size, - as_list = TRUE - ) - }, - env = list( - col_s_size = col_symbol_size, - font_size = font_size - ) + plot_call <- substitute( + decorate_grob(p, titles = title, footnotes = caption, gp_footnotes = grid::gpar(fontsize = 12)), + env = list( + title = `if`( + all_ggplot2_args$labs$subtitle == "", + all_ggplot2_args$labs$title, + c(all_ggplot2_args$labs$title, all_ggplot2_args$labs$subtitle) + ), + caption = all_ggplot2_args$labs$caption, + p = plot_call ) ) - plot_list <- add_expr( - plot_list, - substitute( - expr = { - p <- cowplot::plot_grid( - f[["table"]] + ggplot2::labs(title = ggplot2_args_title, subtitle = ggplot2_args_subtitle), - f[["plot"]] + ggplot2::labs(caption = ggplot2_args_caption), - align = "h", - axis = "tblr", - rel_widths = c(1 - rel_width_forest, rel_width_forest) - ) - }, - env = list( - rel_width_forest = rel_width_forest, - ggplot2_args_title = all_ggplot2_args$labs$title, - ggplot2_args_subtitle = all_ggplot2_args$labs$subtitle, - ggplot2_args_caption = all_ggplot2_args$labs$caption - ) - ) + plot_call <- substitute( + env = list(plot_call = plot_call), + expr = { + p <- plot_call + grid::grid.newpage() + grid::grid.draw(p) + } ) # Plot output. - y$plot <- plot_list + y$plot <- plot_call y } @@ -228,7 +210,6 @@ template_forest_tte <- function(dataname = "ANL", #' This teal module produces a grid style Forest plot for time-to-event data #' with `ADaM` structure #' -#' @inheritParams tern::g_forest #' @inheritParams module_arguments #' @inheritParams tm_g_forest_rsp #' @param ggplot2_args optional, (`ggplot2_args`)\cr @@ -290,7 +271,8 @@ template_forest_tte <- function(dataname = "ANL", #' strata_var = choices_selected( #' variable_choices(ADSL, c("STRATA1", "STRATA2")), #' "STRATA2" -#' ) +#' ), +#' plot_height = c(600, 200, 2000) #' ) #' ) #' ) @@ -324,10 +306,8 @@ tm_g_forest_tte <- function(label, fixed = TRUE ), fixed_symbol_size = TRUE, - plot_height = c(500L, 200L, 2000L), - plot_width = c(1500L, 800L, 3000L), - rel_width_forest = c(25L, 0L, 100L), - font_size = c(15L, 1L, 30L), + plot_height = c(700L, 200L, 2000L), + plot_width = c(1200L, 800L, 3000L), pre_output = NULL, post_output = NULL, ggplot2_args = teal.widgets::ggplot2_args()) { @@ -463,18 +443,6 @@ ui_g_forest_tte <- function(id, ...) { label = "Time Unit Variable", data_extract_spec = a$time_unit_var, is_single_dataset = is_single_dataset_value - ), - teal.widgets::optionalSliderInputValMinMax( - ns("rel_width_forest"), - "Relative Width of Forest Plot (%)", - a$rel_width_forest, - ticks = FALSE, step = 1 - ), - teal.widgets::optionalSliderInputValMinMax( - ns("font_size"), - "Table Font Size", - a$font_size, - ticks = FALSE, step = 1 ) ) ) @@ -656,8 +624,6 @@ srv_g_forest_tte <- function(id, conf_level = as.numeric(input$conf_level), col_symbol_size = if (!input$fixed_symbol_size) 1, time_unit_var = as.vector(anl_m$columns_source$time_unit_var), - rel_width_forest = input$rel_width_forest / 100, - font_size = input$font_size, ggplot2_args = ggplot2_args ) teal.code::eval_code(anl_q(), as.expression(my_calls)) diff --git a/man/template_forest_rsp.Rd b/man/template_forest_rsp.Rd index 55b3bb6207..db9ec80358 100644 --- a/man/template_forest_rsp.Rd +++ b/man/template_forest_rsp.Rd @@ -17,8 +17,6 @@ template_forest_rsp( strata_var = NULL, conf_level = 0.95, col_symbol_size = NULL, - rel_width_forest = 0.25, - font_size = 15, ggplot2_args = teal.widgets::ggplot2_args() ) } @@ -57,11 +55,6 @@ value for the confidence level within the range of (0, 1).} estimator plot symbol. Typically, the symbol size is proportional to the sample size used to calculate the estimator. If \code{NULL}, the same symbol size is used for all subgroups.} -\item{rel_width_forest}{(\code{proportion})\cr proportion of total width to allocate to the forest plot. Relative -width of table is then \code{1 - rel_width_forest}. If \code{as_list = TRUE}, this parameter is ignored.} - -\item{font_size}{(\code{numeric})\cr font size.} - \item{ggplot2_args}{optional, (\code{ggplot2_args})\cr object created by \code{\link[teal.widgets:ggplot2_args]{teal.widgets::ggplot2_args()}} with settings for the module plot. For this module, this argument will only accept \code{ggplot2_args} object with \code{labs} list of following child elements: diff --git a/man/template_forest_tte.Rd b/man/template_forest_tte.Rd index fa1483434e..49ec9db8f9 100644 --- a/man/template_forest_tte.Rd +++ b/man/template_forest_tte.Rd @@ -18,8 +18,6 @@ template_forest_tte( conf_level = 0.95, col_symbol_size = NULL, time_unit_var = "AVALU", - rel_width_forest = 0.25, - font_size = 15, ggplot2_args = teal.widgets::ggplot2_args() ) } @@ -62,11 +60,6 @@ to calculate the estimator. If \code{NULL}, the same symbol size is used for all \item{time_unit_var}{(\code{character})\cr name of the variable representing time units.} -\item{rel_width_forest}{(\code{proportion})\cr proportion of total width to allocate to the forest plot. Relative -width of table is then \code{1 - rel_width_forest}. If \code{as_list = TRUE}, this parameter is ignored.} - -\item{font_size}{(\code{numeric})\cr font size.} - \item{ggplot2_args}{optional, (\code{ggplot2_args})\cr object created by \code{\link[teal.widgets:ggplot2_args]{teal.widgets::ggplot2_args()}} with settings for the module plot. For this module, this argument will only accept \code{ggplot2_args} object with \code{labs} list of following child elements: diff --git a/man/tm_g_forest_rsp.Rd b/man/tm_g_forest_rsp.Rd index 647156d746..805fa239c7 100644 --- a/man/tm_g_forest_rsp.Rd +++ b/man/tm_g_forest_rsp.Rd @@ -21,10 +21,8 @@ tm_g_forest_rsp( TRUE), default_responses = c("CR", "PR", "Y", "Complete Response (CR)", "Partial Response (PR)"), - plot_height = c(500L, 200L, 2000L), - plot_width = c(1500L, 800L, 3000L), - rel_width_forest = c(25L, 0L, 100L), - font_size = c(15L, 1L, 30L), + plot_height = c(700L, 200L, 2000L), + plot_width = c(1200L, 800L, 3000L), pre_output = NULL, post_output = NULL, ggplot2_args = teal.widgets::ggplot2_args() @@ -93,11 +91,6 @@ a vector of length three with \code{c(value, min, max)}. Specifies the width of the main plot and renders a slider on the plot to interactively adjust the plot width.} -\item{rel_width_forest}{(\code{proportion})\cr proportion of total width to allocate to the forest plot. Relative -width of table is then \code{1 - rel_width_forest}. If \code{as_list = TRUE}, this parameter is ignored.} - -\item{font_size}{(\code{numeric})\cr font size.} - \item{pre_output}{optional, (\code{shiny.tag})\cr with text placed before the output to put the output into context. For example a title.} diff --git a/man/tm_g_forest_tte.Rd b/man/tm_g_forest_tte.Rd index 25dfd59f01..8d6b408dba 100644 --- a/man/tm_g_forest_tte.Rd +++ b/man/tm_g_forest_tte.Rd @@ -24,10 +24,8 @@ tm_g_forest_tte( teal.transform::choices_selected(teal.transform::variable_choices(dataname, "AVALU"), "AVALU", fixed = TRUE), fixed_symbol_size = TRUE, - plot_height = c(500L, 200L, 2000L), - plot_width = c(1500L, 800L, 3000L), - rel_width_forest = c(25L, 0L, 100L), - font_size = c(15L, 1L, 30L), + plot_height = c(700L, 200L, 2000L), + plot_width = c(1200L, 800L, 3000L), pre_output = NULL, post_output = NULL, ggplot2_args = teal.widgets::ggplot2_args() @@ -97,11 +95,6 @@ a vector of length three with \code{c(value, min, max)}. Specifies the width of the main plot and renders a slider on the plot to interactively adjust the plot width.} -\item{rel_width_forest}{(\code{proportion})\cr proportion of total width to allocate to the forest plot. Relative -width of table is then \code{1 - rel_width_forest}. If \code{as_list = TRUE}, this parameter is ignored.} - -\item{font_size}{(\code{numeric})\cr font size.} - \item{pre_output}{optional, (\code{shiny.tag})\cr with text placed before the output to put the output into context. For example a title.} @@ -171,7 +164,8 @@ app <- init( strata_var = choices_selected( variable_choices(ADSL, c("STRATA1", "STRATA2")), "STRATA2" - ) + ), + plot_height = c(600, 200, 2000) ) ) ) diff --git a/tests/testthat/_snaps/tm_g_forest_rsp.md b/tests/testthat/_snaps/tm_g_forest_rsp.md index d11b6d169e..ed77908703 100644 --- a/tests/testthat/_snaps/tm_g_forest_rsp.md +++ b/tests/testthat/_snaps/tm_g_forest_rsp.md @@ -30,14 +30,12 @@ vars = c("n_tot", "n", "n_rsp", "prop", "or", "ci")) $plot - $plot[[1]] - f <- g_forest(tbl = result, col_symbol_size = NULL, font_size = 15, - as_list = TRUE) - - $plot[[2]] - p <- cowplot::plot_grid(f[["table"]] + ggplot2::labs(title = "Forest Plot of Best Overall Response for "), - f[["plot"]] + ggplot2::labs(caption = ""), align = "h", axis = "tblr", - rel_widths = c(1 - 0.25, 0.25)) - + { + p <- decorate_grob(g_forest(tbl = result, col_symbol_size = NULL), + titles = "Forest plot of best overall response for ", + footnotes = "", gp_footnotes = grid::gpar(fontsize = 12)) + grid::grid.newpage() + grid::grid.draw(p) + } diff --git a/tests/testthat/_snaps/tm_g_forest_tte.md b/tests/testthat/_snaps/tm_g_forest_tte.md index 8a3e7130a8..f2d83461b2 100644 --- a/tests/testthat/_snaps/tm_g_forest_tte.md +++ b/tests/testthat/_snaps/tm_g_forest_tte.md @@ -33,14 +33,12 @@ } $plot - $plot[[1]] - f <- g_forest(tbl = result, col_symbol_size = NULL, font_size = 15, - as_list = TRUE) - - $plot[[2]] - p <- cowplot::plot_grid(f[["table"]] + ggplot2::labs(title = "Forest Plot of Survival Duration for \nStratified by STRATA2", - subtitle = NULL), f[["plot"]] + ggplot2::labs(caption = ""), - align = "h", axis = "tblr", rel_widths = c(1 - 0.25, 0.25)) - + { + p <- decorate_grob(g_forest(tbl = result, col_symbol_size = NULL), + titles = c("Forest Plot of Survival Duration for ", "Stratified by STRATA2" + ), footnotes = "", gp_footnotes = grid::gpar(fontsize = 12)) + grid::grid.newpage() + grid::grid.draw(p) + } From d34900d054a1c976ccbce91ebb8423b10a6c693d Mon Sep 17 00:00:00 2001 From: edelarua Date: Thu, 18 Jan 2024 16:52:32 +0000 Subject: [PATCH 28/28] [skip actions] Bump version to 0.8.16.9026 --- DESCRIPTION | 4 ++-- NEWS.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index b6f8631d95..f1288470d5 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: teal.modules.clinical Title: Teal Modules for Standard Clinical Outputs -Version: 0.8.16.9025 -Date: 2024-01-12 +Version: 0.8.16.9026 +Date: 2024-01-18 Authors@R: c( person("Joe", "Zhu", , "joe.zhu@roche.com", role = c("aut", "cre")), person("Jana", "Stoilova", , "jana.stoilova@roche.com", role = "aut"), diff --git a/NEWS.md b/NEWS.md index e7cf6af45d..305edabd89 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# teal.modules.clinical 0.8.16.9025 +# teal.modules.clinical 0.8.16.9026 ### Breaking Changes + Adapted all modules to use `teal_data` objects.