Skip to content

Commit

Permalink
adding code for reproducibility and updated news
Browse files Browse the repository at this point in the history
  • Loading branch information
kartikeyakirar committed Nov 8, 2023
1 parent b5c3b8a commit 2bfb054
Show file tree
Hide file tree
Showing 73 changed files with 1,293 additions and 943 deletions.
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(
#' ADSL = adsl,
#' 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::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(
#' ADSL = adsl,
#' 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
27 changes: 15 additions & 12 deletions R/tm_g_barchart_simple.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,17 @@
#' @examples
#' library(nestcolor)
#'
#' adsl <- tmc_ex_adsl %>% dplyr::mutate(ITTFL = factor("Y") %>%
#' 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")))
#' ADAE <- tmc_ex_adae %>% dplyr::filter(!((AETOXGR == 1) & (AESEV == "MILD") & (ARM == "A: Drug X")))
#'
#' app <- init(
#' data = cdisc_data(
#' ADSL = adsl,
#' 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 +35,7 @@
#' dataname = "ADSL",
#' select = select_spec(
#' choices = variable_choices(
#' adsl,
#' ADSL,
#' c(
#' "ARM", "ACTARM", "SEX",
#' "RACE", "ITTFL", "SAFFL", "STRATA2"
Expand All @@ -47,7 +50,7 @@
#' dataname = "ADSL",
#' select = select_spec(
#' choices = variable_choices(
#' adsl,
#' ADSL,
#' c(
#' "ARM", "ACTARM", "SEX",
#' "RACE", "ITTFL", "SAFFL", "STRATA2"
Expand All @@ -60,7 +63,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 +73,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 +82,7 @@
#' dataname = "ADSL",
#' select = select_spec(
#' choices = variable_choices(
#' adsl,
#' ADSL,
#' c(
#' "ARM", "ACTARM", "SEX",
#' "RACE", "ITTFL", "SAFFL", "STRATA2"
Expand All @@ -94,7 +97,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 +106,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 +377,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(
#' ADSL = adsl,
#' 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(
#' ADSL = adsl,
#' 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

0 comments on commit 2bfb054

Please sign in to comment.