Skip to content

Commit

Permalink
Merge pull request #285 from pharmaverse/281_subject_keys
Browse files Browse the repository at this point in the history
closes #281 closes #284 subject keys and slack link
  • Loading branch information
bundfussr authored Jun 18, 2024
2 parents 430574f + d696dcf commit 6d4afe3
Show file tree
Hide file tree
Showing 13 changed files with 123 additions and 117 deletions.
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# admiralonco (development version)

## Updates of Existing Functions

- Replaced hard coding of `expr(USUBJID, STUDYID)` and `expr(USUBJID)` with `get_admiral_option("subject_keys")` so the argument is flexible and can be changed from the default by the user. (#281)

# admiralonco 1.0.0

## Updates of Existing Functions
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ Here’s a summary of our strategy for this package related to R versions:
We use the following for support and communications between user and
developer community:

- [Slack](https://app.slack.com/client/T028PB489D3/C02M8KN8269) - for
- [Slack](https://pharmaverse.slack.com/) - for
informal discussions, Q&A and building our user community. If you
don’t have access, use this
[link](https://join.slack.com/t/pharmaverse/shared_invite/zt-yv5atkr4-Np2ytJ6W_QKz_4Olo7Jo9A)
Expand Down
36 changes: 18 additions & 18 deletions inst/templates/ad_adrs.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ adrs <- rs %>%
derive_vars_merged(
dataset_add = adsl,
new_vars = adsl_vars,
by_vars = exprs(STUDYID, USUBJID)
by_vars = get_admiral_option("subject_keys")
)

# Company-specific pre-processing ----
Expand Down Expand Up @@ -93,15 +93,15 @@ adrs <- adrs %>%
restrict_derivation(
derivation = derive_var_extreme_flag,
args = params(
by_vars = exprs(STUDYID, USUBJID, ADT),
by_vars = c(get_admiral_option("subject_keys"), exprs(ADT)),
order = exprs(worst_resp(AVALC), RSSEQ),
new_var = ANL01FL,
mode = "last"
),
filter = !is.na(AVAL) & ADT >= RANDDT
) %>%
derive_var_relative_flag(
by_vars = exprs(STUDYID, USUBJID),
by_vars = get_admiral_option("subject_keys"),
order = exprs(ADT, RSSEQ),
new_var = ANL02FL,
condition = AVALC == "PD",
Expand Down Expand Up @@ -143,7 +143,7 @@ adrs <- adrs %>%
derive_extreme_records(
dataset_ref = adsl,
dataset_add = adrs,
by_vars = exprs(STUDYID, USUBJID),
by_vars = get_admiral_option("subject_keys"),
filter_add = PARAMCD == "OVR" & AVALC == "PD" & ANL01FL == "Y",
order = exprs(ADT, RSSEQ),
mode = "first",
Expand All @@ -163,7 +163,7 @@ adrs <- adrs %>%
## Response ----
adrs <- adrs %>%
derive_extreme_event(
by_vars = exprs(STUDYID, USUBJID),
by_vars = get_admiral_option("subject_keys"),
order = exprs(event_nr, ADT),
tmp_event_nr_var = event_nr,
mode = "first",
Expand All @@ -186,7 +186,7 @@ adrs <- adrs %>%
## Clinical benefit ----
adrs <- adrs %>%
derive_extreme_event(
by_vars = exprs(STUDYID, USUBJID),
by_vars = get_admiral_option("subject_keys"),
order = exprs(desc(AVALC), ADT, event_nr),
tmp_event_nr_var = event_nr,
mode = "first",
Expand Down Expand Up @@ -214,7 +214,7 @@ adrs <- adrs %>%
# response for this subject.
adrs <- adrs %>%
derive_extreme_event(
by_vars = exprs(STUDYID, USUBJID),
by_vars = get_admiral_option("subject_keys"),
order = exprs(event_nr, ADT),
tmp_event_nr_var = event_nr,
mode = "first",
Expand All @@ -239,7 +239,7 @@ adrs <- adrs %>%
derive_extreme_records(
dataset_ref = adsl,
dataset_add = adrs,
by_vars = exprs(STUDYID, USUBJID),
by_vars = get_admiral_option("subject_keys"),
filter_add = PARAMCD == "BOR" & AVALC %in% c("CR", "PR"),
exist_flag = AVALC,
false_value = "N",
Expand All @@ -257,7 +257,7 @@ adrs <- adrs %>%
## Confirmed response versions of the above parameters ----
adrs <- adrs %>%
derive_extreme_event(
by_vars = exprs(STUDYID, USUBJID),
by_vars = get_admiral_option("subject_keys"),
order = exprs(desc(AVALC), ADT, event_nr),
tmp_event_nr_var = event_nr,
mode = "first",
Expand All @@ -279,7 +279,7 @@ adrs <- adrs %>%

adrs <- adrs %>%
derive_extreme_event(
by_vars = exprs(STUDYID, USUBJID),
by_vars = get_admiral_option("subject_keys"),
order = exprs(desc(AVALC), ADT, event_nr),
tmp_event_nr_var = event_nr,
mode = "first",
Expand All @@ -301,7 +301,7 @@ adrs <- adrs %>%

adrs <- adrs %>%
derive_extreme_event(
by_vars = exprs(STUDYID, USUBJID),
by_vars = get_admiral_option("subject_keys"),
order = exprs(event_nr, ADT),
tmp_event_nr_var = event_nr,
mode = "first",
Expand All @@ -323,7 +323,7 @@ adrs <- adrs %>%
derive_extreme_records(
dataset_ref = adsl,
dataset_add = adrs,
by_vars = exprs(STUDYID, USUBJID),
by_vars = get_admiral_option("subject_keys"),
filter_add = PARAMCD == "CBOR" & AVALC %in% c("CR", "PR"),
exist_flag = AVALC,
false_value = "N",
Expand All @@ -340,13 +340,13 @@ adrs <- adrs %>%

## Death ----
adsldth <- adsl %>%
select(STUDYID, USUBJID, DTHDT, !!!adsl_vars)
select(!!!get_admiral_option("subject_keys"), DTHDT, !!!adsl_vars)

adrs <- adrs %>%
derive_extreme_records(
dataset_ref = adsldth,
dataset_add = adsldth,
by_vars = exprs(STUDYID, USUBJID),
by_vars = get_admiral_option("subject_keys"),
filter_add = !is.na(DTHDT),
exist_flag = AVALC,
false_value = "N",
Expand All @@ -366,7 +366,7 @@ adrs <- adrs %>%
derive_extreme_records(
dataset_ref = adsl,
dataset_add = adrs,
by_vars = exprs(STUDYID, USUBJID),
by_vars = get_admiral_option("subject_keys"),
filter_add = PARAMCD == "OVR" & ANL01FL == "Y",
order = exprs(ADT, RSSEQ),
mode = "last",
Expand All @@ -382,7 +382,7 @@ adrs <- adrs %>%

## Measurable disease at baseline ----
adslmdis <- adsl %>%
select(STUDYID, USUBJID, !!!adsl_vars)
select(!!!get_admiral_option("subject_keys"), !!!adsl_vars)

adrs <- adrs %>%
derive_param_exist_flag(
Expand All @@ -404,7 +404,7 @@ adrs <- adrs %>%
# Derive analysis sequence
adrs <- adrs %>%
derive_var_obs_number(
by_vars = exprs(STUDYID, USUBJID),
by_vars = get_admiral_option("subject_keys"),
order = exprs(PARAMCD, ADT, VISITNUM, RSSEQ),
check_type = "error"
)
Expand All @@ -413,7 +413,7 @@ adrs <- adrs %>%
adrs <- adrs %>%
derive_vars_merged(
dataset_add = select(adsl, !!!negate_vars(adsl_vars)),
by_vars = exprs(STUDYID, USUBJID)
by_vars = get_admiral_option("subject_keys")
)

# Save output ----
Expand Down
22 changes: 11 additions & 11 deletions inst/templates/ad_adrs_basic.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ adrs <- rs %>%
derive_vars_merged(
dataset_add = adsl,
new_vars = adsl_vars,
by_vars = exprs(STUDYID, USUBJID)
by_vars = get_admiral_option("subject_keys")
)

# ---- Company-specific pre-processing ----
Expand Down Expand Up @@ -101,7 +101,7 @@ adrs <- adrs %>%
restrict_derivation(
derivation = derive_var_extreme_flag,
args = params(
by_vars = exprs(STUDYID, USUBJID, ADT),
by_vars = c(get_admiral_option("subject_keys"), exprs(ADT)),
order = exprs(worst_resp(AVALC), RSSEQ),
new_var = ANL01FL,
mode = "last"
Expand All @@ -116,7 +116,7 @@ adrs <- adrs %>%
derive_extreme_records(
dataset_ref = adsl,
dataset_add = adrs,
by_vars = exprs(STUDYID, USUBJID),
by_vars = get_admiral_option("subject_keys"),
filter_add = PARAMCD == "OVR" & AVALC == "PD" & ANL01FL == "Y",
order = exprs(ADT, RSSEQ),
mode = "first",
Expand Down Expand Up @@ -211,7 +211,7 @@ adrs <- adrs %>%
derive_extreme_records(
dataset_ref = adsl,
dataset_add = adrs,
by_vars = exprs(STUDYID, USUBJID),
by_vars = get_admiral_option("subject_keys"),
filter_add = PARAMCD == "BOR" & AVALC %in% c("CR", "PR"),
order = exprs(ADT, RSSEQ),
mode = "first",
Expand Down Expand Up @@ -293,7 +293,7 @@ adrs <- adrs %>%
derive_extreme_records(
dataset_ref = adsl,
dataset_add = adrs,
by_vars = exprs(STUDYID, USUBJID),
by_vars = get_admiral_option("subject_keys"),
filter_add = PARAMCD == "CBOR" & AVALC %in% c("CR", "PR"),
order = exprs(ADT, RSSEQ),
mode = "first",
Expand All @@ -312,13 +312,13 @@ adrs <- adrs %>%

# Death
adsldth <- adsl %>%
select(STUDYID, USUBJID, DTHDT, !!!adsl_vars)
select(!!!get_admiral_option("subject_keys"), DTHDT, !!!adsl_vars)

adrs <- adrs %>%
derive_extreme_records(
dataset_ref = adsldth,
dataset_add = adsldth,
by_vars = exprs(STUDYID, USUBJID),
by_vars = get_admiral_option("subject_keys"),
filter_add = !is.na(DTHDT),
exist_flag = AVALC,
false_value = "N",
Expand All @@ -338,7 +338,7 @@ adrs <- adrs %>%
derive_extreme_records(
dataset_ref = adsl,
dataset_add = adrs,
by_vars = exprs(STUDYID, USUBJID),
by_vars = get_admiral_option("subject_keys"),
filter_add = PARAMCD == "OVR" & ANL01FL == "Y",
order = exprs(ADT, RSSEQ),
mode = "last",
Expand All @@ -354,7 +354,7 @@ adrs <- adrs %>%

# Measurable disease at baseline
adslmdis <- adsl %>%
select(STUDYID, USUBJID, !!!adsl_vars)
select(!!!get_admiral_option("subject_keys"), !!!adsl_vars)

adrs <- adrs %>%
derive_param_exist_flag(
Expand All @@ -376,7 +376,7 @@ adrs <- adrs %>%
# Derive analysis sequence
adrs <- adrs %>%
derive_var_obs_number(
by_vars = exprs(STUDYID, USUBJID),
by_vars = get_admiral_option("subject_keys"),
order = exprs(PARAMCD, ADT, VISITNUM, RSSEQ),
check_type = "error"
)
Expand All @@ -385,7 +385,7 @@ adrs <- adrs %>%
adrs <- adrs %>%
derive_vars_merged(
dataset_add = select(adsl, !!!negate_vars(adsl_vars)),
by_vars = exprs(STUDYID, USUBJID)
by_vars = get_admiral_option("subject_keys")
)

# ---- Save output ----
Expand Down
Loading

0 comments on commit 6d4afe3

Please sign in to comment.