diff --git a/.lycheeignore b/.lycheeignore index a0639583..ad658e96 100644 --- a/.lycheeignore +++ b/.lycheeignore @@ -1,16 +1,5 @@ -# This is a list of urls to ignore in the link checking action Check URLS / -# Validate Links - -https://packagemanager.rstudio.com/cran/linux/focal/latest -https://github.com/pharmaverse/admiralvaccine/blob/main/ -irongut/CodeCoverageSummary@v1.2.0 -insightsengineering/thevalidatoR@v1.2.1 -https://packagemanager.rstudio.com/cran/__linux__/focal/latest -tj-actions/branch-names@v5.2 -https://pharmaverse.github.io/admiral/articles/programming_strategy.html -https://raw.githubusercontent.com/pharmaverse/admiralvaccine/badges/main/test-coverage.svg -https://pharmaverse.github.io/admiral/articles/development_process.html +https://pharmaverse.github.io/admiralvaccine/reference/index.html +https://github.com/pharmaverse/admiralvaccine/blob/test/ 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://github.com/pharmaverse/admiralvaccine/blob +https://www.fda.gov/media/112581/download diff --git a/DESCRIPTION b/DESCRIPTION index b8c412f9..ba1a1c4b 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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 = "sukalpo.saha@pfizer.com", role = c("aut", "cre")), person("Arjun", "Rubalingam", email = "arjun.rubalingam@pfizer.com", role = "aut"), diff --git a/NEWS.md b/NEWS.md index ce417987..81b7e021 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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 diff --git a/R/derive_vars_crit.R b/R/derive_vars_crit.R index 008bd2a8..4ea54ab8 100644 --- a/R/derive_vars_crit.R +++ b/R/derive_vars_crit.R @@ -2,11 +2,9 @@ #' #' #' @description -#' Derive analysis criterion evaluation result variable, paired with character -#' 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 #' @@ -94,6 +92,16 @@ #' ) #' derive_vars_crit <- function(dataset, prefix, crit_label, condition, criterion) { + deprecate_warn( + when = "0.4.0", + what = "derive_vars_crit()", + with = "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)) criterion <- assert_filter_cond(enquo(criterion)) diff --git a/inst/templates/ad_adis.R b/inst/templates/ad_adis.R index a97dd680..23596434 100644 --- a/inst/templates/ad_adis.R +++ b/inst/templates/ad_adis.R @@ -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 ---- diff --git a/man/derive_vars_crit.Rd b/man/derive_vars_crit.Rd index dd06ccad..0c853270 100644 --- a/man/derive_vars_crit.Rd +++ b/man/derive_vars_crit.Rd @@ -39,11 +39,9 @@ Returns \code{NA} for not selected rows (not taken into account from condition)} Dataset with criterion variables } \description{ -Derive analysis criterion evaluation result variable, paired with character -and numeric flags. -This function allows also the derivation of a CRIT like variable with a -different name (ex: \code{ANL01FL}), without generating additional numeric (ex: \code{ANL01FN}) -and character label (ex: \code{ANL01}) variables. +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} + +This function is \emph{deprecated}, please use \code{admiral::derive_vars_crit_flag()} instead. } \examples{ library(tibble) diff --git a/tests/testthat/test-derive_vars_crit.R b/tests/testthat/test-derive_vars_crit.R index 46fa2dcd..bd042fcc 100644 --- a/tests/testthat/test-derive_vars_crit.R +++ b/tests/testthat/test-derive_vars_crit.R @@ -30,18 +30,21 @@ 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 + 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, @@ -53,13 +56,9 @@ test_that("derive_vars_crit Test 1: 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 when AVAL is missing", { # input data input <- tibble::tribble( ~USUBJID, ~AVISITN, ~PARAMCD, ~AVAL, ~ISLLOQ, @@ -89,18 +88,20 @@ 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, @@ -112,64 +113,10 @@ test_that("derive_vars_crit Test 2: Derive CRIT1 variables ) }) +## Test 3: Complicated selections and missing values for AVAL and ISLLOQ - - -## 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", { - # 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 - ) - - # expected dataset - expected <- input %>% - mutate( - ANL01FL = case_when( - !is.na(AVAL) & !is.na(ISLLOQ) & AVAL >= ISLLOQ ~ "Y", - !is.na(AVAL) & !is.na(ISLLOQ) & AVAL < ISLLOQ ~ "N", - TRUE ~ as.character(NA) - ) - ) - - - # actual dataset - actual <- derive_vars_crit( - dataset = input, - prefix = "ANL01", - 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", "ANL01FL") - ) -}) - -## 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 3: Complicated selections and missing values for AVAL and + ISLLOQ", { # input data input <- tibble::tribble( ~USUBJID, ~AVISITN, ~PARAMCD, ~AVAL, ~ISLLOQ, ~BASE, @@ -194,23 +141,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, diff --git a/vignettes/adis.Rmd b/vignettes/adis.Rmd index 5c49c8d4..05b4c600 100644 --- a/vignettes/adis.Rmd +++ b/vignettes/adis.Rmd @@ -85,7 +85,6 @@ library(admiraldev) library(admiralvaccine) library(pharmaversesdtm) library(metatools) -library(pharmaversesdtm) # Load source datasets data("is_vaccine") @@ -519,20 +518,25 @@ dataset_vignette( Derive Criteria Evaluation Analysis Flags. The function selects a subset of rows from the input dataset and apply a criterion to them. -If this criterion is met then `CRIT1FL` (or the name you specified in the first argument) -is equal to `Y`; `N` otherwise. +If this criterion is met then `CRIT1FL` is equal to `Y`; `N` otherwise. The function returns a relative numeric `CRIT1FN` variable (`1` or `0` if the -criterion is met, respectively) and a label `CRIT1` variable -(with the text specified in label_var argument). +criterion is met, respectively) and a label `CRIT1` variable. ```{r eval=TRUE} -adis <- derive_vars_crit( +# STEP 9 Derivation of CRITyFL and CRITyFN ---- +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) ``` ```{r, echo=FALSE}