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

Replace TealData with teal_data in the docs #845

Closed
wants to merge 11 commits into from
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Suggests:
knitr,
lubridate,
nestcolor (>= 0.1.0),
teal.data (>= 0.3.0),
teal.data (>= 0.3.0.9008),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually, I guess we only work after the changes are merged into main and get the proper version. But, since in this case, we're working on top of unmerged changes the version will be higher than this. If everything goes well and we merge join_keys PR first it will be 0.3.0.9009 so I saw we wait for the version bump till the teal.data join_keys PR is merged.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

YEs, once join_keys PR is merged. will make consistent version bump to all the replace doc PR for teal.data

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

testthat (>= 3.0)
VignetteBuilder:
knitr
Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,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
#' data@join_keys <- cdisc_join_keys(!!!datanames)
#'
#' app <- init(
#' data = cdisc_data(
#' cdisc_dataset("ADSL", adsl),
#' cdisc_dataset("ADQS", adqs)
Comment on lines -146 to -147
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this was not the case before, But I think we should make the teal_data object reproducible so that the code in the Show R code works. Right now it won't work because the data creation code is not specified.

@kartikeyakirar what do you think about adding it for all the examples so they are improved?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think its good idea. However, considering that these are for example for TMC modules and the preprocessing code be lengthy in some cases, which in turn might elongate the 'cdisc_data' call, I would lean towards not including it in for all the examples.
@gogonzo @donyunardi WDYT?

Copy link
Contributor

@vedhav vedhav Nov 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there is no need to specify the code anymore, we have the new within() function. I think we need to document it as I believe it's the best practice.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are very few examples like that, and it's included in most of the tmg examples. I will make the update.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vedhav I think this qualifies to another issue. @kartikeyakirar feel free to make code reproducible or keep as reproducible as it was before. We need this soon on @main so I advise to make this branch ready as quick as possible.

#' ),
#' 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 = get_join_keys(data)
join_keys = teal.data::get_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 = get_join_keys(data)
join_keys = teal.data::get_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
#' data@join_keys <- 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 = get_join_keys(data),
join_keys = teal.data::get_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 = get_join_keys(data),
join_keys = teal.data::get_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 = get_join_keys(data),
join_keys = teal.data::get_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 = get_join_keys(data),
join_keys = teal.data::get_join_keys(data),
selector_list = selector_list
)

Expand Down
27 changes: 17 additions & 10 deletions R/tm_g_forest_rsp.R
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ template_forest_rsp <- function(dataname = "ANL",
#' @examples
#' library(nestcolor)
#'
#' adsl <- tmc_ex_adsl
#' adrs <- tmc_ex_adrs %>%
#' ADSL <- tmc_ex_adsl
#' ADRS <- tmc_ex_adrs %>%
#' dplyr::mutate(AVALC = tern::d_onco_rsp_label(AVALC) %>%
#' formatters::with_label("Character Result/Finding")) %>%
#' dplyr::filter(PARAMCD != "OVRINV" | AVISIT == "FOLLOW UP")
Expand All @@ -236,28 +236,35 @@ template_forest_rsp <- function(dataname = "ANL",
#'
#' app <- init(
#' data = cdisc_data(
#' cdisc_dataset("ADSL", adsl),
#' cdisc_dataset("ADRS", adrs)
#' ADSL = ADSL,
#' ADRS = ADRS,
#' code = "
#' ADSL <- tmc_ex_adsl
#' ADRS <- tmc_ex_adrs %>%
#' dplyr::mutate(AVALC = tern::d_onco_rsp_label(AVALC) %>%
#' formatters::with_label(\"Character Result/Finding\")) %>%
#' dplyr::filter(PARAMCD != \"OVRINV\" | AVISIT == \"FOLLOW UP\")
#' "
#' ),
#' modules = modules(
#' tm_g_forest_rsp(
#' label = "Forest Response",
#' dataname = "ADRS",
#' arm_var = choices_selected(
#' variable_choices(adsl, c("ARM", "ARMCD")),
#' variable_choices(ADSL, c("ARM", "ARMCD")),
#' "ARMCD"
#' ),
#' arm_ref_comp = arm_ref_comp,
#' paramcd = choices_selected(
#' value_choices(adrs, "PARAMCD", "PARAM"),
#' value_choices(ADRS, "PARAMCD", "PARAM"),
#' "INVET"
#' ),
#' subgroup_var = choices_selected(
#' variable_choices(adsl, names(adsl)),
#' variable_choices(ADSL, names(ADSL)),
#' c("BMRKR2", "SEX")
#' ),
#' strata_var = choices_selected(
#' variable_choices(adsl, c("STRATA1", "STRATA2")),
#' variable_choices(ADSL, c("STRATA1", "STRATA2")),
#' "STRATA2"
#' ),
#' plot_height = c(600L, 200L, 2000L),
Expand Down Expand Up @@ -514,13 +521,13 @@ srv_g_forest_rsp <- function(id,
datasets = data,
selector_list = selector_list,
merge_function = "dplyr::inner_join",
join_keys = get_join_keys(data)
join_keys = teal.data::get_join_keys(data)
)

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

Expand Down
Loading