Skip to content

Add modular QSP plugin system with turnover biomarker model#7

Closed
jam-sudo wants to merge 1 commit intomainfrom
codex/add-modular-qsp-layer-with-turnover-model
Closed

Add modular QSP plugin system with turnover biomarker model#7
jam-sudo wants to merge 1 commit intomainfrom
codex/add-modular-qsp-layer-with-turnover-model

Conversation

@jam-sudo
Copy link
Copy Markdown
Owner

Motivation

  • Add a modular QSP layer so mechanistic biomarker/cytokine models can be run driven by PBPK concentration signals.
  • Support both a simple post-hoc workflow and an optional coupled PBPK+QSP solve to enable tighter integration when needed.

Description

  • Introduce a new physio_sim.qsp package with BaseQSPModel interface, a model registry (register_qsp_model, get_qsp_model, list_qsp_models), and a built-in turnover model (physio_sim/qsp/models/turnover.py).
  • Add QSP schema and loader (QSPConfig, load_qsp) in physio_sim/config.py and an example YAML examples/qsp_turnover.yaml describing kin, kout, emax, ec50_mg_per_L, hill, and optional B0.
  • Extend the solver (physio_sim/pbpk/solver.py) to support posthoc (default) QSP solving using interpolated plasma signal and an optional coupled mode that augments PBPK state vector and solves PBPK+QSP together with solve_ivp(method="BDF") (kept optional behind qsp_mode).
  • Add CLI non-breaking flags in physio_sim/cli.py: --qsp-model, --qsp-config, and --qsp-mode posthoc|coupled, and append QSP state columns (e.g., B_biomarker) to timecourse.csv and add Bmax, t_Bmax, Bend to summary.json when QSP is enabled.
  • Add documentation (docs/qsp.md, docs/qsp_models.md), README quickstart snippet, and unit/cli tests (tests/test_qsp_turnover.py, tests/test_cli_qsp_smoke.py).

Testing

  • Ran formatting and linting: python -m ruff format . and python -m ruff check . which completed without failures.
  • Ran static typing checks: python -m mypy physio_sim which completed with no issues reported.
  • Ran the test suite: python -m pytest -q and all tests passed (18 passed).

Codex Task

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d05a97a079

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread physio_sim/pbpk/solver.py
@jam-sudo
Copy link
Copy Markdown
Owner Author

I applied PR #7 conceptually on by manually merging its intended changes (QSP plugin CLI integration + turnover model coupling path). Resolved conflicts with current branch state, validated locally (, , on touched files), then closed PR #7 since upstream content is now represented in commit 0382ac9 on main.

@jam-sudo
Copy link
Copy Markdown
Owner Author

I applied PR #7 intent on main (QSP plugin CLI integration + turnover model coupling path) by manual merge due conflict. Conflicts were resolved against current branch state, validated locally (pytest, mypy, ruff on touched files), and committed as 0382ac9 on main. Closing PR #7 as superseded by manual merge.

@jam-sudo jam-sudo closed this Feb 25, 2026
@jam-sudo jam-sudo deleted the codex/add-modular-qsp-layer-with-turnover-model branch February 25, 2026 20:42
jam-sudo added a commit that referenced this pull request Mar 22, 2026
Data fixes (6 entries, cross-referenced against FDA labels):
  valacyclovir: dose 20→1000mg (FDA Valtrex: 1g dose for acyclovir Cmax)
  carglumic acid: flagged uncertain (mg/kg dosing in pediatric label)
  darifenacin: dose 400→15mg (max clinical dose is 15mg)
  sertraline: Cmax 0.165→0.033 (FDA Zoloft 50mg: 33 ng/mL)
  ketorolac: dose 10→30mg (Cmax 2.52 matches 30mg FDA Toradol)
  cetirizine: dose 60→10mg (FDA Zyrtec: 10mg Cmax=311 ng/mL)

AD filter refinement:
  - Thienopyridine SMARTS fixed: [#7]1[#6][#6]c2[#16]ccc2[#6]1 (catches clopidogrel)
  - Extreme lipophilicity threshold: logP 6.0→5.5 (catches sonidegib logP=5.2)

In-domain holdout (54 drugs):
  AAFE: 1.923 [1.691, 2.206]
  %2-fold: 63.0%   %3-fold: 85.2%

Session total: AAFE 3.520 → 1.923 (-45.4%), zero model changes.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
jam-sudo added a commit that referenced this pull request Mar 23, 2026
… correction

## Summary
Comprehensive pipeline improvement across 10 tasks:

### Data Quality (Tasks 1, 8, 9)
- Fix 5 platinum reference Cmax values (diclofenac, posaconazole, lenacapavir,
  valganciclovir, pindolol) — unit errors, route mismatch, extraction errors
- Add DDI-boosted flags for lopinavir and darunavir
- Add nucleoside 5'-ester SMARTS for molnupiravir prodrug detection
- Fix val-ester SMARTS false positive on penicillamine
- First AUC validation with MMPK (32 drugs): AAFE 3.205
- Lombardo/Obach VDss cross-validation (17 drugs): AAFE 3.71

### Pipeline Constants (Tasks 4, 5)
- Revert 4 Optuna constants to pre-Optuna defaults (gut_threshold 2.6,
  peff_min 0.5, pgp 0.5, gse 0.5) — MMPK tuning doesn't generalize
- Verify ODE >> analytical for Cmax on clinical data (AAFE 2.41 vs 11.64)

### UQ System (Task 6)
- Recalibrate AdaptiveConformal: 68 clean drugs, k=30
  Coverage: 93.7% in-domain (was 97% over-wide), width 20.6x (was 4880x)
- Replace broken LHS AUC/t½ CI with Cmax q-value heuristic scaling

### VDss Fix (Task 10)
- Weighted geometric mean (XGB^0.7 × Berez^0.3) always applied for t½
  Core-24 AUC AAFE: 2.344 → 2.142 (-8.6%), Cmax unchanged

### Metrics & Documentation (Tasks 2, 3, 7)
- First Spearman ρ measurement: 0.9379 in-domain (excellent ranking)
- CLAUDE.md: revoke KD#3/#7/#14, add KD#32-41, update performance
- Holdout benchmark: in-domain stratification, DDI-boosted exclusion
- CYP3A4 classifier trained but deferred (AUROC 0.634, no holdout impact)

## Results
- Core-24 Cmax AAFE: 1.977 → 1.879 (-5.0%)
- Core-24 AUC AAFE:  2.344 → 2.142 (-8.6%)
- Holdout ALL:       2.780 → 2.440 (-12.2%)
- Holdout IN-DOMAIN: first measured = 1.966 (under 2.0)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant