Skip to content

[FIX] ProteinQuantifier: correctly split merged ID runs by origin file - #9658

Merged
timosachsenberg merged 2 commits into
developfrom
claude/github-issue-5518-check-5cea73
Jun 25, 2026
Merged

timosachsenberg merged 2 commits into
developfrom
claude/github-issue-5518-check-5cea73

Conversation

@timosachsenberg

@timosachsenberg timosachsenberg commented Jun 25, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #5518

Background

Issue #5518 asked for ProteinQuantifier to support merged ID files directly (so workflows don't have to branch into two different merge strategies). In the thread, @jpfeuffer asked whether this is already handled by the internal PeptideAndProteinQuant algorithm and whether exposing it in the standalone tool would be a small change.

Digging in: the machinery is almost all there. ExperimentalDesign::fromIdentifications() already expands a merged ID run's multiple primary MS run paths into one sample per origin file ("Due to merging it is valid to have multiple origins in a ProteinIDRun"), and PeptideAndProteinQuant::readQuantData() for idXML input contains a {identifier, merge_index} → MS file mapping intended to attribute each PSM back to its origin file. ProteinQuantifier routes idXML input straight through that overload.

The bug

The per-PSM origin lookup read a mistyped meta key:

Size id_merge_idx = (Size)p.getMetaValue("id_merge_idx", 0);   // never set anywhere

IDMerger annotates the origin file index under Constants::UserParam::ID_MERGE_INDEX, whose value is "id_merge_index" (also consumed correctly under that name by IDRipper). The literal "id_merge_idx" appears nowhere else in the codebase — nothing sets it. So the lookup always fell back to the default 0, and every PSM in a merged run was attributed to the first origin file, leaving the remaining per-file samples empty. The experimental design correctly created N samples, but all counts piled into sample 1.

This went unnoticed because no test fed a merged idXML through this path.

The fix

Use the shared constant:

Size id_merge_idx = (Size)p.getMetaValue(Constants::UserParam::ID_MERGE_INDEX, 0);

Unmerged input (a single primary MS run path) still resolves to index 0, so existing behavior is unchanged.

Test

Adds a regression test in PeptideAndProteinQuant_test.cpp that builds a merged ID run with two origin files (PSMs annotated with id_merge_index 0 and 1), runs readQuantData() / quantifyPeptides(), and asserts the two PSMs are split across two distinct samples. Without the fix both collapse into sample 0.

Note

This was developed in an environment where a full OpenMS build/contrib toolchain isn't available, so I relied on CI to compile and run the test. The change is a one-line key correction plus a self-contained unit test; API usages were verified against the headers.

🤖 Generated with Claude Code


Generated by Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Improved how peptide quantification reads merged identification metadata, using the standard user parameter for ID-merge index and applying safe defaults when inputs aren’t merged.
  • Tests

    • Added regression coverage to verify quantification across merged runs distributes PSM abundances to the correct originating samples.
    • Updated ProteomicsLFQ mzTab fixtures to reflect revised protein quantification/summary values for affected records.

PeptideAndProteinQuant::readQuantData() for idXML input read the
per-PSM origin index from a mistyped meta key "id_merge_idx", which is
never set anywhere. IDMerger annotates the origin file index under
Constants::UserParam::ID_MERGE_INDEX ("id_merge_index"). As a result the
lookup always fell back to the default 0, so every PSM in a merged ID
run was attributed to the first origin file and the remaining
per-file samples were left empty.

Use the correct constant so merged idXML input (a single ID run with
several primary MS run paths) is split into one sample per origin file,
as already intended by ExperimentalDesign::fromIdentifications().

Adds a regression test that feeds a merged ID run with two origin files
through readQuantData()/quantifyPeptides() and checks that the two PSMs
land in two distinct samples.

Fixes #5518

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AGp2wPBLyzAGNkcC6AGvMF
@github-actions

Copy link
Copy Markdown
Contributor

@timosachsenberg The following names might be missing from the AUTHORS file:

  • Claude

Please consider applying the following patch:

--- AUTHORS	2026-06-25 05:11:39.515131892 +0000
+++ AUTHORS.new	2026-06-25 05:11:44.789830639 +0000
@@ -25,6 +25,7 @@
  - Chris Bielow
  - Christian Ehrlich
  - Christie Mathews
+ - Claude
  - Clemens Groepl
  - Cornelia Friedle
  - Daniel Jameson

@coderabbitai

coderabbitai Bot commented Jun 25, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8e2602cd-59f4-4714-822d-13a0f8e1d9fa

📥 Commits

Reviewing files that changed from the base of the PR and between 44b6d63 and a4c91e9.

📒 Files selected for processing (2)
  • src/tests/topp/ProteomicsLFQ_4_out.mzTab
  • src/tests/topp/ProteomicsLFQ_6_out.mzTab

📝 Walkthrough

Walkthrough

