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 #847

Closed
Closed
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
b5c3b8a
refactoring cdisc_dataset() call to return teal_data()
kartikeyakirar Nov 7, 2023
d79eff1
[skip actions] Roxygen Man Pages Auto Update
dependabot-preview[bot] Nov 7, 2023
2bfb054
adding code for reproducibility and updated news
kartikeyakirar Nov 8, 2023
3a11031
Merge branch '842_replace_tealdata@main' of https://github.com/insigh…
kartikeyakirar Nov 8, 2023
07fd195
fixing join_key issues.
kartikeyakirar Nov 8, 2023
f3d6296
included code vignettes and fixing notes
kartikeyakirar Nov 8, 2023
a5643f4
addressing comment.
kartikeyakirar Nov 8, 2023
bbbee71
[skip actions] Roxygen Man Pages Auto Update
dependabot-preview[bot] Nov 8, 2023
cb4bccc
fixing styling and rd files
kartikeyakirar Nov 8, 2023
00ecbf5
[skip actions] Roxygen Man Pages Auto Update
dependabot-preview[bot] Nov 8, 2023
b560850
'Empty-Commit'
kartikeyakirar Nov 9, 2023
8fb47d5
adding join_key changes.
kartikeyakirar Nov 9, 2023
2dbd454
[skip actions] Roxygen Man Pages Auto Update
dependabot-preview[bot] Nov 9, 2023
f1012b2
'Empty-Commit'
kartikeyakirar Nov 9, 2023
e94c435
change to default_cdisc_join_keys call.
kartikeyakirar Nov 14, 2023
f65f3f1
[skip actions] Roxygen Man Pages Auto Update
dependabot-preview[bot] Nov 14, 2023
db0ed70
'Empty-Commit'
kartikeyakirar Nov 14, 2023
daea598
simpler join_keys api
kartikeyakirar Nov 15, 2023
6bfbebc
Apply suggestions from code review
kartikeyakirar Nov 15, 2023
ede7aac
resolve conflicts.
kartikeyakirar Nov 16, 2023
8ccac08
bump news.md version
kartikeyakirar Nov 16, 2023
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
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),
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
#' join_keys(data) <- cdisc_join_keys(!!!datanames)
kartikeyakirar marked this conversation as resolved.
Show resolved Hide resolved
#'
#' 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 = 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 = 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) <- 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::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::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::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::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::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::join_keys(data),
anl_name = "ANL_ADSL"
)

Expand Down
Loading