Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
44ab94d
set Remotes and vbump packages
m7pr Jul 11, 2025
dbc0f5d
initial attempt
m7pr Jul 11, 2025
3493b5d
substitute card_fun with teal_card
m7pr Jul 11, 2025
6e82948
[skip style] [skip vbump] Restyle files
github-actions[bot] Jul 11, 2025
c001116
add selected_options
m7pr Jul 11, 2025
97751af
Merge branch 'teal_reportable' of https://github.com/insightsengineer…
m7pr Jul 11, 2025
198218a
[skip style] [skip vbump] Restyle files
github-actions[bot] Jul 11, 2025
4639631
Merge branch 'main' into teal_reportable
m7pr Aug 27, 2025
683ec62
Update DESCRIPTION
m7pr Aug 27, 2025
eb550c1
missing )
m7pr Aug 28, 2025
1c35d66
[skip style] [skip vbump] Restyle files
github-actions[bot] Aug 28, 2025
00d99cc
remove extra plot calls
m7pr Aug 28, 2025
d8d0712
[skip style] [skip vbump] Restyle files
github-actions[bot] Aug 28, 2025
2887192
Empty-Commit
m7pr Aug 28, 2025
fc3de33
vbump teal and teal.reporter
m7pr Sep 4, 2025
e3e221e
revert back expression(library to 'library'
m7pr Sep 5, 2025
b3201c1
add support for plots size
m7pr Sep 9, 2025
701a7e6
[skip style] [skip vbump] Restyle files
github-actions[bot] Sep 9, 2025
0b086be
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
github-actions[bot] Sep 9, 2025
3aa11ec
indirect pws setup throug srv_g_decorate
m7pr Sep 9, 2025
c88d97a
Merge branch 'teal_reportable' of https://github.com/insightsengineer…
m7pr Sep 9, 2025
28de182
Update R/tm_g_spiderplot.R
m7pr Sep 11, 2025
a1a28b8
Update R/utils.R
m7pr Sep 11, 2025
f67875c
[skip style] [skip vbump] Restyle files
github-actions[bot] Sep 11, 2025
88116b9
add plot settings for heat_bygrade
m7pr Sep 11, 2025
97c0d2b
Merge branch 'teal_reportable' of https://github.com/insightsengineer…
m7pr Sep 11, 2025
8180fd8
Apply suggestions from code review
m7pr Sep 12, 2025
9d20593
replace the way we call dplyr in modules
m7pr Sep 15, 2025
4b8603c
remove filter_var from waterfall
m7pr Sep 15, 2025
0a8de78
typo
m7pr Sep 15, 2025
7267f78
last changes for waterfall plot
m7pr Sep 15, 2025
dd96ec0
lintr
m7pr Sep 16, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ Suggests:
testthat (>= 3.2.3),
withr (>= 3.0.0)
Remotes:
insightsengineering/osprey
insightsengineering/osprey,
insightsengineering/teal@teal_reportable,
insightsengineering/teal.reporter@teal_reportable,
Config/Needs/verdepcheck: insightsengineering/osprey, rstudio/shiny,
insightsengineering/teal, insightsengineering/teal.slice,
insightsengineering/teal.transform, mllg/checkmate, tidyverse/dplyr,
Expand Down
45 changes: 15 additions & 30 deletions R/tm_g_ae_oview.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#' sub-groups (e.g. Serious events, Related events, etc.)
#'
#' @inherit argument_convention return
#' @inheritSection teal::example_module Reporting
#'
#' @export
#'
Expand Down Expand Up @@ -129,10 +130,6 @@ ui_g_ae_oview <- function(id, ...) {
plot_decorate_output(id = ns(NULL))
),
encoding = tags$div(
### Reporter
teal.reporter::add_card_button_ui(ns("add_reporter"), label = "Add Report Card"),
tags$br(), tags$br(),
###
teal.widgets::optionalSelectInput(
ns("arm_var"),
"Arm Variable",
Expand Down Expand Up @@ -198,14 +195,10 @@ ui_g_ae_oview <- function(id, ...) {

srv_g_ae_oview <- function(id,
data,
filter_panel_api,
reporter,
dataname,
label,
plot_height,
plot_width) {
with_reporter <- !missing(reporter) && inherits(reporter, "Reporter")
with_filter <- !missing(filter_panel_api) && inherits(filter_panel_api, "FilterPanelAPI")
checkmate::assert_class(data, "reactive")
checkmate::assert_class(isolate(data()), "teal_data")

Expand Down Expand Up @@ -286,7 +279,16 @@ srv_g_ae_oview <- function(id,
output_q <- shiny::debounce(
millis = 200,
r = reactive({
ANL <- data()[[dataname]]
obj <- data()
teal.reporter::teal_card(obj) <-
c(
teal.reporter::teal_card("# AE Overview"),
teal.reporter::teal_card(obj),
teal.reporter::teal_card("## Module's code")
)
obj <- teal.code::eval_code(obj, expression(library("dplyr")))

ANL <- obj[[dataname]]

teal::validate_has_data(ANL, min_nrow = 10, msg = sprintf("%s has not enough data", dataname))

Expand All @@ -297,7 +299,7 @@ srv_g_ae_oview <- function(id,
"Treatment or Control not found in Arm Variable. Perhaps they have been filtered out?"
))

q1 <- teal.code::eval_code(data(), "library(dplyr)") %>%
q1 <- obj %>%
teal.code::eval_code(
code = as.expression(c(
bquote(anl_labels <- formatters::var_labels(.(as.name(dataname)), fill = FALSE)),
Expand All @@ -309,6 +311,8 @@ srv_g_ae_oview <- function(id,
))
)

teal.reporter::teal_card(q1) <- c(teal.reporter::teal_card(q1), "## Plot")

teal.code::eval_code(
q1,
code = as.expression(c(
Expand Down Expand Up @@ -339,25 +343,6 @@ srv_g_ae_oview <- function(id,
verbatim_content = reactive(teal.code::get_code(output_q())),
title = paste("R code for", label)
)
### REPORTER
if (with_reporter) {
card_fun <- function(comment, label) {
card <- teal::report_card_template(
title = "AE Overview",
label = label,
with_filter = with_filter,
filter_panel_api = filter_panel_api
)
card$append_text("Plot", "header3")
card$append_plot(plot_r(), dim = pws$dim())
if (!comment == "") {
card$append_text("Comment", "header3")
card$append_text(comment)
}
card$append_src(teal.code::get_code(output_q()))
card
}
teal.reporter::add_card_button_srv("add_reporter", reporter = reporter, card_fun = card_fun)
}
output_q
})
}
92 changes: 39 additions & 53 deletions R/tm_g_ae_sub.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#' @author Molly He (hey59) \email{[email protected]}
#'
#' @inherit argument_convention return
#' @inheritSection teal::example_module Reporting
#'
#' @export
#'
Expand Down Expand Up @@ -104,10 +105,6 @@ ui_g_ae_sub <- function(id, ...) {
plot_decorate_output(id = ns(NULL))
),
encoding = tags$div(
### Reporter
teal.reporter::add_card_button_ui(ns("add_reporter"), label = "Add Report Card"),
tags$br(), tags$br(),
###
tags$label("Encodings", class = "text-primary"),
helpText("Analysis data:", tags$code("ADAE")),
teal.widgets::optionalSelectInput(
Expand Down Expand Up @@ -175,14 +172,10 @@ ui_g_ae_sub <- function(id, ...) {

srv_g_ae_sub <- function(id,
data,
filter_panel_api,
reporter,
dataname,
label,
plot_height,
plot_width) {
with_reporter <- !missing(reporter) && inherits(reporter, "Reporter")
with_filter <- !missing(filter_panel_api) && inherits(filter_panel_api, "FilterPanelAPI")
checkmate::assert_class(data, "reactive")
checkmate::assert_class(shiny::isolate(data()), "teal_data")

Expand Down Expand Up @@ -317,8 +310,16 @@ srv_g_ae_sub <- function(id,
output_q <- shiny::debounce(
millis = 200,
r = reactive({
ANL <- data()[[dataname]]
ADSL <- data()[["ADSL"]]
obj <- data()
teal.reporter::teal_card(obj) <-
c(
teal.reporter::teal_card("# AE by Subgroups"),
teal.reporter::teal_card(obj),
teal.reporter::teal_card("## Module's code")
)

ANL <- obj[[dataname]]
ADSL <- obj[["ADSL"]]

teal::validate_has_data(ANL, min_nrow = 10, msg = sprintf("%s has not enough data", dataname))

Expand Down Expand Up @@ -347,29 +348,34 @@ srv_g_ae_sub <- function(id,
bquote(group_labels <- setNames(.(group_labels), .(input$groups)))
}

teal.code::eval_code(data(), code = group_labels_call) %>%
teal.code::eval_code(code = "") %>%
teal.code::eval_code(
code = as.expression(c(
bquote(
plot <- osprey::g_ae_sub(
id = .(as.name(dataname))$USUBJID,
arm = as.factor(.(as.name(dataname))[[.(input$arm_var)]]),
arm_sl = as.character(ADSL[[.(input$arm_var)]]),
trt = .(input$arm_trt),
ref = .(input$arm_ref),
subgroups = .(as.name(dataname))[.(input$groups)],
subgroups_sl = ADSL[.(input$groups)],
subgroups_levels = group_labels,
conf_level = .(input$conf_level),
diff_ci_method = .(input$ci),
fontsize = .(font_size()),
arm_n = .(input$arm_n),
draw = TRUE
)
q1 <- teal.code::eval_code(obj, code = group_labels_call) %>%
teal.code::eval_code(code = "")

teal.reporter::teal_card(q1) <- c(teal.reporter::teal_card(q1), "## Plot")

teal.code::eval_code(
q1,
code = as.expression(c(
bquote(
plot <- osprey::g_ae_sub(
id = .(as.name(dataname))$USUBJID,
arm = as.factor(.(as.name(dataname))[[.(input$arm_var)]]),
arm_sl = as.character(ADSL[[.(input$arm_var)]]),
trt = .(input$arm_trt),
ref = .(input$arm_ref),
subgroups = .(as.name(dataname))[.(input$groups)],
subgroups_sl = ADSL[.(input$groups)],
subgroups_levels = group_labels,
conf_level = .(input$conf_level),
diff_ci_method = .(input$ci),
fontsize = .(font_size()),
arm_n = .(input$arm_n),
draw = TRUE
)
))
)
),
quote(plot)
))
)
})
)

Expand All @@ -380,26 +386,6 @@ srv_g_ae_sub <- function(id,
verbatim_content = reactive(teal.code::get_code(output_q())),
title = paste("R code for", label),
)

### REPORTER
if (with_reporter) {
card_fun <- function(comment, label) {
card <- teal::report_card_template(
title = "AE Subgroups",
label = label,
with_filter = with_filter,
filter_panel_api = filter_panel_api
)
card$append_text("Plot", "header3")
card$append_plot(plot_r(), dim = pws$dim())
if (!comment == "") {
card$append_text("Comment", "header3")
card$append_text(comment)
}
card$append_src(teal.code::get_code(output_q()))
card
}
teal.reporter::add_card_button_srv("add_reporter", reporter = reporter, card_fun = card_fun)
}
output_q
})
}
85 changes: 36 additions & 49 deletions R/tm_g_butterfly.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#' used directly as filter.
#'
#' @inherit argument_convention return
#' @inheritSection teal::example_module Reporting
#'
#' @export
#'
Expand Down Expand Up @@ -166,10 +167,6 @@ ui_g_butterfly <- function(id, ...) {
teal.widgets::plot_with_settings_ui(id = ns("butterflyplot"))
),
encoding = tags$div(
### Reporter
teal.reporter::add_card_button_ui(ns("add_reporter"), label = "Add Report Card"),
tags$br(), tags$br(),
###
tags$label("Encodings", class = "text-primary"),
helpText("Dataset is:", tags$code(a$dataname)),
if (!is.null(a$filter_var)) {
Expand Down Expand Up @@ -264,9 +261,7 @@ ui_g_butterfly <- function(id, ...) {
)
}

srv_g_butterfly <- function(id, data, filter_panel_api, reporter, dataname, label, plot_height, plot_width) {
with_reporter <- !missing(reporter) && inherits(reporter, "Reporter")
with_filter <- !missing(filter_panel_api) && inherits(filter_panel_api, "FilterPanelAPI")
srv_g_butterfly <- function(id, data, dataname, label, plot_height, plot_width) {
checkmate::assert_class(data, "reactive")
checkmate::assert_class(shiny::isolate(data()), "teal_data")

Expand Down Expand Up @@ -386,8 +381,17 @@ srv_g_butterfly <- function(id, data, filter_panel_api, reporter, dataname, labe
output_q <- shiny::debounce(
millis = 200,
r = reactive({
ADSL <- data()[["ADSL"]]
ANL <- data()[[dataname]]
obj <- data()
teal.reporter::teal_card(obj) <-
c(
teal.reporter::teal_card("# Butterfly Plot"),
teal.reporter::teal_card(obj),
teal.reporter::teal_card("## Module's code")
)
obj <- teal.code::eval_code(obj, expression(library("dplyr")))

ADSL <- obj[["ADSL"]]
ANL <- obj[[dataname]]

teal::validate_has_data(ADSL, min_nrow = 0, msg = sprintf("%s Data is empty", "ADSL"))
teal::validate_has_data(ANL, min_nrow = 0, msg = sprintf("%s Data is empty", dataname))
Expand Down Expand Up @@ -422,13 +426,13 @@ srv_g_butterfly <- function(id, data, filter_panel_api, reporter, dataname, labe
adsl_vars <- unique(c("USUBJID", "STUDYID", varlist_from_adsl))
anl_vars <- unique(c("USUBJID", "STUDYID", varlist_from_anl))

q1 <- teal.code::eval_code(data(), "library(dplyr)") %>%
teal.code::eval_code(
code = bquote({
ADSL <- ADSL[, .(adsl_vars)] %>% as.data.frame()
ANL <- .(as.name(dataname))[, .(anl_vars)] %>% as.data.frame()
})
)
q1 <- teal.code::eval_code(
obj,
code = bquote({
ADSL <- ADSL[, .(adsl_vars)] %>% as.data.frame()
ANL <- .(as.name(dataname))[, .(anl_vars)] %>% as.data.frame()
})
)

if (!("NULL" %in% filter_var) && !is.null(filter_var)) {
q1 <- teal.code::eval_code(
Expand Down Expand Up @@ -461,6 +465,21 @@ srv_g_butterfly <- function(id, data, filter_panel_api, reporter, dataname, labe
)
}

teal.reporter::teal_card(q1) <- c(teal.reporter::teal_card(q1), "## Plot")

if (!is.null(input$filter_var) || !is.null(input$facet_var) || !is.null(input$sort_by_var)) {
teal.reporter::teal_card(q1) <- c(teal.reporter::teal_card(q1), "### Selected Options")
}
if (!is.null(input$filter_var)) {
teal.reporter::teal_card(q1) <- c(teal.reporter::teal_card(q1), paste0("Preset Data Filters: ", paste(input$filter_var, collapse = ", "), "."))
}
if (!is.null(input$facet_var)) {
teal.reporter::teal_card(q1) <- c(teal.reporter::teal_card(q1), paste0("Faceted by: ", paste(input$facet_var, collapse = ", "), "."))
}
if (!is.null(input$sort_by_var)) {
teal.reporter::teal_card(q1) <- c(teal.reporter::teal_card(q1), paste0("Sorted by: ", paste(input$sort_by_var, collapse = ", "), "."))
}

if (!is.null(right_val) && !is.null(left_val)) {
q1 <- teal.code::eval_code(
q1,
Expand Down Expand Up @@ -511,38 +530,6 @@ srv_g_butterfly <- function(id, data, filter_panel_api, reporter, dataname, labe
title = paste("R code for", label),
verbatim_content = reactive(teal.code::get_code(output_q()))
)

### REPORTER
if (with_reporter) {
card_fun <- function(comment, label) {
card <- teal::report_card_template(
title = "Butterfly Plot",
label = label,
with_filter = with_filter,
filter_panel_api = filter_panel_api
)
if (!is.null(input$filter_var) || !is.null(input$facet_var) || !is.null(input$sort_by_var)) {
card$append_text("Selected Options", "header3")
}
if (!is.null(input$filter_var)) {
card$append_text(paste0("Preset Data Filters: ", paste(input$filter_var, collapse = ", "), "."))
}
if (!is.null(input$facet_var)) {
card$append_text(paste0("Faceted by: ", paste(input$facet_var, collapse = ", "), "."))
}
if (!is.null(input$sort_by_var)) {
card$append_text(paste0("Sorted by: ", paste(input$sort_by_var, collapse = ", "), "."))
}
card$append_text("Plot", "header3")
card$append_plot(plot_r(), dim = pws$dim())
if (!comment == "") {
card$append_text("Comment", "header3")
card$append_text(comment)
}
card$append_src(teal.code::get_code(output_q()))
card
}
teal.reporter::add_card_button_srv("add_reporter", reporter = reporter, card_fun = card_fun)
}
output_q
})
}
Loading
Loading