Skip to content

feat(MSstatsConverter): add flag to control shared peptide filtering - #9068

Merged
timosachsenberg merged 3 commits into
OpenMS:developfrom
ypriverol:fix/msstatsconverter-shared-peptides-flag
Apr 3, 2026
Merged

timosachsenberg merged 3 commits into
OpenMS:developfrom
ypriverol:fix/msstatsconverter-shared-peptides-flag

Conversation

@ypriverol

@ypriverol ypriverol commented Apr 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Add -remove_shared_peptides flag to MSstatsConverter (default true for backward compatibility)
  • When set to false, shared peptides mapping to proteins in different indistinguishable protein groups are retained in the MSstats output
  • Add OPENMS_LOG_WARN messages reporting how many peptide hits were dropped by this filter

Motivation

The isQuantifyable_() method in MSstatsFile.cpp silently drops peptides whose protein accessions span multiple indistinguishable protein groups. This is hardcoded with no user-facing parameter to control the behavior.

In a benchmarking study comparing quantms (which uses OpenMS) against PD on a TMTpro 16-plex dataset, we found that this filter causes:

  • 93 proteins to vanish from the MSstats output (they only have shared peptides crossing group boundaries)
  • 817 peptide hits to be silently dropped

This occurs even when the upstream ProteinQuantifier is configured with use_shared_peptides=true, creating a disconnect between the two tools.

Changes

File Change
MSstatsConverter.cpp Added -remove_shared_peptides advanced flag
MSstatsFile.h Added remove_shared_peptides parameter to storeLFQ() and storeISO()
MSstatsFile.cpp Gate isQuantifyable_() check on the new parameter; add warning log when peptides are dropped

Test plan

  • Verify backward compatibility: default behavior (-remove_shared_peptides set) produces identical output to current version
  • Verify that unsetting the flag retains shared peptides in output
  • Verify warning message is printed when peptides are dropped

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added a new option to control removal of shared peptides from MSstats output (default: remove_shared_peptides = true). Exposed in the command-line tool and Python bindings.
    • When enabled, dropped shared peptides emit a warning reporting how many hits were removed and how to keep them.
  • Documentation
    • Updated parameter documentation describing the new option and behavior.
  • Tests
    • Updated tests to include the new parameter in signatures.

…hared peptide filtering

The MSstatsConverter silently drops peptides mapping to proteins in
different indistinguishable protein groups via isQuantifyable_().
This is hardcoded with no user control, causing proteins with only
shared peptides to vanish from MSstats output even when the upstream
ProteinQuantifier was configured with use_shared_peptides=true.

This commit adds a -remove_shared_peptides flag (default true for
backward compatibility) that allows users to retain shared peptides
in the MSstats output. It also adds OPENMS_LOG_WARN messages
reporting how many peptide hits were dropped, so the filtering is
no longer silent.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Apr 2, 2026 •

Copy link
Copy Markdown
Contributor

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: e11cd8de-1a57-4f66-9a11-88d05fc994e8

📥 Commits

Reviewing files that changed from the base of the PR and between b0c30e9 and 7936069.

📒 Files selected for processing (2)
  • src/pyOpenMS/bindings/bind_format.cpp
  • src/tests/class_tests/openms/source/MSstatsFile_test.cpp

📝 Walkthrough

Walkthrough

Two MSstatsFile methods gained a trailing remove_shared_peptides boolean (default true). MSstatsConverter exposes and forwards this CLI flag. Peptide filtering now conditionally drops shared peptides only when the flag is true and logs a warning when drops occur.

Changes

