Skip to content

Peptide-level shuffled entrapment with a measured T/E; true FDP re-measured - #237

Merged
ypriverol merged 5 commits into
mainfrom
fix/peptide-level-entrapment
Oct 22, 2026
Merged

ypriverol merged 5 commits into
mainfrom
fix/peptide-level-entrapment

Conversation

@ypriverol

@ypriverol ypriverol commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #225

Problem

docs/benchmarks/glyco/build_shuffled_entrap.py shuffled whole proteins. That moves K and R, so most entrapment peptides have no target of the same composition: 89.6% on the HYE database and 91.7% on mouse (cleavage after every K/R, ≤ 2 missed cleavages, 7–40 residues). It also printed a fixed "factor 2 (exactly 1:1)". In peptide space that database has T/E 0.964 (HYE) and 0.971 (mouse), not 1.

Change

  • docs/benchmarks/build_shuffled_entrap.py replaces the glyco-folder script; nothing else imported the old one. It builds the entrapment peptide by peptide, following the peptide-level entrapment construction of Wen et al., Nat. Methods 2025:
    • It digests each target protein into fully cleaved tryptic peptides. By default it cuts after every K/R, including before P, which matches andes trypsin. With --proline-rule it does not cut before P and keeps every K, R and P in place.
    • It shuffles each peptide with the C-terminal residue fixed.
    • A repeated peptide gets the same shuffle everywhere.
    • A shuffle that equals a target peptide (I/L folded) is drawn again, up to 100 times.
    • It writes the targets followed by ENTRAP_ proteins, deterministic per --seed.
    • It prints the T/E it measured with entrap_common.py te, never a fixed factor.
  • entrap_common.py: the T/E k-mer screen now checks every k-mer of a peptide before the substring scan. The result is the same; on HYE the run drops from 58 to 16 minutes.
  • build_databases.sh (GLYCO=1 mouse database), the phospho recipe (hits counted with entrap_common.py count and the measured T/E instead of "2 × hits") and the reproduce and glyco READMEs are updated.
  • Tests (stdlib, python3 -I docs/benchmarks/tests/test_entrap.py) check:
    • the C-terminal residue and cleavage sites are kept;
    • each peptide keeps its composition;
    • K/R/P stay in place under the proline rule;
    • no shuffle collides with a target peptide (I/L folded), and a forced collision is reported;
    • identical peptides are shuffled the same way;
    • the same seed gives the same file;
    • the measured T/E is printed;
    • an input that already has entrapment entries is refused.

Re-measurement (andes 0629cd8, Percolator 3.7.1 -Y, seeds 42/1/2, ALL rule + I/L rescue)

Every design uses the same targets, binary and search. Three designs were compared: the old whole-protein shuffle (the databases behind the published numbers), three peptide-level realisations (builder seeds 1/2/3), and reviewed Arabidopsis (UP000006548) as a foreign reference. Each design uses its own measured T/E. FDP at nominal q 0.01 / 0.05, Percolator per seed:

old peptide-level (3 databases) foreign
Astral, T/E 0.964 1.075 2.228
Astral, Percolator 0.80–0.83 / 4.6–4.9% 0.89–1.04 / 4.8–5.3% 0.97–1.02 / 5.1%
Astral, --rescore-native 0.83 / 4.75% 0.86–1.09 / 4.9–5.2% 0.98 / 4.94%
phospho, T/E 0.971 1.061 1.403
phospho, Percolator 1.03–1.09 / 5.2% 0.94–1.08 / 5.1–5.3% 1.23–1.33 / 5.1–5.2%
phospho, --rescore-native 0.96 / 5.32% 0.96–1.13 / 5.3% 1.34 / 5.33%
glyco quick tier (sequon-corrected) 0.89–1.22 / 4.8–5.0% 0.45–1.45 / 4.3–5.2% (not comparable)

What this shows:

ProteoBench LFQ, 6 runs, match between runs (one peptide-level database). False-donor share of accepted transfers: entrapment-measured vs identity-decoy estimate.

