Skip to content

Commit

Permalink
closes #41 create a basic ADSL for peds test subjects (#43)
Browse files Browse the repository at this point in the history
* #41 create a basic ADSL for peds test subjects

* #41 add adsl_peds dataset and man files

* #41 add missing variable labels

* #41 remove redundant comment

* #41 remove redundant comments

* #41 spelling
  • Loading branch information
rossfarrugia authored May 28, 2024
1 parent 8241b8b commit 1086534
Show file tree
Hide file tree
Showing 7 changed files with 107 additions and 1 deletion.
8 changes: 7 additions & 1 deletion R/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,16 @@
#' @family datasets
"dm_peds"


#' Vital signs Dataset-updated
#'
#' An updated SDTM VS dataset with anthropometric measurements for pediatric patients
#' @keywords datasets
#' @family datasets
"vs_peds"

#' Subject Level Analysis Dataset-updated
#'
#' An updated ADaM ADSL dataset with pediatric patients
#' @keywords datasets
#' @family datasets
"adsl_peds"
75 changes: 75 additions & 0 deletions data-raw/adsl_peds.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Dataset: adsl_peds
# Description: Create ADSL test ADaM dataset for pediatric studies

# Load libraries -----
library(pharmaversesdtm)
library(admiral)
library(dplyr)
library(lubridate)
library(stringr)

# Create a basic ADSL for pediatrics ----

# Read in input data ----
data("dm_peds")
data("ex")

# Derivations ----

# impute start and end time of exposure to first and last respectively, do not impute date
ex_ext <- ex %>%
derive_vars_dtm(
dtc = EXSTDTC,
new_vars_prefix = "EXST"
) %>%
derive_vars_dtm(
dtc = EXENDTC,
new_vars_prefix = "EXEN",
time_imputation = "last"
)

adsl_peds <- dm_peds %>%
## derive treatment variables (TRT01P, TRT01A) ----
mutate(TRT01P = ARM, TRT01A = ACTARM) %>%
## derive treatment start date (TRTSDTM) ----
derive_vars_merged(
dataset_add = ex_ext,
filter_add = (EXDOSE > 0 |
(EXDOSE == 0 &
str_detect(EXTRT, "PLACEBO"))) &
!is.na(EXSTDTM),
new_vars = exprs(TRTSDTM = EXSTDTM, TRTSTMF = EXSTTMF),
order = exprs(EXSTDTM, EXSEQ),
mode = "first",
by_vars = exprs(STUDYID, USUBJID)
) %>%
## derive treatment end date (TRTEDTM) ----
derive_vars_merged(
dataset_add = ex_ext,
filter_add = (EXDOSE > 0 |
(EXDOSE == 0 &
str_detect(EXTRT, "PLACEBO"))) & !is.na(EXENDTM),
new_vars = exprs(TRTEDTM = EXENDTM, TRTETMF = EXENTMF),
order = exprs(EXENDTM, EXSEQ),
mode = "last",
by_vars = exprs(STUDYID, USUBJID)
) %>%
## Derive treatment end/start date TRTSDT/TRTEDT ----
derive_vars_dtm_to_dt(source_vars = exprs(TRTSDTM, TRTEDTM)) %>%
## derive treatment duration (TRTDURD) ----
derive_var_trtdurd()

# Variable labels ----
attr(adsl_peds$TRTSDTM, "label") <- "Datetime of First Exposure to Treatment"
attr(adsl_peds$TRTSTMF, "label") <- "Exposure Start Time Imputation Flag"
attr(adsl_peds$TRTEDTM, "label") <- "Datetime of Last Exposure to Treatment"
attr(adsl_peds$TRTETMF, "label") <- "Exposure End Time Imputation Flag"
attr(adsl_peds$TRTSDT, "label") <- "Date of First Exposure to Treatment"
attr(adsl_peds$TRTEDT, "label") <- "Date of Last Exposure to Treatment"
attr(adsl_peds$TRTDURD, "label") <- "Total Treatment Duration (Days)"

# Label dataset ----
attr(adsl_peds, "label") <- "Subject Level Analysis Dataset"

# Save dataset ----
usethis::use_data(adsl_peds, overwrite = TRUE)
Binary file added data/adsl_peds.rda
Binary file not shown.
1 change: 1 addition & 0 deletions inst/WORDLIST
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
ADaM
ADaMs
ADSL
BMI
Biologics
CDISC
Expand Down
22 changes: 22 additions & 0 deletions man/adsl_peds.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/dm_peds.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/vs_peds.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1086534

Please sign in to comment.