GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - ZengLLQ/bio-kinetics: Non-linear Mixed Effects PK/PD, Target-Mediated Drug Disposition (TMDD) & Bayesian TDM Forecaster

BranchesTags
Open more actions menu

Latest commit

 

History

1 Commit
1 Commit

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
examples
examples
 
 
src/bio_kinetics
src/bio_kinetics
 
 
tests
tests
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
pyproject.toml
pyproject.toml
 
 

Repository files navigation

BioKinetics

CI Python 3.11+ License: MIT Clinical Guideline

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.


Key Features

  • 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).

Architectural Workflow

flowchart TD
    A["Patient Demographics &amp; Labs<br/>(Age, Weight, Height, Scr, Sex)"] --> B["Clinical Biometrics Engine<br/>IBW, ABW, BSA, CrCl"]
    B --> C["Allometric &amp; Covariate Scaler<br/>CL = &theta;<sub>CL</sub> &middot; (WT/70)<sup>0.75</sup> &middot; (CrCl/100)"]
    
    D["Drug Dosing History<br/>(Bolus, Infusion, Oral Schedule)"] --> E["Pharmacokinetic Simulator<br/>1/2/3-Compartment &amp; 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 &amp; Trough Levels)"] --> H["MAP Bayesian Estimator<br/>Objective: Prior Penalty + Data Likelihood"]
    F --> H
    
    H --> I["Empirical Bayes Estimates (EBE)<br/>Individual &eta;<sub>CL</sub>, &eta;<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) &amp; Interval (h)"]
Loading

Mathematical & Pharmacological Foundations

1. Multi-Compartment Linear Pharmacokinetics

For a 2-compartment open model with central volume $V_c$ and peripheral volume $V_p$, the mass transport equations are:

$$\frac{dC_c}{dt} = \frac{\text{Rate}_{in}(t)}{V_c} - \left(\frac{CL}{V_c} + \frac{Q}{V_c}\right) C_c + \frac{Q}{V_c} C_p$$

$$\frac{dC_p}{dt} = \frac{Q}{V_p} C_c - \frac{Q}{V_p} C_p$$

where $CL$ is total systemic clearance, $Q$ is inter-compartmental distribution clearance, and $\text{Rate}_{in}(t)$ represents input from intravenous infusions or oral absorption:

$$\text{Rate}_{oral}(t) = k_a \cdot A_{gut}(t), \quad \frac{dA_{gut}}{dt} = -k_a A_{gut}$$

2. Target-Mediated Drug Disposition (TMDD)

Therapeutic monoclonal antibodies bind with high affinity to target pharmacological receptors $R$, creating reversible drug-target complexes $RC$ that undergo cellular internalization:

$$\frac{dC}{dt} = \frac{\text{Rate}_{in}(t)}{V_c} - \frac{CL}{V_c} C - \frac{Q}{V_c} C + \frac{Q}{V_p} C_p - k_{on} C \cdot R + k_{off} RC$$

$$\frac{dR}{dt} = k_{syn} - k_{deg} R - k_{on} C \cdot R + k_{off} RC$$

$$\frac{d(RC)}{dt} = k_{on} C \cdot R - k_{off} RC - k_{int} RC$$

  • 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$):

$$RO(t) = \frac{RC(t)}{R(t) + RC(t)}$$

          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)       |
      +------------------------------+       +----------------------------+

3. Allometric Scaling & Renal Filtration

Covariate-adjusted clearance and distribution volume are computed using Kleiber's law and the Cockcroft-Gault creatinine clearance formula:

$$CrCl = \frac{(140 - \text{Age}) \cdot \text{Weight}_{kg}}{72 \cdot S_{cr}} \times (0.85 \text{ if female})$$

$$CL_i = \theta_{CL} \cdot \left[ (1 - f_e) \left(\frac{WT_i}{70}\right)^{0.75} + f_e \left(\frac{CrCl_i}{100}\right) \right]$$

$$V_{c, i} = \theta_{V_c} \cdot \left(\frac{WT_i}{70}\right)^{1.0}$$

4. Continuous-Time Stochastic Differential Equations (SDE)

To capture biological clearance drift and physiological blood flow fluctuations, drug concentration is modeled as an Itô diffusion:

$$dC_t = \left(\frac{\text{Rate}_{in}(t)}{V} - \frac{CL}{V} C_t\right) dt + \sigma C_t dW_t$$

Integrated numerically via the Euler-Maruyama algorithm:

$$C_{t+\Delta t} = \max\left(0, , C_t + \left(\frac{\text{Rate}_{in}(t)}{V} - \frac{CL}{V} C_t\right)\Delta t + \sigma C_t \sqrt{\Delta t} Z_t\right), \quad Z_t \sim \mathcal{N}(0, 1)$$

5. Maximum A Posteriori (MAP) Bayesian Forecaster

Given population typical values $\theta$, inter-individual variance matrix $\mathbf{\Omega} = \text{diag}(\omega_{CL}^2, \omega_{V}^2)$, and patient observations $y_k$ at times $t_k$:

$$\min_{\vec{\eta}} \Phi(\vec{\eta}) = \sum_{m} \frac{\eta_m^2}{\omega_m^2} + \sum_{k=1}^K \frac{\left(y_k - \hat{y}(t_k, \vec{\eta})\right)^2}{\sigma_{prop}^2 \hat{y}(t_k, \vec{\eta})^2 + \sigma_{add}^2}$$

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:

$$\text{Dose}_{rec} = \text{Target } AUC_{24} \cdot CL_{ind} \cdot \frac{\tau}{24}$$


Installation

git clone https://github.com/ZengLLQ/bio-kinetics.git
cd bio-kinetics
pip install -e .

For development and test dependencies:

pip install -e ".[dev]"

Command-Line Interface (CLI)

# 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

Sample TDM Clinical Output:

======================================================================
        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
======================================================================

Python API Quickstart

Vancomycin Bayesian MAP Individualization

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")

Verification & Test Suite

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 ==============================

Clinical References

  1. 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.
  2. 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.
  3. 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.
  4. 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.

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

Non-linear Mixed Effects PK/PD, Target-Mediated Drug Disposition (TMDD) & Bayesian TDM Forecaster

Topics

bayesian-estimationmathematical-biologypharmacodynamicspharmacokineticspk-pdpythonscientific-computingsystems-biologytherapeutic-drug-monitoringtmdd

Resources

Readme
MIT license
Activity

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.