Cohort / File(s) Summary
Header Updates
src/openms/include/OpenMS/FORMAT/MSstatsFile.h
Added const bool remove_shared_peptides = true parameter to storeLFQ() and storeISO() declarations; updated docs describing removal of peptides shared across indistinguishable protein groups.
Implementation Logic
src/openms/source/FORMAT/MSstatsFile.cpp
Added remove_shared_peptides parameter to storeLFQ() and storeISO() signatures. Peptide filtering now drops peptides only if remove_shared_peptides is true and isQuantifyable_ is false; added drop counter and warning log when drops occur.
CLI Integration
src/topp/MSstatsConverter.cpp
Added remove_shared_peptides tool parameter (true,false, default true), parsed to a boolean, and passed to storeLFQ()/storeISO(); added param_remove_shared_peptides identifier.
Python Bindings
src/pyOpenMS/bindings/bind_format.cpp
Extended nanobind signatures for OpenMS::MSstatsFile::storeLFQ and storeISO to accept remove_shared_peptides: bool = true and forward it to underlying C++ calls.
Tests
src/tests/class_tests/openms/source/MSstatsFile_test.cpp
Updated test function signatures to include trailing const bool remove_shared_peptides parameter placeholders; test bodies remain placeholders.

Sequence Diagram(s)

sequenceDiagram
    rect rgba(180, 220, 255, 0.5)
    participant User as CLI/User
    end
    rect rgba(200, 255, 200, 0.5)
    participant Tool as MSstatsConverter
    end
    rect rgba(255, 230, 180, 0.5)
    participant Module as MSstatsFile
    end
    rect rgba(255, 200, 200, 0.5)
    participant Log as Logger
    end

    User->>Tool: invoke with --remove_shared_peptides=(true|false)
    Tool->>Module: call storeLFQ/storeISO(..., remove_shared_peptides)
    Module->>Module: evaluate peptides (if remove_shared_peptides && !isQuantifyable_ => drop)
    Module-->>Log: if drops > 0 -> emit warning with count
    Module-->>Tool: return generated MSstats data
    Tool-->>User: write output / exit
Loading

Poem

🐰 I hop through rows of peptide seeds,
A tiny flag decides which leads,
Shared threads fall when I say so,
I count the ones that had to go,
Hop—clean tables bloom where numbers grow. 🌱

