Skip to content

Commit

Permalink
Add TMC example data (#731)
Browse files Browse the repository at this point in the history
Closes #729

---------

Co-authored-by: 27856297+dependabot-preview[bot]@users.noreply.github.com <27856297+dependabot-preview[bot]@users.noreply.github.com>
  • Loading branch information
edelarua and dependabot-preview[bot] authored Mar 1, 2023
1 parent 2b93de5 commit 327fd66
Show file tree
Hide file tree
Showing 41 changed files with 1,487 additions and 635 deletions.
4 changes: 2 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
* Removed unused argument `param` from `tm_g_pp_vitals`.
* Removed optimizer choice from `tm_a_mmrm` since we can just always use the
automatically determined optimizer.
* Creation of internal data for `adsl`, `adae`, `adlb`, `adcm`, `adrs`, and `adtte`. They are accessible
via `tmc_ex_*` prefix.
* Creation of internal data for `adsl`, `adae`, `adaette`, `adcm`, `adeg`, `adex`, `adlb`, `admh`, `adqs`, `adrs`, `adtte`, and `advs`.
They are accessible via `tmc_ex_*` prefix.
* Partial substitution of `scda` data with internal data in examples.

# teal.modules.clinical 0.8.14
Expand Down
29 changes: 27 additions & 2 deletions R/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,42 @@ NULL
#'
"tmc_ex_adae"

#' @describeIn ex_data ADAETTE data
#'
"tmc_ex_adaette"

#' @describeIn ex_data ADCM data
#'
"tmc_ex_adcm"

#' @describeIn ex_data ADEG data
#'
"tmc_ex_adeg"

#' @describeIn ex_data ADEX data
#'
"tmc_ex_adex"

#' @describeIn ex_data ADLB data
#'
"tmc_ex_adlb"

#' @describeIn ex_data ADMH data
#'
"tmc_ex_admh"

#' @describeIn ex_data ADQS data
#'
"tmc_ex_adqs"

#' @describeIn ex_data ADRS data
#'
"tmc_ex_adrs"

#' @describeIn ex_data ADTTE data
#'
"tmc_ex_adtte"
#' @describeIn ex_data ADCM data

#' @describeIn ex_data ADVS data
#'
"tmc_ex_adcm"
"tmc_ex_advs"
3 changes: 1 addition & 2 deletions R/labels.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
#' column_annotation_label(data, "cyl")
#' column_annotation_label(data, "cyl", omit_raw_name = TRUE)
#' \dontrun{
#' ANL <- synthetic_cdisc_dataset("latest", "adsl")
#' column_annotation_label(ANL, "ACTARM")
#' column_annotation_label(tmc_ex_adsl, "ACTARM")
#' }
#' @export
column_annotation_label <- function(dataset, column, omit_raw_name = FALSE) {
Expand Down
25 changes: 5 additions & 20 deletions R/tm_a_gee.R
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,8 @@ template_a_gee <- function(output_table,
#' @export
#'
#' @examples
#' library(scda)
#'
#' ADSL <- synthetic_cdisc_dataset("latest", "adsl")
#' ADQS <- synthetic_cdisc_dataset("latest", "adqs") %>%
#' adsl <- tmc_ex_adsl
#' adqs <- tmc_ex_adqs %>%
#' dplyr::filter(ABLFL != "Y" & ABLFL2 != "Y") %>%
#' dplyr::mutate(
#' AVISIT = as.factor(AVISIT),
Expand All @@ -145,21 +143,8 @@ template_a_gee <- function(output_table,
#'
#' app <- init(
#' data = cdisc_data(
#' cdisc_dataset("ADSL", ADSL),
#' cdisc_dataset("ADQS", ADQS,
#' code = 'ADQS <- synthetic_cdisc_dataset("latest", "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()
#' '
#' )
#' cdisc_dataset("ADSL", adsl),
#' cdisc_dataset("ADQS", adqs)
#' ),
#' modules = modules(
#' tm_a_gee(
Expand All @@ -170,7 +155,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(adqs, "PARAMCD", "PARAM"),
#' selected = "FKSI-FWB"
#' ),
#' cov_var = choices_selected(c("BASE", "AGE", "SEX"), NULL)
Expand Down
31 changes: 8 additions & 23 deletions R/tm_a_mmrm.R
Original file line number Diff line number Diff line change
Expand Up @@ -451,10 +451,8 @@ template_mmrm_plots <- function(fit_name,
#' numerical precision.
#'
#' @examples
#' library(scda)
#'
#' ADSL <- synthetic_cdisc_dataset("latest", "adsl")
#' ADQS <- synthetic_cdisc_dataset("latest", "adqs") %>%
#' 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(
Expand All @@ -474,21 +472,8 @@ template_mmrm_plots <- function(fit_name,
#'
#' app <- init(
#' data = cdisc_data(
#' cdisc_dataset("ADSL", ADSL,
#' code = 'ADSL <- synthetic_cdisc_dataset("latest", "adsl")'
#' ),
#' cdisc_dataset("ADQS", ADQS,
#' code = 'ADQS <- synthetic_cdisc_dataset("latest", "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
#' )'
#' )
#' cdisc_dataset("ADSL", adsl),
#' cdisc_dataset("ADQS", adqs)
#' ),
#' modules = modules(
#' tm_a_mmrm(
Expand All @@ -500,7 +485,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(adqs, "PARAMCD", "PARAM"),
#' selected = "FKSI-FWB"
#' ),
#' cov_var = choices_selected(c("BASE", "AGE", "SEX", "BASE:AVISIT"), NULL)
Expand Down Expand Up @@ -1110,8 +1095,8 @@ srv_mmrm <- function(id,
state_has_changed <- shiny::reactive({
shiny::req(state$input)
displayed_state <- mmrm_inputs_reactive()
equal_ADSL <- dplyr::all_equal(state$input$adsl_filtered, displayed_state$adsl_filtered) # nolint
equal_dataname <- dplyr::all_equal(state$input$anl_filtered, displayed_state$anl_filtered)
equal_ADSL <- all.equal(state$input$adsl_filtered, displayed_state$adsl_filtered) # nolint
equal_dataname <- all.equal(state$input$anl_filtered, displayed_state$anl_filtered)
true_means_change <- vapply(
sync_inputs,
FUN = function(x) {
Expand All @@ -1132,7 +1117,7 @@ srv_mmrm <- function(id,
FUN.VALUE = logical(1)
)

# all_equal function either returns TRUE or a character scalar to describe where there is inequality
# all.equal function either returns TRUE or a character scalar to describe where there is inequality
any(c(is.character(equal_ADSL), is.character(equal_dataname), true_means_change))
})

Expand Down
16 changes: 7 additions & 9 deletions R/tm_g_lineplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -205,30 +205,28 @@ template_g_lineplot <- function(dataname = "ANL",
#' @examples
#' library(nestcolor)
#'
#' ADSL <- tmc_ex_adsl
#' ADLB <- tmc_ex_adlb
#'
#' ADLB <- dplyr::mutate(ADLB, AVISIT == forcats::fct_reorder(AVISIT, AVISITN, min))
#' adsl <- tmc_ex_adsl
#' adlb <- tmc_ex_adlb %>% dplyr::mutate(AVISIT == forcats::fct_reorder(AVISIT, AVISITN, min))
#'
#' app <- init(
#' data = cdisc_data(
#' cdisc_dataset("ADSL", ADSL),
#' cdisc_dataset("ADLB", ADLB)
#' cdisc_dataset("ADSL", adsl),
#' cdisc_dataset("ADLB", adlb)
#' ),
#' modules = modules(
#' tm_g_lineplot(
#' label = "Line Plot",
#' dataname = "ADLB",
#' strata = choices_selected(
#' variable_choices(ADSL, c("ARM", "ARMCD", "ACTARMCD")),
#' variable_choices(adsl, c("ARM", "ARMCD", "ACTARMCD")),
#' "ARM"
#' ),
#' y = choices_selected(
#' variable_choices(ADLB, c("AVAL", "BASE", "CHG", "PCHG")),
#' variable_choices(adlb, c("AVAL", "BASE", "CHG", "PCHG")),
#' "AVAL"
#' ),
#' param = choices_selected(
#' value_choices(ADLB, "PARAMCD", "PARAM"),
#' value_choices(adlb, "PARAMCD", "PARAM"),
#' "ALT"
#' )
#' )
Expand Down
19 changes: 7 additions & 12 deletions R/tm_g_pp_vitals.R
Original file line number Diff line number Diff line change
Expand Up @@ -189,20 +189,15 @@ template_vitals <- function(dataname = "ANL",
#' @export
#'
#' @examples
#' library(scda)
#' library(nestcolor)
#'
#' ADSL <- synthetic_cdisc_dataset("latest", "adsl")
#' ADVS <- synthetic_cdisc_dataset("latest", "advs")
#' adsl <- tmc_ex_adsl
#' advs <- tmc_ex_advs
#'
#' app <- init(
#' data = cdisc_data(
#' cdisc_dataset("ADSL", ADSL,
#' code = 'ADSL <- synthetic_cdisc_dataset("latest", "adsl")'
#' ),
#' cdisc_dataset("ADVS", ADVS,
#' code = 'ADVS <- synthetic_cdisc_dataset("latest", "advs")'
#' )
#' cdisc_dataset("ADSL", adsl),
#' cdisc_dataset("ADVS", advs)
#' ),
#' modules = modules(
#' tm_g_pp_vitals(
Expand All @@ -212,15 +207,15 @@ template_vitals <- function(dataname = "ANL",
#' patient_col = "USUBJID",
#' plot_height = c(600L, 200L, 2000L),
#' paramcd = choices_selected(
#' choices = variable_choices(ADVS, "PARAMCD"),
#' choices = variable_choices(advs, "PARAMCD"),
#' selected = "PARAMCD"
#' ),
#' xaxis = choices_selected(
#' choices = variable_choices(ADVS, "ADY"),
#' choices = variable_choices(advs, "ADY"),
#' selected = "ADY"
#' ),
#' aval = choices_selected(
#' choices = variable_choices(ADVS, "AVAL"),
#' choices = variable_choices(advs, "AVAL"),
#' selected = "AVAL"
#' )
#' )
Expand Down
15 changes: 3 additions & 12 deletions R/tm_t_ancova.R
Original file line number Diff line number Diff line change
Expand Up @@ -429,12 +429,8 @@ template_ancova <- function(dataname = "ANL",
#' @export
#'
#' @examples
#' # Preparation of the test case.
#' library(dplyr)
#' library(scda)
#'
#' adsl <- synthetic_cdisc_dataset("latest", "adsl")
#' adqs <- synthetic_cdisc_dataset("latest", "adqs")
#' adsl <- tmc_ex_adsl
#' adqs <- tmc_ex_adqs
#'
#' arm_ref_comp <- list(
#' ARM = list(
Expand All @@ -450,12 +446,7 @@ template_ancova <- function(dataname = "ANL",
#' app <- init(
#' data = cdisc_data(
#' cdisc_dataset("ADSL", adsl),
#' cdisc_dataset("ADQS", adqs),
#' code =
#' '
#' ADSL <- synthetic_cdisc_dataset("latest", "adsl")
#' ADQS <- synthetic_cdisc_dataset("latest", "adqs")
#' '
#' cdisc_dataset("ADQS", adqs)
#' ),
#' modules = modules(
#' tm_t_ancova(
Expand Down
18 changes: 3 additions & 15 deletions R/tm_t_events_patyear.R
Original file line number Diff line number Diff line change
Expand Up @@ -150,28 +150,16 @@ template_events_patyear <- function(dataname,
#'
#' @export
#' @examples
#' # Preparation of the test case.
#' library(dplyr)
#' library(scda)
#'
#' adsl <- synthetic_cdisc_dataset("latest", "adsl")
#' adaette <- synthetic_cdisc_dataset("latest", "adaette")
#' adaette <- adaette %>%
#' adsl <- tmc_ex_adsl
#' adaette <- tmc_ex_adaette %>%
#' dplyr::filter(PARAMCD %in% c("AETTE1", "AETTE2", "AETTE3")) %>%
#' dplyr::mutate(is_event = CNSR == 0) %>%
#' dplyr::mutate(n_events = as.integer(is_event))
#'
#' app <- init(
#' data = cdisc_data(
#' cdisc_dataset("ADSL", adsl),
#' cdisc_dataset("ADAETTE", adaette),
#' code =
#' 'ADSL <- synthetic_cdisc_dataset("latest", "adsl")
#' ADAETTE <- synthetic_cdisc_dataset("latest", "adaette")
#' ADAETTE <- ADAETTE %>%
#' dplyr::filter(PARAMCD %in% c("AETTE1", "AETTE2", "AETTE3")) %>%
#' dplyr::mutate(is_event = CNSR == 0) %>%
#' dplyr::mutate(n_events = as.integer(is_event))' # nolint
#' cdisc_dataset("ADAETTE", adaette)
#' ),
#' modules = modules(
#' tm_t_events_patyear(
Expand Down
34 changes: 8 additions & 26 deletions R/tm_t_exposure.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

#' Template: Exposure Table for Risk management plan
#'
#' @inheritParams template_arguments
Expand Down Expand Up @@ -233,43 +232,26 @@ template_exposure <- function(parentname,
#' @export
#'
#' @examples
#' library(scda)
#' library(dplyr)
#'
#' adsl <- synthetic_cdisc_dataset("latest", "adsl")
#' adex <- synthetic_cdisc_dataset("latest", "adex")
#' adsl <- tmc_ex_adsl
#' adex <- tmc_ex_adex
#'
#' set.seed(1, kind = "Mersenne-Twister")
#' labels <- formatters::var_labels(adex, fill = FALSE)
#' adex <- adex %>%
#' distinct(USUBJID, .keep_all = TRUE) %>%
#' mutate(
#' dplyr::distinct(USUBJID, .keep_all = TRUE) %>%
#' dplyr::mutate(
#' PARAMCD = "TDURD",
#' PARAM = "Overall duration (days)",
#' AVAL = sample(x = seq(1, 200), size = n(), replace = TRUE),
#' AVAL = sample(x = seq(1, 200), size = dplyr::n(), replace = TRUE),
#' AVALU = "Days"
#' ) %>%
#' bind_rows(adex)
#' dplyr::bind_rows(adex)
#' formatters::var_labels(adex) <- labels
#'
#' app <- init(
#' data = cdisc_data(
#' cdisc_dataset("ADSL", adsl,
#' code = 'ADSL <- synthetic_cdisc_dataset("latest", "adsl")'
#' ),
#' cdisc_dataset("ADEX", adex,
#' code = 'set.seed(1, kind = "Mersenne-Twister")
#' ADEX <- synthetic_cdisc_dataset("latest", "adsl")
#' labels <- formatters::var_labels(ADEX, fill = FALSE)
#' ADEX <- ADEX %>%
#' distinct(USUBJID, .keep_all = TRUE) %>%
#' mutate(PARAMCD = "TDURD",
#' PARAM = "Overall duration (days)",
#' AVAL = sample(x = seq(1, 200), size = n(), replace = TRUE),
#' AVALU = "Days") %>%
#' bind_rows(ADEX)
#' formatters::var_labels(ADEX) <- labels' # nolint
#' )
#' cdisc_dataset("ADSL", adsl),
#' cdisc_dataset("ADEX", adex)
#' ),
#' modules = modules(
#' tm_t_exposure(
Expand Down
Loading

0 comments on commit 327fd66

Please sign in to comment.