PeptideAndProteinQuant now reads peptide merge indices from Constants::UserParam::ID_MERGE_INDEX with a default fallback. The class test adds merged-run regression coverage, and the mzTab fixtures update expected protein quantification outputs.

Changes

Merged ID merge-index handling

Layer / File(s) Summary
Centralized merge-index lookup
src/openms/source/ANALYSIS/QUANTITATION/PeptideAndProteinQuant.cpp
readQuantData(...) reads the peptide merge index from Constants::UserParam::ID_MERGE_INDEX with a default of 0, and the file includes Constants.h.
Merged-run regression
src/tests/class_tests/openms/source/PeptideAndProteinQuant_test.cpp
A regression test builds merged identifications with distinct merge-index metadata and checks that quantification produces two samples and spreads abundances across both origin samples.
Updated mzTab outputs
src/tests/topp/ProteomicsLFQ_4_out.mzTab, src/tests/topp/ProteomicsLFQ_6_out.mzTab
The expected protein rows update their quantitative summary columns and related null/value patterns.

Poem

A bunny found the merge key bright,
And hopped through quants by morning light.
Two samples bloomed where one had been,
With tidy fixtures in between. 🐇

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main fix: splitting merged ID runs by origin file.
Linked Issues check ✅ Passed The code now respects the merged-run origin index during quantification, which addresses support for annotated merged id files in #5518.
Out of Scope Changes check ✅ Passed The mzTab fixture updates are in scope because they update regression references to match the corrected quantification behavior.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/github-issue-5518-check-5cea73

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.

Copy link
Copy Markdown
Contributor Author

CI Failure Analysis

The code fix itself is correct — the typo "id_merge_idx" → Constants::UserParam::ID_MERGE_INDEX is the right change and the new unit test passes.

Why the two TOPP integration tests fail

TOPP_ProteomicsLFQ_4_out_2 and TOPP_ProteomicsLFQ_6_out_2 fail on all 5 platforms because their reference .mzTab files (src/tests/topp/ProteomicsLFQ_4_out.mzTab and src/tests/topp/ProteomicsLFQ_6_out.mzTab) were generated with the buggy code.

The bug made every PSM fall back to origin file index 0, so all protein abundance counts piled into sample 1 with zero in samples 2 and 3. With the fix, PSMs are correctly spread across the three BSA samples.

Concrete diff from CI (test 6, line 95, protein P02769|ALBU_BOVIN):

sample 1 sample 2 sample 3
Reference (buggy) 155.0 0.0 0.0
New output (correct) 73.0 49.0 33.0

The same pattern repeats for every quantified protein in both reference files — the total per-protein count is preserved (73+49+33 = 155), just correctly distributed.

What needs to be done

The reference files must be regenerated from the fixed code. Since a full local build wasn't available when the PR was created, this step was missed.

To fix:

  1. Build ProteomicsLFQ on the branch
  2. Run tests 4 and 6 to produce the new .mztab output files
  3. Copy the outputs over src/tests/topp/ProteomicsLFQ_4_out.mzTab and src/tests/topp/ProteomicsLFQ_6_out.mzTab
  4. Commit and push

The reference update is straightforward once the binary is available — it's purely a consequence of the fix producing the correct values that the old reference doesn't reflect.


Generated by Claude Code

…al counts

The fix correctly attributes each PSM in a merged ID run to its true origin
file (via Constants::UserParam::ID_MERGE_INDEX) instead of collapsing all PSMs
into the first origin file. ProteomicsLFQ's spectral_counting path
(TOPP_ProteomicsLFQ_4 / _6) therefore now distributes protein spectral counts
across the correct samples instead of piling them into sample 1.

Update the two affected mzTab references to the corrected output. Only protein
(PRT) abundance rows change; per-protein totals are conserved and merely
redistributed across the 3 BSA samples, e.g. P02769|ALBU_BOVIN 91 -> 35/31/25
(test 4) and 155 -> 73/49/33 (test 6). MTD headers and PSM rows are unchanged.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@timosachsenberg
timosachsenberg merged commit 34ddcb1 into develop Jun 25, 2026
41 checks passed
@timosachsenberg
timosachsenberg deleted the claude/github-issue-5518-check-5cea73 branch June 25, 2026 12:48
timosachsenberg added a commit that referenced this pull request Jun 26, 2026
Documents PRs that landed after the last CHANGELOG update (#9656):
- #9647 PIP-ECHO match-between-runs algorithm in ProteomicsLFQ
- #9666 ProteomicsLFQ mzTab crash on non-string search settings
- #9658 ProteinQuantifier wrong per-file split on merged ID runs (fixes #5518)
- #9664 Math::quantile1st/3rd crash on 1–2 element inputs (fixes #9659)


Claude-Session: https://claude.ai/code/session_01DYJ6LYHiJADSGjCkfBBJiN

Co-authored-by: Claude <[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.

ProteinQuantifier: support merged id files with option (merge_proteins_add_psms) if file origin is annotated

3 participants