Skip to content

quant: identity decoys and a donor gate for the MBR transfer FDR - #172

Merged
ypriverol merged 7 commits into
mainfrom
quant/donor-identity-fdr
Oct 18, 2026
Merged

ypriverol merged 7 commits into
mainfrom
quant/donor-identity-fdr

Conversation

@ypriverol

Copy link
Copy Markdown
Contributor

The flaw

#167 added peak-shape agreement with the donor run's identified fits as transfer features. A wrong donor identification usually sits on a real MS1 feature (another analyte's peak) that recurs in every run with the same width, tailing and isotope heights. Its transfers therefore look perfect.

The transfer decoys (mass shift, RT shift) only model "right peptide, wrong peak". So the transfer q-value cannot see false donors.

Measured on a public LFQ benchmark (6 runs, HYE plus a 1:1 shuffled entrapment, ALL rule, entrapment factor 1.91), on the same stage 1, transfer q 0.01:

before #167 main
transferred entrapment rows 48 728
entrapment-only precursors (min 3) 0.26 % 0.68 %
false donor transferred, vs an average donor ~3× less likely ~1.5× more likely

Design

  1. Identity decoys.
    • Decoy precursors that pass the library entry gate with decoy PSMs at the donor thresholds become entries flagged identity_decoy, measured exactly like targets: identified rows in their donor runs, transfers elsewhere.
    • Their observations join the alignment after the fit (Alignment::add_observations), so they never move a run map.
    • They are left out of the width prior, the identified quality model and the normalisation, and never reach mbr.tsv or the feature parquet.
    • In finalize, their transfer target probes are a decoy family. They are negatives of the cross-validated classifier, held out by the same folds.
    • The transfer q-value becomes (D + 1) / (K · T) + D_id / T. The first term is the wrong-peak estimate as before; D_id is the identity-decoy transfers at or above the threshold.
    • Under target-decoy competition (the assumption the PSM q-values already rest on), a decoy PSM passing the donor thresholds is as likely as a false target PSM passing them, and it too sits on a real feature. So each identity-decoy entry stands for one false target entry, with no scaling.
    • The two error classes overlap, so the sum is conservative.
  2. Stricter donor for transfer. An entry whose best donor PSM has PSM q > 0.001 is not transferred. Its identified rows are unchanged; its transfers are below_threshold without a q-value.
    • Donor PSM score, q-value and PEP as features were tested and dropped. They had no effect, since a target and its wrong-peak decoys share them.

Other changes:

  • library.parquet goes to schema 4 (identity_decoy, donor_score, donor_psm_q, donor_psm_pep).
  • The validation file and finalize log gain per-family decoy acceptance (mass / RT / identity), the transfers the wrong-peak decoys alone would accept, and donor_gated.
  • DOCS.md explains the estimate.

Calibration. The identity-decoy estimate of the false-donor share of accepted transfers matches the entrapment:

transfer q identity-decoy estimate entrapment
0.01 0.25 % 0.24 %
0.05 0.40 % 0.39 %

Without the donor gate it is 0.49 % vs 0.43 % at 0.01, and 1.52 % vs 1.61 % at 0.05.

A/B

Quant-only, same stage 1. In the precursor columns each cell is precursors (min 3) / median |eps| / E. coli |eps| / CV, normalised.

Base stage 1. Entrapment rows come from the entrapment search; the other columns come from a public LFQ benchmark scored on the non-entrapment search. "Matched depth" is the operating curve at 63.7k precursors (min 3).

