Skip to content

feat: IM and FAIMS support in most feature finder - #7453

Merged
timosachsenberg merged 49 commits into
developfrom
FFID_IM
Nov 29, 2025
Merged

timosachsenberg merged 49 commits into
developfrom
FFID_IM

Conversation

@timosachsenberg

@timosachsenberg timosachsenberg commented Apr 16, 2024 •

Copy link
Copy Markdown
Contributor

PR Summary: FAIMS and Ion Mobility Support for FeatureFinder Tools

Overview

This PR adds comprehensive FAIMS (Field Asymmetric Ion Mobility Spectrometry) support to
multiple FeatureFinder tools and enhances ion mobility handling throughout the OpenMS
codebase. The changes enable proper processing of FAIMS data by splitting experiments by
compensation voltage (CV) and processing each group separately.

Key Changes

  1. FAIMS Support Added to FeatureFinder Tools

All major FeatureFinder tools now support FAIMS data:

  • FeatureFinderIdentification - Processes each FAIMS CV group separately, annotates
    features with FAIMS_CV meta value
  • FeatureFinderMultiplex - Full FAIMS support with proper ConsensusMap handling
  • FeatureFinderMetabo - FAIMS support with helper function for group processing
  • FeatureFinderCentroided - FAIMS support including seed filtering by CV
  • FeatureFinderMetaboIdent - FAIMS support plus new IM extraction window columns
  1. IMDataConverter Enhancement
  • splitByFAIMSCV() now returns std::vector<std::pair<double, MSExperiment>> with the CV
    value paired with each experiment
  • Returns NaN-keyed element for non-FAIMS data, simplifying calling code
  • Consistent pattern across all tools: auto faims_groups =
    IMDataConverter::splitByFAIMSCV(std::move(exp))
  1. New Constants
  • Added Constants::UserParam::FAIMS_CV for consistent meta value naming across tools
  1. FeatureFinderIdentificationAlgorithm Improvements
  • Enhanced IM statistics computation for identifications
  • Reduced log verbosity (per-ID warnings changed to DEBUG level)
  • New addMissingFAIMSToPeptideIDs() function in SpectrumMetaDataLookup
  1. Search Engine Adapter FAIMS Annotations
  • SageAdapter - Annotates MS2 spectra with FAIMS_CV from source spectra
  • CometAdapter - FAIMS_CV annotation support
  • MSGFPlusAdapter - FAIMS_CV annotation support
  1. FeatureFinderMetaboIdent Ion Mobility Support

New optional TSV input columns for targeted metabolite detection:

  • IonMobility - Expected ion mobility value(s)
  • IonMobilityRange - IM extraction window size
  • New algorithm parameter extract:im_window for default IM window

Files Changed (29 files, +1529/-1902 lines)

Core Library:

  • Constants.h - Added FAIMS_CV constant
  • IMDataConverter.h/cpp - Enhanced splitByFAIMSCV() return type
  • SpectrumMetaDataLookup.h/cpp - Added FAIMS annotation function
  • FeatureFinderAlgorithmMetaboIdent.h/cpp - IM support
  • FeatureFinderIdentificationAlgorithm.h/cpp - IM statistics, FAIMS handling

TOPP Tools:

  • FeatureFinderCentroided.cpp - FAIMS support
  • FeatureFinderIdentification.cpp - FAIMS support
  • FeatureFinderMetabo.cpp - FAIMS support
  • FeatureFinderMetaboIdent.cpp - FAIMS + IM support
  • FeatureFinderMultiplex.cpp - FAIMS support
  • SageAdapter.cpp - FAIMS annotation
  • CometAdapter.cpp - FAIMS annotation
  • MSGFPlusAdapter.cpp - FAIMS annotation

Testing

  • All 75 FeatureFinder tests pass
  • FAIMSHelper tests pass
  • Backward compatible with non-FAIMS data (returns NaN-keyed single group)

Usage Pattern

// Split by FAIMS CV (returns single NaN-keyed element for non-FAIMS data)
auto faims_groups = IMDataConverter::splitByFAIMSCV(std::move(exp));
const bool has_faims = faims_groups.size() > 1 || !std::isnan(faims_groups[0].first);

for (auto& [group_cv, faims_group] : faims_groups)
{
// Process each group
// Annotate features with FAIMS_CV if has_faims
}

Summary by CodeRabbit

Release Notes

  • New Features
    • Experimental FAIMS support across feature-finding tools with automatic compensation voltage group detection; features are merged by default
    • Bruker TimsTOF ion mobility support for proteomics workflows
    • New FeatureFinderLFQ tool for label-free proteomics quantification (experimental)

✏️ Tip: You can customize this high-level summary in your review settings.

@timosachsenberg timosachsenberg changed the title start to work on IM code started to work on IM code in FFID Apr 16, 2024
@timosachsenberg

timosachsenberg commented Nov 12, 2024 •

Copy link
Copy Markdown
Contributor Author

Hi @jcharkow, @cbielow and @singjc,

In ProteomicsLFQ (DDA), our input might include ID data with annotated ion mobility (IM) at the precursor level (e.g. from Sage or Comet).
To also support "untargeted" DDA without ID we need to provide seeds for detecting unidentified MS1 peaks. Currently, I plan to use one of our default untargeted feature finders to generate these seeds (I actually already do this for non-IM data in ProteomicsLFQ). Could you point me to the appropriate method for converting the IM MSExperiment data to one with IM collapsed (e.g., somehow merged over the IM dimension)? Does this seem like a sensible approach?

@timosachsenberg

Copy link
Copy Markdown
Contributor Author

@copilot add the same optional FAIMS feature merging logic to Biosaur2Algorithm

Copilot AI commented Nov 28, 2025

Copy link
Copy Markdown
Contributor

@timosachsenberg I've opened a new pull request, #8406, to work on those changes. Once the pull request is ready, I'll request review from you.

* Initial plan

* Add optional FAIMS feature merging to Biosaur2Algorithm/FeatureFinderLFQ

Co-authored-by: timosachsenberg <[email protected]>

* Move FAIMS feature merging to Biosaur2Algorithm

Co-authored-by: timosachsenberg <[email protected]>

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: timosachsenberg <[email protected]>
@timosachsenberg

Copy link
Copy Markdown
Contributor Author

@copilot add to the changelog that there is a new experimental FeatureFinderLFQ tool that internally uses a slightly modified Biosaur2 algorithm to detect features in bottom-up DDA-LFQ. It supports FAIMS and timstof ion mobility.

Copilot AI commented Nov 29, 2025

Copy link
Copy Markdown
Contributor

@timosachsenberg I've opened a new pull request, #8408, to work on those changes. Once the pull request is ready, I'll request review from you.

@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: 0

🧹 Nitpick comments (2)
src/openms/source/FEATUREFINDER/Biosaur2Algorithm.cpp (2)

227-296: FAIMS group processing and merge step are logically sound; consider minor robustness tweaks

The new FAIMS path in run looks correct overall:

  • IMDataConverter::splitByFAIMSCV(std::move(ms_data_)) plus the has_faims check (n_groups > 1 || !std::isnan(groups[0].first)) follows the documented pattern, so non‑FAIMS and tims/PASEF data will bypass FAIMS merging.
  • Per‑group processing is safely parallelized: each OpenMP iteration only touches its own groups[i], hills_per_group[i], features_per_group[i], and fmap_per_group[i], and no shared container is resized in the loop.
  • The combined feature map is only passed to FeatureOverlapFilter::mergeFAIMSFeatures when both FAIMS is present and faims_merge_features_ is enabled, and the INFO log is sensibly emitted only when the feature count actually shrinks.

Two small points you may want to address:

  1. ms_data_ is now moved into splitByFAIMSCV. This is fine for the common “setMSData once, run once” pattern, but it does change semantics for callers that might reuse a single Biosaur2Algorithm instance across multiple run calls without re‑invoking setMSData. If such reuse exists, consider either documenting the one‑shot nature of run or operating on a local copy instead of std::move(ms_data_).
  2. The merge tolerances (5.0, 0.05) are currently hard-coded. Exposing them as advanced parameters (or at least defining named constants) would give power users control and make the intent of the chosen defaults clearer.

3057-3068: Prefer using the FAIMS_CV user param constant instead of a raw string

