Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace usage of scda and scda.2022 with random.cdisc.data #250

Merged
merged 6 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions book/graphs/efficacy/fstg01.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,14 @@ subtitle: Subgroup Analysis of Best Overall Response
```{r setup, message = FALSE}
#| code-fold: show

library(scda)
library(scda.2022)
library(dplyr)
library(tern)
library(nestcolor)

adsl_f <- synthetic_cdisc_dataset("latest", "adsl") %>%
adsl_f <- random.cdisc.data::cadsl %>%
select(STUDYID, USUBJID, ARMCD, ARM, SEX, BMRKR2, STRATA1, STRATA2)

adrs_f <- synthetic_cdisc_dataset("latest", "adrs") %>%
adrs_f <- random.cdisc.data::cadrs %>%
filter(PARAMCD == "INVET") %>%
select(STUDYID, USUBJID, PARAMCD, AVISIT, AVALC)

Expand Down Expand Up @@ -244,11 +242,8 @@ library(teal.modules.clinical)
## Data reproducible code
data <- teal_data()
data <- within(data, {
library(scda)
library(scda.2022)

ADSL <- synthetic_cdisc_dataset("latest", "adsl")
ADRS <- synthetic_cdisc_dataset("latest", "adrs")
ADSL <- random.cdisc.data::cadsl
ADRS <- random.cdisc.data::cadrs
})
datanames <- c("ADSL", "ADRS")
datanames(data) <- datanames
Expand Down
10 changes: 3 additions & 7 deletions book/graphs/efficacy/fstg02.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ library(tern)
library(dplyr)
library(forcats)
library(nestcolor)
library(scda)
library(scda.2022)

preprocess_adtte <- function(adtte) {
# Save variable labels before data processing steps.
Expand Down Expand Up @@ -51,7 +49,7 @@ preprocess_adtte <- function(adtte) {
adtte
}

anl <- synthetic_cdisc_dataset("latest", "adtte") %>%
anl <- random.cdisc.data::cadtte %>%
preprocess_adtte()
```

