Skip to content

Commit

Permalink
Update docs to use the new teal_data instead of TealData (#853)
Browse files Browse the repository at this point in the history
fixes
#842
part of
insightsengineering/nestdevs-tasks#41
insightsengineering/teal.data#184

 

- [x] add thenews section for change.
- [x]  update the examples in the documentation to pass teal_data.
- [x] update join_keys calls once the pull request is completed at
insightsengineering/teal.data#184.
- [x]  Revise and update the vignettes accordingly.
- [ ] make version bump once
insightsengineering/teal.data#184. is merged.

---------

Co-authored-by: 27856297+dependabot-preview[bot]@users.noreply.github.com <27856297+dependabot-preview[bot]@users.noreply.github.com>
Co-authored-by: vedhav <[email protected]>
  • Loading branch information
3 people authored Nov 20, 2023
1 parent 21d2ede commit bcb9ae1
Show file tree
Hide file tree
Showing 75 changed files with 1,339 additions and 971 deletions.
7 changes: 4 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ BugReports:
https://github.com/insightsengineering/teal.modules.clinical/issues
Depends:
R (>= 4.0),
teal (>= 0.14.0),
teal (>= 0.14.0.9019),
tern (>= 0.8.2)
Imports:
assertthat,
Expand Down Expand Up @@ -54,10 +54,10 @@ Imports:
stats,
styler,
teal.code (>= 0.4.0),
teal.data (>= 0.3.0.9009),
teal.data (>= 0.3.0.9010),
teal.logger (>= 0.1.1),
teal.reporter (>= 0.2.0),
teal.transform (>= 0.4.0),
teal.transform (>= 0.4.0.9007),
teal.widgets (>= 0.4.0),
tern.gee (>= 0.1.0),
tern.mmrm (>= 0.2.1),
Expand All @@ -69,6 +69,7 @@ Suggests:
knitr,
lubridate,
nestcolor (>= 0.1.0),
teal.data (>= 0.3.0.9010),
testthat (>= 3.0)
VignetteBuilder:
knitr
Expand Down
7 changes: 6 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# teal.modules.clinical 0.8.16.9011

### Enhancements
* Updated the documentation and vignettes to demonstrate method to pass `teal_data` object to `teal::init()`.

# teal.modules.clinical 0.8.16.9010

### Enhancements
Expand All @@ -13,7 +18,7 @@
* Updated `tm_t_pp_basic_info`, `tm_t_pp_medical_history`, `tm_g_pp_therapy`, `tm_g_pp_adverse_events`, and `tm_t_pp_laboratory` to print patient ID above table.
* Updated `tm_t_pp_basic_info`, `tm_g_pp_therapy`, `tm_g_pp_adverse_events`, and `tm_t_pp_laboratory` to use `rlistings` to print data neatly in reports.
* Updated `tm_g_lineplot` to allow user to remove interval from plot.

* Updated the documentation and vignettes to demonstrate method to pass `teal_data` object to `teal::init()`.

### Bug fixes
* Fixed bug in `tm_t_coxreg` preventing table from being displayed when no covariates are selected.
Expand Down
41 changes: 22 additions & 19 deletions R/tm_a_gee.R
Original file line number Diff line number Diff line change
Expand Up @@ -128,24 +128,27 @@ template_a_gee <- function(output_table,
#' @export
#'
#' @examples
#' adsl <- tmc_ex_adsl
#' adqs <- tmc_ex_adqs %>%
#' dplyr::filter(ABLFL != "Y" & ABLFL2 != "Y") %>%
#' dplyr::mutate(
#' AVISIT = as.factor(AVISIT),
#' AVISITN = rank(AVISITN) %>%
#' as.factor() %>%
#' as.numeric() %>%
#' as.factor(),
#' AVALBIN = AVAL < 50 # Just as an example to get a binary endpoint.
#' ) %>%
#' droplevels()
#' data <- teal_data()
#' data <- within(data, {
#' ADSL <- tmc_ex_adsl
#' ADQS <- tmc_ex_adqs %>%
#' dplyr::filter(ABLFL != "Y" & ABLFL2 != "Y") %>%
#' dplyr::mutate(
#' AVISIT = as.factor(AVISIT),
#' AVISITN = rank(AVISITN) %>%
#' as.factor() %>%
#' as.numeric() %>%
#' as.factor(),
#' AVALBIN = AVAL < 50 #' Just as an example to get a binary endpoint.
#' ) %>%
#' droplevels()
#' })
#' datanames <- c("ADSL", "ADQS")
#' datanames(data) <- datanames
#' join_keys(data) <- default_cdisc_join_keys[datanames]
#'
#' app <- init(
#' data = cdisc_data(
#' cdisc_dataset("ADSL", adsl),
#' cdisc_dataset("ADQS", adqs)
#' ),
#' data = data,
#' modules = modules(
#' tm_a_gee(
#' label = "GEE",
Expand All @@ -155,7 +158,7 @@ template_a_gee <- function(output_table,
#' arm_var = choices_selected(c("ARM", "ARMCD"), "ARM"),
#' visit_var = choices_selected(c("AVISIT", "AVISITN"), "AVISIT"),
#' paramcd = choices_selected(
#' choices = value_choices(adqs, "PARAMCD", "PARAM"),
#' choices = value_choices(data[["ADQS"]], "PARAMCD", "PARAM"),
#' selected = "FKSI-FWB"
#' ),
#' cov_var = choices_selected(c("BASE", "AGE", "SEX", "BASE:AVISIT"), NULL)
Expand Down Expand Up @@ -444,14 +447,14 @@ srv_gee <- function(id,
datasets = data,
selector_list = selector_list,
merge_function = "dplyr::inner_join",
join_keys = teal.data::get_join_keys(data)
join_keys = teal.data::join_keys(data)
)

adsl_inputs <- teal.transform::merge_expression_module(
datasets = data,
data_extract = list(arm_var = arm_var),
anl_name = "ANL_ADSL",
join_keys = teal.data::get_join_keys(data)
join_keys = teal.data::join_keys(data)
)

anl_q <- shiny::reactive({
Expand Down
41 changes: 22 additions & 19 deletions R/tm_a_mmrm.R
Original file line number Diff line number Diff line change
Expand Up @@ -452,30 +452,33 @@ template_mmrm_plots <- function(fit_name,
#' numerical precision.
#'
#' @examples
#' adsl <- tmc_ex_adsl
#' adqs <- tmc_ex_adqs %>%
#' dplyr::filter(ABLFL != "Y" & ABLFL2 != "Y") %>%
#' dplyr::filter(AVISIT %in% c("WEEK 1 DAY 8", "WEEK 2 DAY 15", "WEEK 3 DAY 22")) %>%
#' dplyr::mutate(
#' AVISIT = as.factor(AVISIT),
#' AVISITN = rank(AVISITN) %>%
#' as.factor() %>%
#' as.numeric() %>%
#' as.factor() # making consecutive numeric factor
#' )
#'
#' arm_ref_comp <- list(
#' ARMCD = list(
#' ref = "ARM B",
#' comp = c("ARM A", "ARM C")
#' )
#' )
#'
#' data <- teal_data()
#' data <- within(data, {
#' ADSL <- tmc_ex_adsl
#' ADQS <- tmc_ex_adqs %>%
#' dplyr::filter(ABLFL != "Y" & ABLFL2 != "Y") %>%
#' dplyr::filter(AVISIT %in% c("WEEK 1 DAY 8", "WEEK 2 DAY 15", "WEEK 3 DAY 22")) %>%
#' dplyr::mutate(
#' AVISIT = as.factor(AVISIT),
#' AVISITN = rank(AVISITN) %>%
#' as.factor() %>%
#' as.numeric() %>%
#' as.factor() #' making consecutive numeric factor
#' )
#' })
#'
#' datanames <- c("ADSL", "ADQS")
#' datanames(data) <- datanames
#' join_keys(data) <- default_cdisc_join_keys[datanames]
#' app <- init(
#' data = cdisc_data(
#' cdisc_dataset("ADSL", adsl),
#' cdisc_dataset("ADQS", adqs)
#' ),
#' data = data,
#' modules = modules(
#' tm_a_mmrm(
#' label = "MMRM",
Expand All @@ -486,7 +489,7 @@ template_mmrm_plots <- function(fit_name,
#' visit_var = choices_selected(c("AVISIT", "AVISITN"), "AVISIT"),
#' arm_ref_comp = arm_ref_comp,
#' paramcd = choices_selected(
#' choices = value_choices(adqs, "PARAMCD", "PARAM"),
#' choices = value_choices(data[["ADQS"]], "PARAMCD", "PARAM"),
#' selected = "FKSI-FWB"
#' ),
#' cov_var = choices_selected(c("BASE", "AGE", "SEX", "BASE:AVISIT"), NULL)
Expand Down Expand Up @@ -917,14 +920,14 @@ srv_mmrm <- function(id,
anl_inputs <- teal.transform::merge_expression_srv(
datasets = data,
selector_list = selector_list_without_cov,
join_keys = teal.data::get_join_keys(data),
join_keys = teal.data::join_keys(data),
merge_function = "dplyr::inner_join"
)

adsl_merge_inputs <- teal.transform::merge_expression_module(
datasets = data,
data_extract = list(arm_var = arm_var),
join_keys = teal.data::get_join_keys(data),
join_keys = teal.data::join_keys(data),
anl_name = "ANL_ADSL"
)

Expand Down
33 changes: 20 additions & 13 deletions R/tm_g_barchart_simple.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,21 @@
#' @examples
#' library(nestcolor)
#'
#' adsl <- tmc_ex_adsl %>% dplyr::mutate(ITTFL = factor("Y") %>%
#' formatters::with_label("Intent-To-Treat Population Flag"))
#' adae <- tmc_ex_adae %>% dplyr::filter(!((AETOXGR == 1) & (AESEV == "MILD") & (ARM == "A: Drug X")))
#' ADSL <- tmc_ex_adsl %>%
#' dplyr::mutate(ITTFL = factor("Y") %>%
#' formatters::with_label("Intent-To-Treat Population Flag"))
#' ADAE <- tmc_ex_adae %>%
#' dplyr::filter(!((AETOXGR == 1) & (AESEV == "MILD") & (ARM == "A: Drug X")))
#'
#' app <- init(
#' data = cdisc_data(
#' cdisc_dataset("ADSL", adsl),
#' cdisc_dataset("ADAE", adae)
#' ADSL = ADSL,
#' ADAE = ADAE,
#' code = "ADSL <- tmc_ex_adsl %>%
#' dplyr::mutate(ITTFL = factor(\"Y\") %>%
#' formatters::with_label(\"Intent-To-Treat Population Flag\"))
#' ADAE <- tmc_ex_adae %>%
#' dplyr::filter(!((AETOXGR == 1) & (AESEV == \"MILD\") & (ARM == \"A: Drug X\")))"
#' ),
#' modules = modules(
#' tm_g_barchart_simple(
Expand All @@ -32,7 +39,7 @@
#' dataname = "ADSL",
#' select = select_spec(
#' choices = variable_choices(
#' adsl,
#' ADSL,
#' c(
#' "ARM", "ACTARM", "SEX",
#' "RACE", "ITTFL", "SAFFL", "STRATA2"
Expand All @@ -47,7 +54,7 @@
#' dataname = "ADSL",
#' select = select_spec(
#' choices = variable_choices(
#' adsl,
#' ADSL,
#' c(
#' "ARM", "ACTARM", "SEX",
#' "RACE", "ITTFL", "SAFFL", "STRATA2"
Expand All @@ -60,7 +67,7 @@
#' data_extract_spec(
#' dataname = "ADAE",
#' select = select_spec(
#' choices = variable_choices(adae, c("AETOXGR", "AESEV", "AESER")),
#' choices = variable_choices(ADAE, c("AETOXGR", "AESEV", "AESER")),
#' selected = NULL,
#' multiple = FALSE
#' )
Expand All @@ -70,7 +77,7 @@
#' data_extract_spec(
#' dataname = "ADAE",
#' select = select_spec(
#' choices = variable_choices(adae, c("AETOXGR", "AESEV", "AESER")),
#' choices = variable_choices(ADAE, c("AETOXGR", "AESEV", "AESER")),
#' selected = "AETOXGR",
#' multiple = FALSE
#' )
Expand All @@ -79,7 +86,7 @@
#' dataname = "ADSL",
#' select = select_spec(
#' choices = variable_choices(
#' adsl,
#' ADSL,
#' c(
#' "ARM", "ACTARM", "SEX",
#' "RACE", "ITTFL", "SAFFL", "STRATA2"
Expand All @@ -94,7 +101,7 @@
#' data_extract_spec(
#' dataname = "ADAE",
#' select = select_spec(
#' choices = variable_choices(adae, c("AETOXGR", "AESEV", "AESER")),
#' choices = variable_choices(ADAE, c("AETOXGR", "AESEV", "AESER")),
#' selected = "AESEV",
#' multiple = FALSE
#' )
Expand All @@ -103,7 +110,7 @@
#' dataname = "ADSL",
#' select = select_spec(
#' choices = variable_choices(
#' adsl,
#' ADSL,
#' c(
#' "ARM", "ACTARM", "SEX",
#' "RACE", "ITTFL", "SAFFL", "STRATA2"
Expand Down Expand Up @@ -374,7 +381,7 @@ srv_g_barchart_simple <- function(id,

anl_inputs <- teal.transform::merge_expression_srv(
datasets = data,
join_keys = teal.data::get_join_keys(data),
join_keys = teal.data::join_keys(data),
selector_list = selector_list
)

Expand Down
22 changes: 13 additions & 9 deletions R/tm_g_ci.R
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,17 @@ template_g_ci <- function(dataname, # nolint
#' @examples
#' library(nestcolor)
#'
#' adsl <- tmc_ex_adsl
#' adlb <- tmc_ex_adlb
#' ADSL <- tmc_ex_adsl
#' ADLB <- tmc_ex_adlb
#'
#' app <- init(
#' data = cdisc_data(
#' cdisc_dataset("ADSL", adsl),
#' cdisc_dataset("ADLB", adlb)
#' ADSL = ADSL,
#' ADLB = ADLB,
#' code = "
#' ADSL <- tmc_ex_adsl
#' ADLB <- tmc_ex_adlb
#' "
#' ),
#' modules = modules(
#' tm_g_ci(
Expand All @@ -217,15 +221,15 @@ template_g_ci <- function(dataname, # nolint
#' filter = list(
#' filter_spec(
#' vars = "PARAMCD",
#' choices = levels(adlb$PARAMCD),
#' selected = levels(adlb$PARAMCD)[1],
#' choices = levels(ADLB$PARAMCD),
#' selected = levels(ADLB$PARAMCD)[1],
#' multiple = FALSE,
#' label = "Select lab:"
#' ),
#' filter_spec(
#' vars = "AVISIT",
#' choices = levels(adlb$AVISIT),
#' selected = levels(adlb$AVISIT)[1],
#' choices = levels(ADLB$AVISIT),
#' selected = levels(ADLB$AVISIT)[1],
#' multiple = FALSE,
#' label = "Select visit:"
#' )
Expand Down Expand Up @@ -399,7 +403,7 @@ srv_g_ci <- function(id, # nolint

anl_inputs <- teal.transform::merge_expression_srv(
datasets = data,
join_keys = teal.data::get_join_keys(data),
join_keys = teal.data::join_keys(data),
selector_list = selector_list
)

Expand Down
Loading

0 comments on commit bcb9ae1

Please sign in to comment.