Skip to content

Rescue the pre-release fixes from #188 - #214

Merged
ypriverol merged 19 commits into
mainfrom
fix/rescue-prerelease-040
Oct 21, 2026
Merged

ypriverol merged 19 commits into
mainfrom
fix/rescue-prerelease-040

Conversation

@ypriverol

Copy link
Copy Markdown
Contributor

Bug fixes from the closed pre-release PR #188 that never reached main, re-applied on current main (one commit per fix). Code has moved since #188 (#189–#212), so several fixes were re-implemented rather than cherry-picked, and some #188 commits are left out because main already has an equivalent change or a different design.

Fixes

Identification and rescoring

  • Native ids without scan= (mzML index= native IDs are lost in PIN ScanNr (all become 0) #96): index=N (timsTOF conversions) and scanId=N native ids are read as scan numbers, else the spectrum's 1-based position in the file. Before this, every PIN row had ScanNr 0.
  • Native rescorer folds by spectrum, not ScanNr: with ScanNr 0 on every row, all rows fell into one fold and --rescore-native returned no PSMs, with no warning. The spectrum key is the SpecId without its _{scan}_{rank}[_{row}] suffix. The first _{scan}_ followed by only one or two numbers is taken as the suffix, so a rank or row equal to the scan number does not split one spectrum's rows across folds.
  • --tmt injects its tag whatever the protocol: with --tmt PLEX, an explicit non-isobaric --protocol and no --mods, the search ran without the TMT/iTRAQ fixed mod.

Variants, knockoffs and sites

  • Knockoffs on but none built: apply_knockoff_fdr returned early when the database had no knockoff entry, so variants were accepted on the class FDR alone (nonspecific enzyme, indel-only annotations). With --knockoffs > 0 those variants now get q = 1, and the log counts them. andes inference passes its own --knockoffs.
  • Knockoff counting: k counts distinct knockoff features, so --refine Pass-2 copies no longer inflate it. A knockoff peptide that several variants' knockoffs hold counts 1/k for each variant, where it used to count min(1/k) once.
  • Knockoffs clear of every source's variants: annotation knockoffs keep clear of the database's variant entries. Earlier knockoffs within the knockoff distance of a variant in an annotation file are dropped.
  • Site-claim counting: a PSM whose peptide several genes hold counts once per stratum, as a knockoff PSM does. A placement that is a knockoff site in one protein and a real claim in a paralog now supports that claim; before, the PSM was removed. Module and user docs no longer say the estimate errs only towards rejecting true claims.
  • Annotation ids holding ;, | or whitespace are left out with a reason, because they split the entry's accession. PEFF modification groups listing several positions (12,25|…) now load, where they used to abort the load; a ? position is skipped.
  • Merge map: when two database entries read the same, the first keeps the key, so the result does not depend on database order.

Outputs

  • QPX bundle leaves out knockoff PSMs, which kept the feature parquet's psm_ids from shifting. It also leaves out the decoys that lost target-decoy competition, as it already did for losing targets.
  • Atomic final writes: the QPX bundle, the feature parquet (whole and streamed), the PSM TSV, the protein-group TSV and parquet, the proteoform table and the site table write <path>.partial and rename it when complete.
  • No signal is no quantity: an MBR fit whose amplitude was clamped to 0 is null in mbr.parquet and has an empty intensity list in the feature parquet, not 0 (part of quant: isomer-class precursor identity, mod-aware Percolator join check, MBR zero-vs-missing, finalize memory #148).
  • Proteoform quantities: a member not measured in a column is written NA, not 0.
  • Empty finalize feature parquet keeps the MBR columns.
  • Docs: the bundle's file list, filled fields, MBR evidence types, and --tmt-max-pep with --rescore-native now match what andes writes.

Not carried over from #188

#188 commit Why
Do not list a variant whose peptide another family's reference holds Already in main (#211, stricter rule)
Stop quant library when a per-run result joins none of its run's PSMs Already in main (#212)
Update goldens/tests for stem-prefixed SpecIds; regenerate E. coli PIN digests Already in main (#212)
Route CID and HCD on TOF to the high-res HCD models Handled by the separate TOF model-fallback branch (#97). It merges cleanly with this one.
Build knockoff variants only when andes rescores Conflicts with andes inference (#209). It rebuilds the search's knockoff entries and removes knockoff PSMs from external Percolator results, so the search has to keep building them.
Make site claims opt-in (--site-claims) main keeps site claims on and adds identity and occupancy (#190), which address the measured wrong-modification failure. The counting fixes from that commit are included above.
Apply the TMT gate to the feature parquet main now keeps gated PSMs in tmt.parquet and the feature parquet with quant_weight 0, flagged quant_gate_passed, and documents it. Only the --rescore-native PEP note is included.

Measured (origin/main vs this branch, same inputs)

Run PSMs q ≤ 0.01 main → branch Entrapment FDP main → branch QPX psms.parquet rows (decoys) main → branch
UPS1, Percolator 16,442 → 16,442 1.12% → 1.12% 199,314 (171,410) → 37,017 (9,113)
TMT a05058, Percolator 13,522 → 13,522 – 186,215 (159,913) → 36,226 (9,924)
UPS1, native rescorer 17,716 → 18,244 6.95% → 7.57% –
UPS1 with index= native ids, native rescorer 0 → 18,167 – → 7.54% –
2 EN-TEx TMT runs, UniProt variants, knockoffs 4, --refine 2,605 → 2,605 – 130,845 (115,995) → 25,279 (10,731)
  • Percolator path: IDs are identical. The bundle keeps the same targets (27,904 on UPS1) and drops only the decoys that lost competition. On EN-TEx it also drops 302 knockoff PSMs (14,850 → 14,548 target rows).
  • Native rescorer: index= input goes from 0 PSMs to the same level as scan= input. Re-folding by spectrum changes the scan-numbered result within split-to-split variation (+3% PSMs, +0.6 points entrapment FDP). The native rescorer's FDR on UPS1 is well above nominal on main too; that is a separate issue.
  • Site claims: on EN-TEx, oxidised-M site-claim PSMs at q ≤ 0.01 drop from 51 to 7 once each PSM counts once instead of once per protein. No site is accepted either way.
  • Variant knockoffs: these runs accept no variant before or after the change. The knockoff-count fixes are covered by unit tests, not this benchmark.

Gate

cargo clippy --workspace --all-targets -- -D warnings clean; cargo test --release --workspace --locked: 1743 passed, 0 failed, 9 ignored; the ignored out-of-core PIN goldens pass (4/4). No golden changed. The last commit only reformats the rescued lines (rustfmt).

The MS1 fit clamps a negative amplitude to 0, and finalize reported that as
quantity 0 for an identified precursor with no signal in the run. The
protein roll-up reads 0 as a measured value. Such a row now has no quantity:
null in mbr.parquet and an empty intensity list in the feature parquet (the
normalisation already skipped non-positive quantities). Part of #148.
apply_knockoff_fdr returned early when the database held no knockoff entry,
so with --knockoffs > 0 every variant PSM was accepted on its class q-value.
That happens when the enzyme leaves no position for a knockoff (nonspecific,
no cleavage) or the variants are indels only. The early return now applies
only with --knockoffs 0; otherwise those variants get q = 1, as documented,
and the run log says how many were rejected.
mzML spectra whose native id has no scan= token (index=N from timsTOF
conversions, scanId=N, SCIEX cycle/experiment ids) got no scan number, so
every PIN row had ScanNr 0. The reader now takes scan=, else index=, else
scanId=, else the spectrum's 1-based position in the file. Fixes #96.
The 3-fold CV assigned folds by ScanNr. With ScanNr 0 on every row, all rows
fell into one fold, that fold had no training data, and --rescore-native
returned almost no PSMs without a warning. Rows are now folded and grouped
by their spectrum: the SpecId without its scan, rank and row suffix.
The bundle was written before the knockoff rows were removed, so knockoff
PSMs appeared in psms.parquet as ordinary targets, and the feature parquet's
psm_ids (row indices into psms.parquet) shifted after the first knockoff row.
write_qpx now takes the rows never reported and leaves them out, as it does
for rows target-decoy competition removed.

Under Percolator -Y the bundle also dropped the targets that lost their
scan's competition but kept the losing decoys, so a consumer computing its
own target-decoy FDR from psms.parquet saw extra decoys. Losing decoys are
now left out the same way.
Two counting errors made the variant knockoff q-values optimistic. The
--refine Pass-2 entries copy a knockoff's origin, so each confident knockoff
backbone added one to its variant's knockoff count k; k now counts distinct
knockoff features. A knockoff peptide held by knockoffs of several variants
counted min(1/k) once; it now counts 1/k for each variant it copies.
Each source placed knockoffs only away from its own listed variants. With a
UniProt XML database and --annotations, an annotation knockoff could sit on
or next to a UniProt variant, and a UniProt knockoff on or next to a
variant of the annotation file (such as the sample's own genotype calls), so
the knockoff was no longer surely absent. Annotation knockoffs now keep
clear of the database's variant entries too, and earlier knockoffs within
the knockoff distance of a variant of the file are dropped.
…im win

Two counting errors in the site q-values:
- A PSM whose peptide several reference entries hold counted one claim per
  protein but a knockoff once, which made site q-values too low for peptides
  shared across genes. It now counts once per stratum on both sides.
- A placement that is a knockoff site in one protein and a real claim in a
  paralog counted only as a knockoff; for a sites=annotated mod the PSM was
  then removed from every output. A real claim at the same placement now
  wins.

The module and user docs no longer say the estimate errs only towards
rejecting true claims; it also misses a wrong modification at the right site,
which the site identity columns address.
With --tmt PLEX, an explicit non-isobaric --protocol (e.g. phospho) and no
--mods, the tag match fell through and the search ran without the TMT or
iTRAQ fixed mod. --tmt now names the kit to inject whatever the protocol.
An annotation id becomes part of the entry's accession, so an id holding
';' (the VCF id separator), '|' or whitespace split the entry's accession in
every protein list; the pieces were unknown accessions and the row was
treated as canonical. Such rows are now left out with a reason. A PEFF
modification group listing several positions (12,25|...) aborted the whole
load; each position now becomes a site, and an unknown position (?) is
skipped.
A proteoform-table member with no specific peptide measured in a run or
channel was written as quantity 0, which reads as a measured zero. It is now
NA.
The feature parquet chose the MBR schema only when its first row group
carried MBR fields, so a finalize with no rows (an empty library, or every
row below threshold) wrote a parquet without evidence_type, transfer_q,
quant_q and quantity_se, and a reader selecting them failed. Finalize now
always writes the MBR schema.
The QPX bundle, the feature parquet, the PSM TSV, the protein-group table
and parquet, the proteoform table and the site table were written straight
to their final path, so a failed run left a truncated file under the final
name. They now write <path>.partial and rename it when complete, as the
quant tables and intermediates already did.
--output-parquet writes protein_groups.parquet and, with --tmt or --lfq,
quantms.feature.parquet too; psm_metavalues, PEP and the predicted RT are
filled, not null; the MBR evidence types in the feature parquet are
identified, transfer_ms2 and transfer_ms1; the MBR feature parquet has no
PEP; rescoring adds the q-value and PEP to the QPX bundle, not to
--output-tsv; and --tmt-max-pep also takes the PEP of --rescore-native.
Two database entries with the same (family, kind, sequence) overwrote each
other in the map annotation claims merge into, so which one a claim joined
depended on database order. The first entry now keeps the key.
@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 11 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: ed6692bd-d3d2-4ca5-9541-c46acd3a0609
📥 Commits

Reviewing files that changed from the base of the PR and between 3fceefb and 04c837a.

📒 Files selected for processing: 24
  • DOCS.md
  • README.md
  • crates/andes/src/bin/andes/cli.rs
  • crates/andes/src/bin/andes/inference_cmd.rs
  • crates/andes/src/bin/andes/quant_cmd.rs
  • crates/andes/src/bin/andes/quant_finalize.rs
  • crates/andes/src/bin/andes/quant_mbr.rs
  • crates/andes/src/bin/andes/search.rs
  • crates/andes/tests/quant_mbr_end_to_end.rs
  • crates/input/src/annotation.rs
  • crates/input/src/annotations_file.rs
  • crates/input/src/mzml.rs
  • crates/input/src/peff.rs
  • crates/output/src/atomic.rs
  • crates/output/src/feature_parquet.rs
  • crates/output/src/knockoff_fdr.rs
  • crates/output/src/lib.rs
  • crates/output/src/pg_parquet.rs
  • crates/output/src/protein_inference.rs
  • crates/output/src/proteoform_table.rs
  • crates/output/src/qpx.rs
  • crates/output/src/site_fdr.rs
  • crates/output/src/tsv.rs
  • crates/output/tests/qpx_rescore_join.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.

…-040

# Conflicts:
#	DOCS.md
#	README.md
#	crates/andes/src/rescore.rs
#	crates/output/src/pg_parquet.rs
@ypriverol
ypriverol merged commit 0629cd8 into main Oct 21, 2026
4 of 5 checks passed
@ypriverol
ypriverol deleted the fix/rescue-prerelease-040 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