Science Score: 49.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
✓DOI references
Found 5 DOI reference(s) in README -
✓Academic publication links
Links to: zenodo.org -
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (10.2%) to scientific vocabulary
Repository
Basic Info
- Host: GitHub
- Owner: lshpaner
- License: other
- Language: R
- Default Branch: main
- Homepage: https://lshpaner.github.io/kfre_r/
- Size: 1.64 MB
Statistics
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
- Releases: 1
Metadata Files
README.md
Table of Contents
- KFRE Risk Prediction Tools (R)
- Installation
- GitHub (Development)
- Dependencies
- Quick Start
- Running Tests
- API Surface (Exports)
- Notes on Parity with Python
- References
- License
KFRE Risk Prediction Tools (R)
kfre is an R implementation of helpers around the Kidney Failure Risk Equation (KFRE), including:
- Vectorized and per-person KFRE predictions (4-, 6-, and 8-variable models; 2- and 5-year horizons)
- Convenience wrappers to add KFRE risk columns to a data.frame
- uPCR → uACR conversion utility
- CKD stage labeling utilities
- Evaluation helpers (AUC-ROC, Average Precision, Brier, etc.)
- Publication-style ROC and Precision–Recall plots
Installation
r
install.packages("kfre")
GitHub (Development)
```r
install.packages("remotes")
remotes::installgithub("lshpaner/kfrer") ```
Dependencies
Core imports: R6, stats, ggplot2, pROC, precrec
Suggested for tests/vignettes: testthat (>= 3.0.0), knitr, rmarkdown
Quick Start
1. Toy data
```r toy <- data.frame( age = c(55, 72), sex_txt = c("male", "female"), eGFR = c(45, 28), uACR = c(120, 800), dm = c(1, 0), htn = c(1, 1), albumin = c(4.2, 3.4), phosphorous = c(3.3, 4.6), bicarbonate = c(24, 22), calcium = c(9.1, 9.8), stringsAsFactors = FALSE )
cols <- list( age = "age", sex = "sex_txt", eGFR = "eGFR", uACR = "uACR", dm = "dm", htn = "htn", albumin = "albumin", phosphorous = "phosphorous", bicarbonate = "bicarbonate", calcium = "calcium" ) ```
2. Vectorized predictions with RiskPredictor
```r rp <- RiskPredictor$new(df = toy, columns = cols)
4-variable KFRE (2-year), North America constants
p42y <- rp$predictkfre( years = 2, isnorthamerican = TRUE, useextravars = FALSE, num_vars = 4 )
6-variable KFRE (5-year)
p65y <- rp$predictkfre( years = 5, isnorthamerican = TRUE, useextravars = TRUE, num_vars = 6 )
8-variable KFRE (2-year)
p82y <- rp$predictkfre( years = 2, isnorthamerican = TRUE, useextravars = TRUE, num_vars = 8 )
p42y p65y p8_2y ```
3. Single-person predictions
```r
Male, 55yo, 2-year risk (4-var)
rp$kfreperson( age = 55, ismale = TRUE, eGFR = 45, uACR = 120, isnorthamerican = TRUE, years = 2 )
Female, 72yo, 5-year risk (6-var)
rp$kfreperson( age = 72, ismale = FALSE, eGFR = 28, uACR = 800, isnorthamerican = TRUE, years = 5, dm = 0, htn = 1 )
Female, 72yo, 2-year risk (8-var)
rp$kfreperson( age = 72, ismale = FALSE, eGFR = 28, uACR = 800, isnorthamerican = TRUE, years = 2, albumin = 3.4, phosphorous = 4.6, bicarbonate = 22, calcium = 9.8 ) ```
4. Add KFRE risk columns to a data.frame
```r toykfre <- addkfreriskcol( df = toy, agecol = "age", sexcol = "sextxt", eGFRcol = "eGFR", uACRcol = "uACR", dmcol = "dm", htncol = "htn", albumincol = "albumin", phosphorouscol = "phosphorous", bicarbonatecol = "bicarbonate", calciumcol = "calcium", numvars = c(4, 6, 8), years = c(2, 5), isnorthamerican = TRUE, copy = TRUE )
names(toykfre) head(toykfre)
Adds:
kfre4var2year, kfre4var5year,
kfre6var2year, kfre6var5year,
kfre8var2year, kfre8var5year
```
5. CKD staging & ESRD outcome labels
```r
ESRD outcome within 2 years (duration is in days → converted to years)
out <- data.frame( eGFR = c(95, 25), ESRDflag = c(1, 1), followupdays = c(200, 1000) )
out <- classesrdoutcome( df = out, col = "ESRDflag", years = 2, durationcol = "followupdays", prefix = "esrd", createyears_col = TRUE )
Adds: ESRDdurationyears and esrd2year_outcome
CKD stage labels
out <- classckdstages( df = out, egfrcol = "eGFR", stagecol = "stage", combinedstagecol = "stage_combined" )
table(out$stage) table(out$stage_combined) ```
6. uPCR → uACR conversion
```r df_pcr <- data.frame( sex = c("female","male","female"), dm = c(1,0,1), htn = c(1,1,0), pcr = c(150, 600, 50) )
acr <- upcruacr( dfpcr, sexcol = "sex", diabetescol = "dm", hypertensioncol = "htn", upcrcol = "pcr", female_str = "female" )
acr ```
7. Evaluation metrics (AUC-ROC, AP, Brier…)
Your data.frame must include:
- Outcome columns named like
*_2_year_outcome/*_5_year_outcome - Prediction columns named
kfre_{n}var_{year}year, e.g.kfre_4var_2year
```r met <- evalkfremetrics( df = toykfre, # must contain truth + prediction columns nvarlist = c(4, 6, 8), outcomeyears = c(2, 5), decimal_places = 4 )
met
Rows: Metrics; Cols: "{2year|5year}{4|6|8}var_kfre"
```
8. Plot ROC / PR curves
```r
Basic: compute & plot both ROC and PR (no files written)
plotkfremetrics( df = toykfre, numvars = c(4, 6, 8), plottype = "allplots", mode = "both", # compute + plot show_years = c(2, 5) )
Save to disk (PNG/SVG)
plotkfremetrics( df = toykfre, numvars = c(4, 6), plottype = "aucroc", mode = "both", showyears = c(2, 5), saveplots = TRUE, imagepathpng = "plots", image_prefix = "kfre" ) ```
Running Tests
If you’ve cloned the repo:
r
library(devtools)
devtools::load_all(".")
devtools::test()
You should see unit tests for both the end-to-end flow and the evaluation utilities.
API surface (exports)
RiskPredictor(R6)$predict_kfre(years, is_north_american, use_extra_vars, num_vars)$kfre_person(...)
Wrappers:predict_kfre(df, columns, years, is_north_american, use_extra_vars, num_vars)add_kfre_risk_col(...)
Utilities:upcr_uacr(...)perform_conversions(...)class_esrd_outcome(...)class_ckd_stages(...)eval_kfre_metrics(...)plot_kfre_metrics(...)
Notes on parity with Python
The R implementations are designed to mirror the Python versions (naming, shapes,
and expected columns). Where packages differ (e.g., ROC/PR computation), we use
pROC and precrec to maintain metric parity.
References
Tangri N, Grams ME, Levey AS, et al. (2016). Multinational assessment of accuracy of equations for predicting risk of kidney failure: A meta-analysis. JAMA, 315(2), 164–174. doi:10.1001/jama.2015.18202
Tangri N, Stevens LA, Griffith J, et al. (2011). A predictive model for progression of chronic kidney disease to kidney failure. JAMA, 305(15), 1553–1559. doi:10.1001/jama.2011.451
Sumida K, Nadkarni GN, Grams ME, et al. (2020). Conversion of urine protein-creatinine ratio or urine dipstick protein to urine albumin-creatinine ratio for use in CKD screening and prognosis. Ann Intern Med, 173(6), 426–435. doi:10.7326/M20-0529
License
kfre is distributed under the MIT License. See LICENSE for more information.
Owner
- Name: Leon Shpaner
- Login: lshpaner
- Kind: user
- Website: https://www.leonshpaner.com
- Repositories: 25
- Profile: https://github.com/lshpaner
Data Scientist | Python | R | SQL | LaTeX | Tableau | Educator | German Shepherd Enthusiast
GitHub Events
Total
- Release event: 1
- Push event: 15
- Create event: 1
Last Year
- Release event: 1
- Push event: 15
- Create event: 1
Packages
- Total packages: 1
- Total downloads: unknown
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 1
- Total maintainers: 1
cran.r-project.org: kfre
Kidney Failure Risk Equation (KFRE) Tools
- Homepage: https://github.com/lshpaner/kfre_r
- Documentation: http://cran.r-project.org/web/packages/kfre/kfre.pdf
- License: MIT + file LICENSE
-
Latest release: 0.0.2
published 10 months ago
Rankings
Maintainers (1)
Dependencies
- R >= 3.6 depends
- ggplot2 * imports
- grDevices * imports
- graphics * imports
- stats * imports
- knitr * suggests
- readxl * suggests
- rmarkdown * suggests
- testthat >= 3.0.0 suggests