OpenMS

Compute the area, background and shape metrics of a peak. More...
#include <OpenMS/ANALYSIS/OPENSWATH/PeakIntegrator.h>
Classes  
struct  PeakArea 
struct  PeakBackground 
struct  PeakShapeMetrics 
Public Member Functions  
PeakIntegrator ()  
Constructor. More...  
~PeakIntegrator () override  
Destructor. More...  
PeakArea  integratePeak (const MSChromatogram &chromatogram, const double left, const double right) const 
Compute the area of a peak contained in a MSChromatogram. More...  
PeakArea  integratePeak (const MSChromatogram &chromatogram, MSChromatogram::ConstIterator &left, MSChromatogram::ConstIterator &right) const 
Compute the area of a peak contained in a MSChromatogram. More...  
PeakArea  integratePeak (const MSSpectrum &spectrum, const double left, const double right) const 
Compute the area of a peak contained in a MSSpectrum. More...  
PeakArea  integratePeak (const MSSpectrum &spectrum, MSSpectrum::ConstIterator &left, MSSpectrum::ConstIterator &right) const 
Compute the area of a peak contained in a MSSpectrum. More...  
PeakBackground  estimateBackground (const MSChromatogram &chromatogram, const double left, const double right, const double peak_apex_pos) const 
Estimate the background of a peak contained in a MSChromatogram. More...  
PeakBackground  estimateBackground (const MSChromatogram &chromatogram, MSChromatogram::ConstIterator &left, MSChromatogram::ConstIterator &right, const double peak_apex_pos) const 
Estimate the background of a peak contained in a MSChromatogram. More...  
PeakBackground  estimateBackground (const MSSpectrum &spectrum, const double left, const double right, const double peak_apex_pos) const 
Estimate the background of a peak contained in a MSSpectrum. More...  
PeakBackground  estimateBackground (const MSSpectrum &spectrum, MSSpectrum::ConstIterator &left, MSSpectrum::ConstIterator &right, const double peak_apex_pos) const 
Estimate the background of a peak contained in a MSSpectrum. More...  
PeakShapeMetrics  calculatePeakShapeMetrics (const MSChromatogram &chromatogram, const double left, const double right, const double peak_height, const double peak_apex_pos) const 
Calculate peak's shape metrics. More...  
PeakShapeMetrics  calculatePeakShapeMetrics (const MSChromatogram &chromatogram, MSChromatogram::ConstIterator &left, MSChromatogram::ConstIterator &right, const double peak_height, const double peak_apex_pos) const 
Calculate peak's shape metrics. More...  
PeakShapeMetrics  calculatePeakShapeMetrics (const MSSpectrum &spectrum, const double left, const double right, const double peak_height, const double peak_apex_pos) const 
Calculate peak's shape metrics. More...  
PeakShapeMetrics  calculatePeakShapeMetrics (const MSSpectrum &spectrum, MSSpectrum::ConstIterator &left, MSSpectrum::ConstIterator &right, const double peak_height, const double peak_apex_pos) const 
Calculate peak's shape metrics. More...  
void  getDefaultParameters (Param ¶ms) 
Public Member Functions inherited from DefaultParamHandler  
DefaultParamHandler (const String &name)  
Constructor with name that is displayed in error messages. More...  
DefaultParamHandler (const DefaultParamHandler &rhs)  
Copy constructor. More...  
virtual  ~DefaultParamHandler () 
Destructor. More...  
DefaultParamHandler &  operator= (const DefaultParamHandler &rhs) 
Assignment operator. More...  
virtual bool  operator== (const DefaultParamHandler &rhs) const 
Equality operator. More...  
void  setParameters (const Param ¶m) 
Sets the parameters. More...  
const Param &  getParameters () const 
Nonmutable access to the parameters. More...  
const Param &  getDefaults () const 
Nonmutable access to the default parameters. More...  
const String &  getName () const 
Nonmutable access to the name. More...  
void  setName (const String &name) 
Mutable access to the name. More...  
const std::vector< String > &  getSubsections () const 
Nonmutable access to the registered subsections. More...  
Static Public Attributes  
Constant expressions for parameters  
Constants expressions used throughout the code and tests to set the integration and baseline types.  
static constexpr const char *  INTEGRATION_TYPE_INTENSITYSUM = "intensity_sum" 
static constexpr const char *  INTEGRATION_TYPE_TRAPEZOID = "trapezoid" 
Integration type: trapezoid. More...  
static constexpr const char *  INTEGRATION_TYPE_SIMPSON = "simpson" 
Integration type: simpson. More...  
static constexpr const char *  BASELINE_TYPE_BASETOBASE = "base_to_base" 
Baseline type: base to base. More...  
static constexpr const char *  BASELINE_TYPE_VERTICALDIVISION = "vertical_division" 
Baseline type: vertical division (min of end points; only for backwards compatibility) More...  
static constexpr const char *  BASELINE_TYPE_VERTICALDIVISION_MIN = "vertical_division_min" 
Baseline type: vertical division (min of end points) More...  
static constexpr const char *  BASELINE_TYPE_VERTICALDIVISION_MAX = "vertical_division_max" 
Baseline type: vertical division (max of end points) More...  
Protected Member Functions  
void  updateMembers_ () override 
This method is used to update extra member variables at the end of the setParameters() method. More...  
template<typename PeakContainerT >  
PeakArea  integratePeak_ (const PeakContainerT &pc, double left, double right) const 
template<typename PeakContainerT >  
PeakBackground  estimateBackground_ (const PeakContainerT &pc, double left, double right, const double peak_apex_pos) const 
template<typename PeakContainerConstIteratorT >  
double  simpson_ (PeakContainerConstIteratorT it_begin, PeakContainerConstIteratorT it_end) const 
Simpson's rule algorithm. More...  
template<typename PeakContainerT >  
PeakShapeMetrics  calculatePeakShapeMetrics_ (const PeakContainerT &pc, double left, double right, const double peak_height, const double peak_apex_pos) const 
template<typename PeakContainerConstIteratorT >  
double  findPosAtPeakHeightPercent_ (PeakContainerConstIteratorT it_left, PeakContainerConstIteratorT it_right, PeakContainerConstIteratorT it_end, const double peak_height, const double percent, const bool is_left_half) const 
Find the position (RT/MZ) at a given percentage of peak's height. More...  
Protected Member Functions inherited from DefaultParamHandler  
void  defaultsToParam_ () 
Updates the parameters after the defaults have been set in the constructor. More...  
Private Member Functions  
template<typename PeakContainerT >  
const PeakContainerT &  EMGPreProcess_ (const PeakContainerT &pc, PeakContainerT &emg_pc, double &left, double &right) const 
Fit the peak to the EMG model. More...  
Private Attributes  
bool  fit_EMG_ 
Enable/disable EMG peak model fitting. More...  
EmgGradientDescent  emg_ 
Parameters  
The user is supposed to select a value for these parameters. By default, the integration_type_ is "intensity_sum" and the baseline_type_ is "base_to_base".  
String  integration_type_ = INTEGRATION_TYPE_INTENSITYSUM 
String  baseline_type_ = BASELINE_TYPE_BASETOBASE 
Additional Inherited Members  
Static Public Member Functions inherited from DefaultParamHandler  
static void  writeParametersToMetaValues (const Param &write_this, MetaInfoInterface &write_here, const String &key_prefix="") 
Writes all parameters to meta values. More...  
Protected Attributes inherited from DefaultParamHandler  
Param  param_ 
Container for current parameters. More...  
Param  defaults_ 
Container for default parameters. This member should be filled in the constructor of derived classes! More...  
std::vector< String >  subsections_ 
Container for registered subsections. This member should be filled in the constructor of derived classes! More...  
String  error_name_ 
Name that is displayed in error messages during the parameter checking. More...  
bool  check_defaults_ 
If this member is set to false no checking if parameters in done;. More...  
bool  warn_empty_defaults_ 
If this member is set to false no warning is emitted when defaults are empty;. More...  
Compute the area, background and shape metrics of a peak.
The area computation is performed in integratePeak() and it supports integration by simple sum of the intensity, integration by Simpson's rule implementations for an odd number of unequally spaced points or integration by the trapezoid rule.
The background computation is performed in estimateBackground() and it supports three different approaches to baseline correction, namely computing a rectangular shape under the peak based on the minimum value of the peak borders (vertical_division_min), a rectangular shape based on the maximum value of the beak borders (vertical_division_max) or a trapezoidal shape based on a straight line between the peak borders (base_to_base).
Peak shape metrics are computed in calculatePeakShapeMetrics() and multiple metrics are supported.
The containers supported by the methods are MSChromatogram and MSSpectrum.
struct OpenMS::PeakIntegrator::PeakArea 
struct OpenMS::PeakIntegrator::PeakBackground 
Class Members  

double  area 
The background area estimation 
double  height 
The background height 
struct OpenMS::PeakIntegrator::PeakShapeMetrics 
Class Members  

double  asymmetry_factor 
The asymmetry factor is a measure of peak tailing. It is defined as the distance from the center line of the peak to the back slope divided by the distance from the center line of the peak to the front slope, with all measurements made at 10% of the maximum peak height. asymmetry_factor = As = b/a where a is min width to peak maximum at 10% max peak height b is max width to peak maximum at 10% max peak height 
double  baseline_delta_2_height 
The change in baseline divided by the height is a way of comparing the influence of the change of baseline on the peak height. 
double  end_position_at_10 
The end position at which the intensity is 10% the peak's height. 
double  end_position_at_5 
The end position at which the intensity is 5% the peak's height. 
double  end_position_at_50 
The end position at which the intensity is 50% the peak's height. 
Int  points_across_baseline 
The number of points across the baseline. 
Int  points_across_half_height 
The number of points across half the peak's height. 
double  slope_of_baseline 
The slope of the baseline is a measure of slope change. It is approximated as the difference in baselines between the peak start and peak end. 
double  start_position_at_10 
The start position at which the intensity is 10% the peak's height. 
double  start_position_at_5 
The start position at which the intensity is 5% the peak's height. 
double  start_position_at_50 
The start position at which the intensity is 50% the peak's height. 
double  tailing_factor 
The tailing factor is a measure of peak tailing. It is defined as the distance from the front slope of the peak to the back slope divided by twice the distance from the center line of the peak to the front slope, with all measurements made at 5% of the maximum peak height. tailing_factor = Tf = W0.05/2a where W0.05 is peak width at 5% max peak height a = min width to peak maximum at 5% max peak height b = max width to peak maximum at 5% max peak height 0.9 < Tf < 1.2 front Tf < 0.9 tailing Tf > 1.2 
double  total_width 
The peak's total width. 
double  width_at_10 
The width of the peak at 10% the peak's height. 
double  width_at_5 
The width of the peak at 5% the peak's height. 
double  width_at_50 
The width of the peak at 50% the peak's height. 
PeakIntegrator  (  ) 
Constructor.

override 
Destructor.
PeakShapeMetrics calculatePeakShapeMetrics  (  const MSChromatogram &  chromatogram, 
const double  left,  
const double  right,  
const double  peak_height,  
const double  peak_apex_pos  
)  const 
Calculate peak's shape metrics.
The calculated characteristics are the start and end times at 0.05, 0.10 and 0.5 the peak's height. Also the widths at those positions are calculated. Other values: the peak's total width, its tailing factor, asymmetry factor, baseline delta to height and the slope of the baseline. The number of points across the baseline and also at half height are saved.
[in]  chromatogram  The chromatogram which contains the peak 
[in]  left  The left retention time boundary 
[in]  right  The right retention time boundary 
[in]  peak_height  The peak's highest intensity 
[in]  peak_apex_pos  The position of the point with highest intensity 
PeakShapeMetrics calculatePeakShapeMetrics  (  const MSChromatogram &  chromatogram, 
MSChromatogram::ConstIterator &  left,  
MSChromatogram::ConstIterator &  right,  
const double  peak_height,  
const double  peak_apex_pos  
)  const 
Calculate peak's shape metrics.
The calculated characteristics are the start and end times at 0.05, 0.10 and 0.5 the peak's height. Also the widths at those positions are calculated. Other values: the peak's total width, its tailing factor, asymmetry factor, baseline delta to height and the slope of the baseline. The number of points across the baseline and also at half height are saved.
[in]  chromatogram  The chromatogram which contains the peak 
[in]  left  The iterator to the first point 
[in]  right  The iterator to the last point 
[in]  peak_height  The peak's highest intensity 
[in]  peak_apex_pos  The position of the point with highest intensity 
PeakShapeMetrics calculatePeakShapeMetrics  (  const MSSpectrum &  spectrum, 
const double  left,  
const double  right,  
const double  peak_height,  
const double  peak_apex_pos  
)  const 
Calculate peak's shape metrics.
The calculated characteristics are the start and end positions at 0.05, 0.10 and 0.5 the peak's height. Also the widths at those positions are calculated. Other values: the peak's total width, its tailing factor, asymmetry factor, baseline delta to height and the slope of the baseline. The number of points across the baseline and also at half height are saved.
[in]  spectrum  The spectrum which contains the peak 
[in]  left  The left masstocharge ratio boundary 
[in]  right  The right masstocharge ratio boundary 
[in]  peak_height  The peak's highest intensity 
[in]  peak_apex_pos  The position of the point with highest intensity 
PeakShapeMetrics calculatePeakShapeMetrics  (  const MSSpectrum &  spectrum, 
MSSpectrum::ConstIterator &  left,  
MSSpectrum::ConstIterator &  right,  
const double  peak_height,  
const double  peak_apex_pos  
)  const 
Calculate peak's shape metrics.
The calculated characteristics are the start and end positions at 0.05, 0.10 and 0.5 the peak's height. Also the widths at those positions are calculated. Other values: the peak's total width, its tailing factor, asymmetry factor, baseline delta to height and the slope of the baseline. The number of points across the baseline and also at half height are saved.
[in]  spectrum  The spectrum which contains the peak 
[in]  left  The iterator to the first point 
[in]  right  The iterator to the last point 
[in]  peak_height  The peak's highest intensity 
[in]  peak_apex_pos  The position of the point with highest intensity 

inlineprotected 
References PeakIntegrator::PeakShapeMetrics::asymmetry_factor, PeakIntegrator::PeakShapeMetrics::baseline_delta_2_height, PeakIntegrator::PeakShapeMetrics::end_position_at_10, PeakIntegrator::PeakShapeMetrics::end_position_at_5, PeakIntegrator::PeakShapeMetrics::end_position_at_50, PeakIntegrator::PeakShapeMetrics::points_across_baseline, PeakIntegrator::PeakShapeMetrics::points_across_half_height, PeakIntegrator::PeakShapeMetrics::slope_of_baseline, PeakIntegrator::PeakShapeMetrics::start_position_at_10, PeakIntegrator::PeakShapeMetrics::start_position_at_5, PeakIntegrator::PeakShapeMetrics::start_position_at_50, PeakIntegrator::PeakShapeMetrics::tailing_factor, PeakIntegrator::PeakShapeMetrics::total_width, PeakIntegrator::PeakShapeMetrics::width_at_10, PeakIntegrator::PeakShapeMetrics::width_at_5, and PeakIntegrator::PeakShapeMetrics::width_at_50.

inlineprivate 
Fit the peak to the EMG model.
The fitting process happens only if fit_EMG_
is true. left
and right
are updated accordingly.
PeakContainerT  Either a MSChromatogram or a MSSpectrum 
[in]  pc  Input peak 
[out]  emg_pc  Will possibly contain the processed peak 
[in]  left  RT or MZ value of the first point of interest 
[in]  right  RT or MZ value of the first point of interest 
emg_pc
if the fitting is executed, pc
otherwise. References EmgGradientDescent::fitEMGPeakModel().
PeakBackground estimateBackground  (  const MSChromatogram &  chromatogram, 
const double  left,  
const double  right,  
const double  peak_apex_pos  
)  const 
Estimate the background of a peak contained in a MSChromatogram.
The user can choose to compute one of two background types: "vertical_sum" and "base_to_base". For the former case, the area is computed as a rectangle with delta RT being the base and the minimum intensity on boundaries as the height. For the latter case, the area is computed as a rectangle trapezoid. Similar to the "vertical_sum" solution, this technique also takes into account the area between the intensities on boundaries.
For both cases, the parameter integration_type_ decides which formula to use to compute the area. The user should make sure to use the same integration_type between calls of estimateBackground() and integratePeak().
Exception::InvalidParameter  for class parameter baseline_type . 
[in]  chromatogram  The chromatogram which contains the peak 
[in]  left  The left retention time boundary 
[in]  right  The right retention time boundary 
[in]  peak_apex_pos  The position of the point with highest intensity 
PeakBackground estimateBackground  (  const MSChromatogram &  chromatogram, 
MSChromatogram::ConstIterator &  left,  
MSChromatogram::ConstIterator &  right,  
const double  peak_apex_pos  
)  const 
Estimate the background of a peak contained in a MSChromatogram.
The user can choose to compute one of two background types: "vertical_sum" and "base_to_base". For the former case, the area is computed as a rectangle with delta RT being the base and the minimum intensity on boundaries as the height. For the latter case, the area is computed as a rectangle trapezoid. Similar to the "vertical_sum" solution, this technique also takes into account the area between the intensities on boundaries.
For both cases, the parameter integration_type_ decides which formula to use to compute the area. The user should make sure to use the same integration_type between calls of estimateBackground() and integratePeak().
Exception::InvalidParameter  for class parameter baseline_type . 
[in]  chromatogram  The chromatogram which contains the peak 
[in]  left  The iterator to the first point 
[in]  right  The iterator to the last point 
[in]  peak_apex_pos  The position of the point with highest intensity 
PeakBackground estimateBackground  (  const MSSpectrum &  spectrum, 
const double  left,  
const double  right,  
const double  peak_apex_pos  
)  const 
Estimate the background of a peak contained in a MSSpectrum.
The user can choose to compute one of two background types: "vertical_sum" and "base_to_base". For the former case, the area is computed as a rectangle with delta MZ being the base and the minimum intensity on boundaries as the height. For the latter case, the area is computed as a rectangle trapezoid. Similar to the "vertical_sum" solution, this technique also takes into account the area between the intensities on boundaries.
For both cases, the parameter integration_type_ decides which formula to use to compute the area. The user should make sure to use the same integration_type between calls of estimateBackground() and integratePeak().
Exception::InvalidParameter  for class parameter baseline_type . 
[in]  spectrum  The spectrum which contains the peak 
[in]  left  The left masstocharge ratio boundary 
[in]  right  The right masstocharge ratio boundary 
[in]  peak_apex_pos  The position of the point with highest intensity 
PeakBackground estimateBackground  (  const MSSpectrum &  spectrum, 
MSSpectrum::ConstIterator &  left,  
MSSpectrum::ConstIterator &  right,  
const double  peak_apex_pos  
)  const 
Estimate the background of a peak contained in a MSSpectrum.
The user can choose to compute one of two background types: "vertical_sum" and "base_to_base". For the former case, the area is computed as a rectangle with delta MZ being the base and the minimum intensity on boundaries as the height. For the latter case, the area is computed as a rectangle trapezoid. Similar to the "vertical_sum" solution, this technique also takes into account the area between the intensities on boundaries.
For both cases, the parameter integration_type_ decides which formula to use to compute the area. The user should make sure to use the same integration_type between calls of estimateBackground() and integratePeak().
Exception::InvalidParameter  for class parameter baseline_type . 
[in]  spectrum  The spectrum which contains the peak 
[in]  left  The iterator to the first point 
[in]  right  The iterator to the last point 
[in]  peak_apex_pos  The position of the point with highest intensity 

inlineprotected 

inlineprotected 
Find the position (RT/MZ) at a given percentage of peak's height.
[in]  it_left  The iterator to the first point (must not be past the end) 
[in]  it_right  The iterator to the last point (might be past the end) 
[in]  it_end  The enditerator of the container 
[in]  peak_height  The peak's height 
[in]  percent  At which percentage of the peak height we want to find the position (common values: 0.05, 0.1, 0.5) 
[in]  is_left_half  According to which half of the peak, the algorithm proceeds to the correct direction 
void getDefaultParameters  (  Param &  params  ) 
PeakArea integratePeak  (  const MSChromatogram &  chromatogram, 
const double  left,  
const double  right  
)  const 
Compute the area of a peak contained in a MSChromatogram.
The value of integration_type_ decides which integration technique to use:
Exception::InvalidParameter  for class parameter integration_type . 
[in]  chromatogram  The chromatogram which contains the peak 
[in]  left  The left retention time boundary 
[in]  right  The right retention time boundary 
PeakArea integratePeak  (  const MSChromatogram &  chromatogram, 
MSChromatogram::ConstIterator &  left,  
MSChromatogram::ConstIterator &  right  
)  const 
Compute the area of a peak contained in a MSChromatogram.
The value of integration_type_ decides which integration technique to use:
Exception::InvalidParameter  for class parameter integration_type . 
[in]  chromatogram  The chromatogram which contains the peak 
[in]  left  The iterator to the first point 
[in]  right  The iterator to the last point 
PeakArea integratePeak  (  const MSSpectrum &  spectrum, 
const double  left,  
const double  right  
)  const 
Compute the area of a peak contained in a MSSpectrum.
The value of integration_type_ decides which integration technique to use:
Exception::InvalidParameter  for class parameter integration_type . 
[in]  spectrum  The spectrum which contains the peak 
[in]  left  The left masstocharge ratio boundary 
[in]  right  The right masstocharge ratio boundary 
PeakArea integratePeak  (  const MSSpectrum &  spectrum, 
MSSpectrum::ConstIterator &  left,  
MSSpectrum::ConstIterator &  right  
)  const 
Compute the area of a peak contained in a MSSpectrum.
The value of integration_type_ decides which integration technique to use:
Exception::InvalidParameter  for class parameter integration_type . 
[in]  spectrum  The spectrum which contains the peak 
[in]  left  The iterator to the first point 
[in]  right  The iterator to the last point 

inlineprotected 

inlineprotected 
Simpson's rule algorithm.
This implementation expects an odd number of points. The formula used supports unequally spaced points.
[in]  it_begin  The iterator to the first point 
[in]  it_end  The iterator to the pastthelast point 
References OpenMS::Constants::h, and OpenMS::Constants::k.

overrideprotectedvirtual 
This method is used to update extra member variables at the end of the setParameters() method.
Also call it at the end of the derived classes' copy constructor and assignment operator.
The default implementation is empty.
Reimplemented from DefaultParamHandler.

private 
The baseline type to use in estimateBackground(). Possible values are: "vertical_division_max", "vertical_division_min", "base_to_base".

staticconstexpr 
Baseline type: base to base.

staticconstexpr 
Baseline type: vertical division (min of end points; only for backwards compatibility)

staticconstexpr 
Baseline type: vertical division (max of end points)

staticconstexpr 
Baseline type: vertical division (min of end points)

private 

private 
Enable/disable EMG peak model fitting.

private 
The integration technique to use in integratePeak() and estimateBackground(). Possible values are: "trapezoid", "simpson", "intensity_sum".

staticconstexpr 
Integration type: intensity sum

staticconstexpr 
Integration type: simpson.

staticconstexpr 
Integration type: trapezoid.