old peptide-level foreign
PSM FDP q 0.01 0.79–0.80% 0.93–0.95% 0.90–0.91%
transfer q 0.01: measured / estimate 0.23–0.25 / 0.28–0.31% 0.30–0.38 / 0.28–0.31% 0.24–0.30 / 0.31–0.32%
transfer q 0.05: measured / estimate 0.36–0.37 / 0.44–0.47% 0.52–0.58 / 0.44–0.45% 0.46–0.54 / 0.43–0.45%

The identity-decoy estimate still tracks the false-donor share, within about 25%. It is not an upper bound: at transfer q 0.05 it reads about 20% below the peptide-level measurement.

Docs

Numbers changed in this PR:

page what changed
docs/benchmarks/README.md, Astral true FDP at nominal 1%: 0.95–1.03% → 0.89–1.04%
docs/benchmarks/README.md, phospho 0.97–1.08% → 0.94–1.08%
docs/benchmarks/README.md, glyco quick tier 0.85–1.36% → 0.45–1.45%
docs/benchmarks/README.md, LFQ PSM FDP 0.97% → 0.93–0.95%; the error-control text is rewritten
DOCS.md, identity-decoy calibration paragraph replaced with the new numbers
DOCS.md, protein table row relabelled, with a peptide-level note
DOCS.md, subset-max-train note relabelled as whole-protein shuffle

Rows not re-measured are marked "whole-protein shuffle": the glyco deep tier, the compared engine's phospho FDP, and the --chimeric/--refine FDPs.

500-run check of #216 (PXD042233)

All 500 runs were re-searched against human reviewed + contaminants plus a peptide-level shuffled entrapment (T/E 1.065), with one Percolator over all PINs (seed 42, -Y) and the quant stages at defaults (#216 bagged classifier, finalize seed 42). PSM FDP at q 0.01 is 0.98%.

transfer q accepted transfers entrapment rows measured false-donor share identity-decoy estimate
0.01 240,482 3 0.003% 0.001% (2 decoys)
0.05 5,073,963 9,719 0.40% 0.26%

The earlier whole-protein shuffle gave 0.21% measured against 0.27% estimated at q 0.05, so the estimate looked about 25% conservative. On the peptide-level database it reads about 35% low. The full transfer q-value also carries the wrong-peak term, which is more than ten times the identity term at 0.05, so the q-value as a whole still exceeds the measured false-donor share. DOCS.md now states this.

build_shuffled_entrap.py shuffled whole proteins, which moves K and R:
most entrapment peptides then have no composition- or mass-matched target
and the measured FDP comes out low. It also printed a fixed factor of 2.

The builder now digests each target protein (cleavage after every K/R as
andes trypsin, or --proline-rule), shuffles each peptide with its
C-terminal residue fixed (and K/R/P with the proline rule), maps repeated
peptides consistently, redraws shuffles that equal a target peptide
(I/L folded), and prints the T/E of the database it wrote. It moves next
to entrap_common.py; build_databases.sh and the phospho recipe use it and
the measured T/E. The T/E k-mer screen now tests every k-mer of a
peptide before the substring scan (same result, fewer scans).
Astral, phospho, glyco quick tier and the ProteoBench match-between-runs
error control re-measured at 0629cd8 on peptide-level shuffled
entrapment (three database realisations, Percolator -Y seeds 42/1/2).
Rows not re-measured are marked as measured on the whole-protein
shuffle. The identity-decoy estimate tracks the entrapment-measured
false-donor share but is not an upper bound.
…rapment

# Conflicts:
#	docs/benchmarks/README.md
@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 21, 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 17 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: 68dd74f9-7cab-476d-8dfe-6f8a09cd90e4
📥 Commits

Reviewing files that changed from the base of the PR and between 309f79a and 22ad1b9.

📒 Files selected for processing: 10
  • DOCS.md
  • docs/benchmarks/README.md
  • docs/benchmarks/build_shuffled_entrap.py
  • docs/benchmarks/entrap_common.py
  • docs/benchmarks/glyco/README.md
  • docs/benchmarks/glyco/build_shuffled_entrap.py
  • docs/benchmarks/glyco/cross_engine_pxd031032.md
  • docs/benchmarks/reproduce/README.md
  • docs/benchmarks/reproduce/build_databases.sh
  • docs/benchmarks/tests/test_entrap.py
  • 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.

Shuffled entrapment (build_shuffled_entrap.py) underestimates the FDP by 20–33% and is not 1:1

1 participant