% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/liver_markers.R
\name{liver_markers}
\alias{liver_markers}
\title{Compute liver-related indices (FLI, NFS, APRI, FIB-4, BARD, ALBI, MELD-XI) with validation and diagnostics}
\usage{
liver_markers(
  data,
  col_map = NULL,
  verbose = TRUE,
  na_action = c("keep", "omit", "error"),
  na_warn_prop = 0.2
)
}
\arguments{
\item{data}{A data.frame or tibble containing your liver and anthropometry data.}

\item{col_map}{Named list mapping these keys -> column names in \code{data}:
\itemize{
\item \code{BMI} (kg/m^2), \code{waist} (cm), \code{TG} (mg/dL), \code{GGT} (U/L),
\item \code{age} (years), \code{AST} (U/L), \code{ALT} (U/L), \code{platelets} (10^9/L),
\item \code{albumin} (g/L), \code{diabetes} (0/1 or logical),
\item \code{bilirubin} (mg/dL), \code{creatinine} (mg/dL).
}}

\item{verbose}{Logical; if \code{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.}

\item{na_action}{One of \code{c("keep","omit","error")} controlling missing-data
policy. Default "keep".}

\item{na_warn_prop}{Numeric in \eqn{[0,1]}; per-variable threshold for
high-missingness warnings. Default 0.2.}
}
\value{
A tibble with one column per marker: \code{FLI}, \code{NFS}, \code{APRI}, \code{FIB4},
\code{BARD}, \code{ALBI}, \code{MELD_XI}. If an ID column is detected in \code{data} (e.g.
\code{id}, \code{IID}, \code{participant_id}), it is prepended as the first output column.
}
\description{
Given routine labs and anthropometry, computes:
\itemize{
\item FLI      - Fatty Liver Index (Bedogni et al. 2006)
\item NFS      - NAFLD Fibrosis Score (Angulo et al. 2007)
\item APRI     - AST-to-Platelet Ratio Index
\item FIB4     - Fibrosis-4 Index
\item BARD     - BMI-AST/ALT-Diabetes score
\item ALBI     - Albumin-Bilirubin score
\item MELD_XI  - MELD excluding INR
}
}
\details{
Enhancements:
\itemize{
\item Robust input validation (columns present, types) with informative errors.
\item Configurable NA policy and optional extreme-value scanning/capping.
\item Data-quality warnings (high missingness, non-positive logs, zero denominators).
\item Verbose stepwise progress and completion summary.
}

Units (no automatic conversion):
\itemize{
\item 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.
\item ALBI uses bilirubin in mumol/L internally (converted as bilirubin (mg/dL) * 17.1).
}

Formulas
\itemize{
\item FLI      = logistic(0.953\emph{ln(TG) + 0.139}BMI + 0.718\emph{ln(GGT) + 0.053}waist - 15.745) * 100
\item NFS      = -1.675 + 0.037\emph{age + 0.094}BMI + 1.13\emph{diabetes + 0.99}(AST/ALT) - 0.013\emph{platelets - 0.066}albumin
(albumin in g/L; Angulo 2007 published coefficient -0.66 was for g/dL, divided by 10 here)
\item APRI     = (AST / 40) / platelets * 100; assumes AST upper limit of normal = 40 U/L
\item FIB-4    = (age * AST) / (platelets * sqrt(ALT))
\item BARD     = +1 if BMI>=28, +2 if AST/ALT>=0.8, +1 if diabetes present; sum in 0-4
\item ALBI     = 0.66\emph{log10(bilirubin (mumol/L)) - 0.0852}albumin (g/L)
\item MELD-XI  = 5.11\emph{ln(bilirubin (mg/dL)) + 11.76}ln(creatinine (mg/dL)) + 9.44
}
}
\examples{
# Quick smoke-test
df <- data.frame(ALT = 25, AST = 20, BMI = 24, platelets = 250)
liver_markers(df, verbose = FALSE)

\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(df, verbose = FALSE)
}

}
\references{
\insertRef{bedogni2006fli}{HealthMarkers}
\insertRef{angulo2007nfs}{HealthMarkers}
\insertRef{wai2003apri}{HealthMarkers}
\insertRef{sterling2006fib4}{HealthMarkers}
\insertRef{harrison2008bard}{HealthMarkers}
\insertRef{johnson2015albi}{HealthMarkers}
\insertRef{heuman2007meldxi}{HealthMarkers}
}
\seealso{
\code{\link[=inflammatory_markers]{inflammatory_markers()}}, \code{\link[=kidney_failure_risk]{kidney_failure_risk()}}, \code{\link[=iAge]{iAge()}}
}
