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

Feature Request: Calculate Creatinine Clearance #1826

Closed
jeffreyad opened this issue Mar 16, 2023 · 3 comments · Fixed by #1871
Closed

Feature Request: Calculate Creatinine Clearance #1826

jeffreyad opened this issue Mar 16, 2023 · 3 comments · Fixed by #1871
Assignees
Labels
enhancement New feature or request programming

Comments

@jeffreyad
Copy link
Collaborator

Feature Idea

This function would calculate Creatinine Clearance (CRCL). This is used renal function assessment. It could be used to create a parameter for ADLB or a baseline value. The baseline values are typically used in PK programming for NCA or POPPK. It might be similar to the functions in derive_advs_params.R such as derive_param_bmi() and compute_bmi()

This is the formula I have typically seen used:
For CREATBL in umol/L:
For SEX = 'F': then CRCL = ((140 - AAGE) * WTBL * 1.04) / CREATBL
For SEX = 'M': then CRCL = ((140 - AAGE) * WTBL * 1.23) / CREATBL

There could be the option to use different formulas if desired.

It might also be worth calculating EGFR

Relevant Input

base <- tribble(
  ~STUDYID, ~USUBJID, ~AGE, ~SEX, ~RACE, ~WTBL, ~CREATBL, ~CREATBLU,
  "P01", "P01-1001", 45, "M", "WHITE", 85, 90, "umol/L",
  "P01", "P01-1002", 52, "F", "BLACK OR AFRICAN AMERICAN", 68, 70, "umol/L",
  "P01", "P01-1003", 67, "M", "BLACK OR AFRICAN AMERICAN", 85, 77, "umol/L",
  "P01", "P01-1004", 76, "F", "ASIAN", 60, 65, "umol/L",
)
# A tibble: 4 × 8
  STUDYID USUBJID    AGE SEX   RACE                       WTBL CREATBL CREATBLU
  <chr>   <chr>    <dbl> <chr> <chr>                     <dbl>   <dbl> <chr>   
1 P01     P01-1001    45 M     WHITE                        85      90 umol/L  
2 P01     P01-1002    52 F     BLACK OR AFRICAN AMERICAN    68      70 umol/L  
3 P01     P01-1003    67 M     BLACK OR AFRICAN AMERICAN    85      77 umol/L  
4 P01     P01-1004    76 F     ASIAN                        60      65 umol/L  

Relevant Output

# A tibble: 4 × 10
  STUDYID USUBJID    AGE SEX   RACE                       WTBL CREATBL CREATBLU CRCLBL CRCLBLU
  <chr>   <chr>    <dbl> <chr> <chr>                     <dbl>   <dbl> <chr>     <dbl> <chr>  
1 P01     P01-1001    45 M     WHITE                        85      90 umol/L    110.  mL/min 
2 P01     P01-1002    52 F     BLACK OR AFRICAN AMERICAN    68      70 umol/L     88.9 mL/min 
3 P01     P01-1003    67 M     BLACK OR AFRICAN AMERICAN    85      77 umol/L     99.1 mL/min 
4 P01     P01-1004    76 F     ASIAN                        60      65 umol/L     61.4 mL/min 

Reproducible Example/Pseudo Code

crcl <- base %>%
  mutate(
    CRCLBL = case_when(
      SEX == "F" ~ ((140 - AGE) * WTBL * 1.04) / CREATBL,
      SEX == "M" ~ ((140 - AGE) * WTBL * 1.23) / CREATBL
    ),
    CRCLBLU = "mL/min",
  )
@airdjan
Copy link

airdjan commented Apr 12, 2023

Based on the data set above, I have added the calculation of the GFR value:

CKD-EPI Creatinine Equation (2021)

$$eGFR = 142 \times min(S_{cr}/\kappa, 1)^\alpha \times max(S_cr/\kappa, 1)^{-1.200} \times 0.9938^{Age} \times 1.012 [if female]$$$

where:
$S_{cr}$ = standardized serum creatinine in mg/dL
$\kappa$ = 0.7 (females) or 0.9 (males)
$\alpha$ = -0.241 (female) or -0.302 (male)
min($S_{cr}/\kappa$, 1) is the minimum of $S_{cr}/\kappa$ or 1.0
max($S_{cr}/\kappa$, 1) is the maximum of $S_{cr}/\kappa$ or 1.0
Age (years)

Source = https://www.kidney.org/content/ckd-epi-creatinine-equation-2021

Relevant Input

base <- tribble(
  ~STUDYID, ~USUBJID, ~AGE, ~SEX, ~RACE, ~WTBL, ~CREATBL, ~CREATBLU, ~SCR,
  "P01", "P01-1001", 45, "M", "WHITE", 85, 90, "umol/L", 1.2,
  "P01", "P01-1002", 52, "F", "BLACK OR AFRICAN AMERICAN", 68, 70, "umol/L", 1.3,
  "P01", "P01-1003", 67, "M", "BLACK OR AFRICAN AMERICAN", 85, 77, "umol/L", 1.1,
  "P01", "P01-1004", 76, "F", "ASIAN", 60, 65, "umol/L", 1.2)

