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

1441 Introduce transformators parameter in modules #826

Merged
merged 25 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
801b008
transformators parameter
m7pr Jan 14, 2025
db62734
add transformators to scatterplotmatrix
m7pr Jan 14, 2025
5dc5042
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
github-actions[bot] Jan 14, 2025
6ecf511
do not split documentation of decorators
m7pr Jan 14, 2025
3062a2a
Merge branch '1441_transformators@main' of https://github.com/insight…
m7pr Jan 14, 2025
ee4364d
roxygen changes to documentation
m7pr Jan 14, 2025
afcaa08
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
github-actions[bot] Jan 14, 2025
d62b083
remove transofmators documentation from shared params as it is alread…
m7pr Jan 14, 2025
ea85953
add a link to vignette
m7pr Jan 14, 2025
96132e1
merge
m7pr Jan 14, 2025
98f129e
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
github-actions[bot] Jan 14, 2025
a4df140
Merge branch 'main' into 1441_transformators@main
m7pr Jan 15, 2025
a00f139
Merge branch 'main' into 1441_transformators@main
m7pr Jan 17, 2025
7e89058
unify decorators and transformators default values
m7pr Jan 17, 2025
1208b4e
replace assertions
m7pr Jan 17, 2025
6dec0ec
assertions in regression
m7pr Jan 17, 2025
f3698b4
[skip style] [skip vbump] Restyle files
github-actions[bot] Jan 17, 2025
4a91408
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
github-actions[bot] Jan 17, 2025
dc9ebf6
simplify normalize_decorators
m7pr Jan 17, 2025
e5667d7
Merge branch '1441_transformators@main' of https://github.com/insight…
m7pr Jan 17, 2025
7321de5
Update R/utils.R
m7pr Jan 17, 2025
6b6f63e
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
github-actions[bot] Jan 17, 2025
582a8a3
revert changes on normalize_decorators
m7pr Jan 17, 2025
fff168d
Merge branch '1441_transformators@main' of https://github.com/insight…
m7pr Jan 17, 2025
1764c3e
Merge branch 'main' into 1441_transformators@main
m7pr Jan 20, 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
6 changes: 4 additions & 2 deletions R/tm_a_pca.R
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ tm_a_pca <- function(label = "Principal Component Analysis",
size = c(2, 1, 8),
pre_output = NULL,
post_output = NULL,
decorators = NULL) {
transformators = list(),
decorators = list()) {
message("Initializing tm_a_pca")

# Normalize the parameters
Expand Down Expand Up @@ -186,7 +187,7 @@ tm_a_pca <- function(label = "Principal Component Analysis",

available_decorators <- c("elbow_plot", "circle_plot", "biplot", "eigenvector_plot")
decorators <- normalize_decorators(decorators)
assert_decorators(decorators, null.ok = TRUE, available_decorators)
assert_decorators(decorators, available_decorators)
# End of assertions

# Make UI args
Expand All @@ -208,6 +209,7 @@ tm_a_pca <- function(label = "Principal Component Analysis",
decorators = decorators
)
),
transformators = transformators,
datanames = teal.transform::get_extract_datanames(data_extract_list)
)
attr(ans, "teal_bookmarkable") <- FALSE
Expand Down
8 changes: 5 additions & 3 deletions R/tm_a_regression.R
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ tm_a_regression <- function(label = "Regression Analysis",
default_plot_type = 1,
default_outlier_label = "USUBJID",
label_segment_threshold = c(0.5, 0, 10),
decorators = NULL) {
transformators = list(),
decorators = list()) {
message("Initializing tm_a_regression")

# Normalize the parameters
Expand Down Expand Up @@ -211,7 +212,7 @@ tm_a_regression <- function(label = "Regression Analysis",
checkmate::assert_multi_class(post_output, c("shiny.tag", "shiny.tag.list", "html"), null.ok = TRUE)
checkmate::assert_choice(default_plot_type, seq.int(1L, length(plot_choices)))
checkmate::assert_string(default_outlier_label)
checkmate::assert_list(decorators, "teal_transform_module", null.ok = TRUE)
checkmate::assert_list(decorators, "teal_transform_module")

if (length(label_segment_threshold) == 1) {
checkmate::assert_numeric(label_segment_threshold, any.missing = FALSE, finite = TRUE)
Expand All @@ -225,7 +226,7 @@ tm_a_regression <- function(label = "Regression Analysis",
)
}
decorators <- normalize_decorators(decorators)
assert_decorators(decorators, "plot", null.ok = TRUE)
assert_decorators(decorators, "plot")
# End of assertions

# Make UI args
Expand All @@ -251,6 +252,7 @@ tm_a_regression <- function(label = "Regression Analysis",
decorators = decorators
)
),
transformators = transformators,
datanames = teal.transform::get_extract_datanames(data_extract_list)
)
attr(ans, "teal_bookmarkable") <- FALSE
Expand Down
6 changes: 4 additions & 2 deletions R/tm_g_association.R
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ tm_g_association <- function(label = "Association",
pre_output = NULL,
post_output = NULL,
ggplot2_args = teal.widgets::ggplot2_args(),
decorators = NULL) {
transformators = list(),
decorators = list()) {
message("Initializing tm_g_association")

# Normalize the parameters
Expand Down Expand Up @@ -176,7 +177,7 @@ tm_g_association <- function(label = "Association",
checkmate::assert_subset(names(ggplot2_args), c("default", plot_choices))

decorators <- normalize_decorators(decorators)
assert_decorators(decorators, null.ok = TRUE, "plot")
assert_decorators(decorators, "plot")
# End of assertions

# Make UI args
Expand All @@ -196,6 +197,7 @@ tm_g_association <- function(label = "Association",
data_extract_list,
list(plot_height = plot_height, plot_width = plot_width, ggplot2_args = ggplot2_args, decorators = decorators)
),
transformators = transformators,
datanames = teal.transform::get_extract_datanames(data_extract_list)
)
attr(ans, "teal_bookmarkable") <- TRUE
Expand Down
6 changes: 4 additions & 2 deletions R/tm_g_bivariate.R
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@ tm_g_bivariate <- function(label = "Bivariate Plots",
ggplot2_args = teal.widgets::ggplot2_args(),
pre_output = NULL,
post_output = NULL,
decorators = NULL) {
transformators = list(),
decorators = list()) {
message("Initializing tm_g_bivariate")

# Normalize the parameters
Expand Down Expand Up @@ -277,7 +278,7 @@ tm_g_bivariate <- function(label = "Bivariate Plots",
checkmate::assert_multi_class(post_output, c("shiny.tag", "shiny.tag.list", "html"), null.ok = TRUE)

decorators <- normalize_decorators(decorators)
assert_decorators(decorators, null.ok = TRUE, "plot")
assert_decorators(decorators, "plot")
# End of assertions

# Make UI args
Expand All @@ -303,6 +304,7 @@ tm_g_bivariate <- function(label = "Bivariate Plots",
data_extract_list,
list(plot_height = plot_height, plot_width = plot_width, ggplot2_args = ggplot2_args, decorators = decorators)
),
transformators = transformators,
datanames = teal.transform::get_extract_datanames(data_extract_list)
)
attr(ans, "teal_bookmarkable") <- TRUE
Expand Down
6 changes: 4 additions & 2 deletions R/tm_g_distribution.R
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ tm_g_distribution <- function(label = "Distribution Module",
plot_width = NULL,
pre_output = NULL,
post_output = NULL,
decorators = NULL) {
transformators = list(),
decorators = list()) {
message("Initializing tm_g_distribution")

# Normalize the parameters
Expand Down Expand Up @@ -194,7 +195,7 @@ tm_g_distribution <- function(label = "Distribution Module",

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

# End of assertions

Expand All @@ -221,6 +222,7 @@ tm_g_distribution <- function(label = "Distribution Module",
),
ui = ui_distribution,
ui_args = args,
transformators = transformators,
datanames = teal.transform::get_extract_datanames(data_extract_list)
)
attr(ans, "teal_bookmarkable") <- TRUE
Expand Down
6 changes: 4 additions & 2 deletions R/tm_g_response.R
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ tm_g_response <- function(label = "Response Plot",
ggplot2_args = teal.widgets::ggplot2_args(),
pre_output = NULL,
post_output = NULL,
decorators = NULL) {
transformators = list(),
decorators = list()) {
message("Initializing tm_g_response")

# Normalize the parameters
Expand Down Expand Up @@ -202,7 +203,7 @@ tm_g_response <- function(label = "Response Plot",
checkmate::assert_multi_class(post_output, c("shiny.tag", "shiny.tag.list", "html"), null.ok = TRUE)

decorators <- normalize_decorators(decorators)
assert_decorators(decorators, null.ok = TRUE, "plot")
assert_decorators(decorators, "plot")
# End of assertions

# Make UI args
Expand All @@ -229,6 +230,7 @@ tm_g_response <- function(label = "Response Plot",
decorators = decorators
)
),
transformators = transformators,
datanames = teal.transform::get_extract_datanames(data_extract_list)
)
attr(ans, "teal_bookmarkable") <- TRUE
Expand Down
6 changes: 4 additions & 2 deletions R/tm_g_scatterplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,8 @@ tm_g_scatterplot <- function(label = "Scatterplot",
post_output = NULL,
table_dec = 4,
ggplot2_args = teal.widgets::ggplot2_args(),
decorators = NULL) {
transformators = list(),
decorators = list()) {
message("Initializing tm_g_scatterplot")

# Normalize the parameters
Expand Down Expand Up @@ -299,7 +300,7 @@ tm_g_scatterplot <- function(label = "Scatterplot",
checkmate::assert_class(ggplot2_args, "ggplot2_args")

decorators <- normalize_decorators(decorators)
assert_decorators(decorators, null.ok = TRUE, "plot")
assert_decorators(decorators, "plot")

# End of assertions

Expand Down Expand Up @@ -330,6 +331,7 @@ tm_g_scatterplot <- function(label = "Scatterplot",
decorators = decorators
)
),
transformators = transformators,
datanames = teal.transform::get_extract_datanames(data_extract_list)
)
attr(ans, "teal_bookmarkable") <- TRUE
Expand Down
6 changes: 4 additions & 2 deletions R/tm_g_scatterplotmatrix.R
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ tm_g_scatterplotmatrix <- function(label = "Scatterplot Matrix",
plot_width = NULL,
pre_output = NULL,
post_output = NULL,
decorators = NULL) {
transformators = list(),
decorators = list()) {
message("Initializing tm_g_scatterplotmatrix")

# Normalize the parameters
Expand All @@ -199,7 +200,7 @@ tm_g_scatterplotmatrix <- function(label = "Scatterplot Matrix",
checkmate::assert_multi_class(post_output, c("shiny.tag", "shiny.tag.list", "html"), null.ok = TRUE)

decorators <- normalize_decorators(decorators)
assert_decorators(decorators, null.ok = TRUE, "plot")
assert_decorators(decorators, "plot")
# End of assertions

# Make UI args
Expand All @@ -216,6 +217,7 @@ tm_g_scatterplotmatrix <- function(label = "Scatterplot Matrix",
plot_width = plot_width,
decorators = decorators
),
transformators = transformators,
datanames = teal.transform::get_extract_datanames(variables)
)
attr(ans, "teal_bookmarkable") <- TRUE
Expand Down
6 changes: 4 additions & 2 deletions R/tm_missing_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ tm_missing_data <- function(label = "Missing data",
),
pre_output = NULL,
post_output = NULL,
decorators = NULL) {
transformators = list(),
decorators = list()) {
message("Initializing tm_missing_data")

# Normalize the parameters
Expand Down Expand Up @@ -148,7 +149,7 @@ tm_missing_data <- function(label = "Missing data",

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

ans <- module(
Expand All @@ -164,6 +165,7 @@ tm_missing_data <- function(label = "Missing data",
decorators = decorators
),
ui = ui_page_missing_data,
transformators = transformators,
ui_args = list(pre_output = pre_output, post_output = post_output)
)
attr(ans, "teal_bookmarkable") <- TRUE
Expand Down
6 changes: 4 additions & 2 deletions R/tm_outliers.R
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ tm_outliers <- function(label = "Outliers Module",
plot_width = NULL,
pre_output = NULL,
post_output = NULL,
decorators = NULL) {
transformators = list(),
decorators = list()) {
message("Initializing tm_outliers")

# Normalize the parameters
Expand Down Expand Up @@ -197,7 +198,7 @@ tm_outliers <- function(label = "Outliers Module",

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

# Make UI args
Expand All @@ -221,6 +222,7 @@ tm_outliers <- function(label = "Outliers Module",
),
ui = ui_outliers,
ui_args = args,
transformators = transformators,
datanames = teal.transform::get_extract_datanames(data_extract_list)
)
attr(ans, "teal_bookmarkable") <- TRUE
Expand Down
6 changes: 4 additions & 2 deletions R/tm_t_crosstable.R
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ tm_t_crosstable <- function(label = "Cross Table",
pre_output = NULL,
post_output = NULL,
basic_table_args = teal.widgets::basic_table_args(),
decorators = NULL) {
transformators = list(),
decorators = list()) {
message("Initializing tm_t_crosstable")

# Normalize the parameters
Expand All @@ -164,7 +165,7 @@ tm_t_crosstable <- function(label = "Cross Table",
checkmate::assert_class(basic_table_args, classes = "basic_table_args")

decorators <- normalize_decorators(decorators)
assert_decorators(decorators, null.ok = TRUE, "plot")
assert_decorators(decorators, "plot")
# End of assertions

# Make UI args
Expand All @@ -184,6 +185,7 @@ tm_t_crosstable <- function(label = "Cross Table",
ui = ui_t_crosstable,
ui_args = ui_args,
server_args = server_args,
transformators = transformators,
datanames = teal.transform::get_extract_datanames(list(x = x, y = y))
)
attr(ans, "teal_bookmarkable") <- TRUE
Expand Down
16 changes: 5 additions & 11 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
#' - When the length of `size` is three: the plot points size are dynamically adjusted based on
#' vector of `value`, `min`, and `max`.
#' @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.
#' (`list` of `teal_transform_module`, named `list` of `teal_transform_module`) optional,
#' decorator for tables or plots included in the module output reported.
#' 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`.
Expand Down Expand Up @@ -342,14 +342,9 @@ ui_decorate_teal_data <- function(id, decorators, ...) {

#' Internal function to check if decorators is a valid object
#' @noRd
check_decorators <- function(x, names = NULL, null.ok = FALSE) { # nolint: object_name.
checkmate::qassert(null.ok, "B1")
check_decorators <- function(x, names = NULL) { # nolint: object_name.

check_message <- checkmate::check_list(
x,
null.ok = null.ok,
names = "named"
)
check_message <- checkmate::check_list(x, names = "named")

if (!is.null(names)) {
check_message <- if (isTRUE(check_message)) {
Expand All @@ -373,7 +368,6 @@ check_decorators <- function(x, names = NULL, null.ok = FALSE) { # nolint: objec
x,
checkmate::test_list,
types = "teal_transform_module",
null.ok = TRUE,
FUN.VALUE = logical(1L)
)

Expand Down Expand Up @@ -411,7 +405,7 @@ select_decorators <- function(decorators, scope) {
#' @return A named list of lists with `teal_transform_module` objects.
#' @keywords internal
normalize_decorators <- function(decorators) {
if (checkmate::test_list(decorators, "teal_transform_module", null.ok = TRUE)) {
m7pr marked this conversation as resolved.
Show resolved Hide resolved
if (checkmate::test_list(decorators, "teal_transform_module")) {
if (checkmate::test_names(names(decorators))) {
lapply(decorators, list)
} else {
Expand Down
4 changes: 2 additions & 2 deletions man/shared_params.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 7 additions & 3 deletions man/tm_a_pca.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading