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 #2020 chore: rename wt to weight in compute_egfr #2045

Merged
merged 11 commits into from
Aug 10, 2023
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
- The arguments `dataset_adsl` in the function `derive_param_exist_flag()` and
`subject_keys` have been deprecated versions using the next phase of the deprecation process. (#1950)

- The argument `wt` in the function `compute_egfr()` was deprecated in favor of `weight` using the first phase of the deprecation process. (#2020)

- The `filter` argument in `derive_extreme_records()` was deprecated in favor of
the `filter_add` using the next phase of the deprecation process. (#1950)

Expand Down
32 changes: 21 additions & 11 deletions R/compute_kidney.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#'
#' A numeric vector is expected.
#'
#' @param wt Weight (kg)
#' @param weight Weight (kg)
#'
#' A numeric vector is expected if `method = "CRCL"`
#'
Expand All @@ -42,6 +42,8 @@
#'
#' Expected Values: `"CRCL"`, `"CKD-EPI"`, `"MDRD"`
#'
#' @param wt *Deprecated*, please use `weight` instead.
#'
#' @details
#'
#' Calculates an estimate of Glomerular Filtration Rate (eGFR)
Expand Down Expand Up @@ -92,7 +94,7 @@
#'
#' @examples
#' compute_egfr(
#' creat = 90, creatu = "umol/L", age = 53, wt = 85, sex = "M", method = "CRCL"
#' creat = 90, creatu = "umol/L", age = 53, weight = 85, sex = "M", method = "CRCL"
#' )
#'
#' compute_egfr(
Expand Down Expand Up @@ -120,19 +122,27 @@
#' base %>%
#' dplyr::mutate(
#' CRCL_CG = compute_egfr(
#' creat = CREATBL, creatu = CREATBLU, age = AGE, wt = WTBL, sex = SEX,
#' creat = CREATBL, creatu = CREATBLU, age = AGE, weight = WTBL, sex = SEX,
#' method = "CRCL"
#' ),
#' EGFR_EPI = compute_egfr(
#' creat = CREATBL, creatu = CREATBLU, age = AGE, wt = WTBL, sex = SEX,
#' creat = CREATBL, creatu = CREATBLU, age = AGE, weight = WTBL, sex = SEX,
#' method = "CKD-EPI"
#' ),
#' EGFR_MDRD = compute_egfr(
#' creat = CREATBL, creatu = CREATBLU, age = AGE, wt = WTBL, sex = SEX,
#' creat = CREATBL, creatu = CREATBLU, age = AGE, weight = WTBL, sex = SEX,
#' race = RACE, method = "MDRD"
#' ),
#' )
compute_egfr <- function(creat, creatu = "SI", age, wt, sex, race = NULL, method) {
compute_egfr <- function(creat, creatu = "SI", age, weight, sex, race = NULL, method, wt) {
### BEGIN DEPRECATION
if (!missing(wt)) {
deprecate_warn("0.12.0", "compute_egfr(old_param = 'wt')", "compute_egfr(new_param = 'weight')")
# old_param is given using exprs()
weight <- wt
}
### END DEPRECATION

assert_numeric_vector(creat)
assert_character_vector(creatu, values = c(
"SI", "CV", "mg/dL", "umol/L", NA_character_,
Expand Down Expand Up @@ -164,15 +174,15 @@ compute_egfr <- function(creat, creatu = "SI", age, wt, sex, race = NULL, method
sex == "M" ~ 175 * (scr^-1.154) * (age^-0.203)
)
} else if (method == "CRCL") {
assert_numeric_vector(wt)
assert_numeric_vector(weight)

egfr <- case_when(
tolower(creatu) %in% c("cv", "mg/dl") & sex == "F" ~
((140 - age) * wt * 0.85) / (creat * 72),
((140 - age) * weight * 0.85) / (creat * 72),
tolower(creatu) %in% c("cv", "mg/dl") & sex == "M" ~
((140 - age) * wt) / (creat * 72),
sex == "F" ~ ((140 - age) * wt * 1.04) / creat,
sex == "M" ~ ((140 - age) * wt * 1.23) / creat
((140 - age) * weight) / (creat * 72),
sex == "F" ~ ((140 - age) * weight * 1.04) / creat,
sex == "M" ~ ((140 - age) * weight * 1.23) / creat
)
} else if (method == "CKD-EPI") {
kappa <- case_when(
Expand Down
4 changes: 2 additions & 2 deletions docs/pkgdown.yml
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cicdguy can this be added to .gitignore?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that's be nice. I personally see no benefit in storing docs/ in version control.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@StefanThoma can you put this in .gitignore please.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this was added in a long time ago - can just remove this line
image

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@StefanThoma , @bms63 , @cicdguy , docs/pkgdown.yml was added to create links across packages, e.g., if an example in admiralonco uses an admiral function it is linked automatically to the documentation of the admiral function. It has stopped working when we introduced multiversions docs. Maybe we do not need it anymore if we find a different solution (see pharmaverse/admiralci#131).

However, if we remove the file from .gitignore we should also remove the file itself.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pandoc: 2.11.4
pandoc: 3.1.1
pkgdown: 2.0.7
pkgdown_sha: ~
articles:
Expand All @@ -19,7 +19,7 @@ articles:
queries_dataset: queries_dataset.html
questionnaires: questionnaires.html
visits_periods: visits_periods.html
last_built: 2023-07-19T10:42Z
last_built: 2023-08-07T09:14Z
urls:
reference: https://pharmaverse.github.io/admiral/cran-release/reference/
article: https://pharmaverse.github.io/admiral/cran-release/articles/
Expand Down
4 changes: 2 additions & 2 deletions inst/templates/ad_adppk.R
Original file line number Diff line number Diff line change
Expand Up @@ -448,11 +448,11 @@ covar_vslb <- covar %>%
method = "Mosteller"
),
CRCLBL = compute_egfr(
creat = CREATBL, creatu = "SI", age = AGE, wt = WTBL, sex = SEX,
creat = CREATBL, creatu = "SI", age = AGE, weight = WTBL, sex = SEX,
method = "CRCL"
),
EGFRBL = compute_egfr(
creat = CREATBL, creatu = "SI", age = AGE, wt = WTBL, sex = SEX,
creat = CREATBL, creatu = "SI", age = AGE, weight = WTBL, sex = SEX,
method = "CKD-EPI"
)
) %>%
Expand Down
14 changes: 8 additions & 6 deletions man/compute_egfr.Rd

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

18 changes: 14 additions & 4 deletions tests/testthat/test-compute_kidney.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ test_that("compute_egfr Test 3: CRCL calculation", {
# CRCL Cockcroft and Gault (1973) calculator at
# https://www.kidney.org/professionals/kdoqi/gfr_calculatorCoc
expect_equal(round(compute_egfr(
creat = 1.09, creatu = "mg/dL", age = 55, sex = "M", wt = 90, method = "CRCL"
creat = 1.09, creatu = "mg/dL", age = 55, sex = "M", weight = 90, method = "CRCL"
), 0L), 97)
})

Expand All @@ -38,7 +38,7 @@ test_that("compute_egfr Test 4: CRCL calculation", {
# CRCL Cockcroft and Gault (1973) calculator at
# https://www.kidney.org/professionals/kdoqi/gfr_calculatorCoc
expect_equal(round(compute_egfr(
creat = 85, creatu = "umol/L", age = 65, sex = "F", wt = 60, method = "CRCL"
creat = 85, creatu = "umol/L", age = 65, sex = "F", weight = 60, method = "CRCL"
), 0L), 55)
})

Expand All @@ -49,7 +49,7 @@ test_that("compute_egfr Test 5: EGFR MDRD calculation", {
# MDRD GFR calculator at
# https://www.mdcalc.com/calc/76/mdrd-gfr-equation
expect_equal(round(compute_egfr(
creat = 1.09, creatu = "mg/dL", age = 55, sex = "M", wt = 90, race = "WHITE",
creat = 1.09, creatu = "mg/dL", age = 55, sex = "M", weight = 90, race = "WHITE",
method = "MDRD"
), 1L), 70.2)
})
Expand Down Expand Up @@ -87,7 +87,7 @@ test_that("compute_egfr Test 7: CKD-EPI calculated on input data", {
egfr <- input %>%
dplyr::mutate(
EGFR = compute_egfr(
creat = CREATBL, creatu = CREATBLU, age = AGE, wt = WTBL, sex = SEX,
creat = CREATBL, creatu = CREATBLU, age = AGE, weight = WTBL, sex = SEX,
method = "CKD-EPI"
),
EGFR = round(EGFR, 4L)
Expand All @@ -99,3 +99,13 @@ test_that("compute_egfr Test 7: CKD-EPI calculated on input data", {
keys = c("USUBJID")
)
})

## Test 8: Deprecate wt ----
test_that("compute_egfr Test 8: 'wt' argument deprecation warning", {
# expect deprecation warning
expect_warning(
compute_egfr(
creat = 1.09, creatu = "mg/dL", age = 55, sex = "M", wt = 90, method = "CRCL"
)
)
})
4 changes: 2 additions & 2 deletions vignettes/pk_adnca.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -1377,11 +1377,11 @@ covar_vslb <- covar %>%
),
# Derive CRCLBL and EGFRBL using new function
CRCLBL = compute_egfr(
creat = CREATBL, creatu = "SI", age = AGE, wt = WTBL, sex = SEX,
creat = CREATBL, creatu = "SI", age = AGE, weight = WTBL, sex = SEX,
method = "CRCL"
),
EGFRBL = compute_egfr(
creat = CREATBL, creatu = "SI", age = AGE, wt = WTBL, sex = SEX,
creat = CREATBL, creatu = "SI", age = AGE, weight = WTBL, sex = SEX,
method = "CKD-EPI"
)
) %>%
Expand Down
Loading