-
Notifications
You must be signed in to change notification settings - Fork 6
Closes #292 add ader template #331
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
base: main
Are you sure you want to change the base?
Changes from 12 commits
d8bed2f
4320ff5
cfbde04
5ca36e1
ad702c0
17d2d4d
09605a0
2882a93
be0964e
5a2cb5c
6ec0d27
1023bdf
b520f0f
f0521b8
78be843
6fa458c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,213 @@ | ||
| # Name: ADER | ||
| # | ||
| # Label: Exposure Response Data | ||
| # | ||
| # Input: adsl, adrs, adtte, adlb, advs, adex | ||
| library(admiral) | ||
| library(admiralonco) | ||
| # pharmaverseadam contains example datasets generated from the CDISC pilot | ||
| # project SDTM ran through admiral templates | ||
| library(pharmaverseadam) | ||
| library(dplyr) | ||
| library(lubridate) | ||
| library(stringr) | ||
|
|
||
| # Load source datasets ---- | ||
|
|
||
| # Use e.g. haven::read_sas to read in .sas7bdat, or other suitable functions | ||
| # as needed and assign to the variables below. | ||
| # For illustration purposes read in admiral test data | ||
|
|
||
| data("admiral_adsl") | ||
| data("admiral_adrs") | ||
| data("country_code_lookup") | ||
|
|
||
| adsl <- admiral_adsl | ||
| adrs <- admiral_adrs | ||
|
|
||
| adtte <- pharmaverseadam::adtte_onco | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @bundfussr and @manciniedoardo If I want to include
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pulling from pharmaverseadam would introduce a circular dependency because pharmaverseadam itself has a dependency on admiralonco. So I would say yes.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure. In the other templates we use the ADaM datasets from The only tricky scenario I'm aware of is when for example Maybe we should remove
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok, if that works then it's fine - personally i'd rather not have all these steps but final call is yours of course!
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. By the way, I think even in
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I would use the datasets from |
||
| adlb <- pharmaverseadam::adlb | ||
| advs <- pharmaverseadam::advs | ||
| adex <- pharmaverseadam::adex %>% | ||
| filter(PARCAT1 == "INDIVIDUAL") | ||
|
|
||
| adpp <- pharmaverseadam::adpp | ||
|
|
||
|
|
||
| # Derivations ---- | ||
|
|
||
| # For ADTTE censor variables add "IND" to PARAMCD | ||
| adttei <- adtte %>% | ||
| mutate(PARAMCD = paste0(PARAMCD, "IND")) | ||
|
|
||
| ader_tte <- adsl %>% | ||
| select(!!!get_admiral_option("subject_keys")) %>% | ||
| # Create OS and PFS variables from ADTTE | ||
| derive_vars_transposed( | ||
| dataset_merge = adtte, | ||
| by_vars = get_admiral_option("subject_keys"), | ||
| key_var = PARAMCD, | ||
| value_var = AVAL | ||
| ) %>% | ||
| # Create OS and PFS censor variables | ||
| derive_vars_transposed( | ||
| dataset_merge = adttei, | ||
| by_vars = get_admiral_option("subject_keys"), | ||
| key_var = PARAMCD, | ||
| value_var = CNSR | ||
| ) | ||
|
|
||
| # Derive Best Overall Response (BOR) variables from ADRS | ||
| ader_bor <- ader_tte %>% | ||
| derive_vars_merged( | ||
| dataset_add = adrs, | ||
| filter_add = PARAMCD == "BOR" & ANL01FL == "Y", | ||
| by_vars = get_admiral_option("subject_keys"), | ||
| new_vars = exprs(BOR = AVAL, BORC = AVALC) | ||
| ) | ||
|
|
||
| # Add exposure metrics | ||
|
|
||
| ader_auc <- ader_bor %>% | ||
| derive_vars_transposed( | ||
| dataset_merge = adpp, | ||
| filter = PARAMCD %in% c("AUCLST", "CMAX"), | ||
| by_vars = get_admiral_option("subject_keys"), | ||
| key_var = PARAMCD, | ||
| value_var = AVAL | ||
| ) %>% | ||
| rename(AUCSS = AUCLST, CMAXSS = CMAX) | ||
|
|
||
| # Add Sequence number | ||
|
|
||
| ader_aseq <- ader_auc %>% | ||
| derive_var_obs_number( | ||
| by_vars = get_admiral_option("subject_keys"), | ||
| check_type = "error" | ||
| ) | ||
|
|
||
| # ---- Derive Covariates ---- | ||
| # Include numeric values for STUDYIDN, USUBJIDN, SEXN, RACEN etc. | ||
|
|
||
jeffreyad marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| covar <- adsl %>% | ||
| derive_vars_merged( | ||
| dataset_add = country_code_lookup, | ||
| new_vars = exprs(COUNTRYN = country_number, COUNTRYL = country_name), | ||
| by_vars = exprs(COUNTRY = country_code) | ||
| ) %>% | ||
| mutate( | ||
| STUDYIDN = as.numeric(word(USUBJID, 1, sep = fixed("-"))), | ||
| SITEIDN = as.numeric(word(USUBJID, 2, sep = fixed("-"))), | ||
| USUBJIDN = as.numeric(word(USUBJID, 3, sep = fixed("-"))), | ||
| SUBJIDN = as.numeric(SUBJID), | ||
| SEXN = case_when( | ||
| SEX == "M" ~ 1, | ||
| SEX == "F" ~ 2, | ||
| TRUE ~ 3 | ||
| ), | ||
| RACEN = case_when( | ||
| RACE == "AMERICAN INDIAN OR ALASKA NATIVE" ~ 1, | ||
| RACE == "ASIAN" ~ 2, | ||
| RACE == "BLACK OR AFRICAN AMERICAN" ~ 3, | ||
| RACE == "NATIVE HAWAIIAN OR OTHER PACIFIC ISLANDER" ~ 4, | ||
| RACE == "WHITE" ~ 5, | ||
| TRUE ~ 6 | ||
| ), | ||
| ETHNICN = case_when( | ||
| ETHNIC == "HISPANIC OR LATINO" ~ 1, | ||
| ETHNIC == "NOT HISPANIC OR LATINO" ~ 2, | ||
| TRUE ~ 3 | ||
| ), | ||
| ARMN = case_when( | ||
| ARM == "Placebo" ~ 0, | ||
| ARM == "Xanomeline Low Dose" ~ 1, | ||
| ARM == "Xanomeline High Dose" ~ 2, | ||
| TRUE ~ 3 | ||
| ), | ||
| ACTARMN = case_when( | ||
| ACTARM == "Placebo" ~ 0, | ||
| ACTARM == "Xanomeline Low Dose" ~ 1, | ||
| ACTARM == "Xanomeline High Dose" ~ 2, | ||
| TRUE ~ 3 | ||
| ), | ||
| COHORT = ARMN, | ||
| COHORTC = ARM, | ||
| ROUTE = unique(adex$EXROUTE)[1], | ||
| ROUTEN = case_when( | ||
| ROUTE == "TRANSDERMAL" ~ 3, | ||
| TRUE ~ NA_real_ | ||
| ), | ||
| FORM = unique(adex$EXDOSFRM)[1], | ||
| FORMN = case_when( | ||
| FORM == "PATCH" ~ 3, | ||
| TRUE ~ 4 | ||
| ) | ||
| ) %>% | ||
| select( | ||
| STUDYID, STUDYIDN, SITEID, SITEIDN, USUBJID, USUBJIDN, | ||
| SUBJID, SUBJIDN, AGE, SEX, SEXN, COHORT, COHORTC, ROUTE, ROUTEN, | ||
| RACE, RACEN, ETHNIC, ETHNICN, FORM, FORMN, COUNTRY, COUNTRYN, COUNTRYL | ||
| ) | ||
|
|
||
| # ---- Derive additional baselines from ADVS and ADLB ---- | ||
|
|
||
| labsbl <- adlb %>% | ||
| filter(ABLFL == "Y" & PARAMCD %in% c("CREAT", "ALT", "AST", "BILI")) %>% | ||
| mutate(PARAMCDB = paste0(PARAMCD, "BL")) %>% | ||
| select(STUDYID, USUBJID, PARAMCDB, AVAL) | ||
|
|
||
| covar_vslb <- covar %>% | ||
| derive_vars_merged( | ||
| dataset_add = advs, | ||
| filter_add = PARAMCD == "HEIGHT" & ABLFL == "Y", | ||
| by_vars = exprs(STUDYID, USUBJID), | ||
| new_vars = exprs(HTBL = AVAL) | ||
| ) %>% | ||
| derive_vars_merged( | ||
| dataset_add = advs, | ||
| filter_add = PARAMCD == "WEIGHT" & ABLFL == "Y", | ||
| by_vars = exprs(STUDYID, USUBJID), | ||
| new_vars = exprs(WTBL = AVAL) | ||
| ) %>% | ||
| derive_vars_transposed( | ||
| dataset_merge = labsbl, | ||
| by_vars = exprs(STUDYID, USUBJID), | ||
| key_var = PARAMCDB, | ||
| value_var = AVAL | ||
| ) %>% | ||
| mutate( | ||
| BMIBL = compute_bmi(height = HTBL, weight = WTBL), | ||
| BSABL = compute_bsa( | ||
| height = HTBL, | ||
| weight = WTBL, | ||
| method = "Mosteller" | ||
| ), | ||
| CRCLBL = compute_egfr( | ||
| creat = CREATBL, creatu = "SI", age = AGE, weight = WTBL, sex = SEX, | ||
| method = "CRCL" | ||
| ), | ||
| EGFRBL = compute_egfr( | ||
| creat = CREATBL, creatu = "SI", age = AGE, weight = WTBL, sex = SEX, | ||
| method = "CKD-EPI" | ||
| ) | ||
| ) %>% | ||
| rename(TBILBL = BILIBL) | ||
|
|
||
| # Combine covariates with ADER data | ||
|
|
||
| ader <- ader_aseq %>% | ||
| derive_vars_merged( | ||
| dataset_add = covar_vslb, | ||
| by_vars = exprs(STUDYID, USUBJID) | ||
| ) | ||
|
|
||
| # Save output ---- | ||
|
|
||
| # Change to whichever directory you want to save the dataset in | ||
| dir <- tools::R_user_dir("admiralonco_templates_data", which = "cache") | ||
| if (!file.exists(dir)) { | ||
| # Create the folder | ||
| dir.create(dir, recursive = TRUE, showWarnings = FALSE) | ||
| } | ||
| save(ader, file = file.path(dir, "ader.rda"), compress = "bzip2") | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The template uses
data("admiral_adsl")anddata("admiral_adrs")which is inconsistent with other templates in this package that usedata("adsl")anddata("adrs_onco")respectively. This inconsistency may cause issues if these dataset names don't exist in the expected packages. Review other templates (e.g., inst/templates/ad_adtte.R line 20, inst/templates/ad_adrs.R line 22) for the correct dataset names to ensure consistency.