From 9e80eafa9d103358e2392ccab75ef23469b2f332 Mon Sep 17 00:00:00 2001 From: Xavier <33167618+xgaeta@users.noreply.github.com> Date: Wed, 11 Sep 2024 15:32:09 -0700 Subject: [PATCH 1/8] Update nephro.R with CKiD u25 equations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I have added functions to calculate eGFR for children ages 1-25 using the CKiD U25 algorithms. These include calculations based on creatinine, based on cystatin C, and a composite based on both. References: Pierce CB, Muñoz A, Ng DK, Warady BA, Furth SL, Schwartz GJ. Age- and sex-dependent clinical equations to estimate glomerular filtration rates in children and young adults with chronic kidney disease. Kidney International. 2021;99(4):948–956. doi:10.1016/j.kint.2020.10.047 https://www.niddk.nih.gov/research-funding/research-programs/kidney-clinical-research-epidemiology/laboratory/glomerular-filtration-rate-equations/children-adolescents-young-adults#ckid-u25 --- R/nephro.R | 128 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 128 insertions(+) diff --git a/R/nephro.R b/R/nephro.R index 94d437a..3eac8a1 100644 --- a/R/nephro.R +++ b/R/nephro.R @@ -769,3 +769,131 @@ Schwartz.Bedside <- function(creatinine, ht, age) } else stop ("Some variables are not defined") } + +CKiD.U25.cystatin <- function(cystatin, age, sex) +# CKiD U25 calculation for Cystatin C only +# Requires Cystatin C level, age, sex +{ + if (!is.null(age) & !is.null(cystatin) & !is.null(sex)) + { + cystatin <- as.numeric(cystatin) + age <- as.numeric(age) + sex <- as.numeric(sex) # 0 = male, 1 = female + n <- length(cystatin) + + if (length(age) == n) + { + if ( (min(age)<1) | (max(age)>25)) cat("\nWarning: there are age values <1 or >25 years; for those children, eGFR values might be invalid\n") + + # Identify missing data and store the index + idx <- c(1:n)[is.na(cystatin)] + + # Replace missing data with fake data to avoid problems with formulas + cystatin[is.na(cystatin)] <- 10 + + coeff <- if(age < 12){ + if(sex == 1) 79.9*1.004 ^ (age-12) + else 87.2*1.011 ^ (age-15) + } else if(age < 15) { + if(sex == 1) 79.9*0.974 ^ (age-12) + else 87.2*1.011 ^ (age-15) + } else if (age < 18) { + if(sex == 1) 79.9*0.974 ^ (age-12) + else 87.2*0.960 ^ (age-15) + } else { + if(sex == 1) 77.1 + else 68.3 + } + + eGFR <- coeff / cystatin + + # Restore missing data at the indexed positions + eGFR[idx] <- NA + + # Output + round(eGFR, 1) + + } else + stop ("Different number of observations between variables") + } else + stop ("Some variables are not defined") +} + +CKiD.U25.creatinine <- function(creatinine, age, ht, sex) + # CKiD U25 calculation for creatinine only + # Requires creatinine, age, ht (in cm), sex +{ + if (!is.null(creatinine) & !is.null(ht) & !is.null(age) & !is.null(sex)) + { + creatinine <- as.numeric(creatinine) + ht <- as.numeric(ht) + age <- as.numeric(age) + sex <- as.numeric(sex) # 0 = male, 1 = female + n <- length(creatinine) + + if (length(ht) == n) + { + if ( (min(age)<1) | (max(age)>25)) cat("\nWarning: there are age values <1 or >25 years; for those children, eGFR values might be invalid\n") + + # Identify missing data and store the index + idx <- c(1:n)[is.na(creatinine) | is.na(ht)] + + # Replace missing data with fake data to avoid problems with formulas + creatinine[is.na(creatinine)] <- 10 + ht[is.na(ht)] <- 10 + + coeff <- if(age < 12){ + if(sex == 1) 36.1*1.008 ^ (age - 12) + else 39*1.008 ^ (age - 12) + } else if (age < 18) { + if(sex == 1) 36.1*1.023 ^ (age - 12) + else 39*1.045 ^ (age - 12) + } else { + if(sex == 1) 41.4 + else 50.8 + } + + eGFR <- coeff * (ht / 100) / creatinine + + # Restore missing data at the indexed positions + eGFR[idx] <- NA + + # Output + round(eGFR, 1) + + } else + stop ("Different number of observations between variables") + } else + stop ("Some variables are not defined") +} + +CKiD.U25.combined <- function(creatinine, cystatin, age, ht, sex, verbose = FALSE) + # CKiD U25 calculation for both creatinine and Cystatin C + # Requires serum Cr, Cystatin C level, age, ht (in cm), sex +{ + if (!is.null(creatinine) & !is.null(ht) & !is.null(age) & + !is.null(cystatin) & !is.null(sex)) + { + creatinine <- as.numeric(creatinine) + cystatin <- as.numeric(cystatin) + ht <- as.numeric(ht) + age <- as.numeric(age) + sex <- as.numeric(sex) # 0 = male, 1 = female + + # Return the average of the two other calculations + eGFRU25.cr <- CKiD.U25.creatinine(creatinine = creatinine, age = age, + ht = ht, sex = sex) + eGFRU25.cys <- CKiD.U25.cystatin(cystatin = cystatin, age = age, sex = sex) + sGFRU25.avg <- (eGFRU25.cys + eGFRU25.cr) / 2 + + ## Determine if we should return all the component parts or just the result + ## of the combined calculation + if(verbose) { + return(round(cbind(eGFRU25.cr, eGFRU25.cys, sGFRU25.avg),1)) + } else { + return(round(sGFRU25.avg, 1)) + } + + } else + stop ("Some variables are not defined") +} From 3f7ef78394ae80896d7e4b3681679df448434bfb Mon Sep 17 00:00:00 2001 From: Xavier <33167618+xgaeta@users.noreply.github.com> Date: Mon, 11 Nov 2024 12:07:16 -0800 Subject: [PATCH 2/8] Create README.md --- README.md | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..fc641d2 --- /dev/null +++ b/README.md @@ -0,0 +1,57 @@ +# Nephro with CKiD U25 equations +Xavier Gaeta MD, PhD + +## Nephro - CKiD U25 + +This is fork of the R **nephro** package that’s hosted on CRAN.org which +includes functions to calculate pediatric eGFR based on the following +publication: + +Pierce CB, Muñoz A, Ng DK, Warady BA, Furth SL, Schwartz GJ. **Age- and +sex-dependent clinical equations to estimate glomerular filtration rates +in children and young adults with chronic kidney disease.** *Kidney +International*. 2021;99(4):948–956. +[doi:10.1016/j.kint.2020.10.047](https://doi.org/10.1016/j.kint.2020.10.047 "Persistent DOI link for Pierce et al. paper") + +## Installation + +You can install the package from Github + +``` r +devtools::install_github("xgaeta/nephro-CKiD") +``` + +then include the package in your script: + +``` r +library(nephro) +``` + +## Using the functions + +These new equations follow the same style as the rest of the package, +including sex as a binary variable with 0 for female and 1 for male. +Height is provided in cm. They currently use US based equations. Outputs +are in mL/min/1.73m2. + +``` r +CKiD.U25.cystatin(cystatin = 1.2, age = 9.5, sex = 0) +``` + + [1] 68.4 + +``` r +CKiD.U25.creatinine(creatinine = 0.8, age = 9.5, sex = 0, ht = 132) +``` + + [1] 63.1 + +``` r +CKiD.U25.combined(creatinine = 0.8, cystatin = 1.2, age = 9.5, sex = 0, ht = 132, verbose = TRUE) +``` + + eGFRU25.cr eGFRU25.cys sGFRU25.avg + [1,] 63.1 68.4 65.8 + +Pull requests have been filed to merge these equations into the main +**nephro** package From 994c6fbe14da17f79946ff818cc39a0567a1a7d0 Mon Sep 17 00:00:00 2001 From: Xavier <33167618+xgaeta@users.noreply.github.com> Date: Mon, 11 Nov 2024 12:08:00 -0800 Subject: [PATCH 3/8] Update nephro.R small improvement to labeling --- R/nephro.R | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/R/nephro.R b/R/nephro.R index 3eac8a1..da587d7 100644 --- a/R/nephro.R +++ b/R/nephro.R @@ -884,14 +884,14 @@ CKiD.U25.combined <- function(creatinine, cystatin, age, ht, sex, verbose = FALS eGFRU25.cr <- CKiD.U25.creatinine(creatinine = creatinine, age = age, ht = ht, sex = sex) eGFRU25.cys <- CKiD.U25.cystatin(cystatin = cystatin, age = age, sex = sex) - sGFRU25.avg <- (eGFRU25.cys + eGFRU25.cr) / 2 + eGFRU25.avg <- (eGFRU25.cys + eGFRU25.cr) / 2 ## Determine if we should return all the component parts or just the result ## of the combined calculation if(verbose) { - return(round(cbind(eGFRU25.cr, eGFRU25.cys, sGFRU25.avg),1)) + return(round(cbind(eGFRU25.cr, eGFRU25.cys, eGFRU25.avg),1)) } else { - return(round(sGFRU25.avg, 1)) + return(round(eGFRU25.avg, 1)) } } else From dad064f84d6a8dd2eabbb926ea805074aafadd61 Mon Sep 17 00:00:00 2001 From: Xavier <33167618+xgaeta@users.noreply.github.com> Date: Mon, 11 Nov 2024 12:11:44 -0800 Subject: [PATCH 4/8] Added Readme.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fc641d2..222643b 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ CKiD.U25.creatinine(creatinine = 0.8, age = 9.5, sex = 0, ht = 132) CKiD.U25.combined(creatinine = 0.8, cystatin = 1.2, age = 9.5, sex = 0, ht = 132, verbose = TRUE) ``` - eGFRU25.cr eGFRU25.cys sGFRU25.avg + eGFRU25.cr eGFRU25.cys eGFRU25.avg [1,] 63.1 68.4 65.8 Pull requests have been filed to merge these equations into the main From b0f219e913aa8a56e0f6a14206192f9ec63930e2 Mon Sep 17 00:00:00 2001 From: Xavier <33167618+xgaeta@users.noreply.github.com> Date: Mon, 11 Nov 2024 12:18:17 -0800 Subject: [PATCH 5/8] Update README.md --- README.md | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 222643b..727d36b 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,12 @@ # Nephro with CKiD U25 equations -Xavier Gaeta MD, PhD +**Xavier Gaeta MD, PhD** ## Nephro - CKiD U25 -This is fork of the R **nephro** package that’s hosted on CRAN.org which -includes functions to calculate pediatric eGFR based on the following -publication: +This is a fork of the R +[**nephro**](https://cran.r-project.org/web/packages/nephro/index.html "CRAN repository for original nephro package, currently v1.4") +package that’s hosted on CRAN.org which includes functions to calculate +pediatric eGFR based on the following publication: Pierce CB, Muñoz A, Ng DK, Warady BA, Furth SL, Schwartz GJ. **Age- and sex-dependent clinical equations to estimate glomerular filtration rates @@ -53,5 +54,8 @@ CKiD.U25.combined(creatinine = 0.8, cystatin = 1.2, age = 9.5, sex = 0, ht = 132 eGFRU25.cr eGFRU25.cys eGFRU25.avg [1,] 63.1 68.4 65.8 -Pull requests have been filed to merge these equations into the main -**nephro** package +[Pull requests have been +filed](https://github.com/cran/nephro/pulls "Current status of CKiD U25 pull request") +to merge these equations into the main +[**nephro**](https://cran.r-project.org/web/packages/nephro/index.html "CRAN repository for original nephro package, currently v1.4") +package From a69f5fc6efdf6ecc25148980e4a406345c58ccef Mon Sep 17 00:00:00 2001 From: Xavier <33167618+xgaeta@users.noreply.github.com> Date: Mon, 11 Nov 2024 12:20:50 -0800 Subject: [PATCH 6/8] Create LICENSE --- LICENSE | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..41fe07d --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 Xavier Gaeta MD PhD + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. From 562a557b4d042dbe6cdfc2ab8c4b3d59f2ddb721 Mon Sep 17 00:00:00 2001 From: Xavier <33167618+xgaeta@users.noreply.github.com> Date: Mon, 11 Nov 2024 13:40:35 -0800 Subject: [PATCH 7/8] Update README.md Mixed up sex coding variable, now fixed. No change to the actual functions. --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 727d36b..d84c27d 100644 --- a/README.md +++ b/README.md @@ -31,28 +31,28 @@ library(nephro) ## Using the functions These new equations follow the same style as the rest of the package, -including sex as a binary variable with 0 for female and 1 for male. +including sex as a binary variable with 0 for male and 1 for female. Height is provided in cm. They currently use US based equations. Outputs are in mL/min/1.73m2. ``` r -CKiD.U25.cystatin(cystatin = 1.2, age = 9.5, sex = 0) +CKiD.U25.cystatin(cystatin = 1.2, age = 9.5, sex = 1) ``` - [1] 68.4 + [1] 65.9 ``` r -CKiD.U25.creatinine(creatinine = 0.8, age = 9.5, sex = 0, ht = 132) +CKiD.U25.creatinine(creatinine = 0.8, age = 9.5, sex = 1, ht = 132) ``` - [1] 63.1 + [1] 58.4 ``` r -CKiD.U25.combined(creatinine = 0.8, cystatin = 1.2, age = 9.5, sex = 0, ht = 132, verbose = TRUE) +CKiD.U25.combined(creatinine = 0.8, cystatin = 1.2, age = 9.5, sex = 1, ht = 132, verbose = TRUE) ``` eGFRU25.cr eGFRU25.cys eGFRU25.avg - [1,] 63.1 68.4 65.8 + [1,] 58.4 65.9 62.2 [Pull requests have been filed](https://github.com/cran/nephro/pulls "Current status of CKiD U25 pull request") From 55e8af1dd1887d39bc8162aa5c59d86ad6c48524 Mon Sep 17 00:00:00 2001 From: Xavier <33167618+xgaeta@users.noreply.github.com> Date: Mon, 11 Nov 2024 14:26:50 -0800 Subject: [PATCH 8/8] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d84c27d..ffe53fd 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ CKiD.U25.combined(creatinine = 0.8, cystatin = 1.2, age = 9.5, sex = 1, ht = 132 [1,] 58.4 65.9 62.2 [Pull requests have been -filed](https://github.com/cran/nephro/pulls "Current status of CKiD U25 pull request") +filed](https://github.com/cran/nephro/pull/1 "Current status of CKiD U25 pull request") to merge these equations into the main [**nephro**](https://cran.r-project.org/web/packages/nephro/index.html "CRAN repository for original nephro package, currently v1.4") package