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

253 feature request deprecatesupersede derive vars crit #254

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
ec72fdd
Substituted derive_vars_crit with new admiral function: derive_vars_c…
federicobaratin Dec 12, 2024
19f3c2a
Updated derive_vars_crit_flag function documentation.
federicobaratin Dec 12, 2024
08353a7
Adehering to deprecation strategy.
federicobaratin Dec 12, 2024
ea1ae6c
run roxygen step.
federicobaratin Dec 13, 2024
6c132ba
added CRIT1FLN in ADIS vignette.
federicobaratin Dec 13, 2024
6b0196e
Corrected typo.
federicobaratin Dec 13, 2024
85e7128
Replace old fun body with derive_vars_crit_flag and update test cases
ahasoplakus Jan 13, 2025
6c8f043
fix vignettes and ignore links
ahasoplakus Jan 13, 2025
158a507
appease lychee
ahasoplakus Jan 13, 2025
15e74e7
fix template
ahasoplakus Jan 13, 2025
9e97389
Update news
ahasoplakus Jan 13, 2025
5a9571c
Increment version number to 0.4.0
ahasoplakus Jan 15, 2025
e5d41e3
add deprecation test
ahasoplakus Jan 15, 2025
5623e15
Updated function as per deprecation strategy, Phase 1.
federicobaratin Jan 15, 2025
09c2f16
Rre-run function
federicobaratin Jan 16, 2025
6b660f6
Revert commit
federicobaratin Jan 16, 2025
5e43e5e
Added deprecation message and fixed tests.
federicobaratin Jan 16, 2025
7a62636
Put depracte_warn().
federicobaratin Jan 17, 2025
76d8802
Restored old function
federicobaratin Jan 17, 2025
69f98dd
run roxygen.
federicobaratin Jan 17, 2025
f5e454e
Put rlang
federicobaratin Jan 17, 2025
fc814f2
Put input as workaround
federicobaratin Jan 17, 2025
46ef0db
Removed recall to the other function.
federicobaratin Jan 19, 2025
8ec9bf1
Added test for deprecation.
federicobaratin Jan 19, 2025
72f8481
Test 4 for deprecation is not working.
federicobaratin Jan 19, 2025
316c321
add test for deprecate warn
ahasoplakus Jan 28, 2025
959f2d2
style fix
ahasoplakus Jan 28, 2025
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
1 change: 1 addition & 0 deletions .lycheeignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ https://cran.r-project.org/package=admiralvaccine
https://pharmaverse.github.io/admiralvaccine/reference
https://pharmaverse.github.io/admiralvaccine/articles
https://github.com/pharmaverse/admiralvaccine/blob/*
https://www.fda.gov/media/112581/download
5 changes: 3 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: admiralvaccine
Title: Vaccine Extension Package for ADaM in 'R' Asset Library
Version: 0.3.0
Version: 0.4.0
Authors@R: c(
person("Sukalpo", "Saha", email = "[email protected]", role = c("aut", "cre")),
person("Arjun", "Rubalingam", email = "[email protected]", role = "aut"),
Expand Down Expand Up @@ -83,8 +83,9 @@ Suggests:
metatools
VignetteBuilder:
knitr
Config/testthat/edition: 3
Encoding: UTF-8
Language: en-US
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
RoxygenNote: 7.3.1
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# admiralvaccine 0.4.0

## Breaking Changes

- Function `derive_vars_crit()` has been deprecated. Please use `admiral::derive_vars_crit_flag()` instead. (#253)

# admiralvaccine 0.3.0

## Updates related to CBER requirements for eDiary data
Expand Down
18 changes: 14 additions & 4 deletions R/derive_vars_crit.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
#'
#' @description
#' Derive analysis criterion evaluation result variable, paired with character
ahasoplakus marked this conversation as resolved.
Show resolved Hide resolved
#' and numeric flags.
#' This function allows also the derivation of a CRIT like variable with a
#' different name (ex: `ANL01FL`), without generating additional numeric (ex: `ANL01FN`)
#' and character label (ex: `ANL01`) variables.
#'
#' `r lifecycle::badge("deprecated")`
#'
#' This function is *deprecated*, please use `admiral::derive_vars_crit_flag()` instead.
#'
#' @param dataset Input dataset
#'
Expand Down Expand Up @@ -94,6 +94,16 @@
#' )
#'
derive_vars_crit <- function(dataset, prefix, crit_label, condition, criterion) {
deprecate_warn(
when = "0.4.0",
what = "derive_vars_crit()",
with = "admiral::derive_vars_crit_flag()",
details = c(
x = "This message will turn into a error at the beginning of 2026.",
i = "See admiral's deprecation guidance:
https://pharmaverse.github.io/admiraldev/dev/articles/programming_strategy.html#deprecation"
)
)
condition <- assert_filter_cond(enquo(condition))
ahasoplakus marked this conversation as resolved.
Show resolved Hide resolved
criterion <- assert_filter_cond(enquo(criterion))

Expand Down
18 changes: 12 additions & 6 deletions inst/templates/ad_adis.R
Original file line number Diff line number Diff line change
Expand Up @@ -322,13 +322,19 @@ adis <- restrict_derivation(adis,


# STEP 9 Derivation of CRITyFL and CRITyFN ----
adis <- derive_vars_crit(
adis <- restrict_derivation(
dataset = adis,
prefix = "CRIT1",
crit_label = "Titer >= ISLLOQ",
condition = !is.na(AVAL) & !is.na(ISLLOQ),
criterion = AVAL >= ISLLOQ
)
derivation = derive_vars_crit_flag,
args = params(
crit_nr = 1,
condition = AVAL >= ISLLOQ,
description = "Titer >= ISLLOQ",
values_yn = TRUE,
create_numeric_flag = TRUE
),
filter = !is.na(AVAL)
) %>%
arrange(STUDYID, USUBJID, DERIVED, ISSEQ)


# STEP 10 Derivation of TRTP/A treatment variables ----
Expand Down
8 changes: 4 additions & 4 deletions man/derive_vars_crit.Rd

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

173 changes: 84 additions & 89 deletions tests/testthat/test-derive_vars_crit.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
## Test 1: Derive CRIT1 variables
## Test 1: deprecation message if function is called

test_that("derive_vars_crit Test 1: Derive CRIT1 variables", {
# input data
test_that("derive_vars_crit() Test #: deprecation message if function is called", {
input <- tibble::tribble(
~USUBJID, ~AVISITN, ~PARAMCD, ~AVAL, ~ISLLOQ,
"999999-000001", 10, "J0033VN", 2, 4,
Expand Down Expand Up @@ -30,36 +29,26 @@ test_that("derive_vars_crit Test 1: Derive CRIT1 variables", {
!is.na(AVAL) & !is.na(ISLLOQ) & AVAL < ISLLOQ ~ "N",
TRUE ~ as.character(NA)
),
CRIT1FN = if_else(CRIT1FL == "Y", 1, 0),
CRIT1 = if_else(!is.na(CRIT1FL), "Titer >= ISLLOQ", as.character(NA))
CRIT1 = if_else(!is.na(CRIT1FL), "Titer >= ISLLOQ", as.character(NA)),
CRIT1FN = if_else(CRIT1FL == "Y", 1, 0)
)


# actual dataset
actual <- derive_vars_crit(
dataset = input,
prefix = "CRIT1",
crit_label = "Titer >= ISLLOQ",
condition = !is.na(AVAL) & !is.na(ISLLOQ),
criterion = AVAL >= ISLLOQ
)

expect_dfs_equal(actual,
expected,
keys = c(
"USUBJID", "AVISITN", "PARAMCD", "AVAL", "ISLLOQ", "CRIT1FL",
"CRIT1FN", "CRIT1"
)
expect_warning(
derive_vars_crit(
dataset = input,
prefix = "CRIT1",
crit_label = "Titer >= ISLLOQ",
condition = !is.na(AVAL) & !is.na(ISLLOQ),
criterion = AVAL >= ISLLOQ
),
class = "lifecycle_warning_deprecated"
)
})


## Test 2: Derive CRIT1 variables


## Test 2: Derive CRIT1 variables when AVAL is missing

test_that("derive_vars_crit Test 2: Derive CRIT1 variables
when AVAL is missing", {
test_that("derive_vars_crit Test 2: Derive CRIT1 variables", {
# input data
input <- tibble::tribble(
~USUBJID, ~AVISITN, ~PARAMCD, ~AVAL, ~ISLLOQ,
Expand All @@ -71,14 +60,14 @@ test_that("derive_vars_crit Test 2: Derive CRIT1 variables
"999999-000001", 30, "I0019NT", 567, 6,
"999999-000001", 30, "M0019LN", 659, 4,
"999999-000001", 30, "R0003MA", 250, 6,
"999999-000002", 10, "J0033VN", NA, 4,
"999999-000002", 10, "I0019NT", NA, 6,
"999999-000002", 10, "M0019LN", NA, 4,
"999999-000002", 10, "R0003MA", NA, 6,
"999999-000002", 30, "J0033VN", NA, 4,
"999999-000002", 30, "I0019NT", NA, 6,
"999999-000002", 30, "M0019LN", NA, 4,
"999999-000002", 30, "R0003MA", NA, 6
"999999-000002", 10, "J0033VN", 2, 4,
"999999-000002", 10, "I0019NT", 7, 6,
"999999-000002", 10, "M0019LN", 5, 4,
"999999-000002", 10, "R0003MA", 3, 6,
"999999-000002", 30, "J0033VN", 55, 4,
"999999-000002", 30, "I0019NT", 89, 6,
"999999-000002", 30, "M0019LN", 990, 4,
"999999-000002", 30, "R0003MA", 340, 6
)

# expected dataset
Expand All @@ -89,18 +78,21 @@ test_that("derive_vars_crit Test 2: Derive CRIT1 variables
!is.na(AVAL) & !is.na(ISLLOQ) & AVAL < ISLLOQ ~ "N",
TRUE ~ as.character(NA)
),
CRIT1FN = if_else(CRIT1FL == "Y", 1, 0),
CRIT1 = if_else(!is.na(CRIT1FL), "Titer >= ISLLOQ", as.character(NA))
CRIT1 = if_else(!is.na(CRIT1FL), "Titer >= ISLLOQ", as.character(NA)),
CRIT1FN = if_else(CRIT1FL == "Y", 1, 0)
)


# actual dataset
actual <- derive_vars_crit(
dataset = input,
prefix = "CRIT1",
crit_label = "Titer >= ISLLOQ",
condition = !is.na(AVAL) & !is.na(ISLLOQ),
criterion = AVAL >= ISLLOQ
actual <- admiraldev::suppress_warning(
derive_vars_crit(
dataset = input,
prefix = "CRIT1",
crit_label = "Titer >= ISLLOQ",
condition = !is.na(AVAL) & !is.na(ISLLOQ),
criterion = AVAL >= ISLLOQ
),
regexpr = "was deprecated"
)

expect_dfs_equal(actual,
Expand All @@ -112,64 +104,67 @@ test_that("derive_vars_crit Test 2: Derive CRIT1 variables
)
})

## Test 3: Derive CRIT1 variables when AVAL is missing



## Test 3: Try to apply different vars name and missing ISLLOQ or AVAL

test_that("derive_vars_crit Test 3: Try to apply different vars name and
missing ISLLOQ or AVAL", {
test_that("derive_vars_crit Test 3: Derive CRIT1 variables when AVAL is missing", {
# input data
input <- tibble::tribble(
~USUBJID, ~AVISITN, ~PARAMCD, ~AVAL, ~ISLLOQ,
"999999-000001", 10, "J0033VN", NA, NA,
"999999-000001", 10, "I0019NT", NA, 6,
"999999-000001", 10, "M0019LN", NA, 4,
"999999-000001", 10, "R0003MA", NA, 6,
"999999-000001", 30, "J0033VN", NA, NA,
"999999-000001", 30, "I0019NT", NA, 6,
"999999-000001", 30, "M0019LN", NA, 4,
"999999-000001", 30, "R0003MA", NA, 6,
"999999-000002", 10, "J0033VN", 2, NA,
"999999-000002", 10, "I0019NT", 7, 6,
"999999-000002", 10, "M0019LN", 5, 4,
"999999-000002", 10, "R0003MA", 3, 6,
"999999-000002", 30, "J0033VN", 55, NA,
"999999-000002", 30, "I0019NT", 89, 6,
"999999-000002", 30, "M0019LN", 990, 4,
"999999-000002", 30, "R0003MA", 340, 6
"999999-000001", 10, "J0033VN", 2, 4,
"999999-000001", 10, "I0019NT", 3, 6,
"999999-000001", 10, "M0019LN", 4, 4,
"999999-000001", 10, "R0003MA", 3, 6,
"999999-000001", 30, "J0033VN", 60, 4,
"999999-000001", 30, "I0019NT", 567, 6,
"999999-000001", 30, "M0019LN", 659, 4,
"999999-000001", 30, "R0003MA", 250, 6,
"999999-000002", 10, "J0033VN", NA, 4,
"999999-000002", 10, "I0019NT", NA, 6,
"999999-000002", 10, "M0019LN", NA, 4,
"999999-000002", 10, "R0003MA", NA, 6,
"999999-000002", 30, "J0033VN", NA, 4,
"999999-000002", 30, "I0019NT", NA, 6,
"999999-000002", 30, "M0019LN", NA, 4,
"999999-000002", 30, "R0003MA", NA, 6
)

# expected dataset
expected <- input %>%
mutate(
ANL01FL = case_when(
CRIT1FL = case_when(
!is.na(AVAL) & !is.na(ISLLOQ) & AVAL >= ISLLOQ ~ "Y",
!is.na(AVAL) & !is.na(ISLLOQ) & AVAL < ISLLOQ ~ "N",
TRUE ~ as.character(NA)
)
),
CRIT1 = if_else(!is.na(CRIT1FL), "Titer >= ISLLOQ", as.character(NA)),
CRIT1FN = if_else(CRIT1FL == "Y", 1, 0)
)


# actual dataset
actual <- derive_vars_crit(
dataset = input,
prefix = "ANL01",
crit_label = "Titer >= ISLLOQ",
condition = !is.na(AVAL) & !is.na(ISLLOQ),
criterion = AVAL >= ISLLOQ
actual <- admiraldev::suppress_warning(
derive_vars_crit(
dataset = input,
prefix = "CRIT1",
crit_label = "Titer >= ISLLOQ",
condition = !is.na(AVAL) & !is.na(ISLLOQ),
criterion = AVAL >= ISLLOQ
),
regexpr = "was deprecated"
)

expect_dfs_equal(actual,
expected,
keys = c("USUBJID", "AVISITN", "PARAMCD", "AVAL", "ISLLOQ", "ANL01FL")
keys = c(
"USUBJID", "AVISITN", "PARAMCD", "AVAL", "ISLLOQ", "CRIT1FL",
"CRIT1FN", "CRIT1"
)
)
})

## Test 4: Complicated selections and missing values for AVAL and ISLLOQ

test_that("derive_vars_crit Test 4: Complicated selections and missing values
for AVAL and ISLLOQ", {
test_that("derive_vars_crit Test 4: Complicated selections and missing values for AVAL and
ISLLOQ", {
# input data
input <- tibble::tribble(
~USUBJID, ~AVISITN, ~PARAMCD, ~AVAL, ~ISLLOQ, ~BASE,
Expand All @@ -194,23 +189,23 @@ test_that("derive_vars_crit Test 4: Complicated selections and missing values
# expected dataset
expected <- input %>%
mutate(
CRIT1FL = case_when(
!is.na(AVAL) & !is.na(ISLLOQ) & is.na(BASE) & AVAL >= ISLLOQ & AVAL >= 2 * BASE ~ "Y",
!is.na(AVAL) & !is.na(ISLLOQ) & is.na(BASE) & AVAL < ISLLOQ & AVAL >= 2 * BASE ~ "N",
TRUE ~ as.character(NA)
CRIT1FL = if_else(
AVAL >= ISLLOQ & AVAL >= 2 * BASE, "Y", "N"
),
CRIT1FN = if_else(CRIT1FL == "Y", 1, 0),
CRIT1 = if_else(!is.na(CRIT1FL), "Titer >= ISLLOQ", as.character(NA))
CRIT1 = if_else(!is.na(CRIT1FL), "Titer >= ISLLOQ and Titer >= 2*BASE", as.character(NA)),
CRIT1FN = if_else(CRIT1FL == "Y", 1, 0)
)


# actual dataset
actual <- derive_vars_crit(
dataset = input,
prefix = "CRIT1",
crit_label = "Titer >= ISLLOQ and Titer >= 2*BASE",
condition = !is.na(AVAL) & !is.na(ISLLOQ) & is.na(BASE),
criterion = AVAL >= ISLLOQ & AVAL >= 2 * BASE
actual <- admiraldev::suppress_warning(
derive_vars_crit(
dataset = input,
prefix = "CRIT1",
crit_label = "Titer >= ISLLOQ and Titer >= 2*BASE",
condition = !is.na(AVAL),
criterion = AVAL >= ISLLOQ & AVAL >= 2 * BASE
),
regexpr = "was deprecated"
)

expect_dfs_equal(actual,
Expand Down
Loading
Loading