Compute liver-related indices (FLI, NFS, APRI, FIB-4, BARD, ALBI, MELD-XI) with validation and diagnostics
Source:R/liver_markers.R
liver_markers.RdGiven routine labs and anthropometry, computes:
FLI - Fatty Liver Index (Bedogni et al. 2006)
NFS - NAFLD Fibrosis Score (Angulo et al. 2007)
APRI - AST-to-Platelet Ratio Index
FIB4 - Fibrosis-4 Index
BARD - BMI-AST/ALT-Diabetes score
ALBI - Albumin-Bilirubin score
MELD_XI - MELD excluding INR
Usage
liver_markers(
data,
col_map = NULL,
verbose = TRUE,
na_action = c("keep", "omit", "error"),
na_warn_prop = 0.2
)Arguments
- data
A data.frame or tibble containing your liver and anthropometry data.
- col_map
Named list mapping these keys -> column names in
data:BMI(kg/m^2),waist(cm),TG(mg/dL),GGT(U/L),age(years),AST(U/L),ALT(U/L),platelets(10^9/L),albumin(g/L),diabetes(0/1 or logical),bilirubin(mg/dL),creatinine(mg/dL).
- verbose
Logical; if
TRUE(default), prints column mapping, input availability, physiological range information (informational only, values not altered), the list of markers being computed with their inputs, and a per-column results summary.- na_action
One of
c("keep","omit","error")controlling missing-data policy. Default "keep".- na_warn_prop
Numeric in \([0,1]\); per-variable threshold for high-missingness warnings. Default 0.2.
Value
A tibble with one column per marker: FLI, NFS, APRI, FIB4,
BARD, ALBI, MELD_XI. If an ID column is detected in data (e.g.
id, IID, participant_id), it is prepended as the first output column.
Details
Enhancements:
Robust input validation (columns present, types) with informative errors.
Configurable NA policy and optional extreme-value scanning/capping.
Data-quality warnings (high missingness, non-positive logs, zero denominators).
Verbose stepwise progress and completion summary.
Units (no automatic conversion):
BMI: kg/m^2; Waist: cm; TG: mg/dL; GGT/AST/ALT: U/L; Platelets: 10^9/L; Albumin: g/L; Bilirubin: mg/dL; Creatinine: mg/dL.
ALBI uses bilirubin in mumol/L internally (converted as bilirubin (mg/dL) * 17.1).
Formulas
FLI = logistic(0.953ln(TG) + 0.139BMI + 0.718ln(GGT) + 0.053waist - 15.745) * 100
NFS = -1.675 + 0.037age + 0.094BMI + 1.13diabetes + 0.99(AST/ALT) - 0.013platelets - 0.066albumin (albumin in g/L; Angulo 2007 published coefficient -0.66 was for g/dL, divided by 10 here)
APRI = (AST / 40) / platelets * 100; assumes AST upper limit of normal = 40 U/L
FIB-4 = (age * AST) / (platelets * sqrt(ALT))
BARD = +1 if BMI>=28, +2 if AST/ALT>=0.8, +1 if diabetes present; sum in 0-4
ALBI = 0.66log10(bilirubin (mumol/L)) - 0.0852albumin (g/L)
MELD-XI = 5.11ln(bilirubin (mg/dL)) + 11.76ln(creatinine (mg/dL)) + 9.44
References
Bedogni G, Bellentani S, Miglioli L, others (2006). “The Fatty Liver Index: a simple and accurate predictor of hepatic steatosis in the general population.” BMC Gastroenterology, 6, 33. doi:10.1186/1471-230X-6-33 . Angulo P, Hui JM, Marchesini G, others (2007). “The NAFLD fibrosis score: a noninvasive system that identifies liver fibrosis in patients with NAFLD.” Hepatology, 45(4), 846–854. doi:10.1002/hep.21496 . Wai CT, Greenson JK, Fontana RJ, others (2003). “A simple noninvasive index can predict both significant fibrosis and cirrhosis in patients with chronic hepatitis C.” Hepatology, 38(2), 518–526. doi:10.1053/jhep.2003.50346 . Sterling RK, Lissen E, Clumeck N, others (2006). “Development of a simple noninvasive index to predict significant fibrosis in patients with HIV/HCV coinfection (FIB-4).” Hepatology, 43(6), 1317–1325. doi:10.1002/hep.21178 . Harrison SA, Oliver D, Arnold HL, others (2008). “Development and validation of a simple NAFLD clinical scoring system for identifying patients without advanced disease.” Gut, 57(10), 1441–1447. doi:10.1136/gut.2007.146019 . Johnson PJ, Berhane S, Kagebayashi C, others (2015). “Assessment of liver function in patients with hepatocellular carcinoma: the ALBI grade.” Journal of Clinical Oncology, 33(6), 550–558. doi:10.1200/JCO.2014.57.9151 . Heuman DM, Abou-Assi SG, Habib A, others (2006). “MELD-XI: A rational approach to "sickest first" liver transplantation in cirrhotic patients requiring anticoagulant therapy.” Liver Transplantation, 13(1), 30–37. doi:10.1002/lt.20906 .
Examples
# Quick smoke-test
df <- data.frame(ALT = 25, AST = 20, BMI = 24, platelets = 250)
liver_markers(df, verbose = FALSE)
#> # A tibble: 1 × 7
#> FLI NFS APRI FIB4 BARD ALBI MELD_XI
#> <dbl> <dbl> <dbl> <dbl> <int> <dbl> <dbl>
#> 1 NA NA 0.2 NA 2 NA NA
# \donttest{
library(tibble)
df <- tibble(
BMI = 24,
waist = 80,
TG = 150,
GGT = 30,
age = 45,
AST = 25,
ALT = 20,
platelets = 250,
albumin = 42,
diabetes = FALSE,
bilirubin = 1.0,
creatinine = 0.9
)
liver_markers(df)
#> liver_markers(): reading input 'df' — 1 rows × 12 variables
#> liver_markers(): col_map (12 columns — 12 inferred from data)
#> BMI -> 'BMI' (inferred)
#> waist -> 'waist' (inferred)
#> TG -> 'TG' (inferred)
#> GGT -> 'GGT' (inferred)
#> age -> 'age' (inferred)
#> AST -> 'AST' (inferred)
#> ALT -> 'ALT' (inferred)
#> platelets -> 'platelets' (inferred)
#> albumin -> 'albumin' (inferred)
#> diabetes -> 'diabetes' (inferred)
#> bilirubin -> 'bilirubin' (inferred)
#> creatinine -> 'creatinine' (inferred)
#> liver_markers(): optional inputs
#> present: BMI, waist, TG, GGT, age, AST, ALT, platelets, albumin, diabetes, bilirubin, creatinine
#> liver_markers(): computing markers:
#> FLI [BMI, waist, TG, GGT]
#> NFS [age, BMI, diabetes, AST, ALT, platelets, albumin]
#> APRI [AST, platelets]
#> FIB4 [age, AST, platelets, ALT]
#> BARD [BMI, AST, ALT, diabetes]
#> ALBI [bilirubin, albumin]
#> MELD_XI [bilirubin, creatinine]
#> liver_markers(): results: FLI 1/1, NFS 1/1, APRI 1/1, FIB4 1/1, BARD 1/1, ALBI 1/1, MELD_XI 1/1
#> # A tibble: 1 × 7
#> FLI NFS APRI FIB4 BARD ALBI MELD_XI
#> <dbl> <dbl> <dbl> <dbl> <int> <dbl> <dbl>
#> 1 27.9 -2.54 0.25 1.01 2 -2.76 8.20
liver_markers(df, verbose = FALSE)
#> # A tibble: 1 × 7
#> FLI NFS APRI FIB4 BARD ALBI MELD_XI
#> <dbl> <dbl> <dbl> <dbl> <int> <dbl> <dbl>
#> 1 27.9 -2.54 0.25 1.01 2 -2.76 8.20
# }