arm entrapment transferred rows, q .01 / .05 q 0.01 q 0.05 matched depth eps / E / CV wrong-peak, q .01
before #167 48 / 537 54,932 / .155 / .212 / .110 67,035 / .164 / .317 / .124 .161 / .272 / .120 1.02 %
main (#167) 728 / 1,199 67,586 / .164 / .302 / .120 73,203 / .177 / .471 / .134 .159 / .258 / .114 1.79 %
identity decoys, scored only 86 / 1,103 56,022 / .152 / .209 / .106 72,119 / .173 / .427 / .131 .160 / .263 / .115 1.35 %
identity decoys, trained 148 / 1,044 63,238 / .161 / .261 / .117 72,044 / .173 / .429 / .131 .161 / .267 / .117 1.63 %
donor PSM features 714 / 1,205 67,537 / .164 / .306 / .120 73,176 / .177 / .462 / .134 .159 / .252 / .114 1.79 %
donor PSM q ≤ 0.001 125 / 229 64,150 / .164 / .297 / .121 68,197 / .174 / .439 / .133 .163 / .290 / .120 1.83 %
identity trained + donor features 157 / 1,048 63,183 / .161 / .257 / .117 72,059 / .173 / .427 / .131 .161 / .263 / .117 1.63 %
this PR: identity trained + donor q ≤ 0.001 88 / 222 62,797 / .162 / .273 / .118 68,017 / .173 / .431 / .132 .163 / .295 / .120 1.73 %

Rescoring + chimeric stage 1:

arm entrapment transferred rows, q .01 / .05 q 0.01 q 0.05
before #167 51 / 622 65,098 / .162 / .241 / .114 77,206 / .173 / .339 / .128
main 793 / 1,319 78,531 / .173 / .347 / .124 85,965 / .188 / .530 / .138
this PR 104 / 231 74,225 / .170 / .308 / .122 81,437 / .184 / .482 / .137

Entrapment-only precursors at min 3, q 0.01:

stage 1 this PR main before #167
base 0.24 % 0.68 % 0.26 %
rescoring + chimeric 0.30 % 0.66 % –

Precursors at min 1 do not change. At min 6, q 0.01 (base): 39,507 with this PR, 44,076 on main, 27,430 before #167.

Decoy acceptance per family at q 0.01 (base, this PR): mass shift 0.34 %, RT shift 0.34 %, identity 30.5 %. Identity decoys are accepted at 52–71 % at q 0.05 without the gate, which is the blind spot itself.

Trade-off.

Sanity checks.

  • With identity decoys in the library but left out of finalize, the experiment build reproduces main's mbr.tsv exactly.
  • With the shape features off, it reproduces before-quant: compare a transfer's peak shape with its donor fits #167 exactly.
  • The PR build gives the same mbr.tsv and validation byte for byte as that A/B arm.

Operating point

The transfer q-value now counts false donors too, so it is closer to an honest total error. Recommendation: change the --mbr-fdr default from 0.05 to 0.01 (not done here; one variable per PR).

--mbr-fdr precursors (min 3) median |eps| E. coli CV
0.01 62.8k 0.162 0.273 0.118
0.05 68.0k 0.173 0.431 0.132
0.05, before #167, for comparison 67.0k 0.164 0.317 0.124

So 0.05 adds 5.2k precursors at a large accuracy cost, and is worse than the old 0.05 at the same depth.

Tests

  • Identity decoys go through the same path as targets: same extract rows and fits as the target version of the same precursor.
  • A decoy donor on a real recurring feature is accepted like a true transfer and counted in the identity term, which lifts the targets' q-values above the wrong-peak estimate.
  • Identity-decoy rows never reach mbr.tsv, the features or the identified rows.
  • Covered as well:
    • the donor gate;
    • add_observations leaves the fit unchanged;
    • library schema 4 round-trips;
    • the K-decoy estimate with the identity term;
    • the validation columns.

Gate with the pinned 1.87 toolchain:

  • clippy -D warnings: clean;
  • cargo test --release --workspace with the CI skips: 1,588 passed, 0 failed;
  • rustfmt: clean on changed lines.

Decoy precursors that pass the library entry gate and donor rules with
their decoy PSMs become identity-decoy entries. They are aligned without
moving the run maps, extracted like targets and, in finalize, scored by the
transfer models; their accepted transfers estimate the transfers of false
donor identifications, which the mass- and RT-shift decoys cannot model.
Identity-decoy rows are never reported. The transfer model also takes the
best donor PSM's score, q-value and PEP, and an optional donor PSM q-value
for transfer. library.parquet goes to schema 4.
…PSM q-value gate

The A/B kept identity decoys as training negatives with the combined
estimate, and a best-donor PSM q-value of 0.001 for transfer; donor PSM
score, q and PEP as features did not change the result and are dropped.
@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 17, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 32 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e212d04e-475f-487e-9cb1-c8e462f5fe83
📥 Commits

Reviewing files that changed from the base of the PR and between bfe66d3 and 92764c2.

📒 Files selected for processing: 8
  • DOCS.md
  • crates/andes/src/bin/andes/quant_cmd.rs
  • crates/andes/src/bin/andes/quant_mbr.rs
  • crates/andes/src/transfer_fdr.rs
  • crates/output/src/library_table.rs
  • crates/output/src/mbr_out.rs
  • crates/quant/src/align.rs
  • crates/quant/src/library.rs
  • 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.

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