Skip to content

quant: report MBR quantities at one consensus elution width per precursor - #150

Merged
ypriverol merged 2 commits into
mainfrom
quant/consensus-width-quantity
Oct 14, 2026
Merged

ypriverol merged 2 commits into
mainfrom
quant/consensus-width-quantity

Conversation

@ypriverol

@ypriverol ypriverol commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The extract fit picks each (precursor, run) elution width from the grid {0.7, 1, 1.4} × w_prior, so a precursor's reported area A · w · √(2π) can jump by 40% between runs on the width pick alone. This PR fixes that in two steps:

  1. One consensus width per precursor (quant finalize). Reported quantities use A · w_p · √(2π), where w_p is the median over the precursor's identified fits in aligned runs of w / f_r', carried into each run by that run's local alignment slope. Transfers use the same w_p. Unaligned runs and precursors with no identified fit keep the per-run area. extract.parquet keeps the per-run quantity for provenance. Documented in DOCS.md.
  2. Continuous width refinement (quant extract). After the grid search, a golden-section search on log w refines the width at the winning apex. It searches between the winning grid width's neighbours, one step beyond the grid ends. The grid width is kept unless the search finds a higher LLR. fit and fit_many share the arithmetic and stay identical.

ProteoBench LFQ DDA (6 Orbitrap runs, min_runs 3), one change per A/B

Same stage-1 search, library and alignment for every arm. Only extract and finalize differ.

arm mode nr_prec median abs eps eq_species ECOLI mean abs eps CV median ROC AUC
main id 50,297 0.2518 0.2954 0.3592 0.3825 0.2474 0.9049
+ consensus width id 50,297 0.2298 0.2561 0.2820 0.3461 0.2415 0.9189
+ continuous width id 50,283 0.2258 0.2535 0.2814 0.3342 0.2374 0.9216
main MBR 54,503 0.2531 0.3067 0.3822 0.3870 0.2508 0.9112
+ consensus width MBR 54,503 0.2297 0.2571 0.2813 0.3466 0.2446 0.9240
+ continuous width MBR 54,663 0.2254 0.2531 0.2758 0.3331 0.2397 0.9268

Net vs main (MBR): median abs eps −11%, eq_species −17%, ECOLI −28%, CV −4%, +160 precursors.

A third candidate was tested and left out: a signal-dependent noise term in the isotope exclusion test, which fixed the test firing on 96% of identified peaks. It regressed accuracy against the second step on every metric (id median abs eps 0.2258→0.2271, eq_species 0.2535→0.2574, ECOLI 0.2814→0.2908, −92 id precursors), with +446 MBR precursors as its only gain. It needs more work before it ships.

Test plan

  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo test --release --workspace with the CI skips: 1,412 passed, 0 failed
  • Out-of-core PIN goldens (--ignored): 4 passed
  • rustfmt clean on the changed files
  • New unit tests: consensus-width finalize (per-run vs consensus quantities, extract rows unchanged), width refinement (width recovered between grid points; golden-section search finds the maximum and never loses the start)

Summary by CodeRabbit

  • Improvements
    • Match-between-runs reports now use a shared precursor-level elution width for identified and transferred results from aligned runs, improving consistency across runs. Results without an eligible identified fit, and results from unaligned runs, continue to use per-run quantities.
    • Elution-width fitting can refine estimates between grid values for more precise results.
  • Documentation
    • Clarified how reported quantities and extracted per-run measurements use elution widths.

The extract fit picks the elution width per run from {0.7, 1, 1.4} x w_prior,
so one precursor's area A * w * sqrt(2 pi) jumps by 40 % between runs with
the width pick alone. Finalize now reports A * w_p * sqrt(2 pi) (and
amplitude_se * w_p * sqrt(2 pi)): w_p is the median over the precursor's
identified fits in aligned runs of w / f_r', carried into each run by that
run's local alignment slope. Unaligned runs and precursors without an
identified fit keep the per-run area; extract.parquet keeps the per-run
quantity.
The width grid {0.7, 1, 1.4} x w_prior quantises every fitted width to one of
three values, and the width-prior fits' binned medians collapse onto the
default. After the grid search the width is now refined at the winning apex by
a golden-section search on log w between the winning grid width's neighbours
(one grid step beyond the grid's ends), keeping the grid width unless the
search finds a higher LLR. fit and fit_many share the arithmetic, so they stay
identical.
@qodo-code-review

Copy link
Copy Markdown

ⓘ Qodo reviews are paused because the subscription is no longer active. Ask your workspace admin to reactivate the subscription to resume reviews. Manage billing

@coderabbitai

coderabbitai Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 30bda1be-c576-4d8b-ab27-7296369a39ec
📥 Commits

Reviewing files that changed from the base of the PR and between 1e49397 and 09681e5.

📒 Files selected for processing: 3
  • DOCS.md
  • crates/andes/src/bin/andes/quant_mbr.rs
  • crates/quant/src/evidence.rs

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

📝 Walkthrough

The change refines fitted widths between grid values and uses median slope-adjusted widths to calculate reported quantities and standard errors for eligible aligned MBR rows. Rows without an eligible width and rows from unaligned runs retain their extract quantities.

Changes: MBR width reporting

Layer / File(s) Summary
Refine fitted widths
crates/quant/src/evidence.rs
best_alignment refines the selected grid width in log space. Tests cover width recovery, maximization, and width-bracket behavior.
Report quantities with consensus widths
crates/andes/src/bin/andes/quant_mbr.rs, DOCS.md
MBR output uses the median slope-adjusted width from eligible identified fits to calculate aligned-row quantities and standard errors. Other rows retain extract values. Tests and documentation cover the calculation and fallback rules.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 09681

This change refines fitted elution widths and reports MBR quantities at one consensus width per precursor. The summaries show no concrete merge-blocking risk, and the documentation and tests match the described behavior.

Pre-merge checks: Passed 5
Passed Passed checks: 5 passed
Check name Status Explanation
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 21 functions across 2 files. (1 skipped: 1…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: reporting MBR quantities at one consensus elution width per precursor.
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@ypriverol
ypriverol merged commit cb8e5f5 into main Oct 14, 2026
5 checks passed
@ypriverol
ypriverol deleted the quant/consensus-width-quantity branch October 15, 2026 16:05
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