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

Update docs to use the new teal_data instead of TealData #597

Merged
merged 14 commits into from
Nov 20, 2023
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
8 changes: 4 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Depends:
R (>= 3.6),
shiny (>= 1.6.0),
shinyTree,
teal (>= 0.14.0)
teal (>= 0.14.0.9019)
Imports:
checkmate (>= 2.1.0),
dplyr (>= 1.0.5),
Expand All @@ -39,8 +39,8 @@ Imports:
teal.code (>= 0.4.0),
teal.logger (>= 0.1.1),
teal.reporter (>= 0.2.0),
teal.slice (>= 0.4.0),
teal.transform (>= 0.4.0),
teal.slice (>= 0.4.0.9023),
teal.transform (>= 0.4.0.9007),
teal.widgets (>= 0.4.0),
tern (>= 0.7.10),
tibble (>= 2.0.0),
Expand All @@ -65,7 +65,7 @@ Suggests:
rlang (>= 1.0.0),
rtables (>= 0.5.1),
sparkline,
teal.data (>= 0.3.0),
teal.data (>= 0.3.0.9010),
testthat (>= 3.0.4)
VignetteBuilder:
knitr
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# teal.modules.general 0.2.16.9010

### Enhancements

* Updated the package docs and vignettes with the new way of specifying data for `teal::init()`. The `data` argument will accept a `teal_data` object

### Miscellaneous

