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 #226 updated subject keys across package #239

Merged
merged 3 commits into from
Jun 11, 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
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
* The argument `dataset_occ`
* The argument `lat_vals`

## Various

- All vignettes and templates in `{admiralophtha}` have been updated to use the `{admiral}` subject keys option rather than
explicitly quoting key variables such as `STUYDID` and `USUBJID`. For instance, a line such as `by_vars = exprs(STUDYID, USUBJID)`
would be replaced by `by_vars = get_admiral_option("subject_keys")` (#226).

# admiralophtha 1.0.0

## Updates to Templates
Expand Down
2 changes: 1 addition & 1 deletion R/derive_var_bcvacritxfl.R
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ derive_var_bcvacritxfl <- function(dataset,
critxfl_index = NULL) {
# Input checks
assert_vars(crit_var)
assert_data_frame(dataset, required_vars = c(exprs(STUDYID, USUBJID), crit_var))
assert_data_frame(dataset, required_vars = crit_var)
assert_character_scalar(additional_text)
assert_integer_scalar(critxfl_index, optional = TRUE)
if (!is.null(bcva_ranges)) lapply(bcva_ranges, assert_numeric_vector)
Expand Down
4 changes: 2 additions & 2 deletions R/derive_var_studyeye.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
#'
#' derive_var_studyeye(adsl, sc)
derive_var_studyeye <- function(dataset_adsl, dataset_sc, sctestcd_value = "FOCID") {
assert_data_frame(dataset_sc, required_vars = exprs(STUDYID, USUBJID, SCTESTCD, SCSTRESC))
assert_data_frame(dataset_adsl, required_vars = exprs(STUDYID, USUBJID))
assert_data_frame(dataset_sc, required_vars = exprs(SCTESTCD, SCSTRESC))
assert_data_frame(dataset_adsl)

seye_cat <- function(seye) {
case_when(
Expand Down
28 changes: 17 additions & 11 deletions inst/templates/ad_adbcva.R
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ adbcva_adslvar <- oe %>%
derive_vars_merged(
dataset_add = adsl,
new_vars = adsl_vars,
by_vars = exprs(STUDYID, USUBJID)
by_vars = get_admiral_option("subject_keys")
)

adbcva_aval <- adbcva_adslvar %>%
Expand All @@ -137,7 +137,10 @@ adbcva_nlogparam <- adbcva_aval %>%
adbcva_logparam <- adbcva_nlogparam %>%
# Add derived log parameters
derive_param_computed(
by_vars = c(exprs(STUDYID, USUBJID, VISIT, VISITNUM, OEDY, OEDTC, AFEYE), adsl_vars),
by_vars = c(
get_admiral_option("subject_keys"),
exprs(VISIT, VISITNUM, OEDY, OEDTC, AFEYE, !!!adsl_vars)
),
parameters = c("SBCVA"),
set_values_to = exprs(
AVAL = convert_etdrs_to_logmar(AVAL.SBCVA),
Expand All @@ -148,7 +151,10 @@ adbcva_logparam <- adbcva_nlogparam %>%
)
) %>%
derive_param_computed(
by_vars = c(exprs(STUDYID, USUBJID, VISIT, OEDY, OEDTC, AFEYE), adsl_vars),
by_vars = c(
get_admiral_option("subject_keys"),
exprs(VISIT, VISITNUM, OEDY, OEDTC, AFEYE, !!!adsl_vars)
),
parameters = c("FBCVA"),
set_values_to = exprs(
AVAL = convert_etdrs_to_logmar(AVAL.FBCVA),
Expand Down Expand Up @@ -195,7 +201,7 @@ adbcva_trtflag <- adbcva_visit %>%
derivation = derive_var_extreme_flag,
args = params(
new_var = ABLFL,
by_vars = exprs(STUDYID, USUBJID, BASETYPE, PARAMCD),
by_vars = c(get_admiral_option("subject_keys"), exprs(BASETYPE, PARAMCD)),
order = exprs(ADT, VISITNUM, OESEQ),
mode = "last"
),
Expand All @@ -209,7 +215,7 @@ adbcva_vstflag <- adbcva_trtflag %>%
derivation = derive_var_extreme_flag,
args = params(
new_var = ANL01FL,
by_vars = exprs(USUBJID, PARAMCD, AVISIT, DTYPE),
by_vars = c(get_admiral_option("subject_keys"), exprs(PARAMCD, AVISIT, DTYPE)),
order = exprs(ADT, AVAL),
mode = "last"
),
Expand All @@ -220,7 +226,7 @@ adbcva_vstflag <- adbcva_trtflag %>%
derivation = derive_var_extreme_flag,
args = params(
new_var = ANL02FL,
by_vars = exprs(USUBJID, PARAMCD, ABLFL),
by_vars = c(get_admiral_option("subject_keys"), exprs(PARAMCD, ABLFL)),
order = exprs(ADT),
mode = "last"
),
Expand All @@ -231,7 +237,7 @@ adbcva_vstflag <- adbcva_trtflag %>%
restrict_derivation(
derivation = derive_var_extreme_flag,
args = params(
by_vars = exprs(USUBJID, PARAMCD),
by_vars = c(get_admiral_option("subject_keys"), exprs(PARAMCD)),
order = exprs(AVAL, ADT),
new_var = WORS01FL,
mode = "first"
Expand All @@ -243,13 +249,13 @@ adbcva_vstflag <- adbcva_trtflag %>%
adbcva_change <- adbcva_vstflag %>%
# Calculate BASE
derive_var_base(
by_vars = exprs(STUDYID, USUBJID, PARAMCD, BASETYPE),
by_vars = c(get_admiral_option("subject_keys"), exprs(PARAMCD, BASETYPE)),
source_var = AVAL,
new_var = BASE
) %>%
# Calculate BASEC
derive_var_base(
by_vars = exprs(STUDYID, USUBJID, PARAMCD, BASETYPE),
by_vars = c(get_admiral_option("subject_keys"), exprs(PARAMCD, BASETYPE)),
source_var = AVALC,
new_var = BASEC
) %>%
Expand All @@ -262,7 +268,7 @@ adbcva_change <- adbcva_vstflag %>%
adbcva_aseq <- adbcva_change %>%
derive_var_obs_number(
new_var = ASEQ,
by_vars = exprs(STUDYID, USUBJID),
by_vars = get_admiral_option("subject_keys"),
order = exprs(PARAMCD, ADT, AVISITN, VISITNUM, ATPTN),
check_type = "error"
)
Expand All @@ -271,7 +277,7 @@ adbcva_aseq <- adbcva_change %>%
adbcva_adsl <- adbcva_aseq %>%
derive_vars_merged(
dataset_add = select(adsl, !!!negate_vars(adsl_vars)),
by_vars = exprs(STUDYID, USUBJID)
by_vars = get_admiral_option("subject_keys")
)

adbcva_crtflag <- adbcva_adsl %>%
Expand Down
18 changes: 9 additions & 9 deletions inst/templates/ad_adoe.R
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ adoe_adslvar <- oe %>%
derive_vars_merged(
dataset_add = adsl,
new_vars = adsl_vars,
by_vars = exprs(STUDYID, USUBJID)
by_vars = get_admiral_option("subject_keys")
)

adoe_aval <- adoe_adslvar %>%
Expand Down Expand Up @@ -111,7 +111,7 @@ adoe_trtflag <- adoe_visit %>%
derivation = derive_var_extreme_flag,
args = params(
new_var = ABLFL,
by_vars = exprs(STUDYID, USUBJID, BASETYPE, PARAMCD),
by_vars = c(get_admiral_option("subject_keys"), exprs(BASETYPE, PARAMCD)),
order = exprs(ADT, VISITNUM, OESEQ),
mode = "last"
),
Expand All @@ -125,7 +125,7 @@ adoe_vstflag <- adoe_trtflag %>%
derivation = derive_var_extreme_flag,
args = params(
new_var = ANL01FL,
by_vars = exprs(USUBJID, PARAMCD, AVISIT, DTYPE),
by_vars = c(get_admiral_option("subject_keys"), exprs(PARAMCD, AVISIT, DTYPE)),
order = exprs(ADT, AVAL),
mode = "last"
),
Expand All @@ -136,7 +136,7 @@ adoe_vstflag <- adoe_trtflag %>%
derivation = derive_var_extreme_flag,
args = params(
new_var = ANL02FL,
by_vars = exprs(USUBJID, PARAMCD, ABLFL),
by_vars = c(get_admiral_option("subject_keys"), exprs(PARAMCD, ABLFL)),
order = exprs(ADT),
mode = "last"
),
Expand All @@ -147,7 +147,7 @@ adoe_vstflag <- adoe_trtflag %>%
restrict_derivation(
derivation = derive_var_extreme_flag,
args = params(
by_vars = exprs(USUBJID, PARAMCD),
by_vars = c(get_admiral_option("subject_keys"), exprs(PARAMCD)),
order = exprs(AVAL, ADT),
new_var = WORS01FL,
mode = "last"
Expand All @@ -159,13 +159,13 @@ adoe_vstflag <- adoe_trtflag %>%
adoe_change <- adoe_vstflag %>%
# Calculate BASE
derive_var_base(
by_vars = exprs(STUDYID, USUBJID, PARAMCD, BASETYPE),
by_vars = c(get_admiral_option("subject_keys"), exprs(PARAMCD, BASETYPE)),
source_var = AVAL,
new_var = BASE
) %>%
# Calculate BASEC
derive_var_base(
by_vars = exprs(STUDYID, USUBJID, PARAMCD, BASETYPE),
by_vars = c(get_admiral_option("subject_keys"), exprs(PARAMCD, BASETYPE)),
source_var = AVALC,
new_var = BASEC
) %>%
Expand All @@ -178,7 +178,7 @@ adoe_change <- adoe_vstflag %>%
adoe_aseq <- adoe_change %>%
derive_var_obs_number(
new_var = ASEQ,
by_vars = exprs(STUDYID, USUBJID),
by_vars = get_admiral_option("subject_keys"),
order = exprs(PARAMCD, ADT, AVISITN, VISITNUM, ATPTN),
check_type = "error"
)
Expand All @@ -187,7 +187,7 @@ adoe_aseq <- adoe_change %>%
adoe_adsl <- adoe_aseq %>%
derive_vars_merged(
dataset_add = select(adsl, !!!negate_vars(adsl_vars)),
by_vars = exprs(STUDYID, USUBJID)
by_vars = get_admiral_option("subject_keys")
)

# Final Steps, Select final variables and Add labels
Expand Down
47 changes: 34 additions & 13 deletions inst/templates/ad_advfq.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ advfq_dtdy <- derive_vars_merged(
ungroup(qs),
dataset_add = adsl,
new_vars = adsl_vars,
by_vars = exprs(STUDYID, USUBJID)
by_vars = get_admiral_option("subject_keys")
) %>%
## Calculate ADT, ADY ----
derive_vars_dt(
Expand Down Expand Up @@ -76,7 +76,10 @@ advfq_aval <- advfq_dtdy %>%
advfq_qr01 <- advfq_aval %>%
derive_summary_records(
dataset_add = advfq_aval,
by_vars = exprs(STUDYID, USUBJID, !!!adsl_vars, PARAMCD, VISITNUM, VISIT, ADT, ADY),
by_vars = c(
get_admiral_option("subject_keys"),
exprs(!!!adsl_vars, PARAMCD, VISITNUM, VISIT, ADT, ADY)
),
filter_add = QSTESTCD == "VFQ1" & !is.na(AVAL),
set_values_to = exprs(
AVAL = identity(AVAL),
Expand Down Expand Up @@ -104,7 +107,10 @@ advfq_qr01 <- advfq_aval %>%
advfq_qr02 <- advfq_qr01 %>%
derive_summary_records(
dataset_add = advfq_qr01,
by_vars = exprs(STUDYID, USUBJID, !!!adsl_vars, PARAMCD, VISITNUM, VISIT, ADT, ADY),
by_vars = c(
get_admiral_option("subject_keys"),
exprs(!!!adsl_vars, PARAMCD, VISITNUM, VISIT, ADT, ADY)
),
filter_add = QSTESTCD == "VFQ2" & !is.na(AVAL),
set_values_to = exprs(
AVAL = identity(AVAL),
Expand Down Expand Up @@ -132,7 +138,10 @@ advfq_qr02 <- advfq_qr01 %>%
advfq_qr03 <- advfq_qr02 %>%
derive_summary_records(
dataset_add = advfq_qr02,
by_vars = exprs(STUDYID, USUBJID, PARAMCD, !!!adsl_vars, VISITNUM, VISIT, ADT, ADY),
by_vars = c(
get_admiral_option("subject_keys"),
exprs(PARAMCD, !!!adsl_vars, VISITNUM, VISIT, ADT, ADY)
),
filter_add = QSTESTCD == "VFQ3" & !is.na(AVAL),
set_values_to = exprs(
AVAL = identity(AVAL),
Expand Down Expand Up @@ -160,7 +169,10 @@ advfq_qr03 <- advfq_qr02 %>%
advfq_qr04 <- advfq_qr03 %>%
derive_summary_records(
dataset_add = advfq_qr03,
by_vars = exprs(STUDYID, USUBJID, PARAMCD, !!!adsl_vars, VISITNUM, VISIT, ADT, ADY),
by_vars = c(
get_admiral_option("subject_keys"),
exprs(PARAMCD, !!!adsl_vars, VISITNUM, VISIT, ADT, ADY)
),
filter_add = QSTESTCD == "VFQ4" & !is.na(AVAL),
set_values_to = exprs(
AVAL = identity(AVAL),
Expand All @@ -184,7 +196,10 @@ advfq_qr04 <- advfq_qr03 %>%
advfq_qsg01 <- advfq_qr04 %>%
derive_summary_records(
dataset_add = advfq_qr04,
by_vars = exprs(STUDYID, USUBJID, !!!adsl_vars, VISITNUM, VISIT, ADT, ADY),
by_vars = c(
get_admiral_option("subject_keys"),
exprs(!!!adsl_vars, VISITNUM, VISIT, ADT, ADY)
),
filter_add = PARAMCD %in% c("QR01", "QR02") & !is.na(AVAL),
set_values_to = exprs(
AVAL = mean(AVAL),
Expand All @@ -198,7 +213,10 @@ advfq_qsg01 <- advfq_qr04 %>%
advfq_qsg02 <- advfq_qsg01 %>%
derive_summary_records(
dataset_add = advfq_qsg01,
by_vars = exprs(STUDYID, USUBJID, !!!adsl_vars, VISITNUM, VISIT, ADT, ADY),
by_vars = c(
get_admiral_option("subject_keys"),
exprs(!!!adsl_vars, VISITNUM, VISIT, ADT, ADY)
),
filter_add = PARAMCD %in% c("QR03", "QR04") & !is.na(AVAL),
set_values_to = exprs(
AVAL = mean(AVAL),
Expand All @@ -213,7 +231,10 @@ advfq_qsg02 <- advfq_qsg01 %>%
advfq_qbcs <- advfq_qsg02 %>%
derive_summary_records(
dataset_add = advfq_qsg02,
by_vars = exprs(STUDYID, USUBJID, !!!adsl_vars, VISITNUM, VISIT, ADT, ADY),
by_vars = c(
get_admiral_option("subject_keys"),
exprs(!!!adsl_vars, VISITNUM, VISIT, ADT, ADY)
),
filter_add = PARAMCD %in% c("QSG01", "QSG02") & !is.na(AVAL),
set_values_to = exprs(
AVAL = sum(AVAL),
Expand Down Expand Up @@ -259,7 +280,7 @@ advfq_blfl <- advfq_ontrt %>%
restrict_derivation(
derivation = derive_var_extreme_flag,
args = params(
by_vars = exprs(STUDYID, USUBJID, PARAMCD),
by_vars = c(get_admiral_option("subject_keys"), exprs(PARAMCD)),
order = exprs(ADT, VISITNUM, QSSEQ),
new_var = ABLFL,
mode = "last"
Expand All @@ -271,7 +292,7 @@ advfq_blfl <- advfq_ontrt %>%
advfq_change <- advfq_blfl %>%
# Calculate BASE
derive_var_base(
by_vars = exprs(STUDYID, USUBJID, PARAMCD),
by_vars = c(get_admiral_option("subject_keys"), exprs(PARAMCD)),
source_var = AVAL,
new_var = BASE
) %>%
Expand All @@ -287,7 +308,7 @@ advfq_anlflag <- advfq_change %>%
derivation = derive_var_extreme_flag,
args = params(
new_var = ANL01FL,
by_vars = exprs(USUBJID, PARAMCD, AVISIT),
by_vars = c(get_admiral_option("subject_keys"), exprs(PARAMCD, AVISIT)),
order = exprs(ADT, AVAL),
mode = "last"
),
Expand All @@ -299,7 +320,7 @@ advfq_aseq <- advfq_anlflag %>%
# Calculate ASEQ
derive_var_obs_number(
new_var = ASEQ,
by_vars = exprs(STUDYID, USUBJID),
by_vars = get_admiral_option("subject_keys"),
order = exprs(PARAMCD, ADT, AVISITN, VISITNUM),
check_type = "error"
) %>%
Expand All @@ -311,7 +332,7 @@ advfq_aseq <- advfq_anlflag %>%
advfq_adsl <- advfq_aseq %>%
derive_vars_merged(
dataset_add = select(adsl, !!!negate_vars(adsl_vars)),
by_vars = exprs(STUDYID, USUBJID)
by_vars = get_admiral_option("subject_keys")
)

# Final Steps, Select final variables and Add labels
Expand Down
12 changes: 9 additions & 3 deletions vignettes/adbcva.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ adbcva <- oe %>%
derive_vars_merged(
dataset_add = adsl,
new_vars = adsl_vars,
by_vars = exprs(STUDYID, USUBJID)
by_vars = get_admiral_option("subject_keys")
)
```

Expand Down Expand Up @@ -123,7 +123,10 @@ Often ADBCVA datasets contain derived records for BCVA in LogMAR units. This can
```{r}
adbcva <- adbcva %>%
derive_param_computed(
by_vars = c(exprs(STUDYID, USUBJID, VISIT, VISITNUM, OEDY, OEDTC, AFEYE), adsl_vars),
by_vars = c(
get_admiral_option("subject_keys"),
exprs(VISIT, VISITNUM, OEDY, OEDTC, AFEYE, !!!adsl_vars)
),
parameters = c("SBCVA"),
set_values_to = exprs(
AVAL = convert_etdrs_to_logmar(AVAL.SBCVA),
Expand All @@ -134,7 +137,10 @@ adbcva <- adbcva %>%
)
) %>%
derive_param_computed(
by_vars = c(exprs(STUDYID, USUBJID, VISIT, OEDY, OEDTC, AFEYE), adsl_vars),
by_vars = c(
get_admiral_option("subject_keys"),
exprs(VISIT, VISITNUM, OEDY, OEDTC, AFEYE, !!!adsl_vars)
),
parameters = c("FBCVA"),
set_values_to = exprs(
AVAL = convert_etdrs_to_logmar(AVAL.FBCVA),
Expand Down
2 changes: 1 addition & 1 deletion vignettes/adoe.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ adoe <- oe %>%
derive_vars_merged(
dataset_add = adsl,
new_vars = adsl_vars,
by_vars = exprs(STUDYID, USUBJID)
by_vars = get_admiral_option("subject_keys")
)
```

Expand Down
Loading
Loading