Skip to content

quant finalize: bagged transfer classifier and neighbour donor rate for seed-stable transfer q-values - #207

Merged
ypriverol merged 3 commits into
quant/finalize-mapreducefrom
quant/transfer-fdr-stable
Oct 21, 2026
Merged

ypriverol merged 3 commits into
quant/finalize-mapreducefrom
quant/transfer-fdr-stable

Conversation

@ypriverol

@ypriverol ypriverol commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #203 (quant/finalize-mapreduce).

Problem

On a 500-run LFQ study (464 M extract rows), changing only quant finalize --seed on the same extract tables churned the accepted transfers: two seeds shared 49 % of the transfers accepted at transfer q 0.01 (66 k vs 96 k accepted) and 82 % at 0.05 (11 % of the accepted set lost). The transfer classifier is one GBDT per fold trained on a 2.8 M-row sample of 359 M rows (held-out AUC 0.655).

Root cause (one variable at a time, 3 seeds each, 500 runs)

  • Each seed component alone moves the accepted set by about as much as all three together: folds 8.4 %, training sample 9.5 %, trainer seed alone (same rows, other validation split) 6.2 % of the q 0.05 set lost. It is the variance of one boosted model, not the folds or the q-value construction.
  • More rows do not help: 11 M and 45 M training rows give Jaccard 0.862 and 0.865 at q 0.05 (0.64 at q 0.01). Pooling the folds' step functions, sampling whole precursors, larger leaves, depth 4/8, more rounds or a higher learning rate do not help either (several are worse).
  • Score noise is row-level (93 % of the between-seed variance of score percentiles is within precursors), so it averages out over independently trained models: 5 members Jaccard 0.911, 10 members 0.931, 20 members 0.944 at q 0.05.
  • Features: the donor-run count and library q-value carry most of the separation from identity decoys (zeroing them drops acceptance from 3.3 M to 1.0 M and doubles the identity decoys accepted). The share of the acceptor run's most similar runs that identified the precursor separates better at scale (held-out AUC 0.655 → 0.662) and accepts 1.5× the transfers at q 0.05.

Change

  • Bagged transfer classifier: each fold's score is the mean margin of --transfer-models GBDTs (hidden flag, default 8, 1–64), each trained on its own hashed sample with its own seed. --transfer-models 1 reproduces the single model exactly. The identified-row classifier is unchanged.
  • New transfer feature neighbour_donor_rate: the share of the 50 runs most similar to the transfer's run (Jaccard index of the target entries each run identified) that identified the precursor. It uses donor runs only, is computed the same way for target and decoy precursors, and never counts the row's own run, so a pseudo-transfer does not see its own identification.
  • Pass 3 keeps each run's held-out transfer scores in a temporary Parquet table; pass 5 reads them instead of scoring the transfer rows again, so the members score each row once.

Results

500 runs, 3 seeds (42, 1, 7), mean pairwise Jaccard of the accepted (precursor, run) transfer sets and accepted counts:

arm Jaccard q 0.01 accepted q 0.01 Jaccard q 0.05 accepted q 0.05 finalize wall (16 threads, no outputs)
before (1 model) 0.493 66 k – 98 k 0.817 3.21 M – 3.31 M 8–10 min
neighbour rate, 1 model 0.569 192 k – 238 k 0.858 4.89 M – 4.92 M 7.5–8 min
this PR (neighbour rate, 8 models) 0.787 255 k – 284 k 0.943 5.02 M – 5.04 M 17–19 min
neighbour rate, 16 models 0.840 270 k – 292 k 0.957 5.03 M – 5.05 M 29–31 min

Validation counts at 500 runs: pseudo-transfers accepted at q 0.05 rise from 26.5 % to 38.9 % at a wrong-peak rate of 4.3 % (4.0 % before); identity decoys accepted at q 0.05 are 0.24 % of the accepted transfers (0.14–0.19 % before; the pooled estimate counts them), and 0–2 at q 0.01.

Six-run LFQ benchmark (HYE, and HYE + 1:1 entrapment), default seed: precursors in at least 3 runs, median |log2 error|, E. coli error, CV and the four abundance quartiles are within ±0.1 % of the parent branch at q 0.01 and 0.05 (62,813 vs 62,797 precursors at q 0.01; 68,026 vs 68,017 at q 0.05). Entrapment-measured FDP of transferred rows 0.25 % vs 0.24 % at q 0.01 (93 vs 88 entrapment rows of 71.4 k vs 70.7 k) and 0.40 % vs 0.39 % at q 0.05; identity-decoy estimate 0.254 % and 0.395 % (0.255 %, 0.394 % before). At six runs the neighbour rate is the donor count over 5 and gives the same trees (single model output byte-identical to the parent); the change there is the bagging: seed-to-seed lost transfers 4.5 % → 3.2 % at q 0.01.

