BioKinetics is an open-source, high-performance computational pharmacology and systems biology platform implemented in Python. It provides 1, 2, and 3-compartment linear and non-linear pharmacokinetic (PK) modeling, Target-Mediated Drug Disposition (TMDD) for therapeutic biologics and monoclonal antibodies (mAbs), biophase and turnover pharmacodynamic (PD) effect mechanisms, Itô-Euler-Maruyama Stochastic Differential Equation (SDE) simulation, Non-linear Mixed Effects (NLME) population covariate scaling, and real-time Maximum A Posteriori (MAP) Bayesian Therapeutic Drug Monitoring (TDM) dosing optimization.
-
Multi-Compartment Disposition Engine: Analytical and stiff ODE numerical solvers for 1, 2, and 3-compartment systems under IV bolus, zero-order constant infusion, and first-order oral depot absorption with first-pass bioavailability (
$F$ ). -
Target-Mediated Drug Disposition (TMDD): Mechanistic receptor-binding kinetics (
$k_{on}, k_{off}, k_{syn}, k_{deg}, k_{int}$ ), non-linear target-mediated clearance saturation, and dynamic receptor occupancy ($RO$ ) tracking for therapeutic antibodies. -
Biophase Delay & Indirect Response PD: Direct Hill
$E_{max}$ and$I_{max}$ functions coupled with Dayneka turnover mechanisms (Models I–IV: inhibition or stimulation of synthesis$k_{in}$ or loss$k_{out}$ ) and biophase effect-site equilibration ($k_{e0}$ ). - Stochastic Differential Equation (SDE) PK: Continuous-time Euler-Maruyama simulation capturing endogenous biological noise and intra-individual circadian fluctuations in renal clearance and distribution.
-
Clinical Allometry & Biomarkers: Cockcroft-Gault estimated creatinine clearance (
$CrCl$ ), Devine Ideal Body Weight (IBW), Adjusted Body Weight (ABW), Mosteller Body Surface Area (BSA), and Kleiber 3/4-power allometric clearance scaling. -
Bayesian MAP Therapeutic Drug Monitoring: Empirical Bayes Estimation (EBE) optimizing individual clearance and distribution volumes from sparse clinical serum samples (peaks/troughs) to forecast steady-state exposure (
$AUC_{24}$ ) and recommend personalized dosing regimens. -
Automated Clinical Guideline Auditing: Pre-configured safety protocols for high-risk narrow-therapeutic-index drugs (Vancomycin
$AUC_{24}$ 400–600 mg·h/L for nephrotoxicity mitigation, Tacrolimus, Gentamicin).
flowchart TD
A["Patient Demographics & Labs<br/>(Age, Weight, Height, Scr, Sex)"] --> B["Clinical Biometrics Engine<br/>IBW, ABW, BSA, CrCl"]
B --> C["Allometric & Covariate Scaler<br/>CL = θ<sub>CL</sub> · (WT/70)<sup>0.75</sup> · (CrCl/100)"]
D["Drug Dosing History<br/>(Bolus, Infusion, Oral Schedule)"] --> E["Pharmacokinetic Simulator<br/>1/2/3-Compartment & TMDD ODEs"]
C --> E
E --> F["Predicted Concentration Profile<br/>C(t), C<sub>max</sub>, C<sub>min</sub>, AUC"]
G["Sparse Clinical Lab Measurements<br/>(Serum Peak & Trough Levels)"] --> H["MAP Bayesian Estimator<br/>Objective: Prior Penalty + Data Likelihood"]
F --> H
H --> I["Empirical Bayes Estimates (EBE)<br/>Individual η<sub>CL</sub>, η<sub>Vc</sub>, t<sub>1/2</sub>"]
I --> J["Steady-State Exposure Forecaster<br/>Projected AUC<sub>24</sub>, C<sub>trough,ss</sub>"]
J --> K["Clinical Protocol Auditor<br/>(ASHP/IDSA Vancomycin, Tacrolimus)"]
K --> L["Personalized Dosing Recommendation<br/>Optimal Dose (mg) & Interval (h)"]
For a 2-compartment open model with central volume
where
Therapeutic monoclonal antibodies bind with high affinity to target pharmacological receptors
-
Equilibrium Dissociation Constant:
$K_D = \frac{k_{off}}{k_{on}}$ -
Quasi-Steady-State Constant:
$K_{SS} = \frac{k_{off} + k_{int}}{k_{on}}$ - Receptor Occupancy (
$RO$ ):
Central Compartment (Vc) Target Interaction
+------------------------------+ +----------------------------+
| Free Drug C (mg/L or nM) |<----->| Drug-Target Complex RC |
| - Linear Clearance CL | kon | - Internalization k_int |
+------------------------------+ koff +----------------------------+
^ ^
| Q | Synthesis k_syn
v | Degradation k_deg
+------------------------------+ +----------------------------+
| Peripheral Tissue Cp | | Free Receptor R (nM) |
+------------------------------+ +----------------------------+
Covariate-adjusted clearance and distribution volume are computed using Kleiber's law and the Cockcroft-Gault creatinine clearance formula:
To capture biological clearance drift and physiological blood flow fluctuations, drug concentration is modeled as an Itô diffusion:
Integrated numerically via the Euler-Maruyama algorithm:
Given population typical values
The individual parameters $CL_{ind} = CL_{scaled} \exp(\hat{\eta}{CL})$ and $V{ind} = V_{scaled} \exp(\hat{\eta}_{V})$ yield the individualized dosing recommendation to achieve target 24-hour exposure:
git clone https://github.com/ZengLLQ/bio-kinetics.git cd bio-kinetics pip install -e .
For development and test dependencies:
pip install -e ".[dev]"# 1. Inspect CLI options bio-kinetics --help # 2. Simulate 2-compartment IV infusion regimen bio-kinetics simulate --cl 4.5 --vc 35.0 --dose 1000 --interval 12.0 --doses-count 4 # 3. Perform Bayesian Therapeutic Drug Monitoring (TDM) bio-kinetics tdm --age 65 --weight 80 --scr 1.2 --dose 1000 --interval 12 --measured-peak 32.0 --measured-trough 17.5 # 4. Simulate Monoclonal Antibody TMDD kinetics bio-kinetics tmdd --dose 250 --kon 0.15 --koff 0.015 --kint 0.10 # 5. Simulate Stochastic Itô PK Trajectories bio-kinetics sde --sigma 0.08 --trajectories 25
======================================================================
BioKinetics: Clinical TDM & Bayesian Dosing Dashboard
======================================================================
Patient Profile : 65yo Male, 80kg, CrCl: 69.4 mL/min
Regimen Target : Vancomycin (Target AUC24: 400-600 mg*h/L)
----------------------------------------------------------------------
INDIVIDUAL EMPIRICAL BAYES ESTIMATES (EBE):
Clearance (CL_ind) : 3.24 L/h (eta_CL: -0.156)
Volume (Vc_ind) : 38.10 L (eta_Vc: -0.048)
Elimination t1/2 : 8.15 hours
----------------------------------------------------------------------
STEADY-STATE PHARMACOKINETIC EXPOSURE:
Projected AUC24 : 584.2 mg*h/L
Projected C_trough : 16.40 mg/L
Projected C_peak : 33.80 mg/L
----------------------------------------------------------------------
CLINICAL AUDIT VERDICT:
Status : THERAPEUTIC - TARGET EXPOSURE ACHIEVED
Recommendation : Maintain current dosing regimen. Re-check renal function and serum levels in 48-72 hours.
----------------------------------------------------------------------
OPTIMIZED DOSING RECOMMENDATION:
Prescribed Dose : 1000 mg IV every 12 hours
======================================================================
from bio_kinetics.models import DoseEvent from bio_kinetics.population import PatientCovariates, PopulationParameters, VariabilityModel from bio_kinetics.tdm import MeasuredConcentration, BayesianMAPForecaster, ClinicalProtocolAuditor # 1. Define Patient Covariates patient = PatientCovariates( age_years=62.0, weight_kg=78.0, height_cm=175.0, sex="male", serum_creatinine_mg_dl=1.1, ) # 2. Historical Regimen & Sparse Measured Levels doses = [ DoseEvent(time_h=0.0, amount_mg=1000.0, route="infusion", infusion_duration_h=1.0), DoseEvent(time_h=12.0, amount_mg=1000.0, route="infusion", infusion_duration_h=1.0), ] observations = [ MeasuredConcentration(time_h=2.0, concentration_mg_l=29.5, is_peak=True), MeasuredConcentration(time_h=12.0, concentration_mg_l=15.2, is_trough=True), ] # 3. Fit MAP Bayesian Forecaster pop_params = PopulationParameters(theta_cl=4.0, theta_vc=38.0, renal_fraction=0.8) var_model = VariabilityModel(omega_cl=0.25, omega_vc=0.20, sigma_prop=0.10, sigma_add_mg_l=0.1) forecaster = BayesianMAPForecaster(pop_params, var_model, patient) forecast = forecaster.fit_and_forecast( current_doses=doses, observations=observations, target_auc24=500.0, default_interval_h=12.0, ) # 4. Audit Against 2020 ASHP/IDSA Guidelines audit = ClinicalProtocolAuditor.audit_vancomycin( auc24=forecast.steady_state_auc24, trough_mg_l=forecast.steady_state_trough, ) print(f"Status: {audit.status_summary}") print(f"Recommended Dose: {forecast.recommended_dose_mg:.0f} mg q12h")
The test suite validates compartmental kinetics against analytical equations, verifies TMDD saturation non-linearities, and tests Bayesian MAP convergence:
pytest -v
tests/test_cli.py::test_cli_help PASSED
tests/test_cli.py::test_cli_simulate PASSED
tests/test_cli.py::test_cli_tdm PASSED
tests/test_cli.py::test_cli_tmdd PASSED
tests/test_cli.py::test_cli_sde PASSED
tests/test_compartments.py::test_one_compartment_bolus_analytical PASSED
tests/test_compartments.py::test_two_compartment_biphasic_decay PASSED
tests/test_compartments.py::test_oral_absorption_tmax PASSED
tests/test_nlme.py::test_patient_covariates_cockcroft_gault PASSED
tests/test_nlme.py::test_allometric_scaling PASSED
tests/test_nlme.py::test_nlme_cohort_simulation PASSED
tests/test_pd.py::test_direct_hill_emax PASSED
tests/test_pd.py::test_direct_inhibitory_imax PASSED
tests/test_pd.py::test_indirect_response_turnover PASSED
tests/test_sde.py::test_stochastic_pk_euler_maruyama PASSED
tests/test_tdm.py::test_bayesian_map_forecaster PASSED
tests/test_tdm.py::test_clinical_protocol_auditor PASSED
tests/test_tmdd.py::test_tmdd_baseline_equilibrium PASSED
tests/test_tmdd.py::test_tmdd_saturation_nonlinearity PASSED
============================= 19 passed in 9.02s ==============================
- Rybak, M. J., et al. (2020). Therapeutic monitoring of vancomycin for serious methicillin-resistant Staphylococcus aureus infections: A revised consensus guideline and review by the ASHP, IDSA, PIDS, and SIDP. American Journal of Health-System Pharmacy, 77(11), 835-864.
- Mager, D. E., & Jusko, W. J. (2001). General pharmacokinetic model for drugs exhibiting target-mediated drug disposition. Journal of Pharmacokinetics and Pharmacodynamics, 28(6), 507-532.
- Sheiner, L. B., & Beal, S. L. (1980). Evaluation of methods for estimating population pharmacokinetics parameters. I. Michaelis-Menten model: routine clinical pharmacokinetic data. Journal of Pharmacokinetics and Biopharmaceutics, 8(6), 553-571.
- Dayneka, N. L., Garg, V., & Jusko, W. J. (1993). Comparison of four basic models of indirect pharmacodynamic responses. Journal of Pharmacokinetics and Biopharmaceutics, 21(4), 457-478.
This project is licensed under the MIT License - see the LICENSE file for details.