Clinical Scores Calculator for Healthcare

Introduction

‘amscorer’ package provides functions for calculating various clinical scores used in healthcare. These scores assist in assessing patient risks, predicting outcomes, and making informed clinical decisions. The key clinical scores included in this package are:

  • Charlson Comorbidity Index (CCI): Predicts ten-year mortality risk based on comorbid conditions.

  • EPICES Score: Measures social deprivation.

  • MELD Score: Evaluates the severity of chronic liver disease.

  • Alternative Fistula Risk Score (a-FRS): Assesses the risk of postoperative pancreatic fistula.

  • Distal Pancreatectomy Fistula Risk Score (D-FRS): Estimates the risk of fistula after distal pancreatectomy.

library(amscorer)

Usage Examples :

Calculating the Charlson Comorbidity Index (CCI)

The CCI predicts ten-year mortality risk based on the presence of comorbid conditions.

# Example data for CCI
set.seed(123)
n <- 10
my_data <- data.frame(
  age = sample(30:90, n, replace = TRUE), # age
  mi = sample(0:1, n, replace = TRUE), # Myocardial infraction
  chf = sample(0:1, n, replace = TRUE), # Congestive heart failure
  pvd = sample(0:1, n, replace = TRUE), # preripheral vascular disease
  cevd = sample(0:1, n, replace = TRUE), # Cerebrovascular accident or Transient ischemic attack
  dementia = sample(0:1, n, replace = TRUE), # Dematia
  cpd = sample(0:1, n, replace = TRUE),# Chronic obstructive pulmonary disease
  ctd = sample(0:1, n, replace = TRUE),# Connective tissue disease
  pud = c(sample(0:1, (n-1), replace = TRUE) , NA), # peptide ulcer disease
  liver_disease = sample(0:2, n, replace = TRUE), #Liver disease(None,Mild,Moderate to severe)
  diabetes_mellitus = sample(0:2, n, replace = TRUE),#Diabetes(None,uncomplicated,End-organ)
  hp = sample(0:1, n, replace = TRUE), # Hemipledia
  ckd = sample(0:1, n, replace = TRUE), #Moderate to severe Chronic kidney disease
  solid_tumor = sample(0:2, n, replace = TRUE), #Solid tumor(None,Localized,Metastatic)
  leuk = sample(0:1, n, replace = TRUE), # Leukemia
  lym =  c(sample(0:1, (n-2), replace = TRUE) , c(NA , NA)), # Lymphoma
  aids = sample(0:1, n, replace = TRUE) # AIDS
)
amscorer::cci(my_data ,replace_na_with_zero = FALSE) 
#>    age mi chf pvd cevd dementia cpd ctd pud liver_disease diabetes_mellitus hp
#> 1   60  1   0   0    0        1   0   1   1             0                 0  1
#> 2   44  1   1   1    1        0   1   0   1             1                 1  1
#> 3   80  1   0   0    1        0   1   0   0             1                 0  1
#> 4   43  0   0   1    0        0   0   0   1             0                 1  0
#> 5   32  1   0   1    0        0   0   0   1             1                 0  1
#> 6   71  0   0   0    0        1   1   1   1             0                 2  0
#> 7   79  1   1   0    0        1   0   1   0             0                 2  1
#> 8   83  0   1   0    1        0   0   0   0             1                 1  0
#> 9   72  0   0   0    0        1   0   1   1             2                 2  0
#> 10  66  0   1   1    0        0   0   1  NA             2                 0  0
#>    ckd solid_tumor leuk lym aids cci_score estimated_10_year_survival
#> 1    1           1    1   0    0        14                         0%
#> 2    1           1    1   0    0        16                         0%
#> 3    0           1    0   0    1        18                         0%
#> 4    0           2    1   1    0        13                         0%
#> 5    0           1    0   1    1        16                         0%
#> 6    1           0    1   1    1        21                         0%
#> 7    0           1    0   0    1        19                         0%
#> 8    1           1    0   1    1        20                         0%
#> 9    1           1    0  NA    0        NA                         NA
#> 10   1           2    0  NA    0        NA                         NA

getting CCI score with amscorer

amscorer::cci(my_data ,replace_na_with_zero = FALSE)$cci_score  
#>  [1] 14 16 18 13 16 21 19 20 NA NA

EPICES Score

The EPICES score measures social deprivation through a series of binary responses.

# Example data for EPICES
my_data <- data.frame(
  epices_1 = c(1, 0, 1),
  epices_2 = c(0, 1, 1),
  epices_3 = c(0, 0, 0),
  epices_4 = c(1, 0, 0),
  epices_5 = c(0, 1, 0),
  epices_6 = c(1, 0, 1),
  epices_7 = c(0, 1, 0),
  epices_8 = c(0, 0, 1),
  epices_9 = c(1, 1, 0),
  epices_10 = c(0, 0, 1),
  epices_11 = c(1, 0, NA)
)
amscorer::epices_score(my_data ,prefix = "epices",replace_na_with_zero = FALSE)  
#>   epices_1 epices_2 epices_3 epices_4 epices_5 epices_6 epices_7 epices_8
#> 1        1        0        0        1        0        1        0        0
#> 2        0        1        0        0        1        0        1        0
#> 3        1        1        0        0        0        1        0        1
#>   epices_9 epices_10 epices_11 epices_score
#> 1        1         0         1        53.84
#> 2        1         0         0        61.54
#> 3        0         1        NA           NA

getting only the EPICES score with amscorer

amscorer::epices_score(my_data ,prefix = "epices",replace_na_with_zero = FALSE)$epices_score
#> [1] 53.84 61.54    NA
amscorer::epices_score(my_data ,prefix = "epices",replace_na_with_zero = TRUE)$epices_score
#> Warning in amscorer::epices_score(my_data, prefix = "epices",
#> replace_na_with_zero = TRUE): Missing values are considered as zero
#> [1] 53.84 61.54 50.29

MELD Score (Original, Pre-2016)

my_data <- data.frame(
  Hemodialysis = c(0, 0, 1),
  Creatinine = c(1.2, 0.9, 1.5),
  Bilirubin = c(0.7, 1.1, 0.9),
  INR = c(1.0, 1.2, 1) 
)
amscorer::meld_pre_2016(my_data) 
#>   Hemodialysis Creatinine Bilirubin INR MELD_score three_month_mortality
#> 1            0        1.2       0.7 1.0          8        1.9% mortality
#> 2            0        0.9       1.1 1.2          9        1.9% mortality
#> 3            1        1.5       0.9 1.0         20       19.6% mortality

MELD Na (prior UNOS/OPTN version)

my_data <- data.frame(
  Creatinine = c(1.2, 2.5, 3),
  Bilirubin = c(0.5, 1.0, 2.1),
  INR = c(1.1, 1.5, 1.8),
  Sodium = c(136, 140, 145),
  Hemodialysis = c(0, 1, 0)
)
amscorer::meld_NA(my_data) 
#>   Creatinine Bilirubin INR Sodium Hemodialysis MELD_na_score
#> 1        1.2       0.5 1.1    136            0             9
#> 2        2.5       1.0 1.5    140            1            24
#> 3        3.0       2.1 1.8    145            0            26
#>   Three_Month_Mortality
#> 1        1.9% mortality
#> 2       19.6% mortality
#> 3       19.6% mortality

Intra-operative Distal fistula risk score (D-FRS)

The D-FRS estimates the risk of developing a postoperative pancreatic fistula after distal pancreatectomy.

my_data <- data.frame(
  ID = 1:4,
  BMI = c(20, 25, 30, 10),
  PT = c(5, 43, 1, 20),
  PD_size = c(100, 0, 1, 19),
  OP_time = c(500, 20, 605, 600),
  Texture = c(0, 1, 0, 1)
)
amscorer::io_DFRS(my_data)
#>   ID BMI PT PD_size OP_time Texture POPF_risk risk_category
#> 1  1  20  5     100     500       0    99.99%     High risk
#> 2  2  25 43       0      20       1    73.13%     High risk
#> 3  3  30  1       1     605       0     0.87%      Low risk
#> 4  4  10 20      19     600       1      100%     High risk

Preoperative distal fistula risk score score (D-FRS)

The D-FRS estimates the risk of developing a postoperative pancreatic fistula after distal pancreatectomy.

my_data <- data.frame(
  ID = 1:4,
  PT = c(5, 43, 3, 4),
  PD_size = c(25, 5, 4, 19)
)
amscorer::preop_DFRS(my_data)
#> Warning in amscorer::preop_DFRS(my_data): Some values of PD_size are very high
#> or very low
#>   ID PT PD_size POPF_risk risk_category
#> 1  1  5      25       99%     High risk
#> 2  2 43       5       97%     High risk
#> 3  3  3       4        9%      Low risk
#> 4  4  4      19       98%     High risk

Alternative Fistula Risk Score for Pancreatoduodenectomy (a-FRS):

The a-FRS assesses the risk of developing a postoperative pancreatic fistula (POPF) after pancreatoduodenectomy (PD).

my_data <- data.frame(
  ID = 1:4,
  Texture = c(0, 1, 0,0),
  BMI = c(22, 25, 30 , 20),
  PD_size = c(5, 10, 1,2)
)
amscorer::a_FRS(my_data)
#>   ID Texture BMI PD_size POPF_risk     Risk_category
#> 1  1       0  22       5     2.75%          Low risk
#> 2  2       1  25      10     8.19% Intermediate risk
#> 3  3       0  30       1    18.48% Intermediate risk
#> 4  4       0  20       2     7.26% Intermediate risk

updated Alternative Fistula Risk Score for Pancreatoduodenectomy (ua-FRS):

Alternative Fistula Risk Score for Pancreatoduodenectomy (a-FRS) is designed to predict the risk of postoperative pancreatic fistula (POPF) after pancreatoduodenectomy (PD).

my_data <- data.frame(
  ID = 1:4,
  Sex = c(0, 0, 1,1),
  Texture = c(0, 1, 0,0),
  BMI = c(22, 25, 30 , 20),
  PD_size = c(5, 10, 1,2)
)
amscorer::ua_FRS(my_data)
#>   ID Sex Texture BMI PD_size POPF_risk     Risk_category
#> 1  1   0       0  22       5      5.9% Intermediate risk
#> 2  2   0       1  25      10    16.66% Intermediate risk
#> 3  3   1       0  30       1    49.75%         High risk
#> 4  4   1       0  20       2    24.97%         High risk

Conclusion

‘amscorer’ package provides a comprehensive suite of tools for calculating key clinical scores, enhancing the ability to predict patient outcomes and make informed clinical decisions. By following the examples provided in this vignette, users can easily integrate these scoring functions into their clinical practice or research.