Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🗃️ Decorators feature branch #1252

Merged
merged 94 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
7c29d47
feat: add decorator wrapper
averissimo Nov 25, 2024
45da7ca
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] Nov 25, 2024
537b2c1
Merge branch 'main' into 1187_decorate_output@main
m7pr Nov 26, 2024
84a00fd
add decorators @param to standard template arguments
m7pr Nov 26, 2024
58e65bf
move decorators parameter to module templeate parameters
m7pr Nov 26, 2024
b684fa5
bring check_decorators from tmg
m7pr Nov 26, 2024
0805fa4
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] Nov 26, 2024
29f22c7
rename decorators to transformators in ui_decorate_teal_data
m7pr Nov 26, 2024
3df00dc
Merge branch '1187_decorate_output@main' of https://github.com/insigh…
m7pr Nov 26, 2024
dc682cd
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] Nov 26, 2024
93c6af5
introduce decorators for `tm_g_pp_vitals`
m7pr Nov 27, 2024
1899063
revert changes for vitals
m7pr Nov 27, 2024
64b9d1d
fix: update wrapper to use 'inner' in srv_decorate_teal_data
averissimo Nov 27, 2024
af2a623
Merge branch 'main' into 1187_decorate_output@main
m7pr Nov 27, 2024
b033451
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] Nov 27, 2024
064bcb2
add normalize_decorators
m7pr Nov 27, 2024
a677777
fix normalize_decorators
m7pr Nov 27, 2024
1e9a78c
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] Nov 27, 2024
55cd3d3
update utils from tmg
m7pr Nov 28, 2024
b565310
introduce decorators for `tm_g_ci` (#1265)
llrs-roche Nov 28, 2024
2276fca
Introduce decorators to `tm_g_forest_rsp` (#1266)
llrs-roche Nov 28, 2024
fd17aed
introduce decorators for `tm_g_forest_tte` (#1264)
m7pr Nov 28, 2024
4e747f9
introduce decorators for `tm_a_gee` (#1262)
m7pr Nov 28, 2024
fcc3682
introduce decorators for `tm_g_ipp` (#1263)
m7pr Nov 28, 2024
31fdab6
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] Nov 28, 2024
98520eb
introduce decorators to `tm_g_pp_patient_timeline` (#1270)
llrs-roche Nov 29, 2024
5cf2166
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] Nov 29, 2024
f462d60
introduce decorators for `tm_g_pp_therapy` (#1268)
m7pr Nov 29, 2024
d6416e1
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] Nov 29, 2024
25d9220
chore: necessary for pre-commit
averissimo Nov 29, 2024
956bc9e
chore: remove print plot expression
averissimo Nov 29, 2024
e7132b5
Revert "chore: remove print plot expression"
averissimo Nov 29, 2024
444cd0b
feat: add template for decorators parameter
averissimo Nov 29, 2024
bb3ae23
chore: use decorators template instead of shared parameter
averissimo Nov 29, 2024
e1976b6
chore: change order of null.ok
averissimo Nov 29, 2024
3ae43d2
introduce decorators for `tm_g_pp_vitals` (#1261)
m7pr Nov 29, 2024
d7b036e
introduce decorators for `tm_t_abnormality` (#1257)
m7pr Nov 29, 2024
af7ecff
Introduce decorators for `tm_g_km` (#1254)
m7pr Nov 29, 2024
078fc51
Introduce decorators for `tm_g_lineplot` (#1255)
m7pr Nov 29, 2024
dab7f4e
introduce decorators for `tm_t_ancova` (#1256)
m7pr Nov 29, 2024
e3bc080
introduce decorators for `tm_t_abnormality_by_worst_grade` (#1260)
m7pr Nov 29, 2024
69659e7
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] Nov 29, 2024
1572839
Merged origin/main into 1187_decorate_output@main
llrs-roche Dec 2, 2024
132c4e6
fix: remove teal-only function
averissimo Dec 3, 2024
070e129
Include decorators for `tm_t_events_summary` (#1278)
llrs-roche Dec 4, 2024
6ddb425
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] Dec 4, 2024
37e42a2
Introduce decorators for `tm_t_coxreg` (#1274)
llrs-roche Dec 4, 2024
28ba4c4
Introduce decorator for `tm_t_events_patyear` (#1277)
llrs-roche Dec 4, 2024
5b87fdc
Introduce decorator for `tm_t_events` (#1275)
llrs-roche Dec 4, 2024
78c451d
Introduce decorators for `tm_t_binary_outcome` (#1273)
llrs-roche Dec 4, 2024
5fdc43e
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] Dec 4, 2024
1ac634c
introduce decorators for `tm_g_barchart_simple` (#1267)
m7pr Dec 4, 2024
a9eb913
chore: fix R CMD check with missing arguments and using rlang that is…
averissimo Dec 4, 2024
a78c0ba
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] Dec 4, 2024
06ab990
Add decorators to `tm t mult events` (#1281)
averissimo Dec 5, 2024
b8c3c71
Introduce decorators for `tm_t_tte` (#1280)
averissimo Dec 5, 2024
cbb58b7
docs: documentation simplification
averissimo Dec 5, 2024
e3be031
Merge branch 'main' into 1187_decorate_output@main
averissimo Dec 5, 2024
5822470
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] Dec 5, 2024
2a447e4
docs: minor typo gg -> ggplot2
averissimo Dec 5, 2024
4829c00
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] Dec 5, 2024
a6e730c
introduce decorators for `tm_g_pp_adverse_events` (#1269)
m7pr Dec 9, 2024
a55de1f
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] Dec 9, 2024
bd975e5
Adds decorators to `tm_t_pp_medical_history` (#1289)
averissimo Dec 9, 2024
4d6de2d
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] Dec 9, 2024
59960ba
Adds decorators to `tm_t_logistic` (#1290)
averissimo Dec 10, 2024
3e98e81
Adds decorators to `tm_t_summary` (#1293)
averissimo Dec 10, 2024
015a964
Adds decorators to `tm_t_smq` (#1292)
averissimo Dec 10, 2024
d29d166
Adds decorators to `tm_t_shift_by_grade` (#1285)
averissimo Dec 10, 2024
ab0c15c
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] Dec 10, 2024
8986e27
Adds decorators to `tm_t_summary_by` (#1294)
averissimo Dec 10, 2024
772c14b
Adds decorators to `tm_t_shift_by_arm` (#1287)
averissimo Dec 10, 2024
582ceb3
Adds decorators to `tm_t_shift_by_arm_by_worst` (#1286)
averissimo Dec 10, 2024
66e7b36
feat: pass qenv.error to module when template code fails
averissimo Dec 10, 2024
d403e95
Merge branch 'main' into 1187_decorate_output@main
averissimo Dec 10, 2024
d1d8df8
Introduce decorators for `tm_t_exposure` (#1279)
llrs-roche Dec 11, 2024
c146b11
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] Dec 11, 2024
83d9fb0
Adds decorators to `tm_t_pp_laboratory` (#1291)
averissimo Dec 11, 2024
95f11f3
Adds decorators to `tm_t_pp_basic_info` (#1282)
averissimo Dec 11, 2024
b85523c
Adds decorators to `tm_t_pp_prior_medication` (#1288)
averissimo Dec 11, 2024
eb42bae
Introduce decorators for `tm_t events by grade` (#1276)
llrs-roche Dec 11, 2024
b2919f6
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
github-actions[bot] Dec 11, 2024
5c90ece
docs: remove roxygen inline call
averissimo Dec 11, 2024
274d2b6
Merge branch 'main' into 1187_decorate_output@main
averissimo Dec 11, 2024
f439cd4
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
github-actions[bot] Dec 11, 2024
00c8c0b
fix: linter error
averissimo Dec 11, 2024
a855989
Adds decorators to `tm_a_mmrm` (#1300)
averissimo Dec 12, 2024
0a06fbb
fix: tm_t_coxreg bug
averissimo Dec 12, 2024
6d4ce5b
fix: adverse events error
averissimo Dec 13, 2024
8a9edd2
Uses same code for source code generation in modules (#1301)
averissimo Dec 16, 2024
1db24ad
fix: remove rlang usage
averissimo Dec 17, 2024
19e8752
Decorators: Accepts new snapshot from `testthat::test()` (#1304)
averissimo Dec 17, 2024
9c4612c
fix: adds stats prefix
averissimo Dec 17, 2024
fad76cd
Merge branch 'main' into 1187_decorate_output@main
averissimo Dec 17, 2024
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 .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ repos:
- methods
- rlistings
- rmarkdown
- rtables
- scales
- shiny
- shinyjs
Expand All @@ -48,6 +47,9 @@ repos:
- insightsengineering/teal.widgets
- insightsengineering/tern.gee
- insightsengineering/tern.mmrm
- insightsengineering/rtables
- insightsengineering/rtables.officer
- insightsengineering/formatters
- utils
- vistime
- id: spell-check
Expand Down
8 changes: 8 additions & 0 deletions R/argument_convention.R
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,14 @@ NULL
#' value indicating worst grade.
#' @param worst_flag_var ([teal.transform::choices_selected()])\cr object
#' with all available choices and preselected option for variable names that can be used as worst flag variable.
#' @param decorators `r lifecycle::badge("experimental")`
#' " (`list` of `teal_transform_module`, named `list` of `teal_transform_module` or" `NULL`) optional,
#' if not `NULL`, decorator for tables or plots included in the module.
#' When a named list of `teal_transform_module`, the decorators are applied to the respective output objects.
#'
#' Otherwise, the decorators are applied to all objects, which is equivalent as using the name `default`.
#'
#' See section "Decorating Module" below for more details.
#'
#' @return a `teal_module` object.
#'
Expand Down
58 changes: 39 additions & 19 deletions R/tm_a_gee.R
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ template_a_gee <- function(output_table,
if (output_table == "t_gee_cov") {
substitute(
expr = {
result_table <- tern.gee::as.rtable(model_fit, type = "cov")
subtitles(result_table) <- st
main_footer(result_table) <- mf
table <- tern.gee::as.rtable(model_fit, type = "cov")
subtitles(table) <- st
main_footer(table) <- mf
},
env = list(
st = basic_table_args$subtitles,
Expand All @@ -81,9 +81,9 @@ template_a_gee <- function(output_table,
} else if (output_table == "t_gee_coef") {
substitute(
expr = {
result_table <- tern.gee::as.rtable(data.frame(Coefficient = model_fit$coefficients))
subtitles(result_table) <- st
main_footer(result_table) <- mf
table <- tern.gee::as.rtable(data.frame(Coefficient = model_fit$coefficients))
subtitles(table) <- st
main_footer(table) <- mf
},
env = list(
conf_level = conf_level,
Expand All @@ -95,17 +95,16 @@ template_a_gee <- function(output_table,
substitute(
expr = {
lsmeans_fit_model <- tern.gee::lsmeans(model_fit, conf_level)
result_table <- rtables::basic_table(show_colcounts = TRUE) %>%
table <- rtables::basic_table(show_colcounts = TRUE) %>%
rtables::split_cols_by(var = input_arm_var, ref_group = model_fit$ref_level) %>%
tern.gee::summarize_gee_logistic() %>%
rtables::build_table(
df = lsmeans_fit_model,
alt_counts_df = dataname_lsmeans
)

subtitles(result_table) <- st
main_footer(result_table) <- mf
result_table
subtitles(table) <- st
main_footer(table) <- mf
},
env = list(
dataname_lsmeans = as.name(dataname_lsmeans),
Expand Down Expand Up @@ -135,6 +134,14 @@ template_a_gee <- function(output_table,
#'
#' @inherit module_arguments return seealso
#'
#' @section Decorating Module:
#'
#' This module generates the following objects, which can be modified in place using decorators:
#' - `table` (`ElementaryTable` - output of `rtables::build_table`)
#'
#' For additional details and examples of decorators, refer to the vignette
#' `vignette("decorate-modules-output", package = "teal")` or the [`teal_transform_module()`] documentation.
#'
#' @examplesShinylive
#' library(teal.modules.clinical)
#' interactive <- function() TRUE
Expand Down Expand Up @@ -200,7 +207,8 @@ tm_a_gee <- function(label,
conf_level = teal.transform::choices_selected(c(0.95, 0.9, 0.8), 0.95, keep_order = TRUE),
pre_output = NULL,
post_output = NULL,
basic_table_args = teal.widgets::basic_table_args()) {
basic_table_args = teal.widgets::basic_table_args(),
decorators = NULL) {
message("Initializing tm_a_gee (prototype)")

cov_var <- teal.transform::add_no_selected_choices(cov_var, multiple = TRUE)
Expand All @@ -218,6 +226,8 @@ tm_a_gee <- function(label,
checkmate::assert_class(pre_output, classes = "shiny.tag", null.ok = TRUE)
checkmate::assert_class(post_output, classes = "shiny.tag", null.ok = TRUE)
checkmate::assert_class(basic_table_args, "basic_table_args")
decorators <- normalize_decorators(decorators)
assert_decorators(decorators, "table", null.ok = TRUE)

args <- as.list(environment())

Expand All @@ -243,7 +253,8 @@ tm_a_gee <- function(label,
parentname = parentname,
arm_ref_comp = arm_ref_comp,
label = label,
basic_table_args = basic_table_args
basic_table_args = basic_table_args,
decorators = decorators
)
),
datanames = teal.transform::get_extract_datanames(data_extract_list)
Expand Down Expand Up @@ -358,7 +369,8 @@ ui_gee <- function(id, ...) {
"Coefficients" = "t_gee_coef"
),
selected = "t_gee_lsmeans"
)
),
ui_decorate_teal_data(ns("decorator"), decorators = select_decorators(a$decorators, "table"))
),
forms = tagList(
teal.widgets::verbatim_popup_ui(ns("rcode"), button_label = "Show R code")
Expand All @@ -385,7 +397,8 @@ srv_gee <- function(id,
label,
plot_height,
plot_width,
basic_table_args) {
basic_table_args,
decorators) {
with_reporter <- !missing(reporter) && inherits(reporter, "Reporter")
with_filter <- !missing(filter_panel_api) && inherits(filter_panel_api, "FilterPanelAPI")
checkmate::assert_class(data, "reactive")
Expand Down Expand Up @@ -546,19 +559,26 @@ srv_gee <- function(id,
output_title
})

table_r <- reactive({
table_q()[["result_table"]]
})
decorated_table_q <- srv_decorate_teal_data(
id = "decorator",
data = table_q,
decorators = select_decorators(decorators, "table"),
expr = table
)

# Outputs to render.
table_r <- reactive(decorated_table_q()[["table"]])

teal.widgets::table_with_settings_srv(
id = "table",
table_r = table_r
)

# Render R code
source_code_r <- reactive(teal.code::get_code(req(decorated_table_q())))
teal.widgets::verbatim_popup_srv(
id = "rcode",
verbatim_content = reactive(teal.code::get_code(table_q())),
verbatim_content = source_code_r,
title = label
)

Expand All @@ -582,7 +602,7 @@ srv_gee <- function(id,
card$append_text("Comment", "header3")
card$append_text(comment)
}
card$append_src(teal.code::get_code(table_q()))
card$append_src(source_code_r())
card
}
teal.reporter::simple_reporter_srv("simple_reporter", reporter = reporter, card_fun = card_fun)
Expand Down
Loading
Loading