🚥 Pre-merge checks | ✅ 2 | ❌ 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 (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding a flag to control shared peptide filtering behavior in MSstatsConverter.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
src/topp/MSstatsConverter.cpp (1)

100-105: Please add a regression test for both switch states.

src/tests/class_tests/openms/source/MSstatsFile_test.cpp:16-35 only says these methods are "tested via MSstatsConverter tool", so the default path, the explicit keep-shared-peptides path, and the new warning text are currently unguarded.

Also applies to: 160-170

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/topp/MSstatsConverter.cpp` around lines 100 - 105, Add regression tests
that exercise MSstatsConverter with both settings of the flag
param_remove_shared_peptides (default/remove and explicit keep) and assert the
produced output differs as expected and that the new warning text is emitted;
update or extend src/tests/class_tests/openms/source/MSstatsFile_test.cpp to
invoke MSstatsConverter (or call the underlying conversion routines used by
MSstatsConverter) twice—once using the default behavior and once with the
keep-shared-peptides flag set—and validate (1) that shared peptides are removed
in the default run, (2) that shared peptides remain when the flag is unset, and
(3) that the warning message string introduced for this behavior appears in the
logs for the relevant run.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/openms/include/OpenMS/FORMAT/MSstatsFile.h`:
- Around line 40-49: The header added a new optional parameter
remove_shared_peptides to MSstatsFile::storeLFQ and MSstatsFile::storeISO, so
update the PyOpenMS nanobind lambdas that expose these methods (the lambdas
around the storeLFQ/storeISO bindings in bind_format.cpp) to accept and forward
the new bool remove_shared_peptides parameter, and update the test signatures in
MSstatsFile_test.cpp (the documented section signatures previously listing 8
params at the two locations) to include the new parameter; run the
bindings/tests to ensure compilation and tag the commit with "API" for the C++
API change.

In `@src/topp/MSstatsConverter.cpp`:
- Around line 100-105: The flag param_remove_shared_peptides is currently
registered with registerFlag_ (which defaults to false) but
MSstatsFile::storeLFQ()/storeISO() expect a default of true; replace the
registerFlag_ call with registerStringOption_ using default value "true" and
allowed values ["true","false"], then read the value with getStringOption_
(convert to bool) wherever param_remove_shared_peptides is used; remove or stop
using registerFlag_ for this parameter to ensure the tool defaults to removing
shared peptides.

---

Nitpick comments:
In `@src/topp/MSstatsConverter.cpp`:
- Around line 100-105: Add regression tests that exercise MSstatsConverter with
both settings of the flag param_remove_shared_peptides (default/remove and
explicit keep) and assert the produced output differs as expected and that the
new warning text is emitted; update or extend
src/tests/class_tests/openms/source/MSstatsFile_test.cpp to invoke
MSstatsConverter (or call the underlying conversion routines used by
MSstatsConverter) twice—once using the default behavior and once with the
keep-shared-peptides flag set—and validate (1) that shared peptides are removed
in the default run, (2) that shared peptides remain when the flag is unset, and
(3) that the warning message string introduced for this behavior appears in the
logs for the relevant run.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 18fb162f-499f-4cf2-a244-3f9715cd0da9

📥 Commits

Reviewing files that changed from the base of the PR and between 8c20943 and 6cc018e.

📒 Files selected for processing (3)
  • src/openms/include/OpenMS/FORMAT/MSstatsFile.h
  • src/openms/source/FORMAT/MSstatsFile.cpp
  • src/topp/MSstatsConverter.cpp

Comment thread src/topp/MSstatsConverter.cpp Resolved
…efault for remove_shared_peptides

Add full @PARAM documentation for storeLFQ() to match storeISO() style,
fixing Doxygen warning test failures. Change remove_shared_peptides from
registerFlag_ (default false) to registerStringOption_ with default "true"
so shared peptides are removed by default, preserving backward-compatible
behavior and ensuring test CSV outputs remain unchanged.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@jpfeuffer

Copy link
Copy Markdown
Contributor

Thanks. Please update the nanobind bindings as mentioned by coderabbit.
Also note that I am pretty sure that msstats will fail with shared peptides. And they are pretty useless because I don't know of any mainstream quantification that uses them.

@ypriverol

ypriverol commented Apr 3, 2026 •

Copy link
Copy Markdown
Contributor Author

@jpfeuffer Im trying to do this for consistency across workflows.

…red_peptides

- Add remove_shared_peptides parameter (default true) to storeLFQ() and
  storeISO() nanobind lambdas in bind_format.cpp
- Update MSstatsFile_test.cpp START_SECTION signatures to match the new
  C++ API

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@timosachsenberg

Copy link
Copy Markdown
Contributor

would be important to find out if they include all shared peptides or only those of subsumable etc.
as @jpfeufer mentioned including all likely makes no sense

@timosachsenberg
timosachsenberg merged commit c876742 into OpenMS:develop Apr 3, 2026
38 checks passed
github-actions Bot pushed a commit that referenced this pull request Apr 4, 2026
Add two missing changelog entries for the OpenMS 3.6.0 under-development section:

- General: Fix UpdateCheck crash when $HOME is not writable in containers (#9075)
- TOPP tools / MSstatsConverter: new -remove_shared_peptides parameter (#9068)

Co-authored-by: Copilot <[email protected]>
timosachsenberg added a commit that referenced this pull request Apr 4, 2026
Add two missing changelog entries for the OpenMS 3.6.0 under-development section:

- General: Fix UpdateCheck crash when $HOME is not writable in containers (#9075)
- TOPP tools / MSstatsConverter: new -remove_shared_peptides parameter (#9068)

Co-authored-by: GitHub Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Timo Sachsenberg <[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.

3 participants