Expand Down Expand Up @@ -212,19 +210,17 @@ library(teal.modules.clinical)
## Data reproducible code
data <- teal_data()
data <- within(data, {
library(scda)
library(scda.2022)
library(dplyr)
library(forcats)

ADSL <- synthetic_cdisc_dataset("latest", "adsl")
ADSL <- random.cdisc.data::cadsl
ADSL <- ADSL %>%
filter(ARM %in% c("B: Placebo", "A: Drug X")) %>%
mutate(ARM = droplevels(fct_relevel(ARM, "B: Placebo"))) %>%
mutate(ARMCD = droplevels(fct_relevel(ARMCD, "ARM B")))
ADSL$RACE <- droplevels(ADSL$RACE)

ADTTE <- synthetic_cdisc_dataset("latest", "adtte")
ADTTE <- random.cdisc.data::cadtte
adtte_labels <- col_labels(ADTTE)

ADTTE <- ADTTE %>%
Expand Down
11 changes: 3 additions & 8 deletions book/graphs/efficacy/kmg01.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@ subtitle: Kaplan-Meier Plot
#| code-fold: show

library(tern)
library(scda)
library(scda.2022)
library(dplyr)
library(nestcolor)

adtte <- synthetic_cdisc_dataset("latest", "adtte")
adtte <- random.cdisc.data::cadtte
anl <- adtte %>%
dplyr::filter(PARAMCD == "OS") %>%
dplyr::mutate(is_event = CNSR == 0)
Expand Down Expand Up @@ -183,11 +181,8 @@ library(teal.modules.clinical)
## Data reproducible code
data <- teal_data()
data <- within(data, {
library(scda)
library(scda.2022)

ADSL <- synthetic_cdisc_dataset("latest", "adsl")
ADTTE <- synthetic_cdisc_dataset("latest", "adtte")
ADSL <- random.cdisc.data::cadsl
ADTTE <- random.cdisc.data::cadtte
})
datanames <- c("ADSL", "ADTTE")
datanames(data) <- datanames
Expand Down
12 changes: 4 additions & 8 deletions book/graphs/efficacy/mmrmg01.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,10 @@ Given an MMRM fitted with `s_mmrm`, `g_mmrm_lsmeans` displays for each visit the

library(dplyr)
library(tern.mmrm)
library(scda)
library(scda.2022)
library(nestcolor)

adsl <- synthetic_cdisc_dataset("latest", "adsl")
adqs <- synthetic_cdisc_dataset("latest", "adqs")
adsl <- random.cdisc.data::cadsl
adqs <- random.cdisc.data::cadqs

adqs_f <- adqs %>%
dplyr::filter(PARAMCD == "FKSI-FWB" & !AVISIT %in% c("BASELINE")) %>%
Expand Down Expand Up @@ -124,12 +122,10 @@ library(teal.modules.clinical)
## Data reproducible code
data <- teal_data()
data <- within(data, {
library(scda)
library(scda.2022)
library(dplyr)

ADSL <- synthetic_cdisc_dataset("latest", "adsl")
ADQS <- synthetic_cdisc_dataset("latest", "adqs") %>%
ADSL <- random.cdisc.data::cadsl
ADQS <- random.cdisc.data::cadqs %>%
filter(ABLFL != "Y" & ABLFL2 != "Y") %>%
filter(AVISIT %in% c("WEEK 1 DAY 8", "WEEK 2 DAY 15", "WEEK 3 DAY 22")) %>%
mutate(
Expand Down
6 changes: 2 additions & 4 deletions book/graphs/efficacy/mmrmg02.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@ subtitle: Forest Plot for Mixed-Effect Model Repeated Measures
```{r setup, message = FALSE}
#| code-fold: show

library(scda)
library(scda.2022)
library(dplyr)
library(tern.mmrm)
library(nestcolor)

adsl <- synthetic_cdisc_dataset("latest", "adsl")
adqs <- synthetic_cdisc_dataset("latest", "adqs")
adsl <- random.cdisc.data::cadsl
adqs <- random.cdisc.data::cadqs

adqs_f <- adqs %>%
dplyr::filter(PARAMCD == "FKSI-FWB" & !AVISIT %in% c("BASELINE")) %>%
Expand Down
9 changes: 3 additions & 6 deletions book/graphs/other/brg01.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,11 @@ subtitle: Bar Chart
library(binom)
library(dplyr)
library(ggplot2)
library(scda)
library(scda.2022)
library(tidyr)
library(tern)
library(nestcolor)

adsl <- synthetic_cdisc_dataset("latest", "adsl")
adsl <- random.cdisc.data::cadsl

# filtered population
patpop_df <- adsl %>%
Expand All @@ -31,12 +29,12 @@ patpop_df <- adsl %>%
patpop <- setNames(patpop_df$patpop, patpop_df$STUDYID)
denom <- patpop_df$patpop

adae <- synthetic_cdisc_dataset("latest", "adae") %>%
adae <- random.cdisc.data::cadae %>%
mutate(AETOXGRC = as.character(AETOXGR))
attributes(adae$AETOXGRC)$label <- "Analysis Toxicity Grade (C)"
vl_ae <- var_labels(adae)

adlb <- synthetic_cdisc_dataset("latest", "adlb")
adlb <- random.cdisc.data::cadlb
vl_lb <- var_labels(adlb)
```

Expand Down Expand Up @@ -153,7 +151,6 @@ plot
## {{< fa regular file-lines sm fw >}} Preview

<!-- skip strict because of partial arg match in `bionom` https://github.com/cran/binom/blob/master/R/binom.confint.R#L31 -->

```{r plot5, test = list(plot_v5 = "plot"), opts.label = "skip_test_strict"}
anl <- adlb %>%
filter(PARAMCD == "ALT" & ANRIND == "HIGH")
Expand Down
14 changes: 5 additions & 9 deletions book/graphs/other/bwg01.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@ subtitle: Box Plot
#| code-fold: show

# generic code for all plots
library(scda)
library(scda.2022)
library(dplyr)
library(ggplot2)
library(nestcolor)

adlb <- synthetic_cdisc_dataset("latest", "adlb")
adlb <- random.cdisc.data::cadlb
adlb <- adlb %>% filter(PARAMCD == "ALT" & AVISIT == "WEEK 2 DAY 15")

# Definition of boxplot boundaries and whiskers
Expand Down Expand Up @@ -244,8 +242,8 @@ plot

<!-- skip strict because of https://github.com/r-lib/gtable/pull/94 -->
```{r plot6, test = list(plot_v6 = "plot"), opts.label = "skip_test_strict"}
adsl <- synthetic_cdisc_dataset("latest", "adsl")
adlb <- synthetic_cdisc_dataset("latest", "adlb")
adsl <- random.cdisc.data::cadsl
adlb <- random.cdisc.data::cadlb

adlb_v <- adlb %>%
filter(PARAMCD == "ALT" & AVISIT %in% c("WEEK 1 DAY 8", "WEEK 2 DAY 15", "WEEK 3 DAY 22", "WEEK 4 DAY 29"))
Expand Down Expand Up @@ -433,12 +431,10 @@ library(teal.modules.general)
## Data reproducible code
data <- teal_data()
data <- within(data, {
library(scda)
library(scda.2022)
library(tern)

ADSL <- synthetic_cdisc_dataset("latest", "adsl")
ADLB <- synthetic_cdisc_dataset("latest", "adlb")
ADSL <- random.cdisc.data::cadsl
ADLB <- random.cdisc.data::cadlb

# If PARAMCD and AVISIT are not factors, convert to factors
# Also fill in missing values with "<Missing>"
Expand Down
11 changes: 3 additions & 8 deletions book/graphs/other/cig01.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@ subtitle: Confidence Interval Plot
library(tern)
library(ggplot2)
library(dplyr)
library(scda)
library(scda.2022)
library(nestcolor)

adlb <- synthetic_cdisc_dataset("latest", "adlb") %>%
adlb <- random.cdisc.data::cadlb %>%
filter(PARAMCD == "ALT", AVISIT == "BASELINE")
```

Expand Down Expand Up @@ -214,11 +212,8 @@ library(teal.modules.clinical)
## Data reproducible code
data <- teal_data()
data <- within(data, {
library(scda)
library(scda.2022)

ADSL <- synthetic_cdisc_dataset("latest", "adsl")
ADLB <- synthetic_cdisc_dataset("latest", "adlb")
ADSL <- random.cdisc.data::cadsl
ADLB <- random.cdisc.data::cadlb
})
datanames <- c("ADSL", "ADLB")
datanames(data) <- datanames
Expand Down
12 changes: 4 additions & 8 deletions book/graphs/other/ippg01.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,13 @@ For illustration purposes, we will subset the `adlb` dataset for safety populati
#| code-fold: show

library(tern)
library(scda)
library(scda.2022)
library(dplyr)
library(ggplot2)
library(nestcolor)

# use small sample size
adsl <- synthetic_cdisc_dataset("latest", "adsl") %>% slice(1:15)
adlb <- synthetic_cdisc_dataset("latest", "adlb") %>% filter(USUBJID %in% adsl$USUBJID)
adsl <- random.cdisc.data::cadsl %>% slice(1:15)
adlb <- random.cdisc.data::cadlb %>% filter(USUBJID %in% adsl$USUBJID)

# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.
adlb <- df_explicit_na(adlb)
Expand Down Expand Up @@ -113,13 +111,11 @@ library(teal.modules.clinical)
## Data reproducible code
data <- teal_data()
data <- within(data, {
library(scda)
library(scda.2022)
library(dplyr)

# use small sample size
ADSL <- synthetic_cdisc_dataset("latest", "adsl") %>% slice(1:15)
ADLB <- synthetic_cdisc_dataset("latest", "adlb") %>% filter(USUBJID %in% ADSL$USUBJID)
ADSL <- random.cdisc.data::cadsl %>% slice(1:15)
ADLB <- random.cdisc.data::cadlb %>% filter(USUBJID %in% ADSL$USUBJID)

# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.
ADSL <- df_explicit_na(ADSL)
Expand Down
10 changes: 4 additions & 6 deletions book/graphs/other/ltg01.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,15 @@ Lattice plots are natively handled by R, the examples below rely mostly on the p
```{r setup, message = FALSE}
#| code-fold: show

library(scda)
library(scda.2022)
library(tern)
library(teal.modules.clinical)
library(ggplot2)
library(dplyr)
library(nestcolor)

# Datasets
adsl <- synthetic_cdisc_dataset("latest", "adsl") %>% slice(1:8)
adlb <- synthetic_cdisc_dataset("latest", "adlb") %>% filter(USUBJID %in% adsl$USUBJID)
adsl <- random.cdisc.data::cadsl %>% slice(1:8)
adlb <- random.cdisc.data::cadlb %>% filter(USUBJID %in% adsl$USUBJID)

# Pre-processing
adlb$AVISIT_txt <- adlb$AVISIT
Expand Down Expand Up @@ -135,8 +133,8 @@ The example below suggests a larger dataset, where the individual subject legend
#| code-fold: show

# Datasets
adsl <- synthetic_cdisc_dataset("latest", "adsl") %>% slice(1:40)
adlb <- synthetic_cdisc_dataset("latest", "adlb") %>% filter(USUBJID %in% adsl$USUBJID)
adsl <- random.cdisc.data::cadsl %>% slice(1:40)
adlb <- random.cdisc.data::cadlb %>% filter(USUBJID %in% adsl$USUBJID)

# Pre-processing
adlb$AVISIT_txt <- adlb$AVISIT
Expand Down
14 changes: 5 additions & 9 deletions book/graphs/other/mng01.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@ subtitle: Mean Plot

library(dplyr)
library(tern)
library(scda)
library(scda.2022)
library(nestcolor)

adsl <- synthetic_cdisc_dataset("latest", "adsl")
adlb <- synthetic_cdisc_dataset("latest", "adlb")
advs <- synthetic_cdisc_dataset("latest", "advs")
adsl <- random.cdisc.data::cadsl
adlb <- random.cdisc.data::cadlb
advs <- random.cdisc.data::cadvs

adsl_f <- adsl %>%
filter(SAFFL == "Y") %>%
Expand Down Expand Up @@ -211,13 +209,11 @@ library(teal.modules.clinical)
## Data reproducible code
data <- teal_data()
data <- within(data, {
library(scda)
library(scda.2022)
library(dplyr)
library(forcats)

ADSL <- synthetic_cdisc_dataset("latest", "adsl")
ADLB <- synthetic_cdisc_dataset("latest", "adlb") %>%
ADSL <- random.cdisc.data::cadsl
ADLB <- random.cdisc.data::cadlb %>%
mutate(AVISIT = fct_reorder(AVISIT, AVISITN, min))
})
datanames <- c("ADSL", "ADLB")
Expand Down
4 changes: 1 addition & 3 deletions book/graphs/pharmacokinetic/pkcg01.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@ subtitle: Plot of PK Concentration Over Time by Subject
#| code-fold: show

library(tern)
library(scda)
library(scda.2022)
library(dplyr)
library(ggplot2)
library(nestcolor)

adpc <- synthetic_cdisc_dataset("latest", "adpc")
adpc <- random.cdisc.data::cadpc
```

## Plot in Linear Scale
Expand Down
4 changes: 1 addition & 3 deletions book/graphs/pharmacokinetic/pkcg02.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@ subtitle: Plot of PK Concentration Over Time by Cohort/Treatment Group/Dose
#| code-fold: show

library(tern)
library(scda)
library(scda.2022)
library(dplyr)
library(ggplot2)
library(nestcolor)

adpc <- synthetic_cdisc_dataset("latest", "adpc")
adpc <- random.cdisc.data::cadpc
```

## Plot in Linear Scale
Expand Down
Loading
Loading