Pharmacokinetics¶
Non-compartmental pharmacokinetic analysis (NCA). AUC computation (linear, log-linear, linear-up/log-down), Cmax, Tmax, half-life, clearance, and volume of distribution.
Validates against R packages: PKNCA, NonCompart.
Non-compartmental pharmacokinetic analysis (NCA).
NCA is required for every PK study: AUC, Cmax, half-life, clearance, and volume of distribution. Self-contained, well-defined, formulaic calculations.
Phase 1: NCA only. Compartmental/PopPK is Phase 4+.
Validates against: R packages PKNCA, NonCompart.
- class pystatsbio.pk.NCASolution(result)[source]¶
Bases:
SolutionReprMixinPublic result of an NCA fit — a Solution wrapping
Result[NCAParams].Exposes every NCA parameter as a read-only property plus the uniform
.backend_name/.timing/.warnings/.infometadata and a Jupyter_repr_html_(viaSolutionReprMixin).- Parameters:
result (Result[NCAParams])
- class pystatsbio.pk.NCAParams(auc_last, auc_inf, auc_pct_extrap, cmax, tmax, half_life, lambda_z, lambda_z_r_squared, clearance, vz, aumc_last, aumc_inf, mrt, dose, route, auc_method, n_points, n_terminal)[source]¶
Bases:
objectComputed payload of a non-compartmental pharmacokinetic analysis.
- Parameters:
auc_last (float)
auc_inf (float | None)
auc_pct_extrap (float | None)
cmax (float)
tmax (float)
half_life (float | None)
lambda_z (float | None)
lambda_z_r_squared (float | None)
clearance (float | None)
vz (float | None)
aumc_last (float)
aumc_inf (float | None)
mrt (float | None)
dose (float | None)
route (str)
auc_method (str)
n_points (int)
n_terminal (int)
- exception pystatsbio.pk.LambdaZEstimationError(message, *, iterations=0, reason='terminal-phase log-linear fit failed')[source]¶
Bases:
ConvergenceErrorRaised when the terminal elimination rate constant cannot be estimated.
This is not a programming error — it signals that the concentration-time profile does not contain enough terminal phase data to fit a reliable log-linear slope. Subclasses
ConvergenceError(a fit-quality failure, per the pystatsbio constitution B3), so it is catchable both asLambdaZEstimationErrorand as the library-wideConvergenceError.
- pystatsbio.pk.nca(time, concentration, *, dose=None, route='ev', auc_method='linear-up/log-down', lambda_z_n_points=None)[source]¶
Non-compartmental pharmacokinetic analysis.
- Parameters:
time (array) – Time points (non-negative, no duplicates).
concentration (array) – Plasma concentration values (non-negative).
dose (float or None) – Administered dose (needed for CL and Vz).
route (str) –
'iv'(intravenous bolus) or'ev'(extravascular / oral).auc_method (str) –
'linear'(linear trapezoidal),'log-linear'(log-linear trapezoidal),'linear-up/log-down'(linear up, log-linear down – the default, recommended by FDA guidance).lambda_z_n_points (int or None) – Number of terminal points for half-life estimation. If
None, automatically selects the best terminal phase (maximum adjusted r-squared with >= 3 points).
- Returns:
Solution wrapping all NCA parameters (AUC, Cmax/Tmax, half-life, clearance, volume of distribution, and a summary method), with the uniform .backend_name/.timing/.warnings/.info accessors.
- Return type:
Notes
CPU-only. PK data is always small (typically 10-20 time points per subject).
Validates against: R
NonCompart::sNCA(). (PKNCA uses a different default terminal-slope selection and is not a validated reference for this module.)Notes
If the terminal phase cannot be fitted (too few positive post-Cmax points, or no true elimination phase),
lambda_z— and everything derived from it (half_life,auc_inf,auc_pct_extrap,clearance,vz) — isNone, and the reason is reported in.warnings. Callers must check forNone.