Skip to content

Make per-run PINs poolable: stem-prefixed SpecIds and a data-independent PIN header - #212

Merged
ypriverol merged 9 commits into
mainfrom
fix/per-run-pooled-pin
Oct 21, 2026
Merged

ypriverol merged 9 commits into
mainfrom
fix/per-run-pooled-pin

Conversation

@ypriverol

@ypriverol ypriverol commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Per-run searches pooled into one Percolator run (the scale workflow, the quantms route) broke in two ways on main. This PR fixes both and makes the PIN header depend only on the command line.

1. SpecIds collide across separately searched runs

A single-file search did not prefix the SpecId with the input's file stem; only multi-file searches did. Native titles (controllerType=0 controllerNumber=1 scan=N) repeat across runs, so pooled PINs had duplicate SpecIds and andes quant library stopped with duplicate PSMId.

  • Every search now prefixes the title with <stem>/, so single- and multi-file searches write the same format ({stem}/{title}_{scan}_{rank}). The stem is the file name without its last extension (run.mzML.gz → run.mzML/), as multi-file searches already did.
  • Consumers checked: the quant run tables store the same prefixed SpecId, so the library join on (run, SpecId) is unchanged; the MS2 table and MS3 lookups already stripped the prefix; --predict and the native rescorer key on the PIN SpecId; the QPX spectrum_reference now strips the prefix again so it stays the native id; the TSV SpecID/Title carry the prefix.
  • quant library with per-run results now stops when a run's result joins none of its PSMs (results passed for the wrong run), instead of passing silently.

2. The PIN header depended on the data

  • Charge one-hots were widened to every charge a PSM carried (a declared 6+ precursor is searched even outside --charge), so runs got different chargeN ranges. Concatenating them gives a header from the first file and shifted columns for the rest; Percolator does not detect this. The columns are now the --charge range only (default 2..5), and a charge outside it sets the nearest edge column (a 6+ sets charge5). This keeps every row one-hot on a fixed set of columns. The other option, an all-zero vector, puts those PSMs on an intercept that is never learned. The glyco PIN already used a fixed range plus a chargeHi overflow column and is unchanged.
  • --predict columns: a predictor that scored no row (e.g. an input without retention times, including the default andesrt on MGF) left its columns out. It now always writes them, with 0 and <p>_missing = 1.
  • Glyco Mono* columns: they were left out when --precursor-mono auto ran but fitted no spectrum (an MS2-only mzML). They are now written whenever the correction runs (--glyco, auto, mzML or .raw input), with 0 when nothing fitted. The search itself is unchanged in that case.
  • Every other column of the standard and glyco PINs is fixed by the writer. The remaining dependencies are on configuration, not data: --charge, --predict, and for glyco the input format (MGF has no MS1, so there are no Mono columns). Runs pooled together must share those settings, as they already must share the database and modifications.

Goldens

All changes are deliberate and were checked against the previous binary:

  • precursor_cal_off.{pin,tsv}, glyco.pin, chimeric_slice.pin.gz, refine_slice.pin.gz: the previous goldens with the file stem in front of each SpecId (and TSV Title). No golden row has a charge outside 2..5.
  • glyco_highres.pin: also gains the four Mono* columns at 0 (the fixture is an mzML without MS1).
  • E. coli digests (out_of_core_pin_goldens): the previous binary's PIN for each command line, with the stem added and charges clamped to 2..5, equals the new PIN row for row. The 41/44/42 rows of 6+ precursors move from charge6 to charge5. Row counts are unchanged.
  • pin_constant_columns: lists the andesrt_* columns as fixture-dependent (MGF, no retention times).

Verification

4 PXD042233 runs (Q Exactive HF / HF-X .raw), each searched on its own (5 ppm, 2 missed cleavages, top-1, Carbamidomethyl, Ox-M, protein N-term Acetyl) with main and with this branch:

main branch
distinct PIN headers over 4 runs 3 (charge2..charge9/11/14) 1
PIN rows, all runs 367,334 367,334
plain cat → Percolator 3.7.1 runs, but on shifted columns runs
quant library on the pooled result fails: duplicate PSMId works (4 runs, 367,333 PSMs scored, 92,037 library entries)
  • PIN equivalence: for every run, main's PIN with the stem prefix added and charges clamped to 2..5 equals the branch PIN exactly (69,453–110,904 rows per run; 1,018–1,491 rows per run folded into charge5).
  • Identifications against main with the previous workaround (union charge range merge plus stem prefix), with the same Percolator settings (--seed 42 -Y --only-psms):
workaround (main) plain cat (branch)
PSMs at q ≤ 0.01 183,944 183,951 (183,921 shared)
peptides at q ≤ 0.01 76,152 76,154
PSMs at q ≤ 0.001 161,908 161,868

The PINs differ only in the charge columns, so the remaining difference (±0.03 %) comes from folding 6+ into charge5 instead of separate charge6..14 columns.