# A tibble: 4 × 9
  STUDYID USUBJID    AGE SEX   RACE                       WTBL CREATBL CREATBLU   SCR
  <chr>   <chr>    <dbl> <chr> <chr>                     <dbl>   <dbl> <chr>    <dbl>
1 P01     P01-1001    45 M     WHITE                        85      90 umol/L     1.2
2 P01     P01-1002    52 F     BLACK OR AFRICAN AMERICAN    68      70 umol/L     1.3
3 P01     P01-1003    67 M     BLACK OR AFRICAN AMERICAN    85      77 umol/L     1.1
4 P01     P01-1004    76 F     ASIAN                        60      65 umol/L     1.2

Relevant Output

# A tibble: 4 × 11
# Rowwise: 
  STUDYID USUBJID    AGE SEX   RACE                       WTBL CREATBL CREATBLU   SCR  EGFR EGFRI        
  <chr>   <chr>    <dbl> <chr> <chr>                     <dbl>   <dbl> <chr>    <dbl> <dbl> <chr>        
1 P01     P01-1001    45 M     WHITE                        85      90 umol/L     1.2  76.0 mL/min/1.73m2
2 P01     P01-1002    52 F     BLACK OR AFRICAN AMERICAN    68      70 umol/L     1.3  49.5 mL/min/1.73m2
3 P01     P01-1003    67 M     BLACK OR AFRICAN AMERICAN    85      77 umol/L     1.1  73.6 mL/min/1.73m2
4 P01     P01-1004    76 F     ASIAN                        60      65 umol/L     1.2  46.9 mL/min/1.73m2

Reproducible Example/Pseudo Code

calculate_CKD_EPI <- function(age, sex, scr) {
  if (is.na(age) || is.na(sex) || is.na(scr) ||
      !is.numeric(age) || !is.numeric(scr)) {
    return(NA_real_)
  }
  
  kappa <- case_when(grepl("F",sex) ~ 0.7,
                     grepl("M",sex) ~ 0.9,
                     TRUE ~ NA_real_)
  
  alpha <- case_when(grepl("F",sex) ~  -0.241,
                     grepl("M",sex) ~  -0.302,
                     TRUE ~ NA_real_)
  
  gender_coefficent <- case_when(grepl("F",sex) ~ 1.012,
                                TRUE ~ 1)
  
  gfr <- 142 * min(scr/kappa, 1)^(alpha) * 
    max(scr/kappa, 1)^(-1.200) * 
    0.9938^age * 
    gender_coefficent
  
  return(gfr)
}

#additional compute of the CKD Stages if needed
calculate_CKD_stage <- function(egfr) {
  ckd_stage <- case_when(egfr >= 90 ~ "Stage 1", 
                         (egfr <= 89) | (egfr >= 60) ~ "Stage 2", 
                         (egfr <= 59) | (egfr >= 30) ~ "Stage 3", 
                         (egfr <= 29) | (egfr >= 15) ~ "Stage 4", 
                         egfr < 15 ~ "Stage 5",
                         TRUE ~ "No Stage")
  return(ckd_stage)
}

base %>% 
  rowwise() %>% 
  mutate(EGFR = calculate_CKD_EPI(AGE,SEX,SCR),
         EGFRI = "mL/min/1.73m2")

@bms63
Copy link
Collaborator

bms63 commented Apr 12, 2023

This is awesome @airdjan ! Thank you for putting together. Let's discuss at tomorrow's PK Working group meeting.

@bms63 bms63 moved this from Backlog to Priority in admiral (sdtm/adam, dev, ci, template, core) Apr 12, 2023
@bms63 bms63 moved this from Priority to In Progress in admiral (sdtm/adam, dev, ci, template, core) Apr 12, 2023
jeffreyad added a commit that referenced this issue Apr 20, 2023
@jeffreyad jeffreyad linked a pull request Apr 20, 2023 that will close this issue
14 tasks
@jeffreyad
Copy link
Collaborator Author

@airdjan @bms63 I added an initial compute_crcl() which we can discuss in the PK meeting. We could potentially add the CKD-EPI equation to the same function or a separate function.

jeffreyad added a commit that referenced this issue May 5, 2023
@bms63 bms63 added this to the v0.11 milestone May 9, 2023
jeffreyad added a commit that referenced this issue May 10, 2023
…s in header. Update titles and comments of Tests
jeffreyad added a commit that referenced this issue May 15, 2023
jeffreyad added a commit that referenced this issue May 15, 2023
…mentation guide, including CRCLBL and EGFRBL which depend on #1826 Calculate Creatinine Clearance
@bms63 bms63 moved this from In Progress to In Review in admiral (sdtm/adam, dev, ci, template, core) May 24, 2023
@bms63 bms63 closed this as completed in e94e3a2 Jun 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request programming
Development

Successfully merging a pull request may close this issue.

3 participants