Skip to content

Rescore: FDR within each evidence class (pooled-null p-values, Storey q-values) - #164

Merged
ypriverol merged 2 commits into
mainfrom
feat/class-fdr
Oct 16, 2026
Merged

ypriverol merged 2 commits into
mainfrom
feat/class-fdr

Conversation

@ypriverol

@ypriverol ypriverol commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

One global q-value lets small evidence classes through at much higher error rates than the canonical class. On one Astral file searched with UniProt isoforms, variants and chains, PSMs accepted at a global 1% had these error rates within their own class:

  • isoform-specific: 5.5–6.7%;
  • variant: 2.9–5.1%.

What this does

After --rescore (Percolator) or --rescore-native:

  1. Assign a class. Each PSM gets the class of its most canonical protein: canonical, else isoform, variant, chain or a combination of these.
  2. Compute p-values against the pooled null. Each target's empirical p-value is computed against every decoy of the run.
  3. Compute Storey q-values within each class (λ = 0.5).
  4. Guard. A class falls back to target-decoy competition inside the class, with q = (decoys + 1) / targets, if either:
    • its own decoys land in the pool's top 5% significantly more often than 5% (one-sided z > 2.33), or
    • it has fewer than 20 decoys.
  5. Combine. A target's q-value becomes the larger of its global q-value and its class q-value. The filtered TSV, the QPX q-value and quantification then accept a PSM only if it passes both.

The run log prints each class's target/decoy counts, method and Storey null fraction. A search with a single class, which includes every FASTA search, is unchanged.

Why pooled-null p-values rather than class target-decoy alone

Target-decoy competition inside a small class cannot reach a low q-value. With (D + 1)/T, 85 chain PSMs that have no decoy above them still get q ≈ 1.2%, so every chain and variant PSM of the file was rejected.

On that file, each small class's decoys scored lower than the canonical decoys (two-sample KS, p < 1e-12). The run's pooled decoys are therefore a conservative null for those classes. The guard checks this condition for every class, and on that file it sends the canonical class, whose decoys score higher than the pool, to class target-decoy.

Result on that file (--rescore, Percolator)

Accepted at 1% Canonical Isoform-specific Chain Variant
Global q-value only 46,927 46,561 183 (5.5% class FDR) 85 99 (5.1%)
This PR 47,108 46,884 (0.97%) 92 (0%) 72 (0%) 60 (1.7%)
This PR, with deamidation searched 48,914 48,664 (0.97%) 110 (0.9%) 75 (0%) 65 (0%)

The class FDR in brackets is each class's decoys above its lowest accepted score, divided by its accepted targets, measured on the rescorer's decoy output.

Known limit. Most accepted variant PSMs still have a substitution whose mass equals a common modification (D→N, E→Q, D→E…). That error is a real peptide given the wrong explanation, which decoys cannot model, so it is not addressed here.

Testing

  • Unit tests:
    • class assignment;
    • one class left unchanged;
    • a small class whose decoys score below the pool reaches q ≤ 1% where class target-decoy would give 5%;
    • a class whose decoys score above the pool falls back to class target-decoy.
  • End-to-end with --rescore-native on the BSA fixture: UniProt XML logs the class step, FASTA does not.
  • cargo clippy --workspace --all-targets -D warnings: clean.
  • cargo test --release --workspace with CI's skip list: 1,567 passed, 0 failed.

One q-value over every PSM lets a small class pass at a much higher error
rate than the canonical one: on one Astral file with UniProt isoforms,
variants and chains, isoform-specific PSMs accepted at global 1% carried
4-6% decoys of their own class.

After rescoring (Percolator or the native rescorer), every PSM gets the class
of its most canonical protein (canonical, else isoform, variant, chain or a
combination), target-decoy competition on the rescorer's score runs inside
each class with q = (decoys + 1) / targets made monotone, and a target's
q-value becomes the larger of its global and class q-value. The filtered
TSV, the QPX q-value and quantification therefore accept a PSM only if it
passes both. A search with a single class, any FASTA search, is unchanged.
The run log prints each class's target and decoy counts.
Target-decoy competition inside a small class cannot reach a low q-value:
with q = (decoys + 1) / targets, 85 chain PSMs with no decoy above them
still get 1.2%, so every chain and variant PSM of one Astral file was
rejected. On that file each small class's decoys scored lower than the
canonical ones (two-sample KS, p < 1e-12), so the run's pooled decoys are a
conservative null for them.

Each target now gets an empirical p-value against every decoy of the run,
and Storey q-values (lambda 0.5) are computed within its class. A class
whose own decoys land in the pool's top 5% significantly more often than
5% (one-sided z > 2.33), or that has fewer than 20 decoys, keeps target-
decoy competition inside the class. The run log prints each class's
method and Storey null fraction.
@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 16, 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 49 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: 45ef4fe5-e253-4037-b03c-76efc513eca6
📥 Commits

Reviewing files that changed from the base of the PR and between 6800bc0 and 97ee4d6.

📒 Files selected for processing: 5
  • DOCS.md
  • crates/andes/src/bin/andes/search.rs
  • crates/andes/tests/uniprot_database.rs
  • crates/output/src/class_fdr.rs
  • crates/output/src/lib.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.

@ypriverol
ypriverol merged commit 47d2844 into main Oct 16, 2026
5 checks passed
@ypriverol ypriverol changed the title Rescore: FDR within each evidence class (pooled-null p-values, Storey q-values) Rescore: FDR within each evidence class, and a proteoform table per family Oct 16, 2026
@ypriverol ypriverol changed the title Rescore: FDR within each evidence class, and a proteoform table per family Rescore: FDR within each evidence class (pooled-null p-values, Storey q-values) Oct 16, 2026
timosachsenberg added a commit to OpenMS/OpenMS that referenced this pull request Oct 23, 2026
…lasses (#10636)

New ClassFDR (experimental): each target PSM also gets a q-value within its class (by variable modifications or a peptide hit meta value), from pooled-decoy p-values with Storey q-values, guarded by target-decoy competition inside the class when its decoys are few or unusually strong. The PSM q-value becomes the larger of the overall and the class q-value. Off by default. Ported from bigbio/andes#164.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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