Gate (pinned toolchain 1.87): cargo clippy --locked --workspace --all-targets -D warnings clean; cargo test --release --workspace --locked 1,719 passed, 0 failed; out_of_core_pin_goldens -- --ignored 4/4.

Fixes #126.

Summary by CodeRabbit

  • New Features

    • Spectrum identifiers now include the input file stem, improving traceability across searches.
    • Predictor columns are consistently included in PIN output, with missing predictions marked explicitly.
    • Precursor-mono outputs remain available for applicable glycopeptide searches, including zero-valued results when spectra cannot be fitted.
    • Spectrum references are cleaner and more consistent across input files.
  • Bug Fixes

    • Charge columns now follow the configured range and safely handle out-of-range charges.
    • Quantification now detects mismatched per-run results and reports clearer errors.
    • Multi-run quantification preserves run-specific identifiers when combining results.
  • Documentation

    • Clarified predictor, charge, precursor-mono, identifier, scoring, and quantification output behavior.

Native spectrum titles repeat across files, so PINs from separate per-file
searches collided when pooled into one Percolator run, and quant library
rejected the merged result. The stem prefix was applied only to multi-input
searches; it is now applied to every search. The QPX spectrum_reference
strips it again, so it stays the native id. Fixes #126.
The one-hot block was widened to every charge a PSM carried, so two runs
searched separately could get different PIN headers, and concatenating them
shifted every later column with no error. The block is now the --charge
range; a declared charge outside it sets the nearest edge column.
With every SpecId carrying its file stem, per-run results passed for the
wrong run share no SpecId with it and joined nothing, silently. Such a run
now fails, naming the file.
…only

A --predict predictor that scored no row left its columns out, and a glyco
search whose MS1 fitted no precursor left the Mono columns out, so the PIN
header of a run depended on its data and separately searched runs could not
be concatenated. Both column sets are now written whenever they are
configured, with neutral values (0, and the predictor's missing flag 1) when
nothing was scored.
…e quant test

Separate searches of the runs now write SpecIds that carry their file stem,
so the PINs' merged Percolator result joins every run, and per-run results
passed for the wrong run join nothing and are rejected.
The goldens are the previous ones with the input's file stem in front of
every SpecId (and the TSV Title), and, in the high-res glyco PIN, the four
Mono columns at 0 that a --precursor-mono run without fitted MS1 now writes.
No golden row has a charge outside 2..5, so the charge columns are unchanged.
The guard came from a branch where quant library held the run tables in
memory; it now counts the run's rows during the streamed join.
…umns; list the constant predictor columns

The E. coli PINs equal the previous binary's with the file stem in front of
each SpecId and the 41-44 rows of 6+ precursors moved from charge6 to
charge5. The default andes-rt columns are constant on the MGF fixture, which
has no retention times.
@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

Review in Change Stack →

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e77d60a7-16f0-4948-ba94-7f2ccb7f9e4c
📥 Commits

Reviewing files that changed from the base of the PR and between 4b3a23d and a5dbf6a.

⛔ Files ignored due to path filters: 3
  • test-fixtures/goldens/chimeric_slice.pin.gz is excluded by !**/*.gz
  • test-fixtures/goldens/refine_slice.pin.gz is excluded by !**/*.gz
  • test-fixtures/parity/goldens/precursor_cal_off.tsv is excluded by !**/*.tsv
📒 Files selected for processing: 16
  • DOCS.md
  • crates/andes/src/bin/andes/model_select.rs
  • crates/andes/src/bin/andes/predicted.rs
  • crates/andes/src/bin/andes/quant_cmd.rs
  • crates/andes/src/bin/andes/search.rs
  • crates/andes/src/bin/andes/spectra.rs
  • crates/andes/tests/glyco_golden_highres.rs
  • crates/andes/tests/out_of_core_pin_goldens.rs
  • crates/andes/tests/pin_constant_columns.rs
  • crates/andes/tests/quant_mbr_end_to_end.rs
  • crates/output/src/glyco_pin.rs
  • crates/output/src/pin.rs
  • crates/output/src/qpx.rs
  • test-fixtures/parity/goldens/glyco.pin
  • test-fixtures/parity/goldens/glyco_highres.pin
  • test-fixtures/parity/goldens/precursor_cal_off.pin
+-----------------------------------------------------------------------------------------------------------------------------------------------+
| Costly tools don't produce better designs. Beware of vendor hype, industry dogma, and the aura of the price tag. Judge tools on their merits. |
+-----------------------------------------------------------------------------------------------------------------------------------------------+
  \
   \     /)/)
        ( '')
        /  |
      o(___)
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • 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 cb5b4ff into main Oct 21, 2026
4 of 5 checks passed
@ypriverol
ypriverol deleted the fix/per-run-pooled-pin 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.

PIN SpecIds collide across single-file runs: pooling per-file PINs in one Percolator run silently corrupts FDR

1 participant