* Specified minimal version of package dependencies.
Expand Down
28 changes: 14 additions & 14 deletions R/tm_a_pca.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,25 @@
#'
#' # ADSL example
#'
#' library(nestcolor)
#' ADSL <- teal.modules.general::rADSL
#'
#' data <- teal_data()
#' data <- within(data, {
#' library(nestcolor)
#' ADSL <- teal.modules.general::rADSL
#' })
#' datanames <- c("ADSL")
#' datanames(data) <- datanames
#' join_keys(data) <- default_cdisc_join_keys[datanames]
#' app <- teal::init(
#' data = teal.data::cdisc_data(
#' teal.data::cdisc_dataset(
#' "ADSL", ADSL,
#' code = "ADSL <- teal.modules.general::rADSL"
#' ),
#' check = TRUE
#' ),
#' data = data,
#' modules = teal::modules(
#' teal.modules.general::tm_a_pca(
#' "PCA",
#' dat = teal.transform::data_extract_spec(
#' dataname = "ADSL",
#' select = teal.transform::select_spec(
#' choices = teal.transform::variable_choices(data = ADSL, c("BMRKR1", "AGE", "EOSDY")),
#' choices = teal.transform::variable_choices(
#' data = data[["ADSL"]], c("BMRKR1", "AGE", "EOSDY")
#' ),
#' selected = c("BMRKR1", "AGE"),
#' multiple = TRUE
#' ),
Expand All @@ -56,7 +57,6 @@
#' if (interactive()) {
#' shinyApp(app$ui, app$server)
#' }
#'
tm_a_pca <- function(label = "Principal Component Analysis",
dat,
plot_height = c(600, 200, 2000),
Expand Down Expand Up @@ -257,7 +257,7 @@ srv_a_pca <- function(id, data, reporter, filter_panel_api, dat, plot_height, pl
response[[i]]$select$choices <- var_labels(data[[response[[i]]$dataname]]())
response[[i]]$select$choices <- setdiff(
response[[i]]$select$choices,
unlist(get_join_keys(data)$get(response[[i]]$dataname))
unlist(teal.data::join_keys(data)[[response[[i]]$dataname]])
)
}

Expand Down Expand Up @@ -323,7 +323,7 @@ srv_a_pca <- function(id, data, reporter, filter_panel_api, dat, plot_height, pl
anl_merged_input <- teal.transform::merge_expression_srv(
selector_list = selector_list,
datasets = data,
join_keys = get_join_keys(data)
join_keys = teal.data::join_keys(data)
)

anl_merged_q <- reactive({
Expand Down
18 changes: 11 additions & 7 deletions R/tm_a_regression.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,17 @@
#' # Regression graphs from selected response variable (BMRKR1) and
#' # selected regressors (AGE)
#'
#' ADSL <- teal.modules.general::rADSL
#' data <- teal_data()
#' data <- within(data, {
#' library(nestcolor)
#' ADSL <- teal.modules.general::rADSL
#' })
#' datanames <- c("ADSL")
#' datanames(data) <- datanames
#' join_keys(data) <- default_cdisc_join_keys[datanames]
#'
#' app <- teal::init(
#' data = teal.data::cdisc_data(
#' teal.data::cdisc_dataset("ADSL", ADSL, code = "ADSL <- teal.modules.general::rADSL"),
#' check = TRUE
#' ),
#' data = data,
#' modules = teal::modules(
#' teal.modules.general::tm_a_regression(
#' label = "Regression",
Expand All @@ -58,7 +62,7 @@
#' dataname = "ADSL",
#' select = teal.transform::select_spec(
#' label = "Select variables:",
#' choices = teal.transform::variable_choices(ADSL, c("AGE", "SEX", "RACE")),
#' choices = teal.transform::variable_choices(data[["ADSL"]], c("AGE", "SEX", "RACE")),
#' selected = "AGE",
#' multiple = TRUE,
#' fixed = FALSE
Expand Down Expand Up @@ -291,7 +295,7 @@ srv_a_regression <- function(id,
anl_merged_input <- teal.transform::merge_expression_srv(
selector_list = selector_list,
datasets = data,
join_keys = get_join_keys(data)
join_keys = teal.data::join_keys(data)
)

regression_var <- reactive({
Expand Down
14 changes: 9 additions & 5 deletions R/tm_data_table.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,17 @@
#' @export
#' @examples
#'
#' ADSL <- teal.modules.general::rADSL
#' data <- teal_data()
#' data <- within(data, {
#' library(nestcolor)
#' ADSL <- teal.modules.general::rADSL
#' })
#' datanames <- c("ADSL")
#' datanames(data) <- datanames
#' join_keys(data) <- default_cdisc_join_keys[datanames]
#'
#' app <- teal::init(
#' data = teal.data::cdisc_data(
#' teal.data::cdisc_dataset("ADSL", ADSL, code = "ADSL <- teal.modules.general::rADSL"),
#' check = TRUE
#' ),
#' data = data,
#' modules = teal::modules(
#' teal.modules.general::tm_data_table(
#' variables_selected = list(ADSL = c("STUDYID", "USUBJID", "SUBJID", "SITEID", "AGE", "SEX")),
Expand Down
11 changes: 7 additions & 4 deletions R/tm_file_viewer.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@
#' @export
#'
#' @examples
#' data <- data.frame(1)
#' data <- teal_data()
#' data <- within(data, {
#' data <- data.frame(1)
#' })
#' datanames(data) <- c("data")
#'
#' app <- teal::init(
#' data = teal_data(
#' dataset("data", data)
#' ),
#' data = data,
#' modules = teal::modules(
#' teal.modules.general::tm_file_viewer(
#' input_path = list(
Expand Down
18 changes: 10 additions & 8 deletions R/tm_front_page.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@
#' @export
#' @examples
#'
#' data <- teal_data()
#' data <- within(data, {
#' library(nestcolor)
#' ADSL <- teal.modules.general::rADSL
#' })
#' datanames <- c("ADSL")
#' datanames(data) <- datanames
#' join_keys(data) <- default_cdisc_join_keys[datanames]
#'
#' table_1 <- data.frame(Info = c("A", "B"), Text = c("A", "B"))
#' table_2 <- data.frame(`Column 1` = c("C", "D"), `Column 2` = c(5.5, 6.6), `Column 3` = c("A", "B"))
#' table_3 <- data.frame(Info = c("E", "F"), Text = c("G", "H"))
Expand All @@ -27,15 +36,8 @@
#' "Table 3" = table_3
#' )
#'
#' ADSL <- teal.modules.general::rADSL
#' app <- teal::init(
#' data = teal.data::cdisc_data(
#' teal.data::cdisc_dataset("ADSL", ADSL,
#' code = "ADSL <- teal.modules.general::rADSL",
#' metadata = list("Author" = "NEST team", "data_source" = "synthetic data")
#' ),
#' check = TRUE
#' ),
#' data = data,
#' modules = teal::modules(
#' teal.modules.general::tm_front_page(
#' header_text = c(
Expand Down
21 changes: 12 additions & 9 deletions R/tm_g_association.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,25 @@
#' @examples
#' # Association plot of selected reference variable (SEX)
#' # against other selected variables (BMRKR1)
#' library(nestcolor)
#' ADSL <- teal.modules.general::rADSL
#' data <- teal_data()
#' data <- within(data, {
#' library(nestcolor)
#' ADSL <- teal.modules.general::rADSL
#' })
#' datanames <- c("ADSL")
#' datanames(data) <- datanames
#' join_keys(data) <- default_cdisc_join_keys[datanames]
#'
#' app <- teal::init(
#' data = teal.data::cdisc_data(
#' teal.data::cdisc_dataset("ADSL", ADSL, code = "ADSL <- teal.modules.general::rADSL"),
#' check = TRUE
#' ),
#' data = data,
#' modules = teal::modules(
#' teal.modules.general::tm_g_association(
#' ref = teal.transform::data_extract_spec(
#' dataname = "ADSL",
#' select = teal.transform::select_spec(
#' label = "Select variable:",
#' choices = teal.transform::variable_choices(
#' ADSL,
#' data[["ADSL"]],
#' c("SEX", "RACE", "COUNTRY", "ARM", "STRATA1", "STRATA2", "ITTFL", "BMRKR2")
#' ),
#' selected = "RACE",
Expand All @@ -52,7 +55,7 @@
#' select = teal.transform::select_spec(
#' label = "Select variables:",
#' choices = teal.transform::variable_choices(
#' ADSL,
#' data[["ADSL"]],
#' c("SEX", "RACE", "COUNTRY", "ARM", "STRATA1", "STRATA2", "ITTFL", "BMRKR2")
#' ),
#' selected = "BMRKR2",
Expand Down Expand Up @@ -248,7 +251,7 @@ srv_tm_g_association <- function(id,
anl_merged_input <- teal.transform::merge_expression_srv(
datasets = data,
selector_list = selector_list,
join_keys = get_join_keys(data)
join_keys = teal.data::join_keys(data)
)

anl_merged_q <- reactive({
Expand Down
24 changes: 14 additions & 10 deletions R/tm_g_bivariate.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,24 @@
#'
#' @examples
#' # Bivariate plot of selected variable (AGE) against selected (SEX)
#' ADSL <- teal.modules.general::rADSL
#' data <- teal_data()
#' data <- within(data, {
#' library(nestcolor)
#' ADSL <- teal.modules.general::rADSL
#' })
#' datanames <- c("ADSL")
#' datanames(data) <- datanames
#' join_keys(data) <- default_cdisc_join_keys[datanames]
#'
#' app <- teal::init(
#' data = teal.data::cdisc_data(
#' teal.data::cdisc_dataset("ADSL", ADSL, code = "ADSL <- teal.modules.general::rADSL"),
#' check = TRUE
#' ),
#' data = data,
#' modules = teal::modules(
#' teal.modules.general::tm_g_bivariate(
#' x = teal.transform::data_extract_spec(
#' dataname = "ADSL",
#' select = teal.transform::select_spec(
#' label = "Select variable:",
#' choices = teal.transform::variable_choices(ADSL),
#' choices = teal.transform::variable_choices(data[["ADSL"]]),
#' selected = "AGE",
#' fixed = FALSE
#' )
Expand All @@ -67,7 +71,7 @@
#' dataname = "ADSL",
#' select = teal.transform::select_spec(
#' label = "Select variable:",
#' choices = teal.transform::variable_choices(ADSL),
#' choices = teal.transform::variable_choices(data[["ADSL"]]),
#' selected = "SEX",
#' multiple = FALSE,
#' fixed = FALSE
Expand All @@ -77,7 +81,7 @@
#' dataname = "ADSL",
#' select = teal.transform::select_spec(
#' label = "Select variable:",
#' choices = teal.transform::variable_choices(ADSL),
#' choices = teal.transform::variable_choices(data[["ADSL"]]),
#' selected = "ARM",
#' fixed = FALSE
#' )
Expand All @@ -86,7 +90,7 @@
#' dataname = "ADSL",
#' select = teal.transform::select_spec(
#' label = "Select variable:",
#' choices = teal.transform::variable_choices(ADSL),
#' choices = teal.transform::variable_choices(data[["ADSL"]]),
#' selected = "COUNTRY",
#' fixed = FALSE
#' )
Expand Down Expand Up @@ -437,7 +441,7 @@ srv_g_bivariate <- function(id,
anl_merged_input <- teal.transform::merge_expression_srv(
selector_list = selector_list,
datasets = data,
join_keys = get_join_keys(data)
join_keys = teal.data::join_keys(data)
)

anl_merged_q <- reactive({
Expand Down
32 changes: 22 additions & 10 deletions R/tm_g_distribution.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,15 @@
#'
#' @examples
#' # Example with non-clinical data
#'
#' data <- teal_data()
#' data <- within(data, {
#' iris <- iris
#' })
#' datanames(data) <- c("iris")
#'
#' app <- teal::init(
#' data = teal_data(dataset("iris", iris)),
#' data = data,
#' modules = list(
#' teal.modules.general::tm_g_distribution(
#' dist_var = teal.transform::data_extract_spec(
Expand All @@ -48,22 +55,27 @@
#' }
#'
#' # Example with clinical data
#' ADSL <- teal.modules.general::rADSL
#' data <- teal_data()
#' data <- within(data, {
#' ADSL <- teal.modules.general::rADSL
#' })
#' datanames <- c("ADSL")
#' datanames(data) <- datanames
#' join_keys(data) <- default_cdisc_join_keys[datanames]
#'
#' vars1 <- choices_selected(variable_choices(ADSL, c("ARM", "COUNTRY", "SEX")), selected = NULL)
#' vars1 <- choices_selected(
#' variable_choices(data[["ADSL"]], c("ARM", "COUNTRY", "SEX")),
#' selected = NULL
#' )
#'
#' app <- teal::init(
#' data = teal.data::cdisc_data(
#' teal.data::cdisc_dataset("ADSL", ADSL),
#' code = "ADSL <- teal.modules.general::rADSL",
#' check = FALSE
#' ),
#' data = data,
#' modules = teal::modules(
#' teal.modules.general::tm_g_distribution(
#' dist_var = teal.transform::data_extract_spec(
#' dataname = "ADSL",
#' select = teal.transform::select_spec(
#' choices = teal.transform::variable_choices(ADSL, c("AGE", "BMRKR1")),
#' choices = teal.transform::variable_choices(data[["ADSL"]], c("AGE", "BMRKR1")),
#' selected = "BMRKR1",
#' multiple = FALSE,
#' fixed = FALSE
Expand Down Expand Up @@ -435,7 +447,7 @@ srv_distribution <- function(id,
anl_merged_input <- teal.transform::merge_expression_srv(
selector_list = selector_list,
datasets = data,
join_keys = get_join_keys(data)
join_keys = teal.data::join_keys(data)
)

anl_merged_q <- reactive({
Expand Down
Loading