Skip to content

Commit

Permalink
1441 Introduce transformators parameter in modules (#293)
Browse files Browse the repository at this point in the history
insightsengineering/teal#1441

Included `transformators` parameter in modules. This is passed to
`teal::module` that does assertions and checks on this parameter.

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
m7pr and github-actions[bot] authored Jan 21, 2025
1 parent 5cf3bc3 commit 59f36ef
Show file tree
Hide file tree
Showing 18 changed files with 101 additions and 38 deletions.
5 changes: 4 additions & 1 deletion R/tm_g_ae_oview.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#' Display the `AE` overview plot as a shiny module
#'
#' @inheritParams teal.widgets::standard_layout
#' @inheritParams teal::module
#' @inheritParams argument_convention
#' @param flag_var_anl ([`teal.transform::choices_selected`])
#' `choices_selected` object with variables used to count adverse event
Expand Down Expand Up @@ -77,7 +78,8 @@ tm_g_ae_oview <- function(label,
flag_var_anl,
fontsize = c(5, 3, 7),
plot_height = c(600L, 200L, 2000L),
plot_width = NULL) {
plot_width = NULL,
transformators = list()) {
message("Initializing tm_g_ae_oview")
checkmate::assert_class(arm_var, classes = "choices_selected")
checkmate::assert_class(flag_var_anl, classes = "choices_selected")
Expand Down Expand Up @@ -114,6 +116,7 @@ tm_g_ae_oview <- function(label,
),
ui = ui_g_ae_oview,
ui_args = args,
transformators = transformators,
datanames = c("ADSL", dataname)
)
}
Expand Down
5 changes: 4 additions & 1 deletion R/tm_g_ae_sub.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#' Display the `AE` by subgroups plot as a teal module
#'
#' @inheritParams teal.widgets::standard_layout
#' @inheritParams teal::module
#' @inheritParams argument_convention
#' @param group_var (`choices_selected`) subgroups variables. See [teal.transform::choices_selected()] for details.
#'
Expand Down Expand Up @@ -54,7 +55,8 @@ tm_g_ae_sub <- function(label,
group_var,
plot_height = c(600L, 200L, 2000L),
plot_width = NULL,
fontsize = c(5, 3, 7)) {
fontsize = c(5, 3, 7),
transformators = list()) {
message("Initializing tm_g_ae_sub")
checkmate::assert_class(arm_var, classes = "choices_selected")
checkmate::assert_class(group_var, classes = "choices_selected")
Expand Down Expand Up @@ -90,6 +92,7 @@ tm_g_ae_sub <- function(label,
group_var = group_var,
fontsize = fontsize
),
transformators = transformators,
datanames = c("ADSL", dataname)
)
}
Expand Down
7 changes: 5 additions & 2 deletions R/tm_g_butterfly.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#' Display butterfly plot as a shiny module
#'
#' @inheritParams teal.widgets::standard_layout
#' @inheritParams teal::module
#' @inheritParams argument_convention
#' @param filter_var (`choices_selected`) variable name of data filter, please see details regarding
#' expected values, default is`NULL`.`choices`
Expand Down Expand Up @@ -118,7 +119,8 @@ tm_g_butterfly <- function(label,
plot_height = c(600L, 200L, 2000L),
plot_width = NULL,
pre_output = NULL,
post_output = NULL) {
post_output = NULL,
transformators = list()) {
message("Initializing tm_g_butterfly")
checkmate::assert_string(label)
checkmate::assert_string(dataname)
Expand Down Expand Up @@ -150,7 +152,8 @@ tm_g_butterfly <- function(label,
server = srv_g_butterfly,
server_args = list(dataname = dataname, label = label, plot_height = plot_height, plot_width = plot_width),
ui = ui_g_butterfly,
ui_args = args
ui_args = args,
transformators = transformators
)
}

Expand Down
5 changes: 4 additions & 1 deletion R/tm_g_events_term_id.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#' Display Events by Term plot as a shiny module
#'
#' @inheritParams teal.widgets::standard_layout
#' @inheritParams teal::module
#' @inheritParams argument_convention
#' @param term_var [teal.transform::choices_selected] object with all available choices
#' and pre-selected option names that can be used to specify the term for events
Expand Down Expand Up @@ -57,7 +58,8 @@ tm_g_events_term_id <- function(label,
arm_var,
fontsize = c(5, 3, 7),
plot_height = c(600L, 200L, 2000L),
plot_width = NULL) {
plot_width = NULL,
transformators = list()) {
message("Initializing tm_g_events_term_id")
checkmate::assert_string(label)
checkmate::assert_class(term_var, classes = "choices_selected")
Expand Down Expand Up @@ -90,6 +92,7 @@ tm_g_events_term_id <- function(label,
server_args = list(label = label, dataname = dataname, plot_height = plot_height, plot_width = plot_width),
ui = ui_g_events_term_id,
ui_args = args,
transformators = transformators,
datanames = c("ADSL", dataname)
)
}
Expand Down
5 changes: 4 additions & 1 deletion R/tm_g_heat_bygrade.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#' Display the heatmap by grade as a shiny module
#'
#' @inheritParams teal.widgets::standard_layout
#' @inheritParams teal::module
#' @inheritParams argument_convention
#' @param sl_dataname (`character`) subject level dataset name,
#' needs to be available in the list passed to the `data`
Expand Down Expand Up @@ -129,7 +130,8 @@ tm_g_heat_bygrade <- function(label,
conmed_var = NULL,
fontsize = c(5, 3, 7),
plot_height = c(600L, 200L, 2000L),
plot_width = NULL) {
plot_width = NULL,
transformators = list()) {
message("Initializing tm_g_heat_bygrade")
args <- as.list(environment())

Expand Down Expand Up @@ -178,6 +180,7 @@ tm_g_heat_bygrade <- function(label,
),
ui = ui_g_heatmap_bygrade,
ui_args = args,
transformators = transformators,
datanames = "all"
)
}
Expand Down
5 changes: 4 additions & 1 deletion R/tm_g_patient_profile.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#' Display patient profile plot as a shiny module
#'
#' @inheritParams teal.widgets::standard_layout
#' @inheritParams teal::module
#' @inheritParams argument_convention
#' @param patient_id (`choices_seleced`) unique subject ID variable
#' @param sl_dataname (`character`) subject level dataset name,
Expand Down Expand Up @@ -151,7 +152,8 @@ tm_g_patient_profile <- function(label = "Patient Profile Plot",
plot_height = c(1200L, 400L, 5000L),
plot_width = NULL,
pre_output = NULL,
post_output = NULL) {
post_output = NULL,
transformators = list()) {
args <- as.list(environment())
checkmate::assert_string(label)
checkmate::assert_string(sl_dataname)
Expand Down Expand Up @@ -201,6 +203,7 @@ tm_g_patient_profile <- function(label = "Patient Profile Plot",
plot_height = plot_height,
plot_width = plot_width
),
transformators = transformators,
datanames = "all"
)
}
Expand Down
7 changes: 5 additions & 2 deletions R/tm_g_spiderplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#' Display spider plot as a shiny module
#'
#' @inheritParams teal.widgets::standard_layout
#' @inheritParams teal::module
#' @inheritParams argument_convention
#' @param x_var x-axis variables
#' @param y_var y-axis variables
Expand Down Expand Up @@ -93,7 +94,8 @@ tm_g_spiderplot <- function(label,
plot_height = c(600L, 200L, 2000L),
plot_width = NULL,
pre_output = NULL,
post_output = NULL) {
post_output = NULL,
transformators = list()) {
message("Initializing tm_g_spiderplot")
checkmate::assert_class(paramcd, classes = "choices_selected")
checkmate::assert_class(x_var, classes = "choices_selected")
Expand Down Expand Up @@ -130,7 +132,8 @@ tm_g_spiderplot <- function(label,
plot_width = plot_width
),
ui = ui_g_spider,
ui_args = args
ui_args = args,
transformators = transformators
)
}

Expand Down
5 changes: 4 additions & 1 deletion R/tm_g_swimlane.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#' This is teal module that generates a `swimlane` plot (bar plot with markers) for `ADaM` data
#'
#' @inheritParams teal.widgets::standard_layout
#' @inheritParams teal::module
#' @inheritParams argument_convention
#' @param dataname analysis data used for plotting, needs to be available in the list passed to the `data`
#' argument of [teal::init()]. If no markers are to be plotted in the module, `"ADSL"` should be
Expand Down Expand Up @@ -120,7 +121,8 @@ tm_g_swimlane <- function(label,
plot_width = NULL,
pre_output = NULL,
post_output = NULL,
x_label = "Time from First Treatment (Day)") {
x_label = "Time from First Treatment (Day)",
transformators = list()) {
message("Initializing tm_g_swimlane")
args <- as.list(environment())

Expand Down Expand Up @@ -165,6 +167,7 @@ tm_g_swimlane <- function(label,
plot_width = plot_width,
x_label = x_label
),
transformators = transformators,
datanames = c("ADSL", dataname)
)
}
Expand Down
5 changes: 4 additions & 1 deletion R/tm_g_waterfall.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#' This is teal module that generates a waterfall plot for `ADaM` data
#'
#' @inheritParams teal.widgets::standard_layout
#' @inheritParams teal::module
#' @inheritParams argument_convention
#' @param dataname_tr tumor burden analysis data used in teal module to plot as bar height, needs to
#' be available in the list passed to the `data` argument of [teal::init()]
Expand Down Expand Up @@ -102,7 +103,8 @@ tm_g_waterfall <- function(label,
plot_height = c(1200L, 400L, 5000L),
plot_width = NULL,
pre_output = NULL,
post_output = NULL) {
post_output = NULL,
transformators = list()) {
message("Initializing tm_g_waterfall")
checkmate::assert_string(label)
checkmate::assert_string(dataname_tr)
Expand Down Expand Up @@ -145,6 +147,7 @@ tm_g_waterfall <- function(label,
plot_height = plot_height,
plot_width = plot_width
),
transformators = transformators,
datanames = "all"
)
}
Expand Down
10 changes: 7 additions & 3 deletions man/tm_g_ae_oview.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_g_ae_sub.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_g_butterfly.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_g_events_term_id.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_g_heat_bygrade.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_g_patient_profile.Rd

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

Loading

0 comments on commit 59f36ef

Please sign in to comment.