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

Remove "default" decoration and use the same way of decoration in all modules #846

Merged
merged 5 commits into from
Feb 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions R/tm_a_pca.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,18 @@
#' - `biplot` (`ggplot2`)
#' - `eigenvector_plot` (`ggplot2`)
#'
#' Decorators can be applied to all outputs or only to specific objects using a
#' named list of `teal_transform_module` objects.
#' The `"default"` name is reserved for decorators that are applied to all outputs.
#' A Decorator is applied to the specific output using a named list of `teal_transform_module` objects.
#' The name of this list corresponds to the name of the output to which the decorator is applied.
#' See code snippet below:
#'
#' ```
#' tm_a_pca(
#' ..., # arguments for module
#' decorators = list(
#' default = list(teal_transform_module(...)), # applied to all outputs
#' elbow_plot = list(teal_transform_module(...)), # applied only to `elbow_plot` output
#' circle_plot = list(teal_transform_module(...)) # applied only to `circle_plot` output
#' biplot = list(teal_transform_module(...)) # applied only to `biplot` output
#' eigenvector_plot = list(teal_transform_module(...)) # applied only to `eigenvector_plot` output
#' elbow_plot = teal_transform_module(...), # applied to the `elbow_plot` output
#' circle_plot = teal_transform_module(...), # applied to the `circle_plot` output
#' biplot = teal_transform_module(...), # applied to the `biplot` output
#' eigenvector_plot = teal_transform_module(...) # applied to the `eigenvector_plot` output
#' )
#' )
#' ```
Expand Down Expand Up @@ -186,9 +184,7 @@ tm_a_pca <- function(label = "Principal Component Analysis",
checkmate::assert_multi_class(post_output, c("shiny.tag", "shiny.tag.list", "html"), null.ok = TRUE)

available_decorators <- c("elbow_plot", "circle_plot", "biplot", "eigenvector_plot")
decorators <- normalize_decorators(decorators)
assert_decorators(decorators, available_decorators)
# End of assertions

# Make UI args
args <- as.list(environment())
Expand Down
14 changes: 13 additions & 1 deletion R/tm_a_regression.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,19 @@
#' This module generates the following objects, which can be modified in place using decorators:
#' - `plot` (`ggplot2`)
#'
#' A Decorator is applied to the specific output using a named list of `teal_transform_module` objects.
#' The name of this list corresponds to the name of the output to which the decorator is applied.
#' See code snippet below:
#'
#' ```
#' tm_a_regression(
#' ..., # arguments for module
#' decorators = list(
#' plot = teal_transform_module(...) # applied to the `plot` output
#' )
#' )
#' ```
#'
#' For additional details and examples of decorators, refer to the vignette
#' `vignette("decorate-modules-output", package = "teal")` or the [`teal::teal_transform_module()`] documentation.
#'
Expand Down Expand Up @@ -225,7 +238,6 @@ tm_a_regression <- function(label = "Regression Analysis",
.var.name = "label_segment_threshold"
)
}
decorators <- normalize_decorators(decorators)
assert_decorators(decorators, "plot")
# End of assertions

Expand Down
14 changes: 13 additions & 1 deletion R/tm_g_association.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,19 @@
#' This module generates the following objects, which can be modified in place using decorators:
#' - `plot` (`grob` created with [ggplot2::ggplotGrob()])
#'
#' A Decorator is applied to the specific output using a named list of `teal_transform_module` objects.
#' The name of this list corresponds to the name of the output to which the decorator is applied.
#' See code snippet below:
#'
#' ```
#' tm_g_association(
#' ..., # arguments for module
#' decorators = list(
#' plot = teal_transform_module(...) # applied to the `plot` output
#' )
#' )
#' ```
#'
#' For additional details and examples of decorators, refer to the vignette
#' `vignette("decorate-modules-output", package = "teal")` or the [`teal::teal_transform_module()`] documentation.
#'
Expand Down Expand Up @@ -176,7 +189,6 @@ tm_g_association <- function(label = "Association",
checkmate::assert_list(ggplot2_args, types = "ggplot2_args")
checkmate::assert_subset(names(ggplot2_args), c("default", plot_choices))

decorators <- normalize_decorators(decorators)
assert_decorators(decorators, "plot")
# End of assertions

Expand Down
14 changes: 13 additions & 1 deletion R/tm_g_bivariate.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,19 @@
#' This module generates the following objects, which can be modified in place using decorators:
#' - `plot` (`ggplot2`)
#'
#' A Decorator is applied to the specific output using a named list of `teal_transform_module` objects.
#' The name of this list corresponds to the name of the output to which the decorator is applied.
#' See code snippet below:
#'
#' ```
#' tm_g_bivariate(
#' ..., # arguments for module
#' decorators = list(
#' plot = teal_transform_module(...) # applied to the `plot` output
#' )
#' )
#' ```
#'
#' For additional details and examples of decorators, refer to the vignette
#' `vignette("decorate-modules-output", package = "teal")` or the [`teal::teal_transform_module()`] documentation.
#'
Expand Down Expand Up @@ -277,7 +290,6 @@ tm_g_bivariate <- function(label = "Bivariate Plots",
checkmate::assert_multi_class(pre_output, c("shiny.tag", "shiny.tag.list", "html"), null.ok = TRUE)
checkmate::assert_multi_class(post_output, c("shiny.tag", "shiny.tag.list", "html"), null.ok = TRUE)

decorators <- normalize_decorators(decorators)
assert_decorators(decorators, "plot")
# End of assertions

Expand Down
15 changes: 6 additions & 9 deletions R/tm_g_distribution.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,18 @@
#' - `summary_table` (`listing_df` created with [rlistings::as_listing()])
#' - `test_table` (`listing_df` created with [rlistings::as_listing()])
#'
#' Decorators can be applied to all outputs or only to specific objects using a
#' named list of `teal_transform_module` objects.
#' The `"default"` name is reserved for decorators that are applied to all outputs.
#' A Decorator is applied to the specific output using a named list of `teal_transform_module` objects.
#' The name of this list corresponds to the name of the output to which the decorator is applied.
#' See code snippet below:
#'
#' ```
#' tm_g_distribution(
#' ..., # arguments for module
#' decorators = list(
#' default = list(teal_transform_module(...)), # applied to all outputs
#' histogram_plot = list(teal_transform_module(...)), # applied only to `histogram_plot` output
#' qq_plot = list(teal_transform_module(...)) # applied only to `qq_plot` output
#' summary_table = list(teal_transform_module(...)) # applied only to `summary_table` output
#' test_table = list(teal_transform_module(...)) # applied only to `test_table` output
#' histogram_plot = teal_transform_module(...), # applied only to `histogram_plot` output
#' qq_plot = teal_transform_module(...), # applied only to `qq_plot` output
#' summary_table = teal_transform_module(...), # applied only to `summary_table` output
#' test_table = teal_transform_module(...) # applied only to `test_table` output
#' )
#' )
#' ```
Expand Down Expand Up @@ -194,7 +192,6 @@ tm_g_distribution <- function(label = "Distribution Module",
checkmate::assert_multi_class(post_output, c("shiny.tag", "shiny.tag.list", "html"), null.ok = TRUE)

available_decorators <- c("histogram_plot", "qq_plot", "test_table", "summary_table")
decorators <- normalize_decorators(decorators)
assert_decorators(decorators, names = available_decorators)

# End of assertions
Expand Down
14 changes: 13 additions & 1 deletion R/tm_g_response.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,19 @@
#' This module generates the following objects, which can be modified in place using decorators:
#' - `plot` (`ggplot2`)
#'
#' A Decorator is applied to the specific output using a named list of `teal_transform_module` objects.
#' The name of this list corresponds to the name of the output to which the decorator is applied.
#' See code snippet below:
#'
#' ```
#' tm_g_response(
#' ..., # arguments for module
#' decorators = list(
#' plot = teal_transform_module(...) # applied to the `plot` output
#' )
#' )
#' ```
#'
#' For additional details and examples of decorators, refer to the vignette
#' `vignette("decorate-modules-output", package = "teal")` or the [`teal::teal_transform_module()`] documentation.
#'
Expand Down Expand Up @@ -202,7 +215,6 @@ tm_g_response <- function(label = "Response Plot",
checkmate::assert_multi_class(pre_output, c("shiny.tag", "shiny.tag.list", "html"), null.ok = TRUE)
checkmate::assert_multi_class(post_output, c("shiny.tag", "shiny.tag.list", "html"), null.ok = TRUE)

decorators <- normalize_decorators(decorators)
assert_decorators(decorators, "plot")
# End of assertions

Expand Down
14 changes: 13 additions & 1 deletion R/tm_g_scatterplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,19 @@
#' This module generates the following objects, which can be modified in place using decorators:
#' - `plot` (`ggplot2`)
#'
#' A Decorator is applied to the specific output using a named list of `teal_transform_module` objects.
#' The name of this list corresponds to the name of the output to which the decorator is applied.
#' See code snippet below:
#'
#' ```
#' tm_g_scatterplot(
#' ..., # arguments for module
#' decorators = list(
#' plot = teal_transform_module(...) # applied to the `plot` output
#' )
#' )
#' ```
#'
#' For additional details and examples of decorators, refer to the vignette
#' `vignette("decorate-modules-output", package = "teal")` or the [`teal::teal_transform_module()`] documentation.
#'
Expand Down Expand Up @@ -299,7 +312,6 @@ tm_g_scatterplot <- function(label = "Scatterplot",
checkmate::assert_scalar(table_dec)
checkmate::assert_class(ggplot2_args, "ggplot2_args")

decorators <- normalize_decorators(decorators)
assert_decorators(decorators, "plot")

# End of assertions
Expand Down
14 changes: 13 additions & 1 deletion R/tm_g_scatterplotmatrix.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,19 @@
#' This module generates the following objects, which can be modified in place using decorators:
#' - `plot` (`trellis` - output of `lattice::splom`)
#'
#' A Decorator is applied to the specific output using a named list of `teal_transform_module` objects.
#' The name of this list corresponds to the name of the output to which the decorator is applied.
#' See code snippet below:
#'
#' ```
#' tm_g_scatterplotmatrix(
#' ..., # arguments for module
#' decorators = list(
#' plot = teal_transform_module(...) # applied to the `plot` output
#' )
#' )
#' ```
#'
#' For additional details and examples of decorators, refer to the vignette
#' `vignette("decorate-modules-output", package = "teal")` or the [`teal::teal_transform_module()`] documentation.
#'
Expand Down Expand Up @@ -199,7 +212,6 @@ tm_g_scatterplotmatrix <- function(label = "Scatterplot Matrix",
checkmate::assert_multi_class(pre_output, c("shiny.tag", "shiny.tag.list", "html"), null.ok = TRUE)
checkmate::assert_multi_class(post_output, c("shiny.tag", "shiny.tag.list", "html"), null.ok = TRUE)

decorators <- normalize_decorators(decorators)
assert_decorators(decorators, "plot")
# End of assertions

Expand Down
21 changes: 9 additions & 12 deletions R/tm_missing_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,18 @@
#' - `by_subject_plot` (`ggplot2`)
#' - `table` (`listing_df` created with [rlistings::as_listing()])
#'
#' Decorators can be applied to all outputs or only to specific objects using a
#' named list of `teal_transform_module` objects.
#' The `"default"` name is reserved for decorators that are applied to all outputs.
#' A Decorator is applied to the specific output using a named list of `teal_transform_module` objects.
#' The name of this list corresponds to the name of the output to which the decorator is applied.
#' See code snippet below:
#'
#' ```
#' tm_missing_data(
#' ..., # arguments for module
#' decorators = list(
#' default = list(teal_transform_module(...)), # applied to all outputs
#' summary_plot = list(teal_transform_module(...)), # applied only to `summary_plot` output
#' combination_plot = list(teal_transform_module(...)) # applied only to `combination_plot` output
#' by_subject_plot = list(teal_transform_module(...)) # applied only to `by_subject_plot` output
#' table = list(teal_transform_module(...)) # applied only to `table` output
#' summary_plot = teal_transform_module(...), # applied only to `summary_plot` output
#' combination_plot = teal_transform_module(...), # applied only to `combination_plot` output
#' by_subject_plot = teal_transform_module(...), # applied only to `by_subject_plot` output
#' table = teal_transform_module(...) # applied only to `table` output
#' )
#' )
#' ```
Expand Down Expand Up @@ -147,8 +145,7 @@ tm_missing_data <- function(label = "Missing data",
checkmate::assert_multi_class(pre_output, c("shiny.tag", "shiny.tag.list", "html"), null.ok = TRUE)
checkmate::assert_multi_class(post_output, c("shiny.tag", "shiny.tag.list", "html"), null.ok = TRUE)

available_decorators <- c("summary_plot", "combination_plot", "by_subject_plot", "summary_table")
decorators <- normalize_decorators(decorators)
available_decorators <- c("summary_plot", "combination_plot", "by_subject_plot", "table")
assert_decorators(decorators, names = available_decorators)
# End of assertions

Expand Down Expand Up @@ -446,7 +443,7 @@ encoding_missing_data <- function(id, summary_per_patient = FALSE, ggtheme, data
selected = "counts",
inline = TRUE
),
ui_decorate_teal_data(ns("dec_summary_table"), decorators = select_decorators(decorators, "summary_table"))
ui_decorate_teal_data(ns("dec_summary_table"), decorators = select_decorators(decorators, "table"))
),
teal.widgets::panel_item(
title = "Plot settings",
Expand Down Expand Up @@ -1295,7 +1292,7 @@ srv_missing_data <- function(id,
decorated_summary_table_q <- srv_decorate_teal_data(
id = "dec_summary_table",
data = summary_table_q,
decorators = select_decorators(decorators, "summary_table"),
decorators = select_decorators(decorators, "table"),
expr = table
)

Expand Down
15 changes: 6 additions & 9 deletions R/tm_outliers.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,18 @@
#' - `cumulative_plot` (`ggplot2`)
#' - `table` (`listing_df` created with [rlistings::as_listing()])
#'
#' Decorators can be applied to all outputs or only to specific objects using a
#' named list of `teal_transform_module` objects.
#' The `"default"` name is reserved for decorators that are applied to all outputs.
#' A Decorator is applied to the specific output using a named list of `teal_transform_module` objects.
#' The name of this list corresponds to the name of the output to which the decorator is applied.
#' See code snippet below:
#'
#' ```
#' tm_outliers(
#' ..., # arguments for module
#' decorators = list(
#' default = list(teal_transform_module(...)), # applied to all outputs
#' box_plot = list(teal_transform_module(...)), # applied only to `box_plot` output
#' density_plot = list(teal_transform_module(...)) # applied only to `density_plot` output
#' cumulative_plot = list(teal_transform_module(...)) # applied only to `cumulative_plot` output
#' table = list(teal_transform_module(...)) # applied only to `table` output
#' box_plot = teal_transform_module(...), # applied only to `box_plot` output
#' density_plot = teal_transform_module(...), # applied only to `density_plot` output
#' cumulative_plot = teal_transform_module(...), # applied only to `cumulative_plot` output
#' table = teal_transform_module(...) # applied only to `table` output
#' )
#' )
#' ```
Expand Down Expand Up @@ -197,7 +195,6 @@ tm_outliers <- function(label = "Outliers Module",
checkmate::assert_multi_class(post_output, c("shiny.tag", "shiny.tag.list", "html"), null.ok = TRUE)

available_decorators <- c("box_plot", "density_plot", "cumulative_plot", "table")
decorators <- normalize_decorators(decorators)
assert_decorators(decorators, names = available_decorators)
# End of assertions

Expand Down
19 changes: 15 additions & 4 deletions R/tm_t_crosstable.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@
#' This module generates the following objects, which can be modified in place using decorators:
#' - `table` (`ElementaryTable` - output of `rtables::build_table`)
#'
#' A Decorator is applied to the specific output using a named list of `teal_transform_module` objects.
#' The name of this list corresponds to the name of the output to which the decorator is applied.
#' See code snippet below:
#'
#' ```
#' tm_t_crosstable(
#' ..., # arguments for module
#' decorators = list(
#' table = teal_transform_module(...) # applied to the `table` output
#' )
#' )
#' ```
#' For additional details and examples of decorators, refer to the vignette
#' `vignette("decorate-modules-output", package = "teal")` or the [`teal::teal_transform_module()`] documentation.
#'
Expand Down Expand Up @@ -164,8 +176,7 @@ tm_t_crosstable <- function(label = "Cross Table",
checkmate::assert_multi_class(post_output, c("shiny.tag", "shiny.tag.list", "html"), null.ok = TRUE)
checkmate::assert_class(basic_table_args, classes = "basic_table_args")

decorators <- normalize_decorators(decorators)
assert_decorators(decorators, "plot")
assert_decorators(decorators, "table")
# End of assertions

# Make UI args
Expand Down Expand Up @@ -233,7 +244,7 @@ ui_t_crosstable <- function(id, x, y, show_percentage, show_total, pre_output, p
checkboxInput(ns("show_total"), "Show total column", value = show_total)
)
),
ui_decorate_teal_data(ns("decorator"), decorators = select_decorators(args$decorators, "plot"))
ui_decorate_teal_data(ns("decorator"), decorators = select_decorators(args$decorators, "table"))
),
forms = tagList(
teal.widgets::verbatim_popup_ui(ns("rcode"), "Show R code")
Expand Down Expand Up @@ -409,7 +420,7 @@ srv_t_crosstable <- function(id, data, reporter, filter_panel_api, label, x, y,
decorated_output_q <- srv_decorate_teal_data(
id = "decorator",
data = output_q,
decorators = select_decorators(decorators, "plot"),
decorators = select_decorators(decorators, "table"),
expr = table
)

Expand Down
Loading
Loading