Skip to content

fix(renal): account for passive tubular reabsorption - #110

Open
jam-sudo wants to merge 1 commit into
mainfrom
fix/renal-tubular-reabsorption
Open

jam-sudo wants to merge 1 commit into
mainfrom
fix/renal-tubular-reabsorption

Conversation

@jam-sudo

Copy link
Copy Markdown
Owner

Summary

_estimate_renal_clearance previously used CL_renal = GFR * fup for every compound, the zero-permeability limit in which filtered drug is never reabsorbed. This overestimates renal clearance for permeable, weakly protein-bound compounds. The new one-region, well-stirred tubule balance uses the existing peff prediction:

CL_renal = fup * UF * (GFR + PS) / (UF + PS), with PS = peff * TSA, urine flow UF = 0.06 L/h, and effective surface area TSA = 57.8 cm².

This is the single-region reduction of Scotcher et al. 2016, algebraically identical to its fup * GFR * (1 - F_reabs) form, where F_reabs = F' * (1 - UF/GFR) and F' = PS / (PS + UF). It recovers fup * GFR as PS -> 0 and approaches fup * UF as PS -> infinity. The effective surface area is back-calculated from that paper's own F' = 0.5 calibration at Caco-2 Papp 14.8e-6 cm/s, through the existing adme._CACO2_TO_INVIVO_OFFSET. It was never fitted to this project's Cmax loss, consistent with Invariant #8.

This model does not cover active tubular secretion, pH/ionisation-dependent uptake, or peff uncertainty; the returned CV still tracks fup only.

Validation

The change ships on correctness. Its 107-drug holdout headline is neutral: Meta AAFE 2.7428 -> 2.7416 (delta -0.0012), Engine 4.2779 -> 4.2548 (delta -0.0232), and ML unchanged. Meta 2-fold and 3-fold coverage are unchanged; Engine 2-fold coverage is unchanged, while 3-fold coverage moves 43.9% -> 43.0%. Engine Cmax moves for 37/107 drugs, each by no more than 4%. The local stack reproduces the committed cache bit-identically, and DE-43 already documents how fixed meta weights damp engine changes; renal is a minor elimination route for most holdout drugs. The holdout cache was not regenerated on macOS.

Renal CL fold error versus clinical values improves for caffeine 52.6 -> 13.0, antipyrine 25.6 -> 5.3, theophylline 10.9 -> 3.4, paracetamol 9.5 -> 3.4, and midazolam 11.9 -> 3.4. Secretion-dominant metformin, atenolol, and lisinopril remain underpredicted, as expected without secretion. Full results are in data/validation/renal_reabsorption_2026-09-22.json.

  • Full suite: 1,307 passed, 14 skipped, 6 xfailed, 1 xpassed.
  • ruff check src tests: passed.
  • python3 scripts/check_no_internal_refs.py: passed.

Use the published one-region tubule balance with the existing permeability estimate. Anchor the effective surface area to the Scotcher calibration point, without fitting to Cmax loss.

Document the model limits and out-of-scope mechanisms, add focused checks, and record the headline-neutral validation.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-23T03:40:47.528251Z a6c1fd6 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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

Copy link
Copy Markdown

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: a6c1fd6afe

ℹ️ 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".

"""
cl_renal = _GFR_L_PER_H * fup.mean
# peff (x10^-4 cm/s) * TSA (cm^2) -> L/h
ps_l_per_h = peff.mean * 1e-4 * 3600.0 * _TUBULAR_SURFACE_AREA_CM2 / 1000.0

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Recompute renal clearance after Peff posterior updates

When SBI or TDM varies Peff, apply_theta_to_drug, _build_drug_from_3d, and _apply_multipliers replace drug.peff while deliberately retaining the nominal renal_clearance. After making clearance depend on peff.mean here, those posterior particles therefore simulate absorption with the updated Peff but elimination with clearance derived from a different Peff, biasing inference for high-fup or renally cleared drugs. Recompute renal clearance whenever these paths update Peff, or derive it dynamically from the current drug parameters.

Useful? React with 👍 / 👎.


# Estimate renal clearance
renal_cl = _estimate_renal_clearance(adme.fup, profile)
renal_cl = _estimate_renal_clearance(adme.fup, adme.peff)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Retrain the surrogate with the new renal model

The shipped surrogate and its training generator still use filtration-only clearance: scripts/train_surrogate.py:123 constructs renal_clearance=7.5*fup, whereas production drugs now receive this Peff-dependent value. Because the training data made renal clearance collinear with fup and never modeled its Peff interaction, the existing range guard can accept these inputs while returning predictions learned from the old elimination dynamics; even rerunning the current training script would preserve the mismatch. Update the generator and regenerate the surrogate artifacts before using the surrogate MC/TDM backends.

Useful? React with 👍 / 👎.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant