Skip to content

Conversation

@zhuoxinshi
Copy link
Contributor

@zhuoxinshi zhuoxinshi commented Oct 10, 2025

This pull request introduces significant enhancements and new features to the DIA (Data Independent Acquisition) analysis engine, particularly focusing on improved precursor-fragment grouping algorithms and support for ISD (In-Source Decay) data. The main changes include the addition of a new ISDEngine class, integration of DIA-Umpire inspired grouping logic, expanded configuration options, and new correlation/overlap calculation methods. These updates provide more flexibility and accuracy in DIA data analysis workflows.

New Engines and Grouping Algorithms:

  • Added a new ISDEngine class that inherits from DIAEngine, enabling ISD data analysis using a workflow similar to DIA, including ISD-specific scan grouping, relabeling, and pseudo-MS2 scan generation. (MetaMorpheus/EngineLayer/DIA/ISDEngine.cs)
  • Introduced the UmpirePfGroupingEngine class, implementing precursor-fragment grouping algorithms based on DIA-Umpire (Nat Methods 2015) with custom overlap and correlation calculations. (MetaMorpheus/EngineLayer/DIA/PrecursorFragmentGrouping/UmpirePfGroupingEngine.cs)

Precursor-Fragment Grouping Enhancements:

  • Refactored XicGroupingEngine to support configurable precursor and fragment rank thresholds, improved parallelization, and post-filtering of groups based on these ranks. (MetaMorpheus/EngineLayer/DIA/PrecursorFragmentGrouping/XicGroupingEngine.cs, PfGroupingEngine.cs) [1] [2] [3] [4]
  • Added static method FilterPfPairsByRank in PfGroupingEngine to filter precursor-fragment pairs within groups according to rank thresholds. (MetaMorpheus/EngineLayer/DIA/PrecursorFragmentGrouping/PfGroupingEngine.cs)

Correlation and Overlap Calculation Methods:

  • Implemented new methods for calculating XIC correlation and overlap based on DIA-Umpire algorithms: CalculateXicCorrXYData_Umpire and CalculateXicOverlapRatio_Umpire. (MetaMorpheus/EngineLayer/DIA/PrecursorFragmentGroup.cs) [1] [2]
  • Added SetFragmentRankForPfPairs to rank fragments within precursor-fragment groups. (MetaMorpheus/EngineLayer/DIA/PrecursorFragmentGroup.cs)

Configuration and API Improvements:

  • Updated DIAparameters to include a CombineFragments boolean option and an updated constructor to control whether fragment XICs from different groups are combined before PF grouping. (MetaMorpheus/EngineLayer/DIA/DIAparameters.cs)
  • Made GetPseudoMs2Scans in DIAEngine virtual to allow overriding in derived engines such as ISDEngine. (MetaMorpheus/EngineLayer/DIA/DIAEngine.cs)

These changes collectively expand the analytical capabilities of the DIA engine, improve configurability, and lay the groundwork for more advanced DIA and ISD data processing.This PR is a follow up of the first DIA PR, which includes the following updates:

  • Added functionalities to rank PrecursorFragmentPair based on their XIC correlation and remove PfPairs in a PrecursorFragmentGroup that has low rankings.
  • Added ISDEngine as a child class of DIAEngine to process ISD data, including functionalities to group ISD fragment spectra based on ISD energy levels and relabel those ISD scans as MS2 scans.
  • Added UmpireGrouping which does PF grouping using algorithms from DIA Umpire.
  • Added GetAllXicsWithXicSpline in XicConstructor which finds all XICs and do interpolations on individual XICs in the same method.

Copy link
Member

@nbollis nbollis left a comment

Choose a reason for hiding this comment

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

So close to being ready, I just want a few summary comments on important methods and parameters. Good work!

/// DIAEngine defines a workflow of generating DDA-like pseudo MS2 scans for DIA data analysis. It includes the processes of extracting precursor and
/// fragment XICs, grouping them into PrecursorFragmentsGroup objects, and constructing pseudo MS2 scans.
/// </summary>
public class DIAEngine
Copy link
Member

Choose a reason for hiding this comment

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

A future refactor should make DIAEngine a child class of MetaMorpheusEngine to take advantage of our time tracking, result writing, file specific parameters, and status and warning messages.

@trishorts trishorts requested a review from Copilot October 24, 2025 18:10
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 15 out of 16 changed files in this pull request and generated 3 comments.

Comments suppressed due to low confidence (1)

MetaMorpheus/EngineLayer/DIA/PrecursorFragmentGrouping/XicGroupingEngine.cs:1

  • The XicLinearSpline instantiation on line 98 of TestPfPairAndPfGroup.cs is missing the scanIndexBased parameter that was used in the removed test on line 93 of TestXicGrouping.cs, potentially changing test behavior.
using System;

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

}
var xic2 = new ExtractedIonChromatogram(peakList2);
double corr = PrecursorFragmentsGroup.CalculateXicCorrelation(xic1, xic2);
//Assert.That(corr, Is.EqualTo(1.0).Within(1e-6));
Copy link

Copilot AI Oct 24, 2025

Choose a reason for hiding this comment

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

Remove commented-out assertions or replace with actual test logic. These lines (210, 221, 231) appear to be debugging remnants.

Copilot uses AI. Check for mistakes.
Comment on lines +141 to +148
if (arrayA[idx] == 0f)
{
arrayA[idx] = (arrayA[idx - 1] + arrayA[idx + 1]) / 2;
}
if (arrayB[idx] == 0f)
{
arrayB[idx] = (arrayB[idx - 1] + arrayB[idx + 1]) / 2;
}
Copy link

Copilot AI Oct 24, 2025

Choose a reason for hiding this comment

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

The zero-filling logic uses magic number comparisons (0f). Consider extracting this interpolation logic into a named helper method or add comments explaining why zero values are being interpolated.

Copilot uses AI. Check for mistakes.
nbollis
nbollis previously approved these changes Oct 27, 2025
nbollis
nbollis previously approved these changes Oct 30, 2025
Copy link
Contributor

@Alexander-Sol Alexander-Sol left a comment

Choose a reason for hiding this comment

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

Nice work!

@trishorts trishorts merged commit b3c331d into smith-chem-wisc:master Jan 22, 2026
8 checks passed
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.

4 participants