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

Closes #33 Create RECIST data #61

Merged
merged 15 commits into from
Aug 31, 2023
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
# RStudio files
.Rproj.user/

# helper files for interchange data between scripts
data-raw/tu_help_data.rds

# produced vignettes
vignettes/*.html
vignettes/*.pdf
Expand Down
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@

- Ophthalmology variants of `ex` and `qs` SDTM datasets added. (#15)
- Migrate data and function `get_terms()` from `admiral.test`. (#1, #49)
- Oncology datasets `tu_onco_recist`, `tr_onco_recist`, and `rs_onco_recist`
using RECIST 1.1 response criteria. The datasets contain just a few patients.
They are intended for vignettes and examples of ADaM datasets creation. (#33)

26 changes: 26 additions & 0 deletions R/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,32 @@
#' @author Gopi Vegesna
"rs_onco"

#' Tumor Results Dataset (RECIST 1.1)
#'
#' A SDTM TR dataset using RECIST 1.1. The dataset contains just a few patients.
#' It is intended for vignettes and examples of ADaM dataset creation.
#'
#' @author Stefan Bundfuss
"tr_onco_recist"

#' Tumor Identification Dataset (RECIST 1.1)
#'
#' A SDTM TU dataset using RECIST 1.1. The dataset contains just a few patients.
#' It is intended for vignettes and examples of ADaM dataset creation.
#'
#' @author Stefan Bundfuss
"tu_onco_recist"

#' Disease Response Dataset (RECIST 1.1)
#'
#' A SDTM RS dataset using RECIST 1.1. The dataset contains just a few patients.
#' It is intended for vignettes and examples of ADaM dataset creation.
#'
#' @source The dataset is derived from \code{tr_onco_recist}.
#'
#' @author Stefan Bundfuss
"rs_onco_recist"

#' Supplemental Adverse Events Dataset
#'
#' A SDTM SUPPAE dataset from the CDISC pilot project
Expand Down
98 changes: 98 additions & 0 deletions data-raw/rs_onco_recist.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# ATTENTION: tr_onco_recist.R and tu_onco_recist.R must be run before this script
library(admiral)

data("tu_onco_recist")
data("tr_onco_recist")

tu <- tu_onco_recist

# add location to tr
tr <- derive_vars_merged(
tr_onco_recist,
dataset_add = tu,
by_vars = exprs(USUBJID, TREVAL = TUEVAL, TREVALID = TUEVALID, TRLNKID = TULNKID),
new_vars = exprs(TRLOC = TULOC)
)

# select tr results to consider:
tr <- tr %>%
filter(
TRTESTCD == "LDIAM" & TRLOC != "LYMPH NODE" |
TRTESTCD == "LPERP" & TRLOC == "LYMPH NODE" |
TRTESTCD == "TUMSTATE"
) %>%
# flag complete response by tumor
mutate(
CRFL = if_else(
TRTESTCD == "LDIAM" & TRSTRESN == 0 |
TRTESTCD == "LPERP" & TRSTRESN < 10 |
TRTESTCD == "TUMSTATE" & TRSTRESC == "ABSENT",
TRUE,
FALSE
)
)

# derive sums of diameters
sums <- tr %>%
group_by(STUDYID, USUBJID, TREVAL, TREVALID, TRACPTFL, VISITNUM, VISIT, TRDTC) %>%
summarise(
TRSTRESN = sum(TRSTRESN),
CRFL = all(CRFL),
IDS = paste(sort(TRLNKID), collapse = ", "),
NTFL = all(substr(TRLNKID, 1, 1) == "N")
) %>%
mutate(TRTESTCD = "SUMDIAM") %>%
ungroup()

sums <- derive_vars_merged(
sums,
dataset_add = sums,
filter_add = VISIT == "SCREENING",
by_vars = exprs(USUBJID, TREVAL, TREVALID),
new_vars = exprs(BASE = TRSTRESN, BASEIDS = IDS)
)
sums <- derive_vars_joined(
sums,
dataset_add = sums,
by_vars = exprs(USUBJID),
order = exprs(TRSTRESN),
new_vars = exprs(NADIR = TRSTRESN),
join_vars = exprs(VISITNUM),
filter_add = BASEIDS == IDS,
filter_join = VISITNUM > VISITNUM.join,
mode = "first",
check_type = "none"
)

# derive responses
rs_onco_recist <- sums %>%
mutate(
DOMAIN = "RS",
.before = STUDYID
) %>%
mutate(
RSTESTCD = "OVRLRESP",
RSTEST = "Overall Response",
RSORRES = case_when(
CRFL & IDS == BASEIDS ~ "CR",
TRSTRESN - NADIR >= 5 & TRSTRESN / NADIR >= 1.2 ~ "PD",
TRSTRESN / BASE <= 0.7 & IDS == BASEIDS ~ "PR",
!is.na(TRSTRESN) & IDS == BASEIDS ~ "SD",
NTFL ~ "NON-CR/NON-PD",
TRUE ~ "NE"
),
RSSTRESC = RSORRES,
RSEVAL = TREVAL,
RSEVALID = TREVALID,
RSACPTFL = TRACPTFL,
RSDTC = TRDTC
) %>%
select(-starts_with("TR"), -BASE, -BASEIDS, -NADIR, -IDS, -CRFL, -NTFL) %>%
filter(VISIT != "SCREENING") %>%
derive_var_obs_number(
by_vars = exprs(USUBJID),
new_var = RSSEQ,
order = exprs(VISITNUM, RSEVAL, RSEVALID)
)

usethis::use_data(rs_onco_recist, overwrite = TRUE)
Loading
Loading