From b858b618fa51059a0702c55bc4b0592c244319f2 Mon Sep 17 00:00:00 2001 From: Aleksander Chlebowski Date: Thu, 16 Nov 2023 01:59:34 +0100 Subject: [PATCH 1/8] change examples --- R/tm_g_ae_oview.R | 90 +++++++++++-------------------- R/tm_g_ae_sub.R | 22 ++++---- R/tm_g_butterfly.R | 56 +++++++++----------- R/tm_g_events_term_id.R | 22 ++++---- R/tm_g_heat_bygrade.R | 111 +++++++++++++++------------------------ R/tm_g_patient_profile.R | 79 ++++++++-------------------- R/tm_g_spiderplot.R | 26 +++++---- R/tm_g_swimlane.R | 46 +++++++--------- R/tm_g_waterfall.R | 33 ++++++------ 9 files changed, 189 insertions(+), 296 deletions(-) diff --git a/R/tm_g_ae_oview.R b/R/tm_g_ae_oview.R index 206750ca..4cd49b0d 100644 --- a/R/tm_g_ae_oview.R +++ b/R/tm_g_ae_oview.R @@ -16,67 +16,40 @@ #' @export #' #' @examples -#' library(nestcolor) +#' data <- teal.data::cdisc_data() |> +#' within(library(nestcolor)) |> +#' within(ADSL <- osprey::rADSL) |> +#' within(ADAE <- osprey::rADAE) |> +#' within(add_event_flags <- function(dat) { +#' dat <- dat |> +#' dplyr::mutate( +#' TMPFL_SER = AESER == "Y", +#' TMPFL_REL = AEREL == "Y", +#' TMPFL_GR5 = AETOXGR == "5", +#' AEREL1 = (AEREL == "Y" & ACTARM == "A: Drug X"), +#' AEREL2 = (AEREL == "Y" & ACTARM == "B: Placebo") +#' ) +#' labels <- c( +#' "Serious AE", "Related AE", "Grade 5 AE", +#' "AE related to A: Drug X", "AE related to B: Placebo" +#' ) +#' cols <- c("TMPFL_SER", "TMPFL_REL", "TMPFL_GR5", "AEREL1", "AEREL2") +#' for (i in seq_along(labels)) { +#' attr(dat[[cols[i]]], "label") <- labels[i] +#' } +#' dat +#' }) |> +#' within(ADAE <- add_event_flags(ADAE)) #' -#' ADSL <- osprey::rADSL -#' ADAE <- osprey::rADAE +#' teal.data::datanames(data) <- c("ADSL", "ADAE") +#' teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[teal.data::datanames(data)] #' -#' # Add additional dummy causality flags. -#' add_event_flags <- function(dat) { -#' dat <- dat %>% -#' dplyr::mutate( -#' TMPFL_SER = AESER == "Y", -#' TMPFL_REL = AEREL == "Y", -#' TMPFL_GR5 = AETOXGR == "5", -#' AEREL1 = (AEREL == "Y" & ACTARM == "A: Drug X"), -#' AEREL2 = (AEREL == "Y" & ACTARM == "B: Placebo") -#' ) -#' labels <- c( -#' "Serious AE", "Related AE", "Grade 5 AE", -#' "AE related to A: Drug X", "AE related to B: Placebo" -#' ) -#' cols <- c("TMPFL_SER", "TMPFL_REL", "TMPFL_GR5", "AEREL1", "AEREL2") -#' for (i in seq_along(labels)) { -#' attr(dat[[cols[i]]], "label") <- labels[i] -#' } -#' dat -#' } -#' ADAE <- ADAE %>% add_event_flags() +#' ADSL <- data[["ADSL"]] +#' ADAE <- data[["ADAE"]] #' -#' app <- init( -#' data = cdisc_data( -#' cdisc_dataset("ADSL", ADSL, code = "ADSL <- osprey::rADSL"), -#' cdisc_dataset("ADAE", ADAE, -#' code = -#' "ADAE <- osprey::rADAE -#' add_event_flags <- function(dat) { -#' dat <- dat %>% -#' dplyr::mutate( -#' TMPFL_SER = AESER == 'Y', -#' TMPFL_REL = AEREL == 'Y', -#' TMPFL_GR5 = AETOXGR == '5', -#' AEREL1 = (AEREL == 'Y' & ACTARM == 'A: Drug X'), -#' AEREL2 = (AEREL == 'Y' & ACTARM == 'B: Placebo') -#' ) -#' labels <- c( -#' 'Serious AE', -#' 'Related AE', -#' 'Grade 5 AE', -#' 'AE related to A: Drug X', -#' 'AE related to B: Placebo' -#' ) -#' cols <- c('TMPFL_SER', 'TMPFL_REL', 'TMPFL_GR5', 'AEREL1', 'AEREL2') -#' for (i in seq_along(labels)) { -#' attr(dat[[cols[i]]], 'label') <- labels[i] -#' } -#' dat -#' } -#' # Generating user-defined event flags. -#' ADAE <- ADAE %>% add_event_flags()" -#' ), -#' check = TRUE -#' ), -#' modules = modules( +#' app <- teal::init( +#' data = data, +#' modules = teal::modules( #' tm_g_ae_oview( #' label = "AE Overview", #' dataname = "ADAE", @@ -98,6 +71,7 @@ #' if (interactive()) { #' shinyApp(app$ui, app$server) #' } +#' tm_g_ae_oview <- function(label, dataname, arm_var, diff --git a/R/tm_g_ae_sub.R b/R/tm_g_ae_sub.R index c47dfc94..3ed81c38 100644 --- a/R/tm_g_ae_sub.R +++ b/R/tm_g_ae_sub.R @@ -18,16 +18,19 @@ #' #' @examples #' # Example using stream (ADaM) dataset -#' ADSL <- osprey::rADSL -#' ADAE <- osprey::rADAE +#' data <- teal.data::cdisc_data() |> +#' within(ADSL <- osprey::rADSL) |> +#' within(ADAE <- osprey::rADAE) #' -#' app <- init( -#' data = cdisc_data( -#' cdisc_dataset("ADSL", ADSL, code = "ADSL <- osprey::rADSL"), -#' cdisc_dataset("ADAE", ADAE, code = "ADAE <- osprey::rADAE"), -#' check = TRUE -#' ), -#' modules = modules( +#' teal.data::datanames(data) <- c("ADSL", "ADAE") +#' teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[teal.data::datanames(data)] +#' +#' ADSL <- data[["ADSL"]] +#' ADAE <- data[["ADAE"]] +#' +#' app <- teal::init( +#' data = data, +#' modules = teal::modules( #' tm_g_ae_sub( #' label = "AE by Subgroup", #' dataname = "ADAE", @@ -46,6 +49,7 @@ #' if (interactive()) { #' shinyApp(app$ui, app$server) #' } +#' tm_g_ae_sub <- function(label, dataname, arm_var, diff --git a/R/tm_g_butterfly.R b/R/tm_g_butterfly.R index c3870334..96550f99 100644 --- a/R/tm_g_butterfly.R +++ b/R/tm_g_butterfly.R @@ -40,41 +40,33 @@ #' @template author_liaoc10 #' #' @examples -#' #' # Example using stream (ADaM) dataset -#' library(dplyr) -#' library(nestcolor) +#' data <- teal.data::cdisc_data() |> +#' within({ +#' library(dplyr) +#' library(nestcolor) +#' }) |> +#' within(set.seed(23)) |> +#' within(ADSL <- osprey::rADSL) |> +#' within(ADAE <- osprey::rADAE) |> +#' within(ADSL <- mutate(ADSL, DOSE = paste(sample(1:3, n(), replace = TRUE), "UG"))) |> +#' within(ADAE <- mutate( +#' ADAE, +#' flag1 = ifelse(AETOXGR == 1, 1, 0), +#' flag2 = ifelse(AETOXGR == 2, 1, 0), +#' flag3 = ifelse(AETOXGR == 3, 1, 0), +#' flag1_filt = rep("Y", n()) +#' )) #' -#' set.seed(23) -#' ADSL <- osprey::rADSL -#' ADAE <- osprey::rADAE -#' ADSL <- mutate(ADSL, DOSE = paste(sample(1:3, n(), replace = TRUE), "UG")) -#' ADAE <- mutate( -#' ADAE, -#' flag1 = ifelse(AETOXGR == 1, 1, 0), -#' flag2 = ifelse(AETOXGR == 2, 1, 0), -#' flag3 = ifelse(AETOXGR == 3, 1, 0), -#' flag1_filt = rep("Y", n()) -#' ) +#' teal.data::datanames(data) <- c("ADSL", "ADAE") +#' teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[teal.data::datanames(data)] +#' +#' ADSL <- data[["ADSL"]] +#' ADAE <- data[["ADAE"]] #' -#' app <- init( -#' data = cdisc_data( -#' cdisc_dataset("ADSL", ADSL, -#' code = "ADSL <- osprey::rADSL -#' set.seed(23) -#' ADSL <- mutate(ADSL, DOSE = paste(sample(1:3, n(), replace = TRUE), 'UG'))" -#' ), -#' cdisc_dataset("ADAE", ADAE, -#' code = "ADAE <- osprey::rADAE -#' ADAE <- mutate(ADAE, -#' flag1 = ifelse(AETOXGR == 1, 1, 0), -#' flag2 = ifelse(AETOXGR == 2, 1, 0), -#' flag3 = ifelse(AETOXGR == 3, 1, 0), -#' flag1_filt = rep('Y', n()))" -#' ), -#' check = TRUE -#' ), -#' modules = modules( +#' app <- teal::init( +#' data = data, +#' modules = teal::modules( #' tm_g_butterfly( #' label = "Butterfly Plot", #' dataname = "ADAE", diff --git a/R/tm_g_events_term_id.R b/R/tm_g_events_term_id.R index 6d84621b..9ba45542 100644 --- a/R/tm_g_events_term_id.R +++ b/R/tm_g_events_term_id.R @@ -18,18 +18,20 @@ #' @author Molly He (hey59) \email{hey59@gene.com} #' #' @examples -#' library(nestcolor) +#' data <- teal.data::cdisc_data() |> +#' within(library(nestcolor)) |> +#' within(ADSL <- osprey::rADSL) |> +#' within(ADAE <- osprey::rADAE) #' -#' ADSL <- osprey::rADSL -#' ADAE <- osprey::rADAE +#' teal.data::datanames(data) <- c("ADSL", "ADAE") +#' teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[teal.data::datanames(data)] #' -#' app <- init( -#' data = cdisc_data( -#' cdisc_dataset("ADSL", ADSL, code = "ADSL <- osprey::rADSL"), -#' cdisc_dataset("ADAE", ADAE, code = "ADAE <- osprey::rADAE"), -#' check = TRUE -#' ), -#' modules = modules( +#' ADSL <- data[["ADSL"]] +#' ADAE <- data[["ADAE"]] +#' +#' app <- teal::init( +#' data = data, +#' modules = teal::modules( #' tm_g_events_term_id( #' label = "Common AE", #' dataname = "ADAE", diff --git a/R/tm_g_heat_bygrade.R b/R/tm_g_heat_bygrade.R index 18580b3e..4738cdbd 100644 --- a/R/tm_g_heat_bygrade.R +++ b/R/tm_g_heat_bygrade.R @@ -34,79 +34,49 @@ #' @export #' #' @examples -#' library(dplyr) -#' library(nestcolor) -#' ADSL <- osprey::rADSL %>% slice(1:30) -#' ADEX <- osprey::rADEX %>% filter(USUBJID %in% ADSL$USUBJID) -#' ADAE <- osprey::rADAE %>% filter(USUBJID %in% ADSL$USUBJID) -#' ADCM <- osprey::rADCM %>% filter(USUBJID %in% ADSL$USUBJID) +#' data <- teal.data::cdisc_data() |> +#' within(library(dplyr)) |> +#' within(library(nestcolor)) |> +#' within(ADSL <- osprey::rADSL %>% slice(1:30)) |> +#' within(ADEX <- osprey::rADEX %>% filter(USUBJID %in% ADSL$USUBJID)) |> +#' within(ADAE <- osprey::rADAE %>% filter(USUBJID %in% ADSL$USUBJID)) |> +#' within(ADCM <- osprey::rADCM %>% filter(USUBJID %in% ADSL$USUBJID)) |> +#' # This preprocess is only to force legacy standard on ADCM +#' within(ADCM <- ADCM %>% select(-starts_with("ATC")) %>% unique()) |> +#' # function to derive AVISIT from ADEX +#' within(add_visit <- function(data_need_visit) { +#' visit_dates <- ADEX %>% +#' filter(PARAMCD == "DOSE") %>% +#' distinct(USUBJID, AVISIT, ASTDTM) %>% +#' group_by(USUBJID) %>% +#' arrange(ASTDTM) %>% +#' mutate(next_vis = lead(ASTDTM), is_last = ifelse(is.na(next_vis), TRUE, FALSE)) %>% +#' rename(this_vis = ASTDTM) +#' data_visit <- data_need_visit %>% +#' select(USUBJID, ASTDTM) %>% +#' left_join(visit_dates, by = "USUBJID") %>% +#' filter(ASTDTM > this_vis & (ASTDTM < next_vis | is_last == TRUE)) %>% +#' left_join(data_need_visit) %>% +#' distinct() +#' return(data_visit) +#' }) |> +#' # derive AVISIT for ADAE and ADCM +#' within(ADAE <- add_visit(ADAE)) |> +#' within(ADCM <- add_visit(ADCM)) |> +#' # derive ongoing status variable for ADEX +#' within(ADEX <- ADEX %>% filter(PARCAT1 == "INDIVIDUAL") %>% mutate(ongo_status = (EOSSTT == "ONGOING"))) #' -#' # This preprocess is only to force legacy standard on ADCM -#' ADCM <- ADCM %>% -#' select(-starts_with("ATC")) %>% -#' unique() +#' teal.data::datanames(data) <- c("ADSL", "ADEX", "ADAE", "ADCM") +#' teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[teal.data::datanames(data)] #' -#' # function to derive AVISIT from ADEX -#' add_visit <- function(data_need_visit) { -#' visit_dates <- ADEX %>% -#' filter(PARAMCD == "DOSE") %>% -#' distinct(USUBJID, AVISIT, ASTDTM) %>% -#' group_by(USUBJID) %>% -#' arrange(ASTDTM) %>% -#' mutate(next_vis = lead(ASTDTM), is_last = ifelse(is.na(next_vis), TRUE, FALSE)) %>% -#' rename(this_vis = ASTDTM) -#' data_visit <- data_need_visit %>% -#' select(USUBJID, ASTDTM) %>% -#' left_join(visit_dates, by = "USUBJID") %>% -#' filter(ASTDTM > this_vis & (ASTDTM < next_vis | is_last == TRUE)) %>% -#' left_join(data_need_visit) %>% -#' distinct() -#' return(data_visit) -#' } -#' # derive AVISIT for ADAE and ADCM -#' ADAE <- add_visit(ADAE) -#' ADCM <- add_visit(ADCM) -#' # derive ongoing status variable for ADEX -#' ADEX <- ADEX %>% -#' filter(PARCAT1 == "INDIVIDUAL") %>% -#' mutate(ongo_status = (EOSSTT == "ONGOING")) +#' ADSL <- data[["ADSL"]] +#' ADEX <- data[["ADEX"]] +#' ADAE <- data[["ADAE"]] +#' ADCM <- data[["ADCM"]] #' -#' app <- init( -#' data = cdisc_data( -#' cdisc_dataset("ADSL", ADSL), -#' cdisc_dataset("ADEX", ADEX), -#' cdisc_dataset("ADAE", ADAE), -#' cdisc_dataset("ADCM", ADCM, keys = c("STUDYID", "USUBJID", "ASTDTM", "CMSEQ", "CMDECOD")), -#' code = " -#' ADSL <- osprey::rADSL %>% slice(1:30) -#' ADEX <- osprey::rADEX %>% filter(USUBJID %in% ADSL$USUBJID) -#' ADAE <- osprey::rADAE %>% filter(USUBJID %in% ADSL$USUBJID) -#' ADCM <- osprey::rADCM %>% filter(USUBJID %in% ADSL$USUBJID) -#' ADCM <- ADCM %>% select(-starts_with(\"ATC\")) %>% unique() -#' ADEX <- ADEX %>% -#' filter(PARCAT1 == 'INDIVIDUAL') %>% -#' mutate(ongo_status = (EOSSTT == 'ONGOING')) -#' add_visit <- function(data_need_visit) { -#' visit_dates <- ADEX %>% -#' filter(PARAMCD == 'DOSE') %>% -#' distinct(USUBJID, AVISIT, ASTDTM) %>% -#' group_by(USUBJID) %>% -#' arrange(ASTDTM) %>% -#' mutate(next_vis = lead(ASTDTM), is_last = ifelse(is.na(next_vis), TRUE, FALSE)) %>% -#' rename(this_vis = ASTDTM) -#' data_visit <- data_need_visit %>% -#' select(USUBJID, ASTDTM) %>% -#' left_join(visit_dates, by = 'USUBJID') %>% -#' filter(ASTDTM > this_vis & (ASTDTM < next_vis | is_last == TRUE)) %>% -#' left_join(data_need_visit) %>% distinct() -#' return(data_visit) -#' } -#' ADAE <- add_visit(ADAE) -#' ADCM <- add_visit(ADCM) -#' ", -#' check = TRUE -#' ), -#' modules = modules( +#' app <- teal::init( +#' data = data, +#' modules = teal::modules( #' tm_g_heat_bygrade( #' label = "Heatmap by grade", #' sl_dataname = "ADSL", @@ -144,6 +114,7 @@ #' if (interactive()) { #' shinyApp(app$ui, app$server) #' } +#' tm_g_heat_bygrade <- function(label, sl_dataname, ex_dataname, diff --git a/R/tm_g_patient_profile.R b/R/tm_g_patient_profile.R index f7950419..e0277a2c 100644 --- a/R/tm_g_patient_profile.R +++ b/R/tm_g_patient_profile.R @@ -62,67 +62,30 @@ #' @export #' #' @examples -#' library(nestcolor) +#' data <- teal.data::cdisc_data() |> +#' within(library(nestcolor)) |> +#' within(ADSL <- osprey::rADSL) |> +#' within(ADAE <- osprey::rADAE %>% mutate(ASTDT = as.Date(ASTDTM), AENDT = as.Date(AENDTM))) |> +#' within(ADCM <- osprey::rADCM %>% mutate(ASTDT = as.Date(ASTDTM), AENDT = as.Date(AENDTM))) |> +#' # The step below is to pre-process ADCM to legacy standard +#' within(ADCM <- ADCM %>% select(-starts_with("ATC")) %>% unique()) |> +#' within(ADRS <- osprey::rADRS %>% mutate(ADT = as.Date(ADTM))) |> +#' within(ADEX <- osprey::rADEX %>% mutate(ASTDT = as.Date(ASTDTM), AENDT = as.Date(AENDTM))) |> +#' within(ADLB <- osprey::rADLB %>% mutate(ADT = as.Date(ADTM),LBSTRESN = as.numeric(LBSTRESC))) #' -#' ADSL <- osprey::rADSL -#' ADAE <- osprey::rADAE %>% -#' mutate( -#' ASTDT = as.Date(ASTDTM), -#' AENDT = as.Date(AENDTM) -#' ) -#' ADCM <- osprey::rADCM %>% -#' mutate( -#' ASTDT = as.Date(ASTDTM), -#' AENDT = as.Date(AENDTM) -#' ) -#' -#' # The step below is to pre-process ADCM to legacy standard -#' ADCM <- ADCM %>% -#' select(-starts_with("ATC")) %>% -#' unique() +#' teal.data::datanames(data) <- c("ADSL", "ADAE", "ADCM", "ADRS", "ADEX", "ADLB") +#' teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[teal.data::datanames(data)] #' -#' ADRS <- osprey::rADRS %>% -#' mutate(ADT = as.Date(ADTM)) -#' ADEX <- osprey::rADEX %>% -#' mutate( -#' ASTDT = as.Date(ASTDTM), -#' AENDT = as.Date(AENDTM) -#' ) -#' ADLB <- osprey::rADLB %>% -#' mutate( -#' ADT = as.Date(ADTM), -#' LBSTRESN = as.numeric(LBSTRESC) -#' ) +#' ADSL <- data[["ADSL"]] +#' ADAE <- data[["ADAE"]] +#' ADCM <- data[["ADCM"]] +#' ADRS <- data[["ADRS"]] +#' ADEX <- data[["ADEX"]] +#' ADLB <- data[["ADLB"]] #' -#' app <- init( -#' data = cdisc_data( -#' cdisc_dataset("ADSL", ADSL, code = "ADSL <- osprey::rADSL"), -#' cdisc_dataset("ADRS", ADRS, code = "ADRS <- osprey::rADRS %>% mutate(ADT = as.Date(ADTM))"), -#' cdisc_dataset("ADAE", ADAE, -#' code = "ADAE <- osprey::rADAE %>% -#' mutate(ASTDT = as.Date(ASTDTM), -#' AENDT = as.Date(AENDTM))" -#' ), -#' cdisc_dataset("ADCM", ADCM, -#' code = "ADCM <- osprey::rADCM %>% -#' mutate(ASTDT = as.Date(ASTDTM), -#' AENDT = as.Date(AENDTM)) -#' ADCM <- ADCM %>% select(-starts_with(\"ATC\")) %>% unique()", -#' keys = c("STUDYID", "USUBJID", "ASTDTM", "CMSEQ", "CMDECOD") -#' ), -#' cdisc_dataset("ADLB", ADLB, -#' code = "ADLB <- osprey::rADLB %>% -#' mutate(ADT = as.Date(ADTM), -#' LBSTRESN = as.numeric(LBSTRESC))" -#' ), -#' cdisc_dataset("ADEX", ADEX, -#' code = "ADEX <- osprey::rADEX %>% -#' mutate(ASTDT = as.Date(ASTDTM), -#' AENDT = as.Date(AENDTM))" -#' ), -#' check = FALSE # set FALSE here to keep run time of example short, should be set to TRUE -#' ), -#' modules = modules( +#' app <- teal::init( +#' data = data, +#' modules = teal::modules( #' tm_g_patient_profile( #' label = "Patient Profile Plot", #' patient_id = teal.transform::choices_selected( diff --git a/R/tm_g_spiderplot.R b/R/tm_g_spiderplot.R index 20d17f64..c002ad9c 100644 --- a/R/tm_g_spiderplot.R +++ b/R/tm_g_spiderplot.R @@ -25,24 +25,22 @@ #' @template author_liaoc10 #' #' @examples -#' #' # Example using stream (ADaM) dataset -#' library(dplyr) -#' library(nestcolor) +#' data <- teal.data::cdisc_data() |> +#' within(library(dplyr)) |> +#' within(library(nestcolor)) |> +#' within(ADSL <- osprey::rADSL) |> +#' within(ADTR <- osprey::rADTR) +#' +#' teal.data::datanames(data) <- c("ADSL", "ADTR") +#' teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[teal.data::datanames(data)] #' -#' ADSL <- osprey::rADSL -#' ADTR <- osprey::rADTR +#' ADSL <- data[["ADSL"]] +#' ADTR <- data[["ADTR"]] #' #' app <- teal::init( -#' data = cdisc_data( -#' cdisc_dataset("ADSL", ADSL, code = "ADSL <- osprey::rADSL"), -#' cdisc_dataset("ADTR", ADTR, -#' code = "ADTR <- osprey::rADTR", -#' keys = c("STUDYID", "USUBJID", "PARAMCD", "AVISIT") -#' ), -#' check = TRUE -#' ), -#' modules = modules( +#' data = data, +#' modules = teal::modules( #' tm_g_spiderplot( #' label = "Spider plot", #' dataname = "ADTR", diff --git a/R/tm_g_swimlane.R b/R/tm_g_swimlane.R index ea6661dd..88bc4e62 100644 --- a/R/tm_g_swimlane.R +++ b/R/tm_g_swimlane.R @@ -35,37 +35,29 @@ #' @template author_qit3 #' #' @examples -#' #' # Example using stream (ADaM) dataset -#' library(dplyr) -#' library(nestcolor) +#' data <- teal.data::cdisc_data() |> +#' within(library(dplyr)) |> +#' within(library(nestcolor)) |> +#' within(ADSL <- osprey::rADSL %>% +#' dplyr::mutate(TRTDURD = as.integer(TRTEDTM - TRTSDTM) + 1) %>% +#' dplyr::filter(STRATA1 == "A" & ARMCD == "ARM A")) |> +#' within(ADRS <- osprey::rADRS) |> +#' within(ADRS <- ADRS %>% +#' dplyr::filter(PARAMCD == "LSTASDI" & DCSREAS == "Death") %>% +#' mutate(AVALC = DCSREAS, ADY = EOSDY) %>% +#' base::rbind(ADRS %>% dplyr::filter(PARAMCD == "OVRINV" & AVALC != "NE")) %>% +#' arrange(USUBJID)) #' -#' ADSL <- osprey::rADSL %>% -#' dplyr::mutate(TRTDURD = as.integer(TRTEDTM - TRTSDTM) + 1) %>% -#' dplyr::filter(STRATA1 == "A" & ARMCD == "ARM A") -#' ADRS <- osprey::rADRS +#' teal.data::datanames(data) <- c("ADSL", "ADRS") +#' teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[teal.data::datanames(data)] #' -#' ADRS <- ADRS %>% -#' dplyr::filter(PARAMCD == "LSTASDI" & DCSREAS == "Death") %>% -#' mutate(AVALC = DCSREAS, ADY = EOSDY) %>% -#' base::rbind(ADRS %>% dplyr::filter(PARAMCD == "OVRINV" & AVALC != "NE")) %>% -#' arrange(USUBJID) +#' ADSL <- data[["ADSL"]] +#' ADRS <- data[["ADRS"]] #' -#' app <- init( -#' data = cdisc_data( -#' cdisc_dataset("ADSL", ADSL, code = "ADSL <- osprey::rADSL %>% -#' dplyr::mutate(TRTDURD = as.integer(TRTEDTM - TRTSDTM) + 1) %>% -#' dplyr::filter(STRATA1 == 'A' & ARMCD == 'ARM A')"), -#' cdisc_dataset("ADRS", ADRS, -#' code = "ADRS <- rADRS -#' ADRS <- ADRS %>% dplyr::filter(PARAMCD == 'LSTASDI' & DCSREAS == 'Death') %>% -#' mutate(AVALC = DCSREAS, ADY = EOSDY) %>% -#' rbind(ADRS %>% dplyr::filter(PARAMCD == 'OVRINV' & AVALC != 'NE')) %>% -#' arrange(USUBJID)" -#' ), -#' check = TRUE -#' ), -#' modules = modules( +#' app <- teal::init( +#' data = data, +#' modules = teal::modules( #' tm_g_swimlane( #' label = "Swimlane Plot", #' dataname = "ADRS", diff --git a/R/tm_g_waterfall.R b/R/tm_g_waterfall.R index f329e48d..8e42b8fb 100644 --- a/R/tm_g_waterfall.R +++ b/R/tm_g_waterfall.R @@ -47,27 +47,23 @@ #' @author houx14 \email{houx14@gene.com} #' #' @examples -#' library(nestcolor) -#' ADSL <- osprey::rADSL -#' ADRS <- osprey::rADRS -#' ADTR <- osprey::rADTR +#' data <- teal.data::cdisc_data() |> +#' within(library(nestcolor)) |> +#' within(ADSL <- osprey::rADSL) |> +#' within(ADRS <- osprey::rADRS) |> +#' within(ADTR <- osprey::rADTR) |> +#' within(ADSL$SEX <- factor(ADSL$SEX, levels = unique(ADSL$SEX))) #' -#' ADSL$SEX <- factor(ADSL$SEX, levels = unique(ADSL$SEX)) +#' teal.data::datanames(data) <- c("ADSL", "ADTR", "ADRS") +#' teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[teal.data::datanames(data)] +#' +#' ADSL <- data[["ADSL"]] +#' ADTR <- data[["ADTR"]] +#' ADRS <- data[["ADRS"]] #' #' app <- teal::init( -#' data = cdisc_data( -#' cdisc_dataset("ADSL", ADSL, -#' code = "ADSL <- rADSL -#' ADSL$SEX <- factor(ADSL$SEX, levels = unique(ADSL$SEX))" -#' ), -#' cdisc_dataset("ADRS", ADRS, code = "ADRS <- rADRS"), -#' cdisc_dataset("ADTR", ADTR, -#' code = " ADTR <- rADTR", -#' c("STUDYID", "USUBJID", "PARAMCD", "AVISIT") -#' ), -#' check = TRUE -#' ), -#' modules = modules( +#' data = data, +#' modules = teal::modules( #' tm_g_waterfall( #' label = "Waterfall", #' dataname_tr = "ADTR", @@ -89,6 +85,7 @@ #' if (interactive()) { #' shinyApp(app$ui, app$server) #' } +#' #' tm_g_waterfall <- function(label, dataname_tr = "ADTR", dataname_rs = "ADRS", From 4773d5e3bf3c81dd00dc6c4ddf2a9909a6574049 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 16 Nov 2023 01:08:13 +0000 Subject: [PATCH 2/8] [skip actions] Restyle files --- R/tm_g_patient_profile.R | 2 +- R/tm_g_swimlane.R | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/R/tm_g_patient_profile.R b/R/tm_g_patient_profile.R index e0277a2c..bb5fa5c4 100644 --- a/R/tm_g_patient_profile.R +++ b/R/tm_g_patient_profile.R @@ -71,7 +71,7 @@ #' within(ADCM <- ADCM %>% select(-starts_with("ATC")) %>% unique()) |> #' within(ADRS <- osprey::rADRS %>% mutate(ADT = as.Date(ADTM))) |> #' within(ADEX <- osprey::rADEX %>% mutate(ASTDT = as.Date(ASTDTM), AENDT = as.Date(AENDTM))) |> -#' within(ADLB <- osprey::rADLB %>% mutate(ADT = as.Date(ADTM),LBSTRESN = as.numeric(LBSTRESC))) +#' within(ADLB <- osprey::rADLB %>% mutate(ADT = as.Date(ADTM), LBSTRESN = as.numeric(LBSTRESC))) #' #' teal.data::datanames(data) <- c("ADSL", "ADAE", "ADCM", "ADRS", "ADEX", "ADLB") #' teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[teal.data::datanames(data)] diff --git a/R/tm_g_swimlane.R b/R/tm_g_swimlane.R index 88bc4e62..7a746f4a 100644 --- a/R/tm_g_swimlane.R +++ b/R/tm_g_swimlane.R @@ -40,14 +40,14 @@ #' within(library(dplyr)) |> #' within(library(nestcolor)) |> #' within(ADSL <- osprey::rADSL %>% -#' dplyr::mutate(TRTDURD = as.integer(TRTEDTM - TRTSDTM) + 1) %>% -#' dplyr::filter(STRATA1 == "A" & ARMCD == "ARM A")) |> +#' dplyr::mutate(TRTDURD = as.integer(TRTEDTM - TRTSDTM) + 1) %>% +#' dplyr::filter(STRATA1 == "A" & ARMCD == "ARM A")) |> #' within(ADRS <- osprey::rADRS) |> #' within(ADRS <- ADRS %>% -#' dplyr::filter(PARAMCD == "LSTASDI" & DCSREAS == "Death") %>% -#' mutate(AVALC = DCSREAS, ADY = EOSDY) %>% -#' base::rbind(ADRS %>% dplyr::filter(PARAMCD == "OVRINV" & AVALC != "NE")) %>% -#' arrange(USUBJID)) +#' dplyr::filter(PARAMCD == "LSTASDI" & DCSREAS == "Death") %>% +#' mutate(AVALC = DCSREAS, ADY = EOSDY) %>% +#' base::rbind(ADRS %>% dplyr::filter(PARAMCD == "OVRINV" & AVALC != "NE")) %>% +#' arrange(USUBJID)) #' #' teal.data::datanames(data) <- c("ADSL", "ADRS") #' teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[teal.data::datanames(data)] From d6992e069534992a0017d4fbe640b0df71964ee0 Mon Sep 17 00:00:00 2001 From: Aleksander Chlebowski Date: Thu, 16 Nov 2023 02:11:22 +0100 Subject: [PATCH 3/8] amend documentation --- man/tm_g_ae_oview.Rd | 90 ++++++++++----------------- man/tm_g_ae_sub.Rd | 22 ++++--- man/tm_g_butterfly.Rd | 60 ++++++++---------- man/tm_g_events_term_id.Rd | 22 ++++--- man/tm_g_heat_bygrade.Rd | 117 ++++++++++++++---------------------- man/tm_g_patient_profile.Rd | 85 ++++++++------------------ man/tm_g_spiderplot.Rd | 26 ++++---- man/tm_g_swimlane.Rd | 52 +++++++--------- man/tm_g_waterfall.Rd | 33 +++++----- 9 files changed, 200 insertions(+), 307 deletions(-) diff --git a/man/tm_g_ae_oview.Rd b/man/tm_g_ae_oview.Rd index f68124a4..06e0e486 100644 --- a/man/tm_g_ae_oview.Rd +++ b/man/tm_g_ae_oview.Rd @@ -51,67 +51,40 @@ the \code{\link[teal:module]{teal::module()}} object. Display the \code{AE} overview plot as a shiny module } \examples{ -library(nestcolor) +data <- teal.data::cdisc_data() |> + within(library(nestcolor)) |> + within(ADSL <- osprey::rADSL) |> + within(ADAE <- osprey::rADAE) |> + within(add_event_flags <- function(dat) { + dat <- dat |> + dplyr::mutate( + TMPFL_SER = AESER == "Y", + TMPFL_REL = AEREL == "Y", + TMPFL_GR5 = AETOXGR == "5", + AEREL1 = (AEREL == "Y" & ACTARM == "A: Drug X"), + AEREL2 = (AEREL == "Y" & ACTARM == "B: Placebo") + ) + labels <- c( + "Serious AE", "Related AE", "Grade 5 AE", + "AE related to A: Drug X", "AE related to B: Placebo" + ) + cols <- c("TMPFL_SER", "TMPFL_REL", "TMPFL_GR5", "AEREL1", "AEREL2") + for (i in seq_along(labels)) { + attr(dat[[cols[i]]], "label") <- labels[i] + } + dat + }) |> + within(ADAE <- add_event_flags(ADAE)) -ADSL <- osprey::rADSL -ADAE <- osprey::rADAE +teal.data::datanames(data) <- c("ADSL", "ADAE") +teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[teal.data::datanames(data)] -# Add additional dummy causality flags. -add_event_flags <- function(dat) { - dat <- dat \%>\% - dplyr::mutate( - TMPFL_SER = AESER == "Y", - TMPFL_REL = AEREL == "Y", - TMPFL_GR5 = AETOXGR == "5", - AEREL1 = (AEREL == "Y" & ACTARM == "A: Drug X"), - AEREL2 = (AEREL == "Y" & ACTARM == "B: Placebo") - ) - labels <- c( - "Serious AE", "Related AE", "Grade 5 AE", - "AE related to A: Drug X", "AE related to B: Placebo" - ) - cols <- c("TMPFL_SER", "TMPFL_REL", "TMPFL_GR5", "AEREL1", "AEREL2") - for (i in seq_along(labels)) { - attr(dat[[cols[i]]], "label") <- labels[i] - } - dat -} -ADAE <- ADAE \%>\% add_event_flags() +ADSL <- data[["ADSL"]] +ADAE <- data[["ADAE"]] -app <- init( - data = cdisc_data( - cdisc_dataset("ADSL", ADSL, code = "ADSL <- osprey::rADSL"), - cdisc_dataset("ADAE", ADAE, - code = - "ADAE <- osprey::rADAE - add_event_flags <- function(dat) { - dat <- dat \%>\% - dplyr::mutate( - TMPFL_SER = AESER == 'Y', - TMPFL_REL = AEREL == 'Y', - TMPFL_GR5 = AETOXGR == '5', - AEREL1 = (AEREL == 'Y' & ACTARM == 'A: Drug X'), - AEREL2 = (AEREL == 'Y' & ACTARM == 'B: Placebo') - ) - labels <- c( - 'Serious AE', - 'Related AE', - 'Grade 5 AE', - 'AE related to A: Drug X', - 'AE related to B: Placebo' - ) - cols <- c('TMPFL_SER', 'TMPFL_REL', 'TMPFL_GR5', 'AEREL1', 'AEREL2') - for (i in seq_along(labels)) { - attr(dat[[cols[i]]], 'label') <- labels[i] - } - dat - } - # Generating user-defined event flags. - ADAE <- ADAE \%>\% add_event_flags()" - ), - check = TRUE - ), - modules = modules( +app <- teal::init( + data = data, + modules = teal::modules( tm_g_ae_oview( label = "AE Overview", dataname = "ADAE", @@ -133,4 +106,5 @@ app <- init( if (interactive()) { shinyApp(app$ui, app$server) } + } diff --git a/man/tm_g_ae_sub.Rd b/man/tm_g_ae_sub.Rd index 2eb7a4ed..ddf1ce3f 100644 --- a/man/tm_g_ae_sub.Rd +++ b/man/tm_g_ae_sub.Rd @@ -50,16 +50,19 @@ Display the \code{AE} by subgroups plot as a teal module } \examples{ # Example using stream (ADaM) dataset -ADSL <- osprey::rADSL -ADAE <- osprey::rADAE +data <- teal.data::cdisc_data() |> + within(ADSL <- osprey::rADSL) |> + within(ADAE <- osprey::rADAE) -app <- init( - data = cdisc_data( - cdisc_dataset("ADSL", ADSL, code = "ADSL <- osprey::rADSL"), - cdisc_dataset("ADAE", ADAE, code = "ADAE <- osprey::rADAE"), - check = TRUE - ), - modules = modules( +teal.data::datanames(data) <- c("ADSL", "ADAE") +teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[teal.data::datanames(data)] + +ADSL <- data[["ADSL"]] +ADAE <- data[["ADAE"]] + +app <- teal::init( + data = data, + modules = teal::modules( tm_g_ae_sub( label = "AE by Subgroup", dataname = "ADAE", @@ -78,6 +81,7 @@ app <- init( if (interactive()) { shinyApp(app$ui, app$server) } + } \author{ Liming Li (Lil128) \email{liming.li@roche.com} diff --git a/man/tm_g_butterfly.Rd b/man/tm_g_butterfly.Rd index a1e138f8..c9e96684 100644 --- a/man/tm_g_butterfly.Rd +++ b/man/tm_g_butterfly.Rd @@ -86,41 +86,33 @@ used for subsequent analysis. Flag variables (from \code{ADaM} datasets) can be used directly as filter. } \examples{ - # Example using stream (ADaM) dataset -library(dplyr) -library(nestcolor) - -set.seed(23) -ADSL <- osprey::rADSL -ADAE <- osprey::rADAE -ADSL <- mutate(ADSL, DOSE = paste(sample(1:3, n(), replace = TRUE), "UG")) -ADAE <- mutate( - ADAE, - flag1 = ifelse(AETOXGR == 1, 1, 0), - flag2 = ifelse(AETOXGR == 2, 1, 0), - flag3 = ifelse(AETOXGR == 3, 1, 0), - flag1_filt = rep("Y", n()) -) - -app <- init( - data = cdisc_data( - cdisc_dataset("ADSL", ADSL, - code = "ADSL <- osprey::rADSL - set.seed(23) - ADSL <- mutate(ADSL, DOSE = paste(sample(1:3, n(), replace = TRUE), 'UG'))" - ), - cdisc_dataset("ADAE", ADAE, - code = "ADAE <- osprey::rADAE - ADAE <- mutate(ADAE, - flag1 = ifelse(AETOXGR == 1, 1, 0), - flag2 = ifelse(AETOXGR == 2, 1, 0), - flag3 = ifelse(AETOXGR == 3, 1, 0), - flag1_filt = rep('Y', n()))" - ), - check = TRUE - ), - modules = modules( +data <- teal.data::cdisc_data() |> + within({ + library(dplyr) + library(nestcolor) + }) |> + within(set.seed(23)) |> + within(ADSL <- osprey::rADSL) |> + within(ADAE <- osprey::rADAE) |> + within(ADSL <- mutate(ADSL, DOSE = paste(sample(1:3, n(), replace = TRUE), "UG"))) |> + within(ADAE <- mutate( + ADAE, + flag1 = ifelse(AETOXGR == 1, 1, 0), + flag2 = ifelse(AETOXGR == 2, 1, 0), + flag3 = ifelse(AETOXGR == 3, 1, 0), + flag1_filt = rep("Y", n()) + )) + +teal.data::datanames(data) <- c("ADSL", "ADAE") +teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[teal.data::datanames(data)] + +ADSL <- data[["ADSL"]] +ADAE <- data[["ADAE"]] + +app <- teal::init( + data = data, + modules = teal::modules( tm_g_butterfly( label = "Butterfly Plot", dataname = "ADAE", diff --git a/man/tm_g_events_term_id.Rd b/man/tm_g_events_term_id.Rd index 6399ae81..75fdf48c 100644 --- a/man/tm_g_events_term_id.Rd +++ b/man/tm_g_events_term_id.Rd @@ -50,18 +50,20 @@ the \code{\link[teal:module]{teal::module()}} object. Display Events by Term plot as a shiny module } \examples{ -library(nestcolor) +data <- teal.data::cdisc_data() |> + within(library(nestcolor)) |> + within(ADSL <- osprey::rADSL) |> + within(ADAE <- osprey::rADAE) -ADSL <- osprey::rADSL -ADAE <- osprey::rADAE +teal.data::datanames(data) <- c("ADSL", "ADAE") +teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[teal.data::datanames(data)] -app <- init( - data = cdisc_data( - cdisc_dataset("ADSL", ADSL, code = "ADSL <- osprey::rADSL"), - cdisc_dataset("ADAE", ADAE, code = "ADAE <- osprey::rADAE"), - check = TRUE - ), - modules = modules( +ADSL <- data[["ADSL"]] +ADAE <- data[["ADAE"]] + +app <- teal::init( + data = data, + modules = teal::modules( tm_g_events_term_id( label = "Common AE", dataname = "ADAE", diff --git a/man/tm_g_heat_bygrade.Rd b/man/tm_g_heat_bygrade.Rd index 7a6b452c..8b516746 100644 --- a/man/tm_g_heat_bygrade.Rd +++ b/man/tm_g_heat_bygrade.Rd @@ -76,79 +76,49 @@ the \code{\link[teal:module]{teal::module()}} object. Display the heatmap by grade as a shiny module } \examples{ -library(dplyr) -library(nestcolor) -ADSL <- osprey::rADSL \%>\% slice(1:30) -ADEX <- osprey::rADEX \%>\% filter(USUBJID \%in\% ADSL$USUBJID) -ADAE <- osprey::rADAE \%>\% filter(USUBJID \%in\% ADSL$USUBJID) -ADCM <- osprey::rADCM \%>\% filter(USUBJID \%in\% ADSL$USUBJID) - -# This preprocess is only to force legacy standard on ADCM -ADCM <- ADCM \%>\% - select(-starts_with("ATC")) \%>\% - unique() - -# function to derive AVISIT from ADEX -add_visit <- function(data_need_visit) { - visit_dates <- ADEX \%>\% - filter(PARAMCD == "DOSE") \%>\% - distinct(USUBJID, AVISIT, ASTDTM) \%>\% - group_by(USUBJID) \%>\% - arrange(ASTDTM) \%>\% - mutate(next_vis = lead(ASTDTM), is_last = ifelse(is.na(next_vis), TRUE, FALSE)) \%>\% - rename(this_vis = ASTDTM) - data_visit <- data_need_visit \%>\% - select(USUBJID, ASTDTM) \%>\% - left_join(visit_dates, by = "USUBJID") \%>\% - filter(ASTDTM > this_vis & (ASTDTM < next_vis | is_last == TRUE)) \%>\% - left_join(data_need_visit) \%>\% - distinct() - return(data_visit) -} -# derive AVISIT for ADAE and ADCM -ADAE <- add_visit(ADAE) -ADCM <- add_visit(ADCM) -# derive ongoing status variable for ADEX -ADEX <- ADEX \%>\% - filter(PARCAT1 == "INDIVIDUAL") \%>\% - mutate(ongo_status = (EOSSTT == "ONGOING")) - -app <- init( - data = cdisc_data( - cdisc_dataset("ADSL", ADSL), - cdisc_dataset("ADEX", ADEX), - cdisc_dataset("ADAE", ADAE), - cdisc_dataset("ADCM", ADCM, keys = c("STUDYID", "USUBJID", "ASTDTM", "CMSEQ", "CMDECOD")), - code = " - ADSL <- osprey::rADSL \%>\% slice(1:30) - ADEX <- osprey::rADEX \%>\% filter(USUBJID \%in\% ADSL$USUBJID) - ADAE <- osprey::rADAE \%>\% filter(USUBJID \%in\% ADSL$USUBJID) - ADCM <- osprey::rADCM \%>\% filter(USUBJID \%in\% ADSL$USUBJID) - ADCM <- ADCM \%>\% select(-starts_with(\"ATC\")) \%>\% unique() - ADEX <- ADEX \%>\% - filter(PARCAT1 == 'INDIVIDUAL') \%>\% - mutate(ongo_status = (EOSSTT == 'ONGOING')) - add_visit <- function(data_need_visit) { - visit_dates <- ADEX \%>\% - filter(PARAMCD == 'DOSE') \%>\% - distinct(USUBJID, AVISIT, ASTDTM) \%>\% - group_by(USUBJID) \%>\% - arrange(ASTDTM) \%>\% - mutate(next_vis = lead(ASTDTM), is_last = ifelse(is.na(next_vis), TRUE, FALSE)) \%>\% - rename(this_vis = ASTDTM) - data_visit <- data_need_visit \%>\% - select(USUBJID, ASTDTM) \%>\% - left_join(visit_dates, by = 'USUBJID') \%>\% - filter(ASTDTM > this_vis & (ASTDTM < next_vis | is_last == TRUE)) \%>\% - left_join(data_need_visit) \%>\% distinct() - return(data_visit) - } - ADAE <- add_visit(ADAE) - ADCM <- add_visit(ADCM) - ", - check = TRUE - ), - modules = modules( +data <- teal.data::cdisc_data() |> + within(library(dplyr)) |> + within(library(nestcolor)) |> + within(ADSL <- osprey::rADSL \%>\% slice(1:30)) |> + within(ADEX <- osprey::rADEX \%>\% filter(USUBJID \%in\% ADSL$USUBJID)) |> + within(ADAE <- osprey::rADAE \%>\% filter(USUBJID \%in\% ADSL$USUBJID)) |> + within(ADCM <- osprey::rADCM \%>\% filter(USUBJID \%in\% ADSL$USUBJID)) |> + # This preprocess is only to force legacy standard on ADCM + within(ADCM <- ADCM \%>\% select(-starts_with("ATC")) \%>\% unique()) |> + # function to derive AVISIT from ADEX + within(add_visit <- function(data_need_visit) { + visit_dates <- ADEX \%>\% + filter(PARAMCD == "DOSE") \%>\% + distinct(USUBJID, AVISIT, ASTDTM) \%>\% + group_by(USUBJID) \%>\% + arrange(ASTDTM) \%>\% + mutate(next_vis = lead(ASTDTM), is_last = ifelse(is.na(next_vis), TRUE, FALSE)) \%>\% + rename(this_vis = ASTDTM) + data_visit <- data_need_visit \%>\% + select(USUBJID, ASTDTM) \%>\% + left_join(visit_dates, by = "USUBJID") \%>\% + filter(ASTDTM > this_vis & (ASTDTM < next_vis | is_last == TRUE)) \%>\% + left_join(data_need_visit) \%>\% + distinct() + return(data_visit) + }) |> + # derive AVISIT for ADAE and ADCM + within(ADAE <- add_visit(ADAE)) |> + within(ADCM <- add_visit(ADCM)) |> + # derive ongoing status variable for ADEX + within(ADEX <- ADEX \%>\% filter(PARCAT1 == "INDIVIDUAL") \%>\% mutate(ongo_status = (EOSSTT == "ONGOING"))) + +teal.data::datanames(data) <- c("ADSL", "ADEX", "ADAE", "ADCM") +teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[teal.data::datanames(data)] + +ADSL <- data[["ADSL"]] +ADEX <- data[["ADEX"]] +ADAE <- data[["ADAE"]] +ADCM <- data[["ADCM"]] + +app <- teal::init( + data = data, + modules = teal::modules( tm_g_heat_bygrade( label = "Heatmap by grade", sl_dataname = "ADSL", @@ -186,4 +156,5 @@ app <- init( if (interactive()) { shinyApp(app$ui, app$server) } + } diff --git a/man/tm_g_patient_profile.Rd b/man/tm_g_patient_profile.Rd index 7d122fd6..4508e649 100644 --- a/man/tm_g_patient_profile.Rd +++ b/man/tm_g_patient_profile.Rd @@ -108,67 +108,30 @@ the start date } } \examples{ -library(nestcolor) - -ADSL <- osprey::rADSL -ADAE <- osprey::rADAE \%>\% - mutate( - ASTDT = as.Date(ASTDTM), - AENDT = as.Date(AENDTM) - ) -ADCM <- osprey::rADCM \%>\% - mutate( - ASTDT = as.Date(ASTDTM), - AENDT = as.Date(AENDTM) - ) - -# The step below is to pre-process ADCM to legacy standard -ADCM <- ADCM \%>\% - select(-starts_with("ATC")) \%>\% - unique() - -ADRS <- osprey::rADRS \%>\% - mutate(ADT = as.Date(ADTM)) -ADEX <- osprey::rADEX \%>\% - mutate( - ASTDT = as.Date(ASTDTM), - AENDT = as.Date(AENDTM) - ) -ADLB <- osprey::rADLB \%>\% - mutate( - ADT = as.Date(ADTM), - LBSTRESN = as.numeric(LBSTRESC) - ) - -app <- init( - data = cdisc_data( - cdisc_dataset("ADSL", ADSL, code = "ADSL <- osprey::rADSL"), - cdisc_dataset("ADRS", ADRS, code = "ADRS <- osprey::rADRS \%>\% mutate(ADT = as.Date(ADTM))"), - cdisc_dataset("ADAE", ADAE, - code = "ADAE <- osprey::rADAE \%>\% - mutate(ASTDT = as.Date(ASTDTM), - AENDT = as.Date(AENDTM))" - ), - cdisc_dataset("ADCM", ADCM, - code = "ADCM <- osprey::rADCM \%>\% - mutate(ASTDT = as.Date(ASTDTM), - AENDT = as.Date(AENDTM)) - ADCM <- ADCM \%>\% select(-starts_with(\"ATC\")) \%>\% unique()", - keys = c("STUDYID", "USUBJID", "ASTDTM", "CMSEQ", "CMDECOD") - ), - cdisc_dataset("ADLB", ADLB, - code = "ADLB <- osprey::rADLB \%>\% - mutate(ADT = as.Date(ADTM), - LBSTRESN = as.numeric(LBSTRESC))" - ), - cdisc_dataset("ADEX", ADEX, - code = "ADEX <- osprey::rADEX \%>\% - mutate(ASTDT = as.Date(ASTDTM), - AENDT = as.Date(AENDTM))" - ), - check = FALSE # set FALSE here to keep run time of example short, should be set to TRUE - ), - modules = modules( +data <- teal.data::cdisc_data() |> + within(library(nestcolor)) |> + within(ADSL <- osprey::rADSL) |> + within(ADAE <- osprey::rADAE \%>\% mutate(ASTDT = as.Date(ASTDTM), AENDT = as.Date(AENDTM))) |> + within(ADCM <- osprey::rADCM \%>\% mutate(ASTDT = as.Date(ASTDTM), AENDT = as.Date(AENDTM))) |> + # The step below is to pre-process ADCM to legacy standard + within(ADCM <- ADCM \%>\% select(-starts_with("ATC")) \%>\% unique()) |> + within(ADRS <- osprey::rADRS \%>\% mutate(ADT = as.Date(ADTM))) |> + within(ADEX <- osprey::rADEX \%>\% mutate(ASTDT = as.Date(ASTDTM), AENDT = as.Date(AENDTM))) |> + within(ADLB <- osprey::rADLB \%>\% mutate(ADT = as.Date(ADTM), LBSTRESN = as.numeric(LBSTRESC))) + +teal.data::datanames(data) <- c("ADSL", "ADAE", "ADCM", "ADRS", "ADEX", "ADLB") +teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[teal.data::datanames(data)] + +ADSL <- data[["ADSL"]] +ADAE <- data[["ADAE"]] +ADCM <- data[["ADCM"]] +ADRS <- data[["ADRS"]] +ADEX <- data[["ADEX"]] +ADLB <- data[["ADLB"]] + +app <- teal::init( + data = data, + modules = teal::modules( tm_g_patient_profile( label = "Patient Profile Plot", patient_id = teal.transform::choices_selected( diff --git a/man/tm_g_spiderplot.Rd b/man/tm_g_spiderplot.Rd index 2d28e6eb..107c582f 100644 --- a/man/tm_g_spiderplot.Rd +++ b/man/tm_g_spiderplot.Rd @@ -77,24 +77,22 @@ the \code{\link[teal:module]{teal::module()}} object. Display spider plot as a shiny module } \examples{ - # Example using stream (ADaM) dataset -library(dplyr) -library(nestcolor) +data <- teal.data::cdisc_data() |> + within(library(dplyr)) |> + within(library(nestcolor)) |> + within(ADSL <- osprey::rADSL) |> + within(ADTR <- osprey::rADTR) + +teal.data::datanames(data) <- c("ADSL", "ADTR") +teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[teal.data::datanames(data)] -ADSL <- osprey::rADSL -ADTR <- osprey::rADTR +ADSL <- data[["ADSL"]] +ADTR <- data[["ADTR"]] app <- teal::init( - data = cdisc_data( - cdisc_dataset("ADSL", ADSL, code = "ADSL <- osprey::rADSL"), - cdisc_dataset("ADTR", ADTR, - code = "ADTR <- osprey::rADTR", - keys = c("STUDYID", "USUBJID", "PARAMCD", "AVISIT") - ), - check = TRUE - ), - modules = modules( + data = data, + modules = teal::modules( tm_g_spiderplot( label = "Spider plot", dataname = "ADTR", diff --git a/man/tm_g_swimlane.Rd b/man/tm_g_swimlane.Rd index 0f9dca4d..54a68ff4 100644 --- a/man/tm_g_swimlane.Rd +++ b/man/tm_g_swimlane.Rd @@ -81,37 +81,29 @@ the \code{\link[teal:module]{teal::module()}} object. This is teal module that generates a \code{swimlane} plot (bar plot with markers) for \code{ADaM} data } \examples{ - # Example using stream (ADaM) dataset -library(dplyr) -library(nestcolor) - -ADSL <- osprey::rADSL \%>\% - dplyr::mutate(TRTDURD = as.integer(TRTEDTM - TRTSDTM) + 1) \%>\% - dplyr::filter(STRATA1 == "A" & ARMCD == "ARM A") -ADRS <- osprey::rADRS - -ADRS <- ADRS \%>\% - dplyr::filter(PARAMCD == "LSTASDI" & DCSREAS == "Death") \%>\% - mutate(AVALC = DCSREAS, ADY = EOSDY) \%>\% - base::rbind(ADRS \%>\% dplyr::filter(PARAMCD == "OVRINV" & AVALC != "NE")) \%>\% - arrange(USUBJID) - -app <- init( - data = cdisc_data( - cdisc_dataset("ADSL", ADSL, code = "ADSL <- osprey::rADSL \%>\% - dplyr::mutate(TRTDURD = as.integer(TRTEDTM - TRTSDTM) + 1) \%>\% - dplyr::filter(STRATA1 == 'A' & ARMCD == 'ARM A')"), - cdisc_dataset("ADRS", ADRS, - code = "ADRS <- rADRS - ADRS <- ADRS \%>\% dplyr::filter(PARAMCD == 'LSTASDI' & DCSREAS == 'Death') \%>\% - mutate(AVALC = DCSREAS, ADY = EOSDY) \%>\% - rbind(ADRS \%>\% dplyr::filter(PARAMCD == 'OVRINV' & AVALC != 'NE')) \%>\% - arrange(USUBJID)" - ), - check = TRUE - ), - modules = modules( +data <- teal.data::cdisc_data() |> + within(library(dplyr)) |> + within(library(nestcolor)) |> + within(ADSL <- osprey::rADSL \%>\% + dplyr::mutate(TRTDURD = as.integer(TRTEDTM - TRTSDTM) + 1) \%>\% + dplyr::filter(STRATA1 == "A" & ARMCD == "ARM A")) |> + within(ADRS <- osprey::rADRS) |> + within(ADRS <- ADRS \%>\% + dplyr::filter(PARAMCD == "LSTASDI" & DCSREAS == "Death") \%>\% + mutate(AVALC = DCSREAS, ADY = EOSDY) \%>\% + base::rbind(ADRS \%>\% dplyr::filter(PARAMCD == "OVRINV" & AVALC != "NE")) \%>\% + arrange(USUBJID)) + +teal.data::datanames(data) <- c("ADSL", "ADRS") +teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[teal.data::datanames(data)] + +ADSL <- data[["ADSL"]] +ADRS <- data[["ADRS"]] + +app <- teal::init( + data = data, + modules = teal::modules( tm_g_swimlane( label = "Swimlane Plot", dataname = "ADRS", diff --git a/man/tm_g_waterfall.Rd b/man/tm_g_waterfall.Rd index 0667c00f..0cf1cab6 100644 --- a/man/tm_g_waterfall.Rd +++ b/man/tm_g_waterfall.Rd @@ -100,27 +100,23 @@ the \code{\link[teal:module]{teal::module()}} object. This is teal module that generates a waterfall plot for \code{ADaM} data } \examples{ -library(nestcolor) -ADSL <- osprey::rADSL -ADRS <- osprey::rADRS -ADTR <- osprey::rADTR +data <- teal.data::cdisc_data() |> + within(library(nestcolor)) |> + within(ADSL <- osprey::rADSL) |> + within(ADRS <- osprey::rADRS) |> + within(ADTR <- osprey::rADTR) |> + within(ADSL$SEX <- factor(ADSL$SEX, levels = unique(ADSL$SEX))) -ADSL$SEX <- factor(ADSL$SEX, levels = unique(ADSL$SEX)) +teal.data::datanames(data) <- c("ADSL", "ADTR", "ADRS") +teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[teal.data::datanames(data)] + +ADSL <- data[["ADSL"]] +ADTR <- data[["ADTR"]] +ADRS <- data[["ADRS"]] app <- teal::init( - data = cdisc_data( - cdisc_dataset("ADSL", ADSL, - code = "ADSL <- rADSL - ADSL$SEX <- factor(ADSL$SEX, levels = unique(ADSL$SEX))" - ), - cdisc_dataset("ADRS", ADRS, code = "ADRS <- rADRS"), - cdisc_dataset("ADTR", ADTR, - code = " ADTR <- rADTR", - c("STUDYID", "USUBJID", "PARAMCD", "AVISIT") - ), - check = TRUE - ), - modules = modules( + data = data, + modules = teal::modules( tm_g_waterfall( label = "Waterfall", dataname_tr = "ADTR", @@ -142,6 +138,7 @@ app <- teal::init( if (interactive()) { shinyApp(app$ui, app$server) } +#' } \author{ Ting Qi (qit3) \email{qit3@gene.com} From e093900944b31f1766925e21b31e5bb5a0588ecd Mon Sep 17 00:00:00 2001 From: Aleksander Chlebowski Date: Thu, 16 Nov 2023 13:53:03 +0100 Subject: [PATCH 4/8] remove unnecessary variable assignments --- R/tm_g_ae_oview.R | 7 +++---- R/tm_g_ae_sub.R | 3 --- R/tm_g_butterfly.R | 3 --- R/tm_g_events_term_id.R | 3 --- R/tm_g_heat_bygrade.R | 3 --- R/tm_g_patient_profile.R | 5 ----- R/tm_g_spiderplot.R | 3 --- R/tm_g_waterfall.R | 6 +----- man/tm_g_ae_oview.Rd | 7 +++---- man/tm_g_ae_sub.Rd | 3 --- man/tm_g_butterfly.Rd | 3 --- man/tm_g_events_term_id.Rd | 3 --- man/tm_g_heat_bygrade.Rd | 3 --- man/tm_g_patient_profile.Rd | 5 ----- man/tm_g_spiderplot.Rd | 3 --- man/tm_g_waterfall.Rd | 6 +----- 16 files changed, 8 insertions(+), 58 deletions(-) diff --git a/R/tm_g_ae_oview.R b/R/tm_g_ae_oview.R index 4cd49b0d..b83cca4f 100644 --- a/R/tm_g_ae_oview.R +++ b/R/tm_g_ae_oview.R @@ -16,7 +16,7 @@ #' @export #' #' @examples -#' data <- teal.data::cdisc_data() |> +#' data <- cdisc_data() |> #' within(library(nestcolor)) |> #' within(ADSL <- osprey::rADSL) |> #' within(ADAE <- osprey::rADAE) |> @@ -41,10 +41,9 @@ #' }) |> #' within(ADAE <- add_event_flags(ADAE)) #' -#' teal.data::datanames(data) <- c("ADSL", "ADAE") -#' teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[teal.data::datanames(data)] +#' datanames(data) <- c("ADSL", "ADAE") +#' join_keys(data) <- default_cdisc_join_keys[datanames(data)] #' -#' ADSL <- data[["ADSL"]] #' ADAE <- data[["ADAE"]] #' #' app <- teal::init( diff --git a/R/tm_g_ae_sub.R b/R/tm_g_ae_sub.R index 3ed81c38..13644bc6 100644 --- a/R/tm_g_ae_sub.R +++ b/R/tm_g_ae_sub.R @@ -25,9 +25,6 @@ #' teal.data::datanames(data) <- c("ADSL", "ADAE") #' teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[teal.data::datanames(data)] #' -#' ADSL <- data[["ADSL"]] -#' ADAE <- data[["ADAE"]] -#' #' app <- teal::init( #' data = data, #' modules = teal::modules( diff --git a/R/tm_g_butterfly.R b/R/tm_g_butterfly.R index 96550f99..e462f53e 100644 --- a/R/tm_g_butterfly.R +++ b/R/tm_g_butterfly.R @@ -61,9 +61,6 @@ #' teal.data::datanames(data) <- c("ADSL", "ADAE") #' teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[teal.data::datanames(data)] #' -#' ADSL <- data[["ADSL"]] -#' ADAE <- data[["ADAE"]] -#' #' app <- teal::init( #' data = data, #' modules = teal::modules( diff --git a/R/tm_g_events_term_id.R b/R/tm_g_events_term_id.R index 9ba45542..60f0fcde 100644 --- a/R/tm_g_events_term_id.R +++ b/R/tm_g_events_term_id.R @@ -26,9 +26,6 @@ #' teal.data::datanames(data) <- c("ADSL", "ADAE") #' teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[teal.data::datanames(data)] #' -#' ADSL <- data[["ADSL"]] -#' ADAE <- data[["ADAE"]] -#' #' app <- teal::init( #' data = data, #' modules = teal::modules( diff --git a/R/tm_g_heat_bygrade.R b/R/tm_g_heat_bygrade.R index 4738cdbd..1435755b 100644 --- a/R/tm_g_heat_bygrade.R +++ b/R/tm_g_heat_bygrade.R @@ -69,9 +69,6 @@ #' teal.data::datanames(data) <- c("ADSL", "ADEX", "ADAE", "ADCM") #' teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[teal.data::datanames(data)] #' -#' ADSL <- data[["ADSL"]] -#' ADEX <- data[["ADEX"]] -#' ADAE <- data[["ADAE"]] #' ADCM <- data[["ADCM"]] #' #' app <- teal::init( diff --git a/R/tm_g_patient_profile.R b/R/tm_g_patient_profile.R index bb5fa5c4..2c792b1c 100644 --- a/R/tm_g_patient_profile.R +++ b/R/tm_g_patient_profile.R @@ -77,11 +77,6 @@ #' teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[teal.data::datanames(data)] #' #' ADSL <- data[["ADSL"]] -#' ADAE <- data[["ADAE"]] -#' ADCM <- data[["ADCM"]] -#' ADRS <- data[["ADRS"]] -#' ADEX <- data[["ADEX"]] -#' ADLB <- data[["ADLB"]] #' #' app <- teal::init( #' data = data, diff --git a/R/tm_g_spiderplot.R b/R/tm_g_spiderplot.R index c002ad9c..8c2161c5 100644 --- a/R/tm_g_spiderplot.R +++ b/R/tm_g_spiderplot.R @@ -35,9 +35,6 @@ #' teal.data::datanames(data) <- c("ADSL", "ADTR") #' teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[teal.data::datanames(data)] #' -#' ADSL <- data[["ADSL"]] -#' ADTR <- data[["ADTR"]] -#' #' app <- teal::init( #' data = data, #' modules = teal::modules( diff --git a/R/tm_g_waterfall.R b/R/tm_g_waterfall.R index 8e42b8fb..8d37ecb4 100644 --- a/R/tm_g_waterfall.R +++ b/R/tm_g_waterfall.R @@ -57,10 +57,6 @@ #' teal.data::datanames(data) <- c("ADSL", "ADTR", "ADRS") #' teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[teal.data::datanames(data)] #' -#' ADSL <- data[["ADSL"]] -#' ADTR <- data[["ADTR"]] -#' ADRS <- data[["ADRS"]] -#' #' app <- teal::init( #' data = data, #' modules = teal::modules( @@ -85,7 +81,7 @@ #' if (interactive()) { #' shinyApp(app$ui, app$server) #' } -#' #' +#' tm_g_waterfall <- function(label, dataname_tr = "ADTR", dataname_rs = "ADRS", diff --git a/man/tm_g_ae_oview.Rd b/man/tm_g_ae_oview.Rd index 06e0e486..706305f8 100644 --- a/man/tm_g_ae_oview.Rd +++ b/man/tm_g_ae_oview.Rd @@ -51,7 +51,7 @@ the \code{\link[teal:module]{teal::module()}} object. Display the \code{AE} overview plot as a shiny module } \examples{ -data <- teal.data::cdisc_data() |> +data <- cdisc_data() |> within(library(nestcolor)) |> within(ADSL <- osprey::rADSL) |> within(ADAE <- osprey::rADAE) |> @@ -76,10 +76,9 @@ data <- teal.data::cdisc_data() |> }) |> within(ADAE <- add_event_flags(ADAE)) -teal.data::datanames(data) <- c("ADSL", "ADAE") -teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[teal.data::datanames(data)] +datanames(data) <- c("ADSL", "ADAE") +join_keys(data) <- default_cdisc_join_keys[datanames(data)] -ADSL <- data[["ADSL"]] ADAE <- data[["ADAE"]] app <- teal::init( diff --git a/man/tm_g_ae_sub.Rd b/man/tm_g_ae_sub.Rd index ddf1ce3f..0c40830f 100644 --- a/man/tm_g_ae_sub.Rd +++ b/man/tm_g_ae_sub.Rd @@ -57,9 +57,6 @@ data <- teal.data::cdisc_data() |> teal.data::datanames(data) <- c("ADSL", "ADAE") teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[teal.data::datanames(data)] -ADSL <- data[["ADSL"]] -ADAE <- data[["ADAE"]] - app <- teal::init( data = data, modules = teal::modules( diff --git a/man/tm_g_butterfly.Rd b/man/tm_g_butterfly.Rd index c9e96684..fc606b32 100644 --- a/man/tm_g_butterfly.Rd +++ b/man/tm_g_butterfly.Rd @@ -107,9 +107,6 @@ data <- teal.data::cdisc_data() |> teal.data::datanames(data) <- c("ADSL", "ADAE") teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[teal.data::datanames(data)] -ADSL <- data[["ADSL"]] -ADAE <- data[["ADAE"]] - app <- teal::init( data = data, modules = teal::modules( diff --git a/man/tm_g_events_term_id.Rd b/man/tm_g_events_term_id.Rd index 75fdf48c..504b536a 100644 --- a/man/tm_g_events_term_id.Rd +++ b/man/tm_g_events_term_id.Rd @@ -58,9 +58,6 @@ data <- teal.data::cdisc_data() |> teal.data::datanames(data) <- c("ADSL", "ADAE") teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[teal.data::datanames(data)] -ADSL <- data[["ADSL"]] -ADAE <- data[["ADAE"]] - app <- teal::init( data = data, modules = teal::modules( diff --git a/man/tm_g_heat_bygrade.Rd b/man/tm_g_heat_bygrade.Rd index 8b516746..9f868114 100644 --- a/man/tm_g_heat_bygrade.Rd +++ b/man/tm_g_heat_bygrade.Rd @@ -111,9 +111,6 @@ data <- teal.data::cdisc_data() |> teal.data::datanames(data) <- c("ADSL", "ADEX", "ADAE", "ADCM") teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[teal.data::datanames(data)] -ADSL <- data[["ADSL"]] -ADEX <- data[["ADEX"]] -ADAE <- data[["ADAE"]] ADCM <- data[["ADCM"]] app <- teal::init( diff --git a/man/tm_g_patient_profile.Rd b/man/tm_g_patient_profile.Rd index 4508e649..8d649905 100644 --- a/man/tm_g_patient_profile.Rd +++ b/man/tm_g_patient_profile.Rd @@ -123,11 +123,6 @@ teal.data::datanames(data) <- c("ADSL", "ADAE", "ADCM", "ADRS", "ADEX", "ADLB") teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[teal.data::datanames(data)] ADSL <- data[["ADSL"]] -ADAE <- data[["ADAE"]] -ADCM <- data[["ADCM"]] -ADRS <- data[["ADRS"]] -ADEX <- data[["ADEX"]] -ADLB <- data[["ADLB"]] app <- teal::init( data = data, diff --git a/man/tm_g_spiderplot.Rd b/man/tm_g_spiderplot.Rd index 107c582f..b6a2e6ac 100644 --- a/man/tm_g_spiderplot.Rd +++ b/man/tm_g_spiderplot.Rd @@ -87,9 +87,6 @@ data <- teal.data::cdisc_data() |> teal.data::datanames(data) <- c("ADSL", "ADTR") teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[teal.data::datanames(data)] -ADSL <- data[["ADSL"]] -ADTR <- data[["ADTR"]] - app <- teal::init( data = data, modules = teal::modules( diff --git a/man/tm_g_waterfall.Rd b/man/tm_g_waterfall.Rd index 0cf1cab6..8743cb1f 100644 --- a/man/tm_g_waterfall.Rd +++ b/man/tm_g_waterfall.Rd @@ -110,10 +110,6 @@ data <- teal.data::cdisc_data() |> teal.data::datanames(data) <- c("ADSL", "ADTR", "ADRS") teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[teal.data::datanames(data)] -ADSL <- data[["ADSL"]] -ADTR <- data[["ADTR"]] -ADRS <- data[["ADRS"]] - app <- teal::init( data = data, modules = teal::modules( @@ -138,7 +134,7 @@ app <- teal::init( if (interactive()) { shinyApp(app$ui, app$server) } -#' + } \author{ Ting Qi (qit3) \email{qit3@gene.com} From 04b366ce462b3d6cfca6cb7e92d99a2ca728d716 Mon Sep 17 00:00:00 2001 From: Aleksander Chlebowski Date: Thu, 16 Nov 2023 14:05:53 +0100 Subject: [PATCH 5/8] temporarily restore prefixes --- R/tm_g_ae_oview.R | 4 ++-- man/tm_g_ae_oview.Rd | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/R/tm_g_ae_oview.R b/R/tm_g_ae_oview.R index b83cca4f..aa53f067 100644 --- a/R/tm_g_ae_oview.R +++ b/R/tm_g_ae_oview.R @@ -41,8 +41,8 @@ #' }) |> #' within(ADAE <- add_event_flags(ADAE)) #' -#' datanames(data) <- c("ADSL", "ADAE") -#' join_keys(data) <- default_cdisc_join_keys[datanames(data)] +#' teal.data::datanames(data) <- c("ADSL", "ADAE") +#' teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[datanames(data)] #' #' ADAE <- data[["ADAE"]] #' diff --git a/man/tm_g_ae_oview.Rd b/man/tm_g_ae_oview.Rd index 706305f8..67d3e8e2 100644 --- a/man/tm_g_ae_oview.Rd +++ b/man/tm_g_ae_oview.Rd @@ -76,8 +76,8 @@ data <- cdisc_data() |> }) |> within(ADAE <- add_event_flags(ADAE)) -datanames(data) <- c("ADSL", "ADAE") -join_keys(data) <- default_cdisc_join_keys[datanames(data)] +teal.data::datanames(data) <- c("ADSL", "ADAE") +teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[datanames(data)] ADAE <- data[["ADAE"]] From ca5073cfb656a0e5725a296ab99a5eed96cab096 Mon Sep 17 00:00:00 2001 From: Aleksander Chlebowski Date: Thu, 16 Nov 2023 14:32:45 +0100 Subject: [PATCH 6/8] single within calls --- R/tm_g_ae_oview.R | 42 ++++++++++++------------ R/tm_g_ae_sub.R | 8 +++-- R/tm_g_butterfly.R | 26 ++++++++------- R/tm_g_events_term_id.R | 6 ++-- R/tm_g_heat_bygrade.R | 64 ++++++++++++++++++++----------------- R/tm_g_patient_profile.R | 19 ++++++----- R/tm_g_spiderplot.R | 12 ++++--- R/tm_g_waterfall.R | 10 +++--- man/tm_g_ae_oview.Rd | 42 ++++++++++++------------ man/tm_g_ae_sub.Rd | 7 ++-- man/tm_g_butterfly.Rd | 25 ++++++++------- man/tm_g_events_term_id.Rd | 6 ++-- man/tm_g_heat_bygrade.Rd | 64 ++++++++++++++++++++----------------- man/tm_g_patient_profile.Rd | 19 ++++++----- man/tm_g_spiderplot.Rd | 12 ++++--- man/tm_g_waterfall.Rd | 10 +++--- 16 files changed, 206 insertions(+), 166 deletions(-) diff --git a/R/tm_g_ae_oview.R b/R/tm_g_ae_oview.R index aa53f067..374f511d 100644 --- a/R/tm_g_ae_oview.R +++ b/R/tm_g_ae_oview.R @@ -18,28 +18,30 @@ #' @examples #' data <- cdisc_data() |> #' within(library(nestcolor)) |> -#' within(ADSL <- osprey::rADSL) |> -#' within(ADAE <- osprey::rADAE) |> -#' within(add_event_flags <- function(dat) { -#' dat <- dat |> -#' dplyr::mutate( -#' TMPFL_SER = AESER == "Y", -#' TMPFL_REL = AEREL == "Y", -#' TMPFL_GR5 = AETOXGR == "5", -#' AEREL1 = (AEREL == "Y" & ACTARM == "A: Drug X"), -#' AEREL2 = (AEREL == "Y" & ACTARM == "B: Placebo") +#' within({ +#' ADSL <- osprey::rADSL +#' ADAE <- osprey::rADAE +#' add_event_flags <- function(dat) { +#' dat <- dat |> +#' dplyr::mutate( +#' TMPFL_SER = AESER == "Y", +#' TMPFL_REL = AEREL == "Y", +#' TMPFL_GR5 = AETOXGR == "5", +#' AEREL1 = (AEREL == "Y" & ACTARM == "A: Drug X"), +#' AEREL2 = (AEREL == "Y" & ACTARM == "B: Placebo") +#' ) +#' labels <- c( +#' "Serious AE", "Related AE", "Grade 5 AE", +#' "AE related to A: Drug X", "AE related to B: Placebo" #' ) -#' labels <- c( -#' "Serious AE", "Related AE", "Grade 5 AE", -#' "AE related to A: Drug X", "AE related to B: Placebo" -#' ) -#' cols <- c("TMPFL_SER", "TMPFL_REL", "TMPFL_GR5", "AEREL1", "AEREL2") -#' for (i in seq_along(labels)) { -#' attr(dat[[cols[i]]], "label") <- labels[i] +#' cols <- c("TMPFL_SER", "TMPFL_REL", "TMPFL_GR5", "AEREL1", "AEREL2") +#' for (i in seq_along(labels)) { +#' attr(dat[[cols[i]]], "label") <- labels[i] +#' } +#' dat #' } -#' dat -#' }) |> -#' within(ADAE <- add_event_flags(ADAE)) +#' ADAE <- add_event_flags(ADAE) +#' }) #' #' teal.data::datanames(data) <- c("ADSL", "ADAE") #' teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[datanames(data)] diff --git a/R/tm_g_ae_sub.R b/R/tm_g_ae_sub.R index 13644bc6..1c9a2fbb 100644 --- a/R/tm_g_ae_sub.R +++ b/R/tm_g_ae_sub.R @@ -17,10 +17,12 @@ #' @export #' #' @examples -#' # Example using stream (ADaM) dataset +# Example using stream (ADaM) dataset #' data <- teal.data::cdisc_data() |> -#' within(ADSL <- osprey::rADSL) |> -#' within(ADAE <- osprey::rADAE) +#' within({ +#' ADSL <- osprey::rADSL +#' ADAE <- osprey::rADAE +#' }) #' #' teal.data::datanames(data) <- c("ADSL", "ADAE") #' teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[teal.data::datanames(data)] diff --git a/R/tm_g_butterfly.R b/R/tm_g_butterfly.R index e462f53e..5cd7e85d 100644 --- a/R/tm_g_butterfly.R +++ b/R/tm_g_butterfly.R @@ -40,23 +40,25 @@ #' @template author_liaoc10 #' #' @examples -#' # Example using stream (ADaM) dataset +# Example using stream (ADaM) dataset #' data <- teal.data::cdisc_data() |> #' within({ #' library(dplyr) #' library(nestcolor) #' }) |> -#' within(set.seed(23)) |> -#' within(ADSL <- osprey::rADSL) |> -#' within(ADAE <- osprey::rADAE) |> -#' within(ADSL <- mutate(ADSL, DOSE = paste(sample(1:3, n(), replace = TRUE), "UG"))) |> -#' within(ADAE <- mutate( -#' ADAE, -#' flag1 = ifelse(AETOXGR == 1, 1, 0), -#' flag2 = ifelse(AETOXGR == 2, 1, 0), -#' flag3 = ifelse(AETOXGR == 3, 1, 0), -#' flag1_filt = rep("Y", n()) -#' )) +#' within({ +#' set.seed(23) +#' ADSL <- osprey::rADSL +#' ADAE <- osprey::rADAE +#' ADSL <- mutate(ADSL, DOSE = paste(sample(1:3, n(), replace = TRUE), "UG")) +#' ADAE <- mutate( +#' ADAE, +#' flag1 = ifelse(AETOXGR == 1, 1, 0), +#' flag2 = ifelse(AETOXGR == 2, 1, 0), +#' flag3 = ifelse(AETOXGR == 3, 1, 0), +#' flag1_filt = rep("Y", n()) +#' ) +#' }) #' #' teal.data::datanames(data) <- c("ADSL", "ADAE") #' teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[teal.data::datanames(data)] diff --git a/R/tm_g_events_term_id.R b/R/tm_g_events_term_id.R index 60f0fcde..6fd75a17 100644 --- a/R/tm_g_events_term_id.R +++ b/R/tm_g_events_term_id.R @@ -20,8 +20,10 @@ #' @examples #' data <- teal.data::cdisc_data() |> #' within(library(nestcolor)) |> -#' within(ADSL <- osprey::rADSL) |> -#' within(ADAE <- osprey::rADAE) +#' within({ +#' ADSL <- osprey::rADSL +#' ADAE <- osprey::rADAE +#' }) #' #' teal.data::datanames(data) <- c("ADSL", "ADAE") #' teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[teal.data::datanames(data)] diff --git a/R/tm_g_heat_bygrade.R b/R/tm_g_heat_bygrade.R index 1435755b..7ace55d0 100644 --- a/R/tm_g_heat_bygrade.R +++ b/R/tm_g_heat_bygrade.R @@ -35,36 +35,40 @@ #' #' @examples #' data <- teal.data::cdisc_data() |> -#' within(library(dplyr)) |> -#' within(library(nestcolor)) |> -#' within(ADSL <- osprey::rADSL %>% slice(1:30)) |> -#' within(ADEX <- osprey::rADEX %>% filter(USUBJID %in% ADSL$USUBJID)) |> -#' within(ADAE <- osprey::rADAE %>% filter(USUBJID %in% ADSL$USUBJID)) |> -#' within(ADCM <- osprey::rADCM %>% filter(USUBJID %in% ADSL$USUBJID)) |> -#' # This preprocess is only to force legacy standard on ADCM -#' within(ADCM <- ADCM %>% select(-starts_with("ATC")) %>% unique()) |> -#' # function to derive AVISIT from ADEX -#' within(add_visit <- function(data_need_visit) { -#' visit_dates <- ADEX %>% -#' filter(PARAMCD == "DOSE") %>% -#' distinct(USUBJID, AVISIT, ASTDTM) %>% -#' group_by(USUBJID) %>% -#' arrange(ASTDTM) %>% -#' mutate(next_vis = lead(ASTDTM), is_last = ifelse(is.na(next_vis), TRUE, FALSE)) %>% -#' rename(this_vis = ASTDTM) -#' data_visit <- data_need_visit %>% -#' select(USUBJID, ASTDTM) %>% -#' left_join(visit_dates, by = "USUBJID") %>% -#' filter(ASTDTM > this_vis & (ASTDTM < next_vis | is_last == TRUE)) %>% -#' left_join(data_need_visit) %>% -#' distinct() -#' return(data_visit) -#' }) |> -#' # derive AVISIT for ADAE and ADCM -#' within(ADAE <- add_visit(ADAE)) |> -#' within(ADCM <- add_visit(ADCM)) |> -#' # derive ongoing status variable for ADEX -#' within(ADEX <- ADEX %>% filter(PARCAT1 == "INDIVIDUAL") %>% mutate(ongo_status = (EOSSTT == "ONGOING"))) +#' within({ +#' library(dplyr) +#' library(nestcolor) +#' }) |> +#' within({ +#' ADSL <- osprey::rADSL %>% slice(1:30) +#' ADEX <- osprey::rADEX %>% filter(USUBJID %in% ADSL$USUBJID) +#' ADAE <- osprey::rADAE %>% filter(USUBJID %in% ADSL$USUBJID) +#' ADCM <- osprey::rADCM %>% filter(USUBJID %in% ADSL$USUBJID) +#' # This preprocess is only to force legacy standard on ADCM +#' ADCM <- ADCM %>% select(-starts_with("ATC")) %>% unique() +#' # function to derive AVISIT from ADEX +#' add_visit <- function(data_need_visit) { +#' visit_dates <- ADEX %>% +#' filter(PARAMCD == "DOSE") %>% +#' distinct(USUBJID, AVISIT, ASTDTM) %>% +#' group_by(USUBJID) %>% +#' arrange(ASTDTM) %>% +#' mutate(next_vis = lead(ASTDTM), is_last = ifelse(is.na(next_vis), TRUE, FALSE)) %>% +#' rename(this_vis = ASTDTM) +#' data_visit <- data_need_visit %>% +#' select(USUBJID, ASTDTM) %>% +#' left_join(visit_dates, by = "USUBJID") %>% +#' filter(ASTDTM > this_vis & (ASTDTM < next_vis | is_last == TRUE)) %>% +#' left_join(data_need_visit) %>% +#' distinct() +#' return(data_visit) +#' } +#' # derive AVISIT for ADAE and ADCM +#' ADAE <- add_visit(ADAE) +#' ADCM <- add_visit(ADCM) +#' # derive ongoing status variable for ADEX +#' ADEX <- ADEX %>% filter(PARCAT1 == "INDIVIDUAL") %>% mutate(ongo_status = (EOSSTT == "ONGOING")) +#' }) #' #' teal.data::datanames(data) <- c("ADSL", "ADEX", "ADAE", "ADCM") #' teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[teal.data::datanames(data)] diff --git a/R/tm_g_patient_profile.R b/R/tm_g_patient_profile.R index 2c792b1c..930d1c4f 100644 --- a/R/tm_g_patient_profile.R +++ b/R/tm_g_patient_profile.R @@ -64,14 +64,17 @@ #' @examples #' data <- teal.data::cdisc_data() |> #' within(library(nestcolor)) |> -#' within(ADSL <- osprey::rADSL) |> -#' within(ADAE <- osprey::rADAE %>% mutate(ASTDT = as.Date(ASTDTM), AENDT = as.Date(AENDTM))) |> -#' within(ADCM <- osprey::rADCM %>% mutate(ASTDT = as.Date(ASTDTM), AENDT = as.Date(AENDTM))) |> -#' # The step below is to pre-process ADCM to legacy standard -#' within(ADCM <- ADCM %>% select(-starts_with("ATC")) %>% unique()) |> -#' within(ADRS <- osprey::rADRS %>% mutate(ADT = as.Date(ADTM))) |> -#' within(ADEX <- osprey::rADEX %>% mutate(ASTDT = as.Date(ASTDTM), AENDT = as.Date(AENDTM))) |> -#' within(ADLB <- osprey::rADLB %>% mutate(ADT = as.Date(ADTM), LBSTRESN = as.numeric(LBSTRESC))) +#' within({ +#' ADSL <- osprey::rADSL +#' ADAE <- osprey::rADAE %>% mutate(ASTDT = as.Date(ASTDTM), AENDT = as.Date(AENDTM)) +#' ADCM <- osprey::rADCM %>% mutate(ASTDT = as.Date(ASTDTM), AENDT = as.Date(AENDTM)) +#' # The step below is to pre-process ADCM to legacy standard +#' ADCM <- ADCM %>% select(-starts_with("ATC")) %>% unique() +#' ADRS <- osprey::rADRS %>% mutate(ADT = as.Date(ADTM)) +#' ADEX <- osprey::rADEX %>% mutate(ASTDT = as.Date(ASTDTM), AENDT = as.Date(AENDTM)) +#' ADLB <- osprey::rADLB %>% mutate(ADT = as.Date(ADTM), LBSTRESN = as.numeric(LBSTRESC)) +#' +#' }) #' #' teal.data::datanames(data) <- c("ADSL", "ADAE", "ADCM", "ADRS", "ADEX", "ADLB") #' teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[teal.data::datanames(data)] diff --git a/R/tm_g_spiderplot.R b/R/tm_g_spiderplot.R index 8c2161c5..968dbd4d 100644 --- a/R/tm_g_spiderplot.R +++ b/R/tm_g_spiderplot.R @@ -27,10 +27,14 @@ #' @examples #' # Example using stream (ADaM) dataset #' data <- teal.data::cdisc_data() |> -#' within(library(dplyr)) |> -#' within(library(nestcolor)) |> -#' within(ADSL <- osprey::rADSL) |> -#' within(ADTR <- osprey::rADTR) +#' within({ +#' library(dplyr) +#' library(nestcolor) +#' }) |> +#' within({ +#' ADSL <- osprey::rADSL +#' ADTR <- osprey::rADTR +#' }) #' #' teal.data::datanames(data) <- c("ADSL", "ADTR") #' teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[teal.data::datanames(data)] diff --git a/R/tm_g_waterfall.R b/R/tm_g_waterfall.R index 8d37ecb4..c4e90f44 100644 --- a/R/tm_g_waterfall.R +++ b/R/tm_g_waterfall.R @@ -49,10 +49,12 @@ #' @examples #' data <- teal.data::cdisc_data() |> #' within(library(nestcolor)) |> -#' within(ADSL <- osprey::rADSL) |> -#' within(ADRS <- osprey::rADRS) |> -#' within(ADTR <- osprey::rADTR) |> -#' within(ADSL$SEX <- factor(ADSL$SEX, levels = unique(ADSL$SEX))) +#' within({ +#' ADSL <- osprey::rADSL +#' ADRS <- osprey::rADRS +#' ADTR <- osprey::rADTR +#' ADSL$SEX <- factor(ADSL$SEX, levels = unique(ADSL$SEX)) +#' }) #' #' teal.data::datanames(data) <- c("ADSL", "ADTR", "ADRS") #' teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[teal.data::datanames(data)] diff --git a/man/tm_g_ae_oview.Rd b/man/tm_g_ae_oview.Rd index 67d3e8e2..aedcaa2a 100644 --- a/man/tm_g_ae_oview.Rd +++ b/man/tm_g_ae_oview.Rd @@ -53,28 +53,30 @@ Display the \code{AE} overview plot as a shiny module \examples{ data <- cdisc_data() |> within(library(nestcolor)) |> - within(ADSL <- osprey::rADSL) |> - within(ADAE <- osprey::rADAE) |> - within(add_event_flags <- function(dat) { - dat <- dat |> - dplyr::mutate( - TMPFL_SER = AESER == "Y", - TMPFL_REL = AEREL == "Y", - TMPFL_GR5 = AETOXGR == "5", - AEREL1 = (AEREL == "Y" & ACTARM == "A: Drug X"), - AEREL2 = (AEREL == "Y" & ACTARM == "B: Placebo") + within({ + ADSL <- osprey::rADSL + ADAE <- osprey::rADAE + add_event_flags <- function(dat) { + dat <- dat |> + dplyr::mutate( + TMPFL_SER = AESER == "Y", + TMPFL_REL = AEREL == "Y", + TMPFL_GR5 = AETOXGR == "5", + AEREL1 = (AEREL == "Y" & ACTARM == "A: Drug X"), + AEREL2 = (AEREL == "Y" & ACTARM == "B: Placebo") + ) + labels <- c( + "Serious AE", "Related AE", "Grade 5 AE", + "AE related to A: Drug X", "AE related to B: Placebo" ) - labels <- c( - "Serious AE", "Related AE", "Grade 5 AE", - "AE related to A: Drug X", "AE related to B: Placebo" - ) - cols <- c("TMPFL_SER", "TMPFL_REL", "TMPFL_GR5", "AEREL1", "AEREL2") - for (i in seq_along(labels)) { - attr(dat[[cols[i]]], "label") <- labels[i] + cols <- c("TMPFL_SER", "TMPFL_REL", "TMPFL_GR5", "AEREL1", "AEREL2") + for (i in seq_along(labels)) { + attr(dat[[cols[i]]], "label") <- labels[i] + } + dat } - dat - }) |> - within(ADAE <- add_event_flags(ADAE)) + ADAE <- add_event_flags(ADAE) + }) teal.data::datanames(data) <- c("ADSL", "ADAE") teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[datanames(data)] diff --git a/man/tm_g_ae_sub.Rd b/man/tm_g_ae_sub.Rd index 0c40830f..1b115279 100644 --- a/man/tm_g_ae_sub.Rd +++ b/man/tm_g_ae_sub.Rd @@ -49,10 +49,11 @@ the \code{\link[teal:module]{teal::module()}} object. Display the \code{AE} by subgroups plot as a teal module } \examples{ -# Example using stream (ADaM) dataset data <- teal.data::cdisc_data() |> - within(ADSL <- osprey::rADSL) |> - within(ADAE <- osprey::rADAE) + within({ + ADSL <- osprey::rADSL + ADAE <- osprey::rADAE + }) teal.data::datanames(data) <- c("ADSL", "ADAE") teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[teal.data::datanames(data)] diff --git a/man/tm_g_butterfly.Rd b/man/tm_g_butterfly.Rd index fc606b32..94c612fb 100644 --- a/man/tm_g_butterfly.Rd +++ b/man/tm_g_butterfly.Rd @@ -86,23 +86,24 @@ used for subsequent analysis. Flag variables (from \code{ADaM} datasets) can be used directly as filter. } \examples{ -# Example using stream (ADaM) dataset data <- teal.data::cdisc_data() |> within({ library(dplyr) library(nestcolor) }) |> - within(set.seed(23)) |> - within(ADSL <- osprey::rADSL) |> - within(ADAE <- osprey::rADAE) |> - within(ADSL <- mutate(ADSL, DOSE = paste(sample(1:3, n(), replace = TRUE), "UG"))) |> - within(ADAE <- mutate( - ADAE, - flag1 = ifelse(AETOXGR == 1, 1, 0), - flag2 = ifelse(AETOXGR == 2, 1, 0), - flag3 = ifelse(AETOXGR == 3, 1, 0), - flag1_filt = rep("Y", n()) - )) + within({ + set.seed(23) + ADSL <- osprey::rADSL + ADAE <- osprey::rADAE + ADSL <- mutate(ADSL, DOSE = paste(sample(1:3, n(), replace = TRUE), "UG")) + ADAE <- mutate( + ADAE, + flag1 = ifelse(AETOXGR == 1, 1, 0), + flag2 = ifelse(AETOXGR == 2, 1, 0), + flag3 = ifelse(AETOXGR == 3, 1, 0), + flag1_filt = rep("Y", n()) + ) + }) teal.data::datanames(data) <- c("ADSL", "ADAE") teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[teal.data::datanames(data)] diff --git a/man/tm_g_events_term_id.Rd b/man/tm_g_events_term_id.Rd index 504b536a..7af7b718 100644 --- a/man/tm_g_events_term_id.Rd +++ b/man/tm_g_events_term_id.Rd @@ -52,8 +52,10 @@ Display Events by Term plot as a shiny module \examples{ data <- teal.data::cdisc_data() |> within(library(nestcolor)) |> - within(ADSL <- osprey::rADSL) |> - within(ADAE <- osprey::rADAE) + within({ + ADSL <- osprey::rADSL + ADAE <- osprey::rADAE + }) teal.data::datanames(data) <- c("ADSL", "ADAE") teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[teal.data::datanames(data)] diff --git a/man/tm_g_heat_bygrade.Rd b/man/tm_g_heat_bygrade.Rd index 9f868114..e485bc20 100644 --- a/man/tm_g_heat_bygrade.Rd +++ b/man/tm_g_heat_bygrade.Rd @@ -77,36 +77,40 @@ Display the heatmap by grade as a shiny module } \examples{ data <- teal.data::cdisc_data() |> - within(library(dplyr)) |> - within(library(nestcolor)) |> - within(ADSL <- osprey::rADSL \%>\% slice(1:30)) |> - within(ADEX <- osprey::rADEX \%>\% filter(USUBJID \%in\% ADSL$USUBJID)) |> - within(ADAE <- osprey::rADAE \%>\% filter(USUBJID \%in\% ADSL$USUBJID)) |> - within(ADCM <- osprey::rADCM \%>\% filter(USUBJID \%in\% ADSL$USUBJID)) |> - # This preprocess is only to force legacy standard on ADCM - within(ADCM <- ADCM \%>\% select(-starts_with("ATC")) \%>\% unique()) |> - # function to derive AVISIT from ADEX - within(add_visit <- function(data_need_visit) { - visit_dates <- ADEX \%>\% - filter(PARAMCD == "DOSE") \%>\% - distinct(USUBJID, AVISIT, ASTDTM) \%>\% - group_by(USUBJID) \%>\% - arrange(ASTDTM) \%>\% - mutate(next_vis = lead(ASTDTM), is_last = ifelse(is.na(next_vis), TRUE, FALSE)) \%>\% - rename(this_vis = ASTDTM) - data_visit <- data_need_visit \%>\% - select(USUBJID, ASTDTM) \%>\% - left_join(visit_dates, by = "USUBJID") \%>\% - filter(ASTDTM > this_vis & (ASTDTM < next_vis | is_last == TRUE)) \%>\% - left_join(data_need_visit) \%>\% - distinct() - return(data_visit) - }) |> - # derive AVISIT for ADAE and ADCM - within(ADAE <- add_visit(ADAE)) |> - within(ADCM <- add_visit(ADCM)) |> - # derive ongoing status variable for ADEX - within(ADEX <- ADEX \%>\% filter(PARCAT1 == "INDIVIDUAL") \%>\% mutate(ongo_status = (EOSSTT == "ONGOING"))) + within({ + library(dplyr) + library(nestcolor) + }) |> + within({ + ADSL <- osprey::rADSL \%>\% slice(1:30) + ADEX <- osprey::rADEX \%>\% filter(USUBJID \%in\% ADSL$USUBJID) + ADAE <- osprey::rADAE \%>\% filter(USUBJID \%in\% ADSL$USUBJID) + ADCM <- osprey::rADCM \%>\% filter(USUBJID \%in\% ADSL$USUBJID) + # This preprocess is only to force legacy standard on ADCM + ADCM <- ADCM \%>\% select(-starts_with("ATC")) \%>\% unique() + # function to derive AVISIT from ADEX + add_visit <- function(data_need_visit) { + visit_dates <- ADEX \%>\% + filter(PARAMCD == "DOSE") \%>\% + distinct(USUBJID, AVISIT, ASTDTM) \%>\% + group_by(USUBJID) \%>\% + arrange(ASTDTM) \%>\% + mutate(next_vis = lead(ASTDTM), is_last = ifelse(is.na(next_vis), TRUE, FALSE)) \%>\% + rename(this_vis = ASTDTM) + data_visit <- data_need_visit \%>\% + select(USUBJID, ASTDTM) \%>\% + left_join(visit_dates, by = "USUBJID") \%>\% + filter(ASTDTM > this_vis & (ASTDTM < next_vis | is_last == TRUE)) \%>\% + left_join(data_need_visit) \%>\% + distinct() + return(data_visit) + } + # derive AVISIT for ADAE and ADCM + ADAE <- add_visit(ADAE) + ADCM <- add_visit(ADCM) + # derive ongoing status variable for ADEX + ADEX <- ADEX \%>\% filter(PARCAT1 == "INDIVIDUAL") \%>\% mutate(ongo_status = (EOSSTT == "ONGOING")) + }) teal.data::datanames(data) <- c("ADSL", "ADEX", "ADAE", "ADCM") teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[teal.data::datanames(data)] diff --git a/man/tm_g_patient_profile.Rd b/man/tm_g_patient_profile.Rd index 8d649905..eba3d8a8 100644 --- a/man/tm_g_patient_profile.Rd +++ b/man/tm_g_patient_profile.Rd @@ -110,14 +110,17 @@ the start date \examples{ data <- teal.data::cdisc_data() |> within(library(nestcolor)) |> - within(ADSL <- osprey::rADSL) |> - within(ADAE <- osprey::rADAE \%>\% mutate(ASTDT = as.Date(ASTDTM), AENDT = as.Date(AENDTM))) |> - within(ADCM <- osprey::rADCM \%>\% mutate(ASTDT = as.Date(ASTDTM), AENDT = as.Date(AENDTM))) |> - # The step below is to pre-process ADCM to legacy standard - within(ADCM <- ADCM \%>\% select(-starts_with("ATC")) \%>\% unique()) |> - within(ADRS <- osprey::rADRS \%>\% mutate(ADT = as.Date(ADTM))) |> - within(ADEX <- osprey::rADEX \%>\% mutate(ASTDT = as.Date(ASTDTM), AENDT = as.Date(AENDTM))) |> - within(ADLB <- osprey::rADLB \%>\% mutate(ADT = as.Date(ADTM), LBSTRESN = as.numeric(LBSTRESC))) + within({ + ADSL <- osprey::rADSL + ADAE <- osprey::rADAE \%>\% mutate(ASTDT = as.Date(ASTDTM), AENDT = as.Date(AENDTM)) + ADCM <- osprey::rADCM \%>\% mutate(ASTDT = as.Date(ASTDTM), AENDT = as.Date(AENDTM)) + # The step below is to pre-process ADCM to legacy standard + ADCM <- ADCM \%>\% select(-starts_with("ATC")) \%>\% unique() + ADRS <- osprey::rADRS \%>\% mutate(ADT = as.Date(ADTM)) + ADEX <- osprey::rADEX \%>\% mutate(ASTDT = as.Date(ASTDTM), AENDT = as.Date(AENDTM)) + ADLB <- osprey::rADLB \%>\% mutate(ADT = as.Date(ADTM), LBSTRESN = as.numeric(LBSTRESC)) + + }) teal.data::datanames(data) <- c("ADSL", "ADAE", "ADCM", "ADRS", "ADEX", "ADLB") teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[teal.data::datanames(data)] diff --git a/man/tm_g_spiderplot.Rd b/man/tm_g_spiderplot.Rd index b6a2e6ac..844e3199 100644 --- a/man/tm_g_spiderplot.Rd +++ b/man/tm_g_spiderplot.Rd @@ -79,10 +79,14 @@ Display spider plot as a shiny module \examples{ # Example using stream (ADaM) dataset data <- teal.data::cdisc_data() |> - within(library(dplyr)) |> - within(library(nestcolor)) |> - within(ADSL <- osprey::rADSL) |> - within(ADTR <- osprey::rADTR) + within({ + library(dplyr) + library(nestcolor) + }) |> + within({ + ADSL <- osprey::rADSL + ADTR <- osprey::rADTR + }) teal.data::datanames(data) <- c("ADSL", "ADTR") teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[teal.data::datanames(data)] diff --git a/man/tm_g_waterfall.Rd b/man/tm_g_waterfall.Rd index 8743cb1f..a6c71e36 100644 --- a/man/tm_g_waterfall.Rd +++ b/man/tm_g_waterfall.Rd @@ -102,10 +102,12 @@ This is teal module that generates a waterfall plot for \code{ADaM} data \examples{ data <- teal.data::cdisc_data() |> within(library(nestcolor)) |> - within(ADSL <- osprey::rADSL) |> - within(ADRS <- osprey::rADRS) |> - within(ADTR <- osprey::rADTR) |> - within(ADSL$SEX <- factor(ADSL$SEX, levels = unique(ADSL$SEX))) + within({ + ADSL <- osprey::rADSL + ADRS <- osprey::rADRS + ADTR <- osprey::rADTR + ADSL$SEX <- factor(ADSL$SEX, levels = unique(ADSL$SEX)) + }) teal.data::datanames(data) <- c("ADSL", "ADTR", "ADRS") teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[teal.data::datanames(data)] From e70fbc7482eecc7204a69d4e48a887b50d6c3fd5 Mon Sep 17 00:00:00 2001 From: Aleksander Chlebowski Date: Thu, 16 Nov 2023 14:48:19 +0100 Subject: [PATCH 7/8] remove prefixes from examples --- R/tm_g_ae_oview.R | 20 +++++++++---------- R/tm_g_ae_sub.R | 14 +++++++------- R/tm_g_butterfly.R | 28 +++++++++++++-------------- R/tm_g_events_term_id.R | 18 +++++++++--------- R/tm_g_heat_bygrade.R | 30 ++++++++++++++--------------- R/tm_g_patient_profile.R | 38 ++++++++++++++++++------------------- R/tm_g_spiderplot.R | 28 +++++++++++++-------------- R/tm_g_waterfall.R | 34 ++++++++++++++++----------------- man/tm_g_ae_oview.Rd | 20 +++++++++---------- man/tm_g_ae_sub.Rd | 14 +++++++------- man/tm_g_butterfly.Rd | 28 +++++++++++++-------------- man/tm_g_events_term_id.Rd | 18 +++++++++--------- man/tm_g_heat_bygrade.Rd | 30 ++++++++++++++--------------- man/tm_g_patient_profile.Rd | 38 ++++++++++++++++++------------------- man/tm_g_spiderplot.Rd | 28 +++++++++++++-------------- man/tm_g_waterfall.Rd | 34 ++++++++++++++++----------------- 16 files changed, 210 insertions(+), 210 deletions(-) diff --git a/R/tm_g_ae_oview.R b/R/tm_g_ae_oview.R index 374f511d..92fd9e63 100644 --- a/R/tm_g_ae_oview.R +++ b/R/tm_g_ae_oview.R @@ -19,11 +19,11 @@ #' data <- cdisc_data() |> #' within(library(nestcolor)) |> #' within({ -#' ADSL <- osprey::rADSL -#' ADAE <- osprey::rADAE +#' ADSL <- rADSL +#' ADAE <- rADAE #' add_event_flags <- function(dat) { #' dat <- dat |> -#' dplyr::mutate( +#' mutate( #' TMPFL_SER = AESER == "Y", #' TMPFL_REL = AEREL == "Y", #' TMPFL_GR5 = AETOXGR == "5", @@ -43,24 +43,24 @@ #' ADAE <- add_event_flags(ADAE) #' }) #' -#' teal.data::datanames(data) <- c("ADSL", "ADAE") -#' teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[datanames(data)] +#' datanames(data) <- c("ADSL", "ADAE") +#' join_keys(data) <- default_cdisc_join_keys[datanames(data)] #' #' ADAE <- data[["ADAE"]] #' -#' app <- teal::init( +#' app <- init( #' data = data, -#' modules = teal::modules( +#' modules = modules( #' tm_g_ae_oview( #' label = "AE Overview", #' dataname = "ADAE", -#' arm_var = teal.transform::choices_selected( +#' arm_var = choices_selected( #' selected = "ACTARM", #' choices = c("ACTARM", "ACTARMCD") #' ), -#' flag_var_anl = teal.transform::choices_selected( +#' flag_var_anl = choices_selected( #' selected = "AEREL1", -#' choices = teal.transform::variable_choices( +#' choices = variable_choices( #' ADAE, #' c("TMPFL_SER", "TMPFL_REL", "TMPFL_GR5", "AEREL1", "AEREL2") #' ), diff --git a/R/tm_g_ae_sub.R b/R/tm_g_ae_sub.R index 1c9a2fbb..7b6841c5 100644 --- a/R/tm_g_ae_sub.R +++ b/R/tm_g_ae_sub.R @@ -18,18 +18,18 @@ #' #' @examples # Example using stream (ADaM) dataset -#' data <- teal.data::cdisc_data() |> +#' data <- cdisc_data() |> #' within({ -#' ADSL <- osprey::rADSL -#' ADAE <- osprey::rADAE +#' ADSL <- rADSL +#' ADAE <- rADAE #' }) #' -#' teal.data::datanames(data) <- c("ADSL", "ADAE") -#' teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[teal.data::datanames(data)] +#' datanames(data) <- c("ADSL", "ADAE") +#' join_keys(data) <- default_cdisc_join_keys[datanames(data)] #' -#' app <- teal::init( +#' app <- init( #' data = data, -#' modules = teal::modules( +#' modules = modules( #' tm_g_ae_sub( #' label = "AE by Subgroup", #' dataname = "ADAE", diff --git a/R/tm_g_butterfly.R b/R/tm_g_butterfly.R index 5cd7e85d..845b573f 100644 --- a/R/tm_g_butterfly.R +++ b/R/tm_g_butterfly.R @@ -41,15 +41,15 @@ #' #' @examples # Example using stream (ADaM) dataset -#' data <- teal.data::cdisc_data() |> +#' data <- cdisc_data() |> #' within({ #' library(dplyr) #' library(nestcolor) #' }) |> #' within({ #' set.seed(23) -#' ADSL <- osprey::rADSL -#' ADAE <- osprey::rADAE +#' ADSL <- rADSL +#' ADAE <- rADAE #' ADSL <- mutate(ADSL, DOSE = paste(sample(1:3, n(), replace = TRUE), "UG")) #' ADAE <- mutate( #' ADAE, @@ -60,40 +60,40 @@ #' ) #' }) #' -#' teal.data::datanames(data) <- c("ADSL", "ADAE") -#' teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[teal.data::datanames(data)] +#' datanames(data) <- c("ADSL", "ADAE") +#' join_keys(data) <- default_cdisc_join_keys[datanames(data)] #' -#' app <- teal::init( +#' app <- init( #' data = data, -#' modules = teal::modules( +#' modules = modules( #' tm_g_butterfly( #' label = "Butterfly Plot", #' dataname = "ADAE", -#' right_var = teal.transform::choices_selected( +#' right_var = choices_selected( #' selected = "SEX", #' choices = c("SEX", "ARM", "RACE") #' ), -#' left_var = teal.transform::choices_selected( +#' left_var = choices_selected( #' selected = "RACE", #' choices = c("SEX", "ARM", "RACE") #' ), -#' category_var = teal.transform::choices_selected( +#' category_var = choices_selected( #' selected = "AEBODSYS", #' choices = c("AEDECOD", "AEBODSYS") #' ), -#' color_by_var = teal.transform::choices_selected( +#' color_by_var = choices_selected( #' selected = "AETOXGR", #' choices = c("AETOXGR", "None") #' ), -#' count_by_var = teal.transform::choices_selected( +#' count_by_var = choices_selected( #' selected = "# of patients", #' choices = c("# of patients", "# of AEs") #' ), -#' facet_var = teal.transform::choices_selected( +#' facet_var = choices_selected( #' selected = NULL, #' choices = c("RACE", "SEX", "ARM") #' ), -#' sort_by_var = teal.transform::choices_selected( +#' sort_by_var = choices_selected( #' selected = "count", #' choices = c("count", "alphabetical") #' ), diff --git a/R/tm_g_events_term_id.R b/R/tm_g_events_term_id.R index 6fd75a17..412b71cf 100644 --- a/R/tm_g_events_term_id.R +++ b/R/tm_g_events_term_id.R @@ -18,30 +18,30 @@ #' @author Molly He (hey59) \email{hey59@gene.com} #' #' @examples -#' data <- teal.data::cdisc_data() |> +#' data <- cdisc_data() |> #' within(library(nestcolor)) |> #' within({ -#' ADSL <- osprey::rADSL -#' ADAE <- osprey::rADAE +#' ADSL <- rADSL +#' ADAE <- rADAE #' }) #' -#' teal.data::datanames(data) <- c("ADSL", "ADAE") -#' teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[teal.data::datanames(data)] +#' datanames(data) <- c("ADSL", "ADAE") +#' join_keys(data) <- default_cdisc_join_keys[datanames(data)] #' -#' app <- teal::init( +#' app <- init( #' data = data, -#' modules = teal::modules( +#' modules = modules( #' tm_g_events_term_id( #' label = "Common AE", #' dataname = "ADAE", -#' term_var = teal.transform::choices_selected( +#' term_var = choices_selected( #' selected = "AEDECOD", #' choices = c( #' "AEDECOD", "AETERM", #' "AEHLT", "AELLT", "AEBODSYS" #' ) #' ), -#' arm_var = teal.transform::choices_selected( +#' arm_var = choices_selected( #' selected = "ACTARMCD", #' choices = c("ACTARM", "ACTARMCD") #' ), diff --git a/R/tm_g_heat_bygrade.R b/R/tm_g_heat_bygrade.R index 7ace55d0..cc3a1aec 100644 --- a/R/tm_g_heat_bygrade.R +++ b/R/tm_g_heat_bygrade.R @@ -34,16 +34,16 @@ #' @export #' #' @examples -#' data <- teal.data::cdisc_data() |> +#' data <- cdisc_data() |> #' within({ #' library(dplyr) #' library(nestcolor) #' }) |> #' within({ -#' ADSL <- osprey::rADSL %>% slice(1:30) -#' ADEX <- osprey::rADEX %>% filter(USUBJID %in% ADSL$USUBJID) -#' ADAE <- osprey::rADAE %>% filter(USUBJID %in% ADSL$USUBJID) -#' ADCM <- osprey::rADCM %>% filter(USUBJID %in% ADSL$USUBJID) +#' ADSL <- rADSL %>% slice(1:30) +#' ADEX <- rADEX %>% filter(USUBJID %in% ADSL$USUBJID) +#' ADAE <- rADAE %>% filter(USUBJID %in% ADSL$USUBJID) +#' ADCM <- rADCM %>% filter(USUBJID %in% ADSL$USUBJID) #' # This preprocess is only to force legacy standard on ADCM #' ADCM <- ADCM %>% select(-starts_with("ATC")) %>% unique() #' # function to derive AVISIT from ADEX @@ -70,41 +70,41 @@ #' ADEX <- ADEX %>% filter(PARCAT1 == "INDIVIDUAL") %>% mutate(ongo_status = (EOSSTT == "ONGOING")) #' }) #' -#' teal.data::datanames(data) <- c("ADSL", "ADEX", "ADAE", "ADCM") -#' teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[teal.data::datanames(data)] +#' datanames(data) <- c("ADSL", "ADEX", "ADAE", "ADCM") +#' join_keys(data) <- default_cdisc_join_keys[datanames(data)] #' #' ADCM <- data[["ADCM"]] #' -#' app <- teal::init( +#' app <- init( #' data = data, -#' modules = teal::modules( +#' modules = modules( #' tm_g_heat_bygrade( #' label = "Heatmap by grade", #' sl_dataname = "ADSL", #' ex_dataname = "ADEX", #' ae_dataname = "ADAE", #' cm_dataname = "ADCM", -#' id_var = teal.transform::choices_selected( +#' id_var = choices_selected( #' selected = "USUBJID", #' choices = c("USUBJID", "SUBJID") #' ), -#' visit_var = teal.transform::choices_selected( +#' visit_var = choices_selected( #' selected = "AVISIT", #' choices = c("AVISIT") #' ), -#' ongo_var = teal.transform::choices_selected( +#' ongo_var = choices_selected( #' selected = "ongo_status", #' choices = c("ongo_status") #' ), -#' anno_var = teal.transform::choices_selected( +#' anno_var = choices_selected( #' selected = c("SEX", "COUNTRY"), #' choices = c("SEX", "COUNTRY", "USUBJID") #' ), -#' heat_var = teal.transform::choices_selected( +#' heat_var = choices_selected( #' selected = "AETOXGR", #' choices = c("AETOXGR") #' ), -#' conmed_var = teal.transform::choices_selected( +#' conmed_var = choices_selected( #' selected = "CMDECOD", #' choices = c("CMDECOD") #' ), diff --git a/R/tm_g_patient_profile.R b/R/tm_g_patient_profile.R index 930d1c4f..d27076c4 100644 --- a/R/tm_g_patient_profile.R +++ b/R/tm_g_patient_profile.R @@ -62,31 +62,31 @@ #' @export #' #' @examples -#' data <- teal.data::cdisc_data() |> +#' data <- cdisc_data() |> #' within(library(nestcolor)) |> #' within({ -#' ADSL <- osprey::rADSL -#' ADAE <- osprey::rADAE %>% mutate(ASTDT = as.Date(ASTDTM), AENDT = as.Date(AENDTM)) -#' ADCM <- osprey::rADCM %>% mutate(ASTDT = as.Date(ASTDTM), AENDT = as.Date(AENDTM)) +#' ADSL <- rADSL +#' ADAE <- rADAE %>% mutate(ASTDT = as.Date(ASTDTM), AENDT = as.Date(AENDTM)) +#' ADCM <- rADCM %>% mutate(ASTDT = as.Date(ASTDTM), AENDT = as.Date(AENDTM)) #' # The step below is to pre-process ADCM to legacy standard #' ADCM <- ADCM %>% select(-starts_with("ATC")) %>% unique() -#' ADRS <- osprey::rADRS %>% mutate(ADT = as.Date(ADTM)) -#' ADEX <- osprey::rADEX %>% mutate(ASTDT = as.Date(ASTDTM), AENDT = as.Date(AENDTM)) -#' ADLB <- osprey::rADLB %>% mutate(ADT = as.Date(ADTM), LBSTRESN = as.numeric(LBSTRESC)) +#' ADRS <- rADRS %>% mutate(ADT = as.Date(ADTM)) +#' ADEX <- rADEX %>% mutate(ASTDT = as.Date(ASTDTM), AENDT = as.Date(AENDTM)) +#' ADLB <- rADLB %>% mutate(ADT = as.Date(ADTM), LBSTRESN = as.numeric(LBSTRESC)) #' #' }) #' -#' teal.data::datanames(data) <- c("ADSL", "ADAE", "ADCM", "ADRS", "ADEX", "ADLB") -#' teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[teal.data::datanames(data)] +#' datanames(data) <- c("ADSL", "ADAE", "ADCM", "ADRS", "ADEX", "ADLB") +#' join_keys(data) <- default_cdisc_join_keys[datanames(data)] #' #' ADSL <- data[["ADSL"]] #' -#' app <- teal::init( +#' app <- init( #' data = data, -#' modules = teal::modules( +#' modules = modules( #' tm_g_patient_profile( #' label = "Patient Profile Plot", -#' patient_id = teal.transform::choices_selected( +#' patient_id = choices_selected( #' choices = unique(ADSL$USUBJID), #' selected = unique(ADSL$USUBJID)[1] #' ), @@ -96,32 +96,32 @@ #' rs_dataname = "ADRS", #' cm_dataname = "ADCM", #' lb_dataname = "ADLB", -#' sl_start_date = teal.transform::choices_selected( +#' sl_start_date = choices_selected( #' selected = "TRTSDTM", #' choices = c("TRTSDTM", "RANDDT") #' ), -#' ex_var = teal.transform::choices_selected( +#' ex_var = choices_selected( #' selected = "PARCAT2", #' choices = "PARCAT2" #' ), -#' ae_var = teal.transform::choices_selected( +#' ae_var = choices_selected( #' selected = "AEDECOD", #' choices = c("AEDECOD", "AESOC") #' ), -#' ae_line_col_var = teal.transform::choices_selected( +#' ae_line_col_var = choices_selected( #' selected = "AESER", #' choices = c("AESER", "AEREL") #' ), #' ae_line_col_opt = c("Y" = "red", "N" = "blue"), -#' rs_var = teal.transform::choices_selected( +#' rs_var = choices_selected( #' selected = "PARAMCD", #' choices = "PARAMCD" #' ), -#' cm_var = teal.transform::choices_selected( +#' cm_var = choices_selected( #' selected = "CMDECOD", #' choices = c("CMDECOD", "CMCAT") #' ), -#' lb_var = teal.transform::choices_selected( +#' lb_var = choices_selected( #' selected = "LBTESTCD", #' choices = c("LBTESTCD", "LBCAT") #' ), diff --git a/R/tm_g_spiderplot.R b/R/tm_g_spiderplot.R index 968dbd4d..7006c80d 100644 --- a/R/tm_g_spiderplot.R +++ b/R/tm_g_spiderplot.R @@ -26,50 +26,50 @@ #' #' @examples #' # Example using stream (ADaM) dataset -#' data <- teal.data::cdisc_data() |> +#' data <- cdisc_data() |> #' within({ #' library(dplyr) #' library(nestcolor) #' }) |> #' within({ -#' ADSL <- osprey::rADSL -#' ADTR <- osprey::rADTR +#' ADSL <- rADSL +#' ADTR <- rADTR #' }) #' -#' teal.data::datanames(data) <- c("ADSL", "ADTR") -#' teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[teal.data::datanames(data)] +#' datanames(data) <- c("ADSL", "ADTR") +#' join_keys(data) <- default_cdisc_join_keys[datanames(data)] #' -#' app <- teal::init( +#' app <- init( #' data = data, -#' modules = teal::modules( +#' modules = modules( #' tm_g_spiderplot( #' label = "Spider plot", #' dataname = "ADTR", -#' paramcd = teal.transform::choices_selected( +#' paramcd = choices_selected( #' choices = "SLDINV", #' selected = "SLDINV" #' ), -#' x_var = teal.transform::choices_selected( +#' x_var = choices_selected( #' choices = "ADY", #' selected = "ADY" #' ), -#' y_var = teal.transform::choices_selected( +#' y_var = choices_selected( #' choices = c("PCHG", "CHG", "AVAL"), #' selected = "PCHG" #' ), -#' marker_var = teal.transform::choices_selected( +#' marker_var = choices_selected( #' choices = c("SEX", "RACE", "USUBJID"), #' selected = "SEX" #' ), -#' line_colorby_var = teal.transform::choices_selected( +#' line_colorby_var = choices_selected( #' choices = c("SEX", "USUBJID", "RACE"), #' selected = "SEX" #' ), -#' xfacet_var = teal.transform::choices_selected( +#' xfacet_var = choices_selected( #' choices = c("SEX", "ARM"), #' selected = "SEX" #' ), -#' yfacet_var = teal.transform::choices_selected( +#' yfacet_var = choices_selected( #' choices = c("SEX", "ARM"), #' selected = "ARM" #' ), diff --git a/R/tm_g_waterfall.R b/R/tm_g_waterfall.R index c4e90f44..ff948143 100644 --- a/R/tm_g_waterfall.R +++ b/R/tm_g_waterfall.R @@ -47,35 +47,35 @@ #' @author houx14 \email{houx14@gene.com} #' #' @examples -#' data <- teal.data::cdisc_data() |> +#' data <- cdisc_data() |> #' within(library(nestcolor)) |> #' within({ -#' ADSL <- osprey::rADSL -#' ADRS <- osprey::rADRS -#' ADTR <- osprey::rADTR +#' ADSL <- rADSL +#' ADRS <- rADRS +#' ADTR <- rADTR #' ADSL$SEX <- factor(ADSL$SEX, levels = unique(ADSL$SEX)) #' }) #' -#' teal.data::datanames(data) <- c("ADSL", "ADTR", "ADRS") -#' teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[teal.data::datanames(data)] +#' datanames(data) <- c("ADSL", "ADTR", "ADRS") +#' join_keys(data) <- default_cdisc_join_keys[datanames(data)] #' -#' app <- teal::init( +#' app <- init( #' data = data, -#' modules = teal::modules( +#' modules = modules( #' tm_g_waterfall( #' label = "Waterfall", #' dataname_tr = "ADTR", #' dataname_rs = "ADRS", -#' bar_paramcd = teal.transform::choices_selected(c("SLDINV"), "SLDINV"), -#' bar_var = teal.transform::choices_selected(c("PCHG", "AVAL"), "PCHG"), -#' bar_color_var = teal.transform::choices_selected(c("ARMCD", "SEX"), "ARMCD"), +#' bar_paramcd = choices_selected(c("SLDINV"), "SLDINV"), +#' bar_var = choices_selected(c("PCHG", "AVAL"), "PCHG"), +#' bar_color_var = choices_selected(c("ARMCD", "SEX"), "ARMCD"), #' bar_color_opt = NULL, -#' sort_var = teal.transform::choices_selected(c("ARMCD", "SEX"), NULL), -#' add_label_var_sl = teal.transform::choices_selected(c("SEX", "EOSDY"), NULL), -#' add_label_paramcd_rs = teal.transform::choices_selected(c("BESRSPI", "OBJRSPI"), NULL), -#' anno_txt_var_sl = teal.transform::choices_selected(c("SEX", "ARMCD", "BMK1", "BMK2"), NULL), -#' anno_txt_paramcd_rs = teal.transform::choices_selected(c("BESRSPI", "OBJRSPI"), NULL), -#' facet_var = teal.transform::choices_selected(c("SEX", "ARMCD", "STRATA1", "STRATA2"), NULL), +#' sort_var = choices_selected(c("ARMCD", "SEX"), NULL), +#' add_label_var_sl = choices_selected(c("SEX", "EOSDY"), NULL), +#' add_label_paramcd_rs = choices_selected(c("BESRSPI", "OBJRSPI"), NULL), +#' anno_txt_var_sl = choices_selected(c("SEX", "ARMCD", "BMK1", "BMK2"), NULL), +#' anno_txt_paramcd_rs = choices_selected(c("BESRSPI", "OBJRSPI"), NULL), +#' facet_var = choices_selected(c("SEX", "ARMCD", "STRATA1", "STRATA2"), NULL), #' href_line = "-30, 20" #' ) #' ) diff --git a/man/tm_g_ae_oview.Rd b/man/tm_g_ae_oview.Rd index aedcaa2a..2d178706 100644 --- a/man/tm_g_ae_oview.Rd +++ b/man/tm_g_ae_oview.Rd @@ -54,11 +54,11 @@ Display the \code{AE} overview plot as a shiny module data <- cdisc_data() |> within(library(nestcolor)) |> within({ - ADSL <- osprey::rADSL - ADAE <- osprey::rADAE + ADSL <- rADSL + ADAE <- rADAE add_event_flags <- function(dat) { dat <- dat |> - dplyr::mutate( + mutate( TMPFL_SER = AESER == "Y", TMPFL_REL = AEREL == "Y", TMPFL_GR5 = AETOXGR == "5", @@ -78,24 +78,24 @@ data <- cdisc_data() |> ADAE <- add_event_flags(ADAE) }) -teal.data::datanames(data) <- c("ADSL", "ADAE") -teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[datanames(data)] +datanames(data) <- c("ADSL", "ADAE") +join_keys(data) <- default_cdisc_join_keys[datanames(data)] ADAE <- data[["ADAE"]] -app <- teal::init( +app <- init( data = data, - modules = teal::modules( + modules = modules( tm_g_ae_oview( label = "AE Overview", dataname = "ADAE", - arm_var = teal.transform::choices_selected( + arm_var = choices_selected( selected = "ACTARM", choices = c("ACTARM", "ACTARMCD") ), - flag_var_anl = teal.transform::choices_selected( + flag_var_anl = choices_selected( selected = "AEREL1", - choices = teal.transform::variable_choices( + choices = variable_choices( ADAE, c("TMPFL_SER", "TMPFL_REL", "TMPFL_GR5", "AEREL1", "AEREL2") ), diff --git a/man/tm_g_ae_sub.Rd b/man/tm_g_ae_sub.Rd index 1b115279..f8e6012c 100644 --- a/man/tm_g_ae_sub.Rd +++ b/man/tm_g_ae_sub.Rd @@ -49,18 +49,18 @@ the \code{\link[teal:module]{teal::module()}} object. Display the \code{AE} by subgroups plot as a teal module } \examples{ -data <- teal.data::cdisc_data() |> +data <- cdisc_data() |> within({ - ADSL <- osprey::rADSL - ADAE <- osprey::rADAE + ADSL <- rADSL + ADAE <- rADAE }) -teal.data::datanames(data) <- c("ADSL", "ADAE") -teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[teal.data::datanames(data)] +datanames(data) <- c("ADSL", "ADAE") +join_keys(data) <- default_cdisc_join_keys[datanames(data)] -app <- teal::init( +app <- init( data = data, - modules = teal::modules( + modules = modules( tm_g_ae_sub( label = "AE by Subgroup", dataname = "ADAE", diff --git a/man/tm_g_butterfly.Rd b/man/tm_g_butterfly.Rd index 94c612fb..d8d08727 100644 --- a/man/tm_g_butterfly.Rd +++ b/man/tm_g_butterfly.Rd @@ -86,15 +86,15 @@ used for subsequent analysis. Flag variables (from \code{ADaM} datasets) can be used directly as filter. } \examples{ -data <- teal.data::cdisc_data() |> +data <- cdisc_data() |> within({ library(dplyr) library(nestcolor) }) |> within({ set.seed(23) - ADSL <- osprey::rADSL - ADAE <- osprey::rADAE + ADSL <- rADSL + ADAE <- rADAE ADSL <- mutate(ADSL, DOSE = paste(sample(1:3, n(), replace = TRUE), "UG")) ADAE <- mutate( ADAE, @@ -105,40 +105,40 @@ data <- teal.data::cdisc_data() |> ) }) -teal.data::datanames(data) <- c("ADSL", "ADAE") -teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[teal.data::datanames(data)] +datanames(data) <- c("ADSL", "ADAE") +join_keys(data) <- default_cdisc_join_keys[datanames(data)] -app <- teal::init( +app <- init( data = data, - modules = teal::modules( + modules = modules( tm_g_butterfly( label = "Butterfly Plot", dataname = "ADAE", - right_var = teal.transform::choices_selected( + right_var = choices_selected( selected = "SEX", choices = c("SEX", "ARM", "RACE") ), - left_var = teal.transform::choices_selected( + left_var = choices_selected( selected = "RACE", choices = c("SEX", "ARM", "RACE") ), - category_var = teal.transform::choices_selected( + category_var = choices_selected( selected = "AEBODSYS", choices = c("AEDECOD", "AEBODSYS") ), - color_by_var = teal.transform::choices_selected( + color_by_var = choices_selected( selected = "AETOXGR", choices = c("AETOXGR", "None") ), - count_by_var = teal.transform::choices_selected( + count_by_var = choices_selected( selected = "# of patients", choices = c("# of patients", "# of AEs") ), - facet_var = teal.transform::choices_selected( + facet_var = choices_selected( selected = NULL, choices = c("RACE", "SEX", "ARM") ), - sort_by_var = teal.transform::choices_selected( + sort_by_var = choices_selected( selected = "count", choices = c("count", "alphabetical") ), diff --git a/man/tm_g_events_term_id.Rd b/man/tm_g_events_term_id.Rd index 7af7b718..7cfe635c 100644 --- a/man/tm_g_events_term_id.Rd +++ b/man/tm_g_events_term_id.Rd @@ -50,30 +50,30 @@ the \code{\link[teal:module]{teal::module()}} object. Display Events by Term plot as a shiny module } \examples{ -data <- teal.data::cdisc_data() |> +data <- cdisc_data() |> within(library(nestcolor)) |> within({ - ADSL <- osprey::rADSL - ADAE <- osprey::rADAE + ADSL <- rADSL + ADAE <- rADAE }) -teal.data::datanames(data) <- c("ADSL", "ADAE") -teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[teal.data::datanames(data)] +datanames(data) <- c("ADSL", "ADAE") +join_keys(data) <- default_cdisc_join_keys[datanames(data)] -app <- teal::init( +app <- init( data = data, - modules = teal::modules( + modules = modules( tm_g_events_term_id( label = "Common AE", dataname = "ADAE", - term_var = teal.transform::choices_selected( + term_var = choices_selected( selected = "AEDECOD", choices = c( "AEDECOD", "AETERM", "AEHLT", "AELLT", "AEBODSYS" ) ), - arm_var = teal.transform::choices_selected( + arm_var = choices_selected( selected = "ACTARMCD", choices = c("ACTARM", "ACTARMCD") ), diff --git a/man/tm_g_heat_bygrade.Rd b/man/tm_g_heat_bygrade.Rd index e485bc20..3b2d021a 100644 --- a/man/tm_g_heat_bygrade.Rd +++ b/man/tm_g_heat_bygrade.Rd @@ -76,16 +76,16 @@ the \code{\link[teal:module]{teal::module()}} object. Display the heatmap by grade as a shiny module } \examples{ -data <- teal.data::cdisc_data() |> +data <- cdisc_data() |> within({ library(dplyr) library(nestcolor) }) |> within({ - ADSL <- osprey::rADSL \%>\% slice(1:30) - ADEX <- osprey::rADEX \%>\% filter(USUBJID \%in\% ADSL$USUBJID) - ADAE <- osprey::rADAE \%>\% filter(USUBJID \%in\% ADSL$USUBJID) - ADCM <- osprey::rADCM \%>\% filter(USUBJID \%in\% ADSL$USUBJID) + ADSL <- rADSL \%>\% slice(1:30) + ADEX <- rADEX \%>\% filter(USUBJID \%in\% ADSL$USUBJID) + ADAE <- rADAE \%>\% filter(USUBJID \%in\% ADSL$USUBJID) + ADCM <- rADCM \%>\% filter(USUBJID \%in\% ADSL$USUBJID) # This preprocess is only to force legacy standard on ADCM ADCM <- ADCM \%>\% select(-starts_with("ATC")) \%>\% unique() # function to derive AVISIT from ADEX @@ -112,41 +112,41 @@ data <- teal.data::cdisc_data() |> ADEX <- ADEX \%>\% filter(PARCAT1 == "INDIVIDUAL") \%>\% mutate(ongo_status = (EOSSTT == "ONGOING")) }) -teal.data::datanames(data) <- c("ADSL", "ADEX", "ADAE", "ADCM") -teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[teal.data::datanames(data)] +datanames(data) <- c("ADSL", "ADEX", "ADAE", "ADCM") +join_keys(data) <- default_cdisc_join_keys[datanames(data)] ADCM <- data[["ADCM"]] -app <- teal::init( +app <- init( data = data, - modules = teal::modules( + modules = modules( tm_g_heat_bygrade( label = "Heatmap by grade", sl_dataname = "ADSL", ex_dataname = "ADEX", ae_dataname = "ADAE", cm_dataname = "ADCM", - id_var = teal.transform::choices_selected( + id_var = choices_selected( selected = "USUBJID", choices = c("USUBJID", "SUBJID") ), - visit_var = teal.transform::choices_selected( + visit_var = choices_selected( selected = "AVISIT", choices = c("AVISIT") ), - ongo_var = teal.transform::choices_selected( + ongo_var = choices_selected( selected = "ongo_status", choices = c("ongo_status") ), - anno_var = teal.transform::choices_selected( + anno_var = choices_selected( selected = c("SEX", "COUNTRY"), choices = c("SEX", "COUNTRY", "USUBJID") ), - heat_var = teal.transform::choices_selected( + heat_var = choices_selected( selected = "AETOXGR", choices = c("AETOXGR") ), - conmed_var = teal.transform::choices_selected( + conmed_var = choices_selected( selected = "CMDECOD", choices = c("CMDECOD") ), diff --git a/man/tm_g_patient_profile.Rd b/man/tm_g_patient_profile.Rd index eba3d8a8..73173b70 100644 --- a/man/tm_g_patient_profile.Rd +++ b/man/tm_g_patient_profile.Rd @@ -108,31 +108,31 @@ the start date } } \examples{ -data <- teal.data::cdisc_data() |> +data <- cdisc_data() |> within(library(nestcolor)) |> within({ - ADSL <- osprey::rADSL - ADAE <- osprey::rADAE \%>\% mutate(ASTDT = as.Date(ASTDTM), AENDT = as.Date(AENDTM)) - ADCM <- osprey::rADCM \%>\% mutate(ASTDT = as.Date(ASTDTM), AENDT = as.Date(AENDTM)) + ADSL <- rADSL + ADAE <- rADAE \%>\% mutate(ASTDT = as.Date(ASTDTM), AENDT = as.Date(AENDTM)) + ADCM <- rADCM \%>\% mutate(ASTDT = as.Date(ASTDTM), AENDT = as.Date(AENDTM)) # The step below is to pre-process ADCM to legacy standard ADCM <- ADCM \%>\% select(-starts_with("ATC")) \%>\% unique() - ADRS <- osprey::rADRS \%>\% mutate(ADT = as.Date(ADTM)) - ADEX <- osprey::rADEX \%>\% mutate(ASTDT = as.Date(ASTDTM), AENDT = as.Date(AENDTM)) - ADLB <- osprey::rADLB \%>\% mutate(ADT = as.Date(ADTM), LBSTRESN = as.numeric(LBSTRESC)) + ADRS <- rADRS \%>\% mutate(ADT = as.Date(ADTM)) + ADEX <- rADEX \%>\% mutate(ASTDT = as.Date(ASTDTM), AENDT = as.Date(AENDTM)) + ADLB <- rADLB \%>\% mutate(ADT = as.Date(ADTM), LBSTRESN = as.numeric(LBSTRESC)) }) -teal.data::datanames(data) <- c("ADSL", "ADAE", "ADCM", "ADRS", "ADEX", "ADLB") -teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[teal.data::datanames(data)] +datanames(data) <- c("ADSL", "ADAE", "ADCM", "ADRS", "ADEX", "ADLB") +join_keys(data) <- default_cdisc_join_keys[datanames(data)] ADSL <- data[["ADSL"]] -app <- teal::init( +app <- init( data = data, - modules = teal::modules( + modules = modules( tm_g_patient_profile( label = "Patient Profile Plot", - patient_id = teal.transform::choices_selected( + patient_id = choices_selected( choices = unique(ADSL$USUBJID), selected = unique(ADSL$USUBJID)[1] ), @@ -142,32 +142,32 @@ app <- teal::init( rs_dataname = "ADRS", cm_dataname = "ADCM", lb_dataname = "ADLB", - sl_start_date = teal.transform::choices_selected( + sl_start_date = choices_selected( selected = "TRTSDTM", choices = c("TRTSDTM", "RANDDT") ), - ex_var = teal.transform::choices_selected( + ex_var = choices_selected( selected = "PARCAT2", choices = "PARCAT2" ), - ae_var = teal.transform::choices_selected( + ae_var = choices_selected( selected = "AEDECOD", choices = c("AEDECOD", "AESOC") ), - ae_line_col_var = teal.transform::choices_selected( + ae_line_col_var = choices_selected( selected = "AESER", choices = c("AESER", "AEREL") ), ae_line_col_opt = c("Y" = "red", "N" = "blue"), - rs_var = teal.transform::choices_selected( + rs_var = choices_selected( selected = "PARAMCD", choices = "PARAMCD" ), - cm_var = teal.transform::choices_selected( + cm_var = choices_selected( selected = "CMDECOD", choices = c("CMDECOD", "CMCAT") ), - lb_var = teal.transform::choices_selected( + lb_var = choices_selected( selected = "LBTESTCD", choices = c("LBTESTCD", "LBCAT") ), diff --git a/man/tm_g_spiderplot.Rd b/man/tm_g_spiderplot.Rd index 844e3199..a4bcdd8a 100644 --- a/man/tm_g_spiderplot.Rd +++ b/man/tm_g_spiderplot.Rd @@ -78,50 +78,50 @@ Display spider plot as a shiny module } \examples{ # Example using stream (ADaM) dataset -data <- teal.data::cdisc_data() |> +data <- cdisc_data() |> within({ library(dplyr) library(nestcolor) }) |> within({ - ADSL <- osprey::rADSL - ADTR <- osprey::rADTR + ADSL <- rADSL + ADTR <- rADTR }) -teal.data::datanames(data) <- c("ADSL", "ADTR") -teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[teal.data::datanames(data)] +datanames(data) <- c("ADSL", "ADTR") +join_keys(data) <- default_cdisc_join_keys[datanames(data)] -app <- teal::init( +app <- init( data = data, - modules = teal::modules( + modules = modules( tm_g_spiderplot( label = "Spider plot", dataname = "ADTR", - paramcd = teal.transform::choices_selected( + paramcd = choices_selected( choices = "SLDINV", selected = "SLDINV" ), - x_var = teal.transform::choices_selected( + x_var = choices_selected( choices = "ADY", selected = "ADY" ), - y_var = teal.transform::choices_selected( + y_var = choices_selected( choices = c("PCHG", "CHG", "AVAL"), selected = "PCHG" ), - marker_var = teal.transform::choices_selected( + marker_var = choices_selected( choices = c("SEX", "RACE", "USUBJID"), selected = "SEX" ), - line_colorby_var = teal.transform::choices_selected( + line_colorby_var = choices_selected( choices = c("SEX", "USUBJID", "RACE"), selected = "SEX" ), - xfacet_var = teal.transform::choices_selected( + xfacet_var = choices_selected( choices = c("SEX", "ARM"), selected = "SEX" ), - yfacet_var = teal.transform::choices_selected( + yfacet_var = choices_selected( choices = c("SEX", "ARM"), selected = "ARM" ), diff --git a/man/tm_g_waterfall.Rd b/man/tm_g_waterfall.Rd index a6c71e36..74d67b1f 100644 --- a/man/tm_g_waterfall.Rd +++ b/man/tm_g_waterfall.Rd @@ -100,35 +100,35 @@ the \code{\link[teal:module]{teal::module()}} object. This is teal module that generates a waterfall plot for \code{ADaM} data } \examples{ -data <- teal.data::cdisc_data() |> +data <- cdisc_data() |> within(library(nestcolor)) |> within({ - ADSL <- osprey::rADSL - ADRS <- osprey::rADRS - ADTR <- osprey::rADTR + ADSL <- rADSL + ADRS <- rADRS + ADTR <- rADTR ADSL$SEX <- factor(ADSL$SEX, levels = unique(ADSL$SEX)) }) -teal.data::datanames(data) <- c("ADSL", "ADTR", "ADRS") -teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[teal.data::datanames(data)] +datanames(data) <- c("ADSL", "ADTR", "ADRS") +join_keys(data) <- default_cdisc_join_keys[datanames(data)] -app <- teal::init( +app <- init( data = data, - modules = teal::modules( + modules = modules( tm_g_waterfall( label = "Waterfall", dataname_tr = "ADTR", dataname_rs = "ADRS", - bar_paramcd = teal.transform::choices_selected(c("SLDINV"), "SLDINV"), - bar_var = teal.transform::choices_selected(c("PCHG", "AVAL"), "PCHG"), - bar_color_var = teal.transform::choices_selected(c("ARMCD", "SEX"), "ARMCD"), + bar_paramcd = choices_selected(c("SLDINV"), "SLDINV"), + bar_var = choices_selected(c("PCHG", "AVAL"), "PCHG"), + bar_color_var = choices_selected(c("ARMCD", "SEX"), "ARMCD"), bar_color_opt = NULL, - sort_var = teal.transform::choices_selected(c("ARMCD", "SEX"), NULL), - add_label_var_sl = teal.transform::choices_selected(c("SEX", "EOSDY"), NULL), - add_label_paramcd_rs = teal.transform::choices_selected(c("BESRSPI", "OBJRSPI"), NULL), - anno_txt_var_sl = teal.transform::choices_selected(c("SEX", "ARMCD", "BMK1", "BMK2"), NULL), - anno_txt_paramcd_rs = teal.transform::choices_selected(c("BESRSPI", "OBJRSPI"), NULL), - facet_var = teal.transform::choices_selected(c("SEX", "ARMCD", "STRATA1", "STRATA2"), NULL), + sort_var = choices_selected(c("ARMCD", "SEX"), NULL), + add_label_var_sl = choices_selected(c("SEX", "EOSDY"), NULL), + add_label_paramcd_rs = choices_selected(c("BESRSPI", "OBJRSPI"), NULL), + anno_txt_var_sl = choices_selected(c("SEX", "ARMCD", "BMK1", "BMK2"), NULL), + anno_txt_paramcd_rs = choices_selected(c("BESRSPI", "OBJRSPI"), NULL), + facet_var = choices_selected(c("SEX", "ARMCD", "STRATA1", "STRATA2"), NULL), href_line = "-30, 20" ) ) From a1f72ee1b020a8cbfec8254a04c572caa2f5043e Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 16 Nov 2023 13:50:43 +0000 Subject: [PATCH 8/8] [skip actions] Restyle files --- R/tm_g_heat_bygrade.R | 10 +++++++--- R/tm_g_patient_profile.R | 5 +++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/R/tm_g_heat_bygrade.R b/R/tm_g_heat_bygrade.R index cc3a1aec..24ce1e78 100644 --- a/R/tm_g_heat_bygrade.R +++ b/R/tm_g_heat_bygrade.R @@ -38,14 +38,16 @@ #' within({ #' library(dplyr) #' library(nestcolor) -#' }) |> +#' }) |> #' within({ #' ADSL <- rADSL %>% slice(1:30) #' ADEX <- rADEX %>% filter(USUBJID %in% ADSL$USUBJID) #' ADAE <- rADAE %>% filter(USUBJID %in% ADSL$USUBJID) #' ADCM <- rADCM %>% filter(USUBJID %in% ADSL$USUBJID) #' # This preprocess is only to force legacy standard on ADCM -#' ADCM <- ADCM %>% select(-starts_with("ATC")) %>% unique() +#' ADCM <- ADCM %>% +#' select(-starts_with("ATC")) %>% +#' unique() #' # function to derive AVISIT from ADEX #' add_visit <- function(data_need_visit) { #' visit_dates <- ADEX %>% @@ -67,7 +69,9 @@ #' ADAE <- add_visit(ADAE) #' ADCM <- add_visit(ADCM) #' # derive ongoing status variable for ADEX -#' ADEX <- ADEX %>% filter(PARCAT1 == "INDIVIDUAL") %>% mutate(ongo_status = (EOSSTT == "ONGOING")) +#' ADEX <- ADEX %>% +#' filter(PARCAT1 == "INDIVIDUAL") %>% +#' mutate(ongo_status = (EOSSTT == "ONGOING")) #' }) #' #' datanames(data) <- c("ADSL", "ADEX", "ADAE", "ADCM") diff --git a/R/tm_g_patient_profile.R b/R/tm_g_patient_profile.R index d27076c4..66483223 100644 --- a/R/tm_g_patient_profile.R +++ b/R/tm_g_patient_profile.R @@ -69,11 +69,12 @@ #' ADAE <- rADAE %>% mutate(ASTDT = as.Date(ASTDTM), AENDT = as.Date(AENDTM)) #' ADCM <- rADCM %>% mutate(ASTDT = as.Date(ASTDTM), AENDT = as.Date(AENDTM)) #' # The step below is to pre-process ADCM to legacy standard -#' ADCM <- ADCM %>% select(-starts_with("ATC")) %>% unique() +#' ADCM <- ADCM %>% +#' select(-starts_with("ATC")) %>% +#' unique() #' ADRS <- rADRS %>% mutate(ADT = as.Date(ADTM)) #' ADEX <- rADEX %>% mutate(ASTDT = as.Date(ASTDTM), AENDT = as.Date(AENDTM)) #' ADLB <- rADLB %>% mutate(ADT = as.Date(ADTM), LBSTRESN = as.numeric(LBSTRESC)) -#' #' }) #' #' datanames(data) <- c("ADSL", "ADAE", "ADCM", "ADRS", "ADEX", "ADLB")