Here you annotate FAIMS CV via:

if (f.drift_time != IMTypes::DRIFTTIME_NOT_SET)
{
  feature.setMetaValue("FAIMS_CV", f.drift_time);
}

Given that Constants::UserParam::FAIMS_CV exists, it would be more robust and self‑documenting to reuse that constant instead of the literal "FAIMS_CV", mirroring how Constants::UserParam::IM is used for ion mobility meta values.

-    if (f.drift_time != IMTypes::DRIFTTIME_NOT_SET)
-    {
-      feature.setMetaValue("FAIMS_CV", f.drift_time);
-    }
+    if (f.drift_time != IMTypes::DRIFTTIME_NOT_SET)
+    {
+      feature.setMetaValue(Constants::UserParam::FAIMS_CV, f.drift_time);
+    }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ef1840c and 409e9b5.

📒 Files selected for processing (4)
  • CHANGELOG (3 hunks)
  • src/openms/include/OpenMS/CONCEPT/Constants.h (1 hunks)
  • src/openms/include/OpenMS/FEATUREFINDER/Biosaur2Algorithm.h (1 hunks)
  • src/openms/source/FEATUREFINDER/Biosaur2Algorithm.cpp (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/openms/include/OpenMS/CONCEPT/Constants.h
🧰 Additional context used
📓 Path-based instructions (2)
src/openms/**/*.{cpp,h,hpp,cc,cxx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

src/openms/**/*.{cpp,h,hpp,cc,cxx}: Follow the existing C++ coding conventions in the codebase
Use the established naming patterns for classes, methods, and variables
Use OpenMS data structures (e.g., MSExperiment, FeatureMap, PeptideIdentification)
Follow the established error handling patterns
Utilize OpenMS logging mechanisms
Be mindful of memory usage when processing large datasets
Consider algorithmic complexity for data processing operations
Use appropriate OpenMS containers and algorithms

Files:

  • src/openms/include/OpenMS/FEATUREFINDER/Biosaur2Algorithm.h
  • src/openms/source/FEATUREFINDER/Biosaur2Algorithm.cpp
src/openms/include/OpenMS/**/*.h

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Add Doxygen comments for new public methods and classes

Files:

  • src/openms/include/OpenMS/FEATUREFINDER/Biosaur2Algorithm.h
🧠 Learnings (7)
📓 Common learnings
Learnt from: jcharkow
Repo: OpenMS/OpenMS PR: 8188
File: src/topp/OpenSwathWorkflow.cpp:1118-1123
Timestamp: 2025-08-29T19:09:45.997Z
Learning: In OpenMS OpenSwathWorkflow, the use_ms1_ion_mobility parameter should be respected when applying estimated MS1 ion mobility extraction windows. The apply_window calls for MS1 ion mobility should check both pasef AND use_ms1_ion_mobility to avoid re-enabling disabled functionality.
Learnt from: jpfeuffer
Repo: OpenMS/OpenMS PR: 7970
File: src/pyOpenMS/addons/MSSpectrum.pyx:24-28
Timestamp: 2025-04-07T21:16:06.557Z
Learning: In OpenMS, the proper way to access ion mobility data in MSSpectrum is to use the `getIMData()` method, which returns a tuple with (position, unit). The position corresponds to the index in the FloatDataArrays where the ion mobility data is stored. Always use this method rather than assuming the first FloatDataArray contains ion mobility data.
Learnt from: jpfeuffer
Repo: OpenMS/OpenMS PR: 7970
File: src/pyOpenMS/addons/MSSpectrum.pyx:24-28
Timestamp: 2025-04-07T21:16:06.557Z
Learning: In OpenMS, the proper way to access ion mobility data in MSSpectrum is to use the `getIMData()` method, which returns a tuple with (position, unit). The position corresponds to the index in the FloatDataArrays where the ion mobility data is stored. Always use this method rather than assuming the first FloatDataArray contains ion mobility data.
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Use OpenMS data structures (e.g., MSExperiment, FeatureMap, PeptideIdentification)
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Use OpenMS data structures (e.g., MSExperiment, FeatureMap, PeptideIdentification)

Applied to files:

  • CHANGELOG
  • src/openms/source/FEATUREFINDER/Biosaur2Algorithm.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Be aware of OpenMS dependencies and external libraries

Applied to files:

  • CHANGELOG
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/include/OpenMS/**/*.h : Add Doxygen comments for new public methods and classes

Applied to files:

  • CHANGELOG
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Use appropriate OpenMS containers and algorithms

Applied to files:

  • src/openms/source/FEATUREFINDER/Biosaur2Algorithm.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Be mindful of memory usage when processing large datasets

Applied to files:

  • src/openms/source/FEATUREFINDER/Biosaur2Algorithm.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Consider algorithmic complexity for data processing operations

Applied to files:

  • src/openms/source/FEATUREFINDER/Biosaur2Algorithm.cpp
🔇 Additional comments (7)
src/openms/include/OpenMS/FEATUREFINDER/Biosaur2Algorithm.h (1)

688-715: FAIMS merge flag wiring in header looks consistent

faims_merge_features_ is added alongside other cached parameters in the private member block with a clear comment; no API surface change beyond internal state, which is appropriate.

src/openms/source/FEATUREFINDER/Biosaur2Algorithm.cpp (3)

19-20: New FeatureOverlapFilter dependency is appropriate

Including FeatureOverlapFilter.h here is justified by the later mergeFAIMSFeatures call and keeps the dependency local to the implementation.


107-112: Parameter definition for faims_merge_features is consistent with existing flags

The new faims_merge_features parameter is registered with sensible defaults, clear documentation, and proper setValidStrings({"true","false"}), matching the pattern of other boolean config flags.


117-165: Member caching and debug logging for faims_merge_features are correct

updateMembers_ correctly caches param_["faims_merge_features"] into faims_merge_features_, and extending the debug line ensures the new parameter is traceable without altering behavior.

CHANGELOG (3)

43-50: FAIMS/IM changelog entries are clear and aligned with the implementation

The new bullets for FeatureFinderCentroided/Metabo/Multiplex and FeatureFinderMetaboIdent/FeatureFinderIdentification accurately summarize automatic FAIMS CV grouping, per‑CV processing, and default cross‑CV merging behavior, and correctly flag both FAIMS and Bruker timsTOF ion mobility support as experimental.


62-62: FeatureFinderLFQ tool entry matches the new Biosaur2-based workflow

The FeatureFinderLFQ (experimental) changelog line concisely describes the new DDA‑LFQ feature finder as Biosaur2‑based with FAIMS and timsTOF IM support, which matches the surrounding code changes in this PR.


72-72: Library entry for FeatureFinderAlgorithmBiosaur2 is appropriate

The FeatureFinderAlgorithmBiosaur2 (experimental) addition under “OpenMS Library: Added” correctly documents the new algorithm and its FAIMS/tims ion mobility capabilities, giving users a clear pointer to the reusable library component behind FeatureFinderLFQ.

@timosachsenberg
timosachsenberg enabled auto-merge (squash) November 29, 2025 11:15
@timosachsenberg
timosachsenberg merged commit 2fe59dc into develop Nov 29, 2025
@timosachsenberg
timosachsenberg deleted the FFID_IM branch November 29, 2025 13:31
@coderabbitai coderabbitai Bot mentioned this pull request Dec 11, 2025
5 tasks
timosachsenberg added a commit that referenced this pull request May 27, 2026
… TSV columns (#9409)

The FeatureFinderMetaboIdent TSV format supports two optional columns
after IsoDistribution:
- IonMobility (added in #7453 for IM/FAIMS support)
- Adduct (added in #9382 for explicit adduct specification)

The pyOpenMS tutorial at doc/pyopenms/docs/source/user_guide/feature_detection.rst
was showing only the 7 required columns and the Python parsing example
did not read or pass the optional columns to FeatureFinderMetaboIdentCompound.

Changes:
- Add a prose note listing the two optional columns with their semantics
- Update the metaboTableFromFile() example to detect IonMobility and
  Adduct columns from the header row and pass them (or empty defaults)
  to the FeatureFinderMetaboIdentCompound constructor, which already
  accepts both as optional keyword arguments.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[quantms,core] add IM support to FeatureFInderIdentification and FeaturteFinderMetaboIdent

4 participants