OpenMS
PeakPickerCWT Class Reference

This class implements a peak picking algorithm using wavelet techniques. More...

#include <OpenMS/TRANSFORMATIONS/RAW2PEAK/PeakPickerCWT.h>

Inheritance diagram for PeakPickerCWT:
[legend]
Collaboration diagram for PeakPickerCWT:
[legend]

Classes

struct  PeakArea_
 Class for the internal peak representation. More...
 

Public Types

typedef MSSpectrum::iterator PeakIterator
 Profile data iterator type. More...
 
typedef MSSpectrum::const_iterator ConstPeakIterator
 Const profile data iterator type. More...
 
- Public Types inherited from ProgressLogger
enum  LogType { CMD , GUI , NONE }
 Possible log types. More...
 

Public Member Functions

 PeakPickerCWT ()
 Constructor. More...
 
 ~PeakPickerCWT () override
 Destructor. More...
 
void pick (const MSSpectrum &input, MSSpectrum &output) const
 Applies the peak picking algorithm to a single spectrum. More...
 
void pickExperiment (const PeakMap &input, PeakMap &output)
 Picks the peaks in an MSExperiment. More...
 
double estimatePeakWidth (const PeakMap &input)
 Estimates average peak width that can then be used for peak picking. More...
 
- 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...
 
DefaultParamHandleroperator= (const DefaultParamHandler &rhs)
 Assignment operator. More...
 
virtual bool operator== (const DefaultParamHandler &rhs) const
 Equality operator. More...
 
void setParameters (const Param &param)
 Sets the parameters. More...
 
const ParamgetParameters () const
 Non-mutable access to the parameters. More...
 
const ParamgetDefaults () const
 Non-mutable access to the default parameters. More...
 
const StringgetName () const
 Non-mutable access to the name. More...
 
void setName (const String &name)
 Mutable access to the name. More...
 
const std::vector< String > & getSubsections () const
 Non-mutable access to the registered subsections. More...
 
- Public Member Functions inherited from ProgressLogger
 ProgressLogger ()
 Constructor. More...
 
virtual ~ProgressLogger ()
 Destructor. More...
 
 ProgressLogger (const ProgressLogger &other)
 Copy constructor. More...
 
ProgressLoggeroperator= (const ProgressLogger &other)
 Assignment Operator. More...
 
void setLogType (LogType type) const
 Sets the progress log that should be used. The default type is NONE! More...
 
LogType getLogType () const
 Returns the type of progress log being used. More...
 
void startProgress (SignedSize begin, SignedSize end, const String &label) const
 Initializes the progress display. More...
 
void setProgress (SignedSize value) const
 Sets the current progress. More...
 
void endProgress (UInt64 bytes_processed=0) const
 
void nextProgress () const
 increment progress by 1 (according to range begin-end) More...
 

Protected Member Functions

void updateMembers_ () override
 This method is used to update extra member variables at the end of the setParameters() method. More...
 
void getPeakArea_ (const PeakArea_ &area, double &area_left, double &area_right) const
 Computes the peak's left and right area. More...
 
PeakShape fitPeakShape_ (const PeakArea_ &area) const
 Returns the best fitting peakshape. More...
 
double correlate_ (const PeakShape &peak, const PeakArea_ &area, Int direction=0) const
 Returns the squared Pearson coefficient. More...
 
bool getMaxPosition_ (const PeakIterator first, const PeakIterator last, const ContinuousWaveletTransform &wt, PeakArea_ &area, const Int distance_from_scan_border, const double peak_bound_cwt, const double peak_bound_ms2_level_cwt, const Int direction=1) const
 Finds the next maximum position in the wavelet transform wt. More...
 
bool getPeakEndPoints_ (PeakIterator first, PeakIterator last, PeakArea_ &area, Int distance_from_scan_border, Int &peak_left_index, Int &peak_right_index, ContinuousWaveletTransformNumIntegration &wt) const
 Determines a peaks's endpoints. More...
 
void getPeakCentroid_ (PeakArea_ &area) const
 Estimates a peak's centroid position. More...
 
double lorentz_ (const double height, const double lambda, const double pos, const double x) const
 Computes the value of a theoretical Lorentz peak at position x. More...
 
void initializeWT_ (ContinuousWaveletTransformNumIntegration &wt, const double peak_bound_in, double &peak_bound_ms_cwt) const
 Computes the threshold for the peak height in the wavelet transform and initializes the wavelet transform. More...
 