Gate

cargo clippy --locked --workspace --all-targets -- -D warnings clean; cargo test --locked --release --workspace 1727 passed, 0 failed. New tests: one member equals the single model, bagged score is the mean of the members, bagging keeps a synthetic mixture calibrated and steadier across seeds, TrainingSample::wants, finalize with 3 members reproducible across batchings with every row reported. The map-reduce equivalence test still checks the score cache byte for byte.

Not done

  • At q 0.01 two seeds still share 79 % (16 members: 84 %): part of the remaining churn is the accepted count itself (255 k to 284 k), set by a few thousand mass-shift decoys at the top of the ranking.
  • Runtime and memory, 500 runs with every output written (16 threads): 18.3 min at 12.2 GB peak vs 9.7 min at 7.5 GB for the parent. Held-out scoring 539 s vs 94 s (it is per member); the output pass is faster (110 s vs 153 s) because it reads the cached transfer scores. The members' samples hold about 4.7 GB; storing them as flat feature arrays would cut that.

…ure, cached transfer scores

The transfer classifier of each fold is now the mean margin of
--transfer-models GBDTs (default 8), each trained on its own hashed sample
of the training rows with its own seed; --transfer-models 1 is the single
model. On 500 runs one model trained on a sample of 2.8 of 359 million
rows moved the accepted transfers between seeds (Jaccard 0.49 at transfer
q 0.01, 0.82 at 0.05) and more rows did not help.

New transfer feature neighbour_donor_rate: the share of the 50 runs most
similar to the transfer's run (Jaccard index of the target entries they
identified) that identified the precursor. Computed from the donor runs
only, the same for target and decoy precursors, never from the row's own
run.

Pass 3 keeps each run's held-out transfer scores in a temporary table and
pass 5 reads them instead of scoring the transfer rows again.
@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 20, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3b2428c1-97c3-484c-a4db-ba1e28e6f97b

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • 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

Copy link
Copy Markdown
Contributor Author

Entrapment check at 500 runs (all PXD042233 runs; study FASTA + 1:1 shuffled entrapment twins; ALL-accessions rule with the I/L rescue; factor 1.940). Same search, library and extracts for every arm; finalize with seeds 42 / 1 / 7.

Arms: A = parent #203 (1 model, no feature); B = 8 members, neighbour_donor_rate held at 0; C = this PR's default (8 members + feature); D = 1 model + feature.

Entrapment-measured false-donor share of accepted transfers vs the identity-decoy estimate (pooled over seeds, 95 % Poisson CI):

arm q 0.01 accepted / FDP / estimate q 0.05 accepted / FDP / estimate seed Jaccard q 0.01 / q 0.05
A 55–72 k / 0.004 % (0.001–0.011) / 0.002 % 2.94–2.98 M / 0.138 % (0.135–0.141) / 0.174 % 0.476 / 0.803
B 63–72 k / 0.002 % (0.000–0.007) / 0.002 % 3.10–3.13 M / 0.121 % (0.118–0.124) / 0.157 % 0.654 / 0.920
C 172–186 k / 0.003 % (0.001–0.006) / 0.007 % 4.73–4.75 M / 0.206 % (0.203–0.209) / 0.273 % 0.681 / 0.941
D 123–175 k / 0.007 % (0.004–0.011) / 0.006 % 4.62–4.67 M / 0.217 % (0.213–0.220) / 0.277 % 0.509 / 0.850
  • In arm C the measured share is at or below the identity-decoy estimate at both thresholds, in every seed (ratio 0.74–0.77 at q 0.05, the same ratio as the parent's 0.71–0.95).
  • The feature raises the absolute false-donor share at q 0.05 (B 0.121 % → C 0.206 %), and the estimate rises with it, so the pooled q still accounts for it.
  • Entrapment tests only false-donor transfers. The wrong-peak part of the estimate (about 4.7 % at q 0.05) is not checked by this design; the pseudo-transfer wrong-peak rate at q 0.05 goes 3.9 % (A/B) → 4.05 % (C).
  • Identification: Percolator PSMs at q 0.01 measure 0.81 % (factor 1.940); identified quant rows 0.195 %.
  • Coverage gain from C over A at q 0.05: +6.8 k precursors at min 50 runs, +6.3 k at min 100.

Verdict: by the agreed rule (measured transfer FDP at or below the estimate, within CI, at q 0.01 and 0.05), the feature can ship by default with 8 members.

@ypriverol
ypriverol merged commit 3db3158 into quant/finalize-mapreduce Oct 21, 2026
1 check passed
ypriverol added a commit that referenced this pull request Oct 21, 2026
Bagged transfer classifier and neighbour_donor_rate (re-land of #207)
@ypriverol
ypriverol deleted the quant/transfer-fdr-stable branch November 4, 2026 07:38
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