Skip to content

Peak Group Identification

Joshua Charkow edited this page Oct 9, 2024 · 10 revisions

Introduction

Feature finding is performed by the pickTransitionGroup() method (invoked by scoreAllChromatograms_) which is found in the MRMTransitionGroupPicker module.

1. Pick Peaks in Each Chromatogram

Peak picking is performed by the pickChromatogram function which takes a chromatogram as input and returns a smoothed version of the chromatogram as well as any peaks (defined by an apex and left and right bounds). found in the chromatogram. computes all peaks. This function is found in the PeakPickerMRM module. Peak picking is only performed for transitions labelled as detecting.

A. Estimate S/N ratio for each datapoint using the median

The S/N ratio represents the ratio between the target intensity and the background noise. In this case, S/N is computed for each point by using the point's intensity as its signal and dividing this by the estimated noise, which is computed using a median histogram apporach. If the signal_to_noise parameter is set > 0, then a SignalToNoiseEstimatorMedian<MSChromatogram> S/N will be computed using the computeSTN_() which computes S/N using a sliding window approach.

  1. Compute the max_intensity. Any intensities above the max_intensity will be added to the last histogram bin. This depends on the mode set.
    1. AUTOMAXBYSTDEV (default)
      1. Guassian Estimator on raw data
      2. max_intensity = mean + sqrt(variance + auto_max_stdev_Factor_
    2. AUTOMAXBYPERCENT = max_intensity is the intensity at a certain percentile
    3. MANUAL = max_intensity is set manually
  2. For each datapoint in the chromatogram
    1. Collect a range of data points around it (dependent on win_len).
    2. Noise = median of the intensities in the current window OR noise_for_empty_window if there is not a sufficient number of points in the window < min_required_elements
    3. Divide target's intensity by the computed noise

B. Smooth Chromatograms

Smoothing is done directly in the pickChromatogram. The default is to smooth using SGolay.

  1. SGolay (using filter(chromatogram) ) - enabled using -PeakPickerMRM::use_gauss false
  2. Gaussian (using filter(chromatogram)) - enabled by setting PeakPickerMRM::use_gauss True
  3. Crawdad - enabled by setting -PeakPickerMRM::method to crawdad

C. Find peak seeds (apex) in the chromatogram (pick_())

Peak picking seeds is done using the pick_() method in PeakPickerHiRes. Although this method also computes the peak boundaries, this output is not used by OpenSwath since OpenSwath has its own peak boundary detection methods discussed below. Thus, we will not discuss peak boundary detection here.
A peak maximum is defined a point which:

  1. Has a greater intensity intensity than its left and right neighbour
  2. Oscillation is not occuring
    • Oscillation is defined as
      1. Left peak neighbour is less than the point to its left
      2. Right neighbour is less than the point on its right
      3. These left-by-2 and right-by-2 points are greater than the s/n cutoff
  3. Is above the S/N cutoff
  4. Left and right neighbours are above the S/N cutoff

Notes

  1. This function fethces RT values using the getMZ() method
  2. S/N cutoff is specified by PeakPickerMRM:signal_to_noise

D. Compute Peak Boundaries (pickChromatogram_)

  1. It seems as though the peak boundaries from above are not saved just the peak maximum and the maximum intensities

  2. However above only the retention time is recorded, so use findClosestPeak in order to find the index of the maximum retention time.

  3. Extend the peak to the left and the right

    • Peak is extended as long as
      • point to be appended is of lower intensity than the previous point OR the peak is smaller than the minimum peak width specified with peak_width
        • by default there is no minimum peak width
  4. Here record the index of the left_bound and the index of the right_bound

E. Remove Overlapping Peaks

Overlaps are removed by the removeOverlappingPeaks_() function (invoked by pickChromatogram_()). Overlaps are only removed if PeakPickerMRM::remove_overlapping_peaks is true.

Overlapping peaks are defined as the current peak left bounds is greater than the next peak's right bounds. If peaks are overlapping, adjust the borders so that they are not overlapping anymore.

F. Integrate Peaks

For each peak boundaries, sum the signals across intensity this is done in the integratePeaks_ method (invoked by pickChromatogram_()).

G. Save Peaks

For each peak in the chromatogram save the peak left boundary, peak right boundary and the integrated intensity.

2. Determine the "Top" Peak

In order to prepare for the creation of an MRMFeature first the top peak in the transition group is determined. The top peak can be determined in 2 ways, specified by the -TransitionGroupPicker::boundary_selection_method argument. The default is largest. The functions below are invoked by pickTransitionGroup().

  1. largest - Use the (transition, peak) combination with the highest intensity as the referecne peak findLargestPeak()
  2. widest - Use the (transition, peak) combination with the widest chromatogram as the reference peak (findWidestPeakIndices)

3. Create MRM Feature (createMRMFeature())

This is done using the createMRMFeature() method which takes in the transition_group, chromatograms and the (transition,peak) index of the "best" peak and returns an MRMFeature.

Features will continue to be created as long as:

  1. Peaks remain
  2. Did not exceed the maximum number of reported features (specified by TransitionGroupPicker::stop_after_feature)
  3. Intensity / total XIC is grater than threshold (specified by TransitionGroupPicker::??)
    • do not really get this because intensity and total xic are then same?

A. Determining the transition group boundaries (recalculatePeakBorders_())

Peak boundaries are recomputed using the recalculatePeakBorders_() function. This only occurs if -TransitionGroupPicker::use_consensus and TransitionGroupPicker::recalculate_peaks are set to true.

The function proceeds as follows:

  1. For each chromatogram iterate through all peaks and find the peak with the maximum intensity with its apex in range of "best left" and "best right"
    1. This will result in 0 or 1 peak being chosen per transition
  2. If no peaks were found (i do not know why this would be because should be able to find the original peak that defined the best left and right) return the empty list
  3. Compute the standard deviation of the right/left borders.
  4. If the standard deviation is acceptable (less than TransitionGroupPicker::recalculate_peaks_max_z) set the right/left boundary to the "pseudo median"

If the peak apex fell out of range during correction, set the apex at the center of the left and right

B. Remove Overlapping features

If TransitionGroupPicker::use_consensus is true remove overlapping features using remove_overlapping_features(). This method remvoes features which are between the left and right boundaries and determines the left and right boundaries.
If TransitionGroupPicker::use_consensus is false determine the left and right boundaries using pickApex(). This method looks at each chromatogram, and chooses the chose the peak whose apex is closest to the consensus apex. If no peak is found in the chromatogram, use the consensus boundaries.

C. Compute Quality

If TransitionGroupPicker::compute_peak_quality is true, compute the peak quality using computeQuality. If quality computing is enabled and below the TransitionGroupPicker::minimal_quality threshold, an empty feature is returned.

D. Linear Resampling

This step performs actually computes the feature, ensuring all chromatograms are on the same common grid. Linear resampling of transition chromatograms is done using the pickFragmentChromatograms() method and linear resampling of precursor chromatograms is done using pickPrecursorChromatograms(). Both methods follow a similar workflow so a generalized workflow is discussed below. Before invoking the main methods prepareMasterContainer_() is called to initiate a specturm container that will store the features.

pickFragmentChromatograms() iterates through all transitions in the peak group and performs the following:

  1. If TransitionGroupPicker::use_consensus is false take the left and right edge of the transition
  2. If the transition is labelled as detecting sum up all the intensities in the chromatogram
  3. If TransitionGroupPicker::compute_total_mi is true take the sum of the mutual information for all detecting transitions (using computeAndAppendRank() and rankedMutualInformation() functions).
  4. Resample the chromatogram (either the smoothed or original depending on the TransitionGroupPicker::peak_integration argument) (using resampleChromatogram)
    1. Determine the "start" and "end" RT of the chromatogram (with a little buffer room)
    2. Call LinearResamplerAlign::raster()
    3. Remove chromatograms without a single peak
    4. Compute the cross correlation scores for the collected intensities
    5. Determine the chromatogram with the minimum shape score and the maximum coelution score
  5. Integrate the Peak (integratePeak())
    1. Integration method is determined by PeakIntegrator::integration_type which is by default the sum of intensities
  6. Perform background subtraction
    1. Background subtraction subtracts a set amount from the intensity
    2. TransitionGroupPicker::background_subtraction can be:
      1. none (default) - No background subtraction is performed
      2. original $$ \frac{i_Li_R}{2}*N $$
        1. Where
          1. iL is the intensity at left bounds
          2. iR is the intensity of the right bounds
          3. N is the number of poins in the chromatogram
      3. exact - Use the estimateBackground method
  7. Save transition data in a Feature
    1. Quality = 0
    2. m/z - m/z of the precursor fragment
    3. RT - peak consensus
    4. ConvexHull2D
      1. Hull points Intensity integrator calculation?
    5. total_mi (if TransitionGroupPicker::compute_total_mi is true)

Some peak group level data is computed as well including:

  1. total_intensity - sum of intensities for all quantifying transitions
  2. total_peak_apices - sum of apices for all quatifying transitions

Note: for backwards compatibility peak shape metrics are computed (calculatePeakShapeMetrics)

E. Write additional MRMFeature Metadata

This metadata is written out at the end of the createMRMTransition function. Metadata saved here includes:

MRMFeature Name .osw Name Description
PeptideRef ??? Transition group id associated with this MRMTransition
leftWidth FEATURE.?? Left boundary of the peak group
rightWidth FEATURE.?? Right boundary of the peak group
total_xic FEATURE.?? sum of the integrated intensity for all transitions
total_mi FEATURE.?? Total MI score of the feature
peak_apices_sum FEATURE.?? sum of all quantifying transition peak apices

4. Check for overlapping peaks

This is done directly in the [pickTransitionGroup()] method. For each feature ensure that there are no "completly duplicate" transitions. If there are, discard them.

Clone this wiki locally