Methods needed for separation of overlapping peaks
bool deconvolutePeak_ (PeakShape &shape, std::vector< PeakShape > &peak_shapes, double peak_bound_cwt) const
 Separates overlapping peaks. More...
 
Int getNumberOfPeaks_ (ConstPeakIterator first, ConstPeakIterator last, std::vector< double > &peak_values, Int direction, double resolution, ContinuousWaveletTransformNumIntegration &wt, double peak_bound_cwt) const
 Determines the number of peaks in the given mass range using the cwt. More...
 
Int determineChargeState_ (std::vector< double > &peak_values) const
 Estimate the charge state of the peaks. More...
 
void addPeak_ (std::vector< PeakShape > &peaks_DC, PeakArea_ &area, double left_width, double right_width, OptimizePeakDeconvolution::Data &data) const
 Add a peak. More...
 
- Protected Member Functions inherited from DefaultParamHandler
void defaultsToParam_ ()
 Updates the parameters after the defaults have been set in the constructor. More...
 

Protected Attributes

float peak_bound_
 Threshold for the peak height in the MS 1 level. More...
 
float peak_bound_ms2_level_
 Threshold for the peak height in the MS 2 level. More...
 
float signal_to_noise_
 Signal to noise threshold. More...
 
float fwhm_bound_
 The minimal full width at half maximum. More...
 
UInt radius_
 The search radius for the determination of a peak's maximum position. More...
 
float scale_
 The dilation of the wavelet. More...
 
float peak_corr_bound_
 The threshold for correlation. More...
 
float noise_level_
 The threshold for the noise level (TODO: Use the information of the signal to noise estimator) More...
 
bool optimization_
 Switch for the optimization of peak parameters. More...
 
bool deconvolution_
 Switch for the deconvolution of peak parameters. More...
 
bool two_d_optimization_
 Switch for the 2D optimization of peak parameters. 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< Stringsubsections_
 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...
 
- Protected Attributes inherited from ProgressLogger
LogType type_
 
time_t last_invoke_
 
ProgressLoggerImplcurrent_logger_
 

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...
 
- Static Protected Member Functions inherited from ProgressLogger
static String logTypeToFactoryName_ (LogType type)
 Return the name of the factory product used for this log type. More...
 
- Static Protected Attributes inherited from ProgressLogger
static int recursion_depth_
 

Detailed Description

This class implements a peak picking algorithm using wavelet techniques.

The algorithm is described in detail in Lange et al. (2006) Proc. PSB-06.

This peak picking algorithm uses the continuous wavelet transform of a profile data signal to detect mass peaks. Afterwards a given asymmetric peak function is fitted to the profile data and important peak parameters (e.g. fwhm) are extracted. In an optional step these parameters can be optimized using a non-linear optimization method.

The peak parameters are stored in the meta data arrays of the spectra (see MSSpectrum) in this order:

  • rValue
  • area
  • fwhm
  • leftWidth
  • rightWidth
  • peakShape
  • SignalToNoise
Note
The peaks must be sorted according to ascending m/z!
Parameters of this class are:

NameTypeDefaultRestrictionsDescription
signal_to_noise float1.0 min: 0.0Minimal signal to noise ratio for a peak to be picked.
centroid_percentage float0.8 min: 0.0 max: 1.0Percentage of the maximum height that the raw data points must exceed to be taken into account for the calculation of the centroid. If it is 1 the centroid position corresponds to the position of the highest intensity.
peak_width float0.15 min: 0.0Approximate fwhm of the peaks.
estimate_peak_width stringfalse true, falseFlag if the average peak width shall be estimated. Attention: when this flag is set, the peak_width is ignored.
fwhm_lower_bound_factor float0.7 min: 0.0Factor that calculates the minimal fwhm value from the peak_width. All peaks with width smaller than fwhm_bound_factor * peak_width are discarded.
fwhm_upper_bound_factor float20.0 min: 0.0Factor that calculates the maximal fwhm value from the peak_width. All peaks with width greater than fwhm_upper_bound_factor * peak_width are discarded.
optimization stringno no, one_dimensional, two_dimensionalIf the peak parameters position, intensity and left/right widthshall be optimized set optimization to one_dimensional or two_dimensional.
thresholds:peak_bound float10.0 min: 0.0Minimal peak intensity.
thresholds:peak_bound_ms2_level float10.0 min: 0.0Minimal peak intensity for MS/MS peaks.
thresholds:correlation float0.5 min: 0.0 max: 1.0minimal correlation of a peak and the raw signal. If a peak has a lower correlation it is skipped.
thresholds:noise_level float0.1 min: 0.0noise level for the search of the peak endpoints.
thresholds:search_radius int3 min: 0search radius for the search of the maximum in the signal after a maximum in the cwt was found
wavelet_transform:spacing float1.0e-03 min: 0.0Spacing of the CWT. Note that the accuracy of the picked peak's centroid position depends in the Raw data spacing, i.e., 50% of raw peak distance at most.
optimization:iterations int400 min: 1maximal number of iterations for the fitting step
optimization:penalties:position float0.0 min: 0.0penalty term for the fitting of the position:If it differs too much from the initial one it can be penalized
optimization:penalties:left_width float1.0 min: 0.0penalty term for the fitting of the left width:If the left width differs too much from the initial one during the fitting it can be penalized.
optimization:penalties:right_width float1.0 min: 0.0penalty term for the fitting of the right width:If the right width differs too much from the initial one during the fitting it can be penalized.
optimization:penalties:height float1.0 min: 0.0penalty term for the fitting of the intensity (only used in 2D Optimization):If it gets negative during the fitting it can be penalized.
optimization:2d:tolerance_mz float2.2 min: 0.0mz tolerance for cluster construction
optimization:2d:max_peak_distance float1.2 min: 0.0maximal peak distance in mz in a cluster
deconvolution:deconvolution stringfalse true, falseIf you want heavily overlapping peaks to be separated set this value to "true"
deconvolution:asym_threshold float0.3 min: 0.0If the symmetry of a peak is smaller than asym_thresholds it is assumed that it consists of more than one peak and the deconvolution procedure is started.
deconvolution:left_width float2.0 min: 0.01/left_width is the initial value for the left width of the peaks found in the deconvolution step.
deconvolution:right_width float2.0 min: 0.01/right_width is the initial value for the right width of the peaks found in the deconvolution step.
deconvolution:scaling float0.12 min: 0.0Initial scaling of the cwt used in the separation of heavily overlapping peaks. The initial value is used for charge 1, for higher charges it is adapted to scaling/charge.
deconvolution:fitting:fwhm_threshold float0.7 min: 0.0If the FWHM of a peak is higher than 'fwhm_thresholds' it is assumed that it consists of more than one peak and the deconvolution procedure is started.
deconvolution:fitting:eps_abs float9.999999747378752e-06 min: 0.0if the absolute error gets smaller than this value the fitting is stopped.
deconvolution:fitting:eps_rel float9.999999747378752e-06 min: 0.0if the relative error gets smaller than this value the fitting is stopped.
deconvolution:fitting:max_iteration int10 min: 1maximal number of iterations for the fitting step
deconvolution:fitting:penalties:position float0.0 min: 0.0penalty term for the fitting of the peak position:If the position changes more than 0.5Da during the fitting it can be penalized as well as discrepancies of the peptide mass rule.
deconvolution:fitting:penalties:height float1.0 min: 0.0penalty term for the fitting of the intensity:If it gets negative during the fitting it can be penalized.
deconvolution:fitting:penalties:left_width float0.0 min: 0.0penalty term for the fitting of the left width:If the left width gets too broad or negative during the fitting it can be penalized.
deconvolution:fitting:penalties:right_width float0.0 min: 0.0penalty term for the fitting of the right width:If the right width gets too broad or negative during the fitting it can be penalized.
SignalToNoiseEstimationParameter:max_intensity int-1 min: -1maximal intensity considered for histogram construction. By default, it will be calculated automatically (see auto_mode). Only provide this parameter if you know what you are doing (and change 'auto_mode' to '-1')! All intensities EQUAL/ABOVE 'max_intensity' will not be added to the histogram. If you choose 'max_intensity' too small, the noise estimate might be too small as well. If chosen too big, the bins become quite large (which you could counter by increasing 'bin_count', which increases runtime).
SignalToNoiseEstimationParameter:auto_max_stdev_factor float3.0 min: 0.0 max: 999.0parameter for 'max_intensity' estimation (if 'auto_mode' == 0): mean + 'auto_max_stdev_factor' * stdev
SignalToNoiseEstimationParameter:auto_max_percentile int95 min: 0 max: 100parameter for 'max_intensity' estimation (if 'auto_mode' == 1): auto_max_percentile th percentile
SignalToNoiseEstimationParameter:auto_mode int0 min: -1 max: 1method to use to determine maximal intensity: -1 --> use 'max_intensity'; 0 --> 'auto_max_stdev_factor' method (default); 1 --> 'auto_max_percentile' method
SignalToNoiseEstimationParameter:win_len float200.0 min: 1.0window length in Thomson
SignalToNoiseEstimationParameter:bin_count int30 min: 3number of bins for intensity values
SignalToNoiseEstimationParameter:stdev_mp float3.0 min: 0.01 max: 999.0multiplier for stdev
SignalToNoiseEstimationParameter:min_required_elements int10 min: 1minimum number of elements required in a window (otherwise it is considered sparse)
SignalToNoiseEstimationParameter:noise_for_empty_window float1.0e20  noise value used for sparse windows

Note:
  • If a section name is documented, the documentation is displayed as tooltip.
  • Advanced parameter names are italic.

Class Documentation

◆ OpenMS::PeakPickerCWT::PeakArea_

struct OpenMS::PeakPickerCWT::PeakArea_

Class for the internal peak representation.

A regular Data-Object which contains some additional useful information for analyzing peaks and their properties The left and right iterators delimit a range in the profile data which represents a profile peak. They define the profile peak endpoints. max points to the profile data point in [left, right] with the highest intensity, the maximum of the profile peak.

Collaboration diagram for PeakPickerCWT::PeakArea_:
[legend]
Class Members
typedef iterator PeakIterator
Class Members
DPosition< 1 > centroid_position The estimated centroid position in m/z.
PeakIterator left iterator to the leftmost valid point
PeakIterator max iterator to the maximum position
PeakIterator right iterator to the rightmost valid point (inclusive)

Member Typedef Documentation

◆ ConstPeakIterator

typedef MSSpectrum::const_iterator ConstPeakIterator

Const profile data iterator type.

◆ PeakIterator

typedef MSSpectrum::iterator PeakIterator

Profile data iterator type.

Constructor & Destructor Documentation

◆ PeakPickerCWT()

Constructor.

◆ ~PeakPickerCWT()

~PeakPickerCWT ( )
override

Destructor.

Member Function Documentation

◆ addPeak_()

void addPeak_ ( std::vector< PeakShape > &  peaks_DC,
PeakArea_ area,
double  left_width,
double  right_width,
OptimizePeakDeconvolution::Data data 
) const
protected

Add a peak.

◆ correlate_()

double correlate_ ( const PeakShape peak,
const PeakArea_ area,
Int  direction = 0 
) const
protected

Returns the squared Pearson coefficient.

Computes the correlation of the peak and the original data given by the peak endpoints area.left and area.right. If the value is near 1, the fitted peakshape and the profile data are expected to be very similar.

◆ deconvolutePeak_()

bool deconvolutePeak_ ( PeakShape shape,
std::vector< PeakShape > &  peak_shapes,
double  peak_bound_cwt 
) const
protected

Separates overlapping peaks.

It determines the number of peaks lying underneath the initial peak using the cwt with different scales. Then a nonlinear optimization procedure is applied to optimize the peak parameters.

◆ determineChargeState_()

Int determineChargeState_ ( std::vector< double > &  peak_values) const
protected

Estimate the charge state of the peaks.

◆ estimatePeakWidth()

double estimatePeakWidth ( const PeakMap input)

Estimates average peak width that can then be used for peak picking.

The spectra with the highest TICs are used to estimate an average peak width that can be used as the peak_width parameter for picking the complete data set. Typically, the number of peaks increases with decreasing peak width until a plateau is reached. The beginning of this plateau is our estimate for the peak width. This estimate is averaged over several spectra.

◆ fitPeakShape_()

PeakShape fitPeakShape_ ( const PeakArea_ area) const
protected

Returns the best fitting peakshape.

◆ getMaxPosition_()

bool getMaxPosition_ ( const PeakIterator  first,
const PeakIterator  last,
const ContinuousWaveletTransform wt,
PeakArea_ area,
const Int  distance_from_scan_border,
const double  peak_bound_cwt,
const double  peak_bound_ms2_level_cwt,
const Int  direction = 1 
) const
protected

Finds the next maximum position in the wavelet transform wt.

If the maximum is greater than peak_bound_cwt we search for the corresponding maximum in the profile data interval [first,last) given a predefined search radius radius. Only peaks with intensities greater than peak_bound_ are relevant. If no peak is detected the method return false. For direction=1, the method runs from first to last given direction=-1 it runs the other way around.

◆ getNumberOfPeaks_()

Int getNumberOfPeaks_ ( ConstPeakIterator  first,
ConstPeakIterator  last,
std::vector< double > &  peak_values,
Int  direction,
double  resolution,
ContinuousWaveletTransformNumIntegration wt,
double  peak_bound_cwt 
) const
protected

Determines the number of peaks in the given mass range using the cwt.

◆ getPeakArea_()

void getPeakArea_ ( const PeakArea_ area,
double &  area_left,
double &  area_right 
) const
protected

Computes the peak's left and right area.

◆ getPeakCentroid_()

void getPeakCentroid_ ( PeakArea_ area) const
protected

Estimates a peak's centroid position.

Computes the centroid position of the peak using all profile data points which are greater than 'centroid_percentage' (user-param) of the most intensive profile data point.

◆ getPeakEndPoints_()

bool getPeakEndPoints_ ( PeakIterator  first,
PeakIterator  last,
PeakArea_ area,
Int  distance_from_scan_border,
Int peak_left_index,
Int peak_right_index,
ContinuousWaveletTransformNumIntegration wt 
) const
protected

Determines a peaks's endpoints.

The algorithm does the following:

  • let x_m be the position of the maximum in the data and let (x_l, x_r) be the left and right neighbours
  • (1) starting from x_l', walk left until one of the following happens
  • the new point is lower than the original bound => we found our left endpoint
  • the new point is larger than the last, but the point left from the new point is smaller. In that case, we either ran into another peak, or we encounter some noise. Therefore we now look in the cwt at the position corresponding to this value. If the cwt here is monotonous, we consider the point as noise and continue further to the left. Otherwise, we probably found the beginning of a new peak and therefore stop here.
  • (2) analogous procedure to the right of x_r

◆ initializeWT_()

void initializeWT_ ( ContinuousWaveletTransformNumIntegration wt,
const double  peak_bound_in,
double &  peak_bound_ms_cwt 
) const
protected

Computes the threshold for the peak height in the wavelet transform and initializes the wavelet transform.

Given the threshold for the peak height a corresponding value peak_bound_cwt can be computed for the continuous wavelet transform. Therefore we compute a theoretical Lorentzian peakshape with height=peak_bound_ and a width which is similar to the width of the wavelet. Taking the maximum in the wavelet transform of the Lorentzian peak we have a peak bound in the wavelet transform.

◆ lorentz_()

double lorentz_ ( const double  height,
const double  lambda,
const double  pos,
const double  x 
) const
inlineprotected

Computes the value of a theoretical Lorentz peak at position x.

◆ pick()

void pick ( const MSSpectrum input,
MSSpectrum output 
) const

Applies the peak picking algorithm to a single spectrum.

Picks the peaks in the input spectrum and writes the resulting peaks to the output container.

◆ pickExperiment()

void pickExperiment ( const PeakMap input,
PeakMap output 
)

Picks the peaks in an MSExperiment.

Picks the peaks successive in every scan in the spectrum range. The detected peaks are stored in the output MSExperiment.

Exceptions
Exception::UnableToFit()if peak width cannot be determined (if estimation is set to auto)

◆ updateMembers_()

void updateMembers_ ( )
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.

Member Data Documentation

◆ deconvolution_

bool deconvolution_
protected

Switch for the deconvolution of peak parameters.

◆ fwhm_bound_

float fwhm_bound_
protected

The minimal full width at half maximum.

◆ noise_level_

float noise_level_
protected

The threshold for the noise level (TODO: Use the information of the signal to noise estimator)

◆ optimization_

bool optimization_
protected

Switch for the optimization of peak parameters.

◆ peak_bound_

float peak_bound_
protected

Threshold for the peak height in the MS 1 level.

◆ peak_bound_ms2_level_

float peak_bound_ms2_level_
protected

Threshold for the peak height in the MS 2 level.

◆ peak_corr_bound_

float peak_corr_bound_
protected

The threshold for correlation.

◆ radius_

UInt radius_
protected

The search radius for the determination of a peak's maximum position.

◆ scale_

float scale_
protected

The dilation of the wavelet.

◆ signal_to_noise_

float signal_to_noise_
protected

Signal to noise threshold.

◆ two_d_optimization_

bool two_d_optimization_
protected

Switch for the 2D optimization of peak parameters.