find_peaks: Find peaks

View source: R/fit_peaks.R

find_peaksR Documentation

Find peaks

Description

Detects peaks in chromatographic profile.

Usage

find_peaks(
  y,
  smooth_type = c("gaussian", "box", "savgol", "mva", "tmva", "none"),
  smooth_window = 0.001,
  slope_thresh = 0,
  amp_thresh = 0,
  bounds = TRUE
)

Arguments

y

Signal (as a numerical vector).

smooth_type

Type of smoothing. Either gaussian kernel ("gaussian"), box kernel ("box"), savitzky-golay smoothing ("savgol"), moving average ("mva"), triangular moving average ("tmva"), or no smoothing ("none").

smooth_window

Smoothing window. Larger values of this parameter will exclude sharp, narrow features. If the supplied value is between 0 and 1, window will be interpreted as a proportion of points to include. Otherwise, the window will be the absolute number of points to include in the window. (Defaults to .001).

slope_thresh

Minimum threshold for slope of the smoothed first derivative. This parameter filters on the basis of peak width, such that larger values will exclude broad peaks from the peak list. (Defaults to 0).

amp_thresh

Minimum threshold for peak amplitude. This parameter filters on the basis of peak height, such that larger values will exclude small peaks from the peak list. (Defaults to 0).

bounds

Logical. If TRUE, includes peak boundaries in data.frame. (Defaults to TRUE).

Details

Detects peaks by looking for zero-crossings in the smoothed first derivative of the signal (y) that exceed the specified slope threshold (slope_thresh). Additionally, peaks can be filtered by supplying a minimal amplitude threshold (amp_thresh), filtering out peaks below the specified height. Smoothing is intended to prevent the algorithm from getting caught up on local minima and maxima that do not represent true features. Several smoothing options are available, including "gaussian", box kernel ("box"), savitzky-golay smoothing ("savgol"), moving average ("mva"), triangular moving average ("tmva"), or no smoothing ("none").

It is recommended to do pre-processing using the preprocess function before peak detection. Overly high chromatographic resolution can sometimes cause peaks to be split into multiple segments. In this case, it is recommended to increase the smooth_window or reduce the resolution along the time axis by adjusting the dim1 argument during preprocessing.

Value

If bounds == TRUE, returns a data.frame containing the center, start, and end of each identified peak. Otherwise, returns a numeric vector of peak centers. All locations are expressed as indices.

Note

The find_peaks function is adapted from MATLAB code included in Prof. Tom O'Haver's Pragmatic Introduction to Signal Processing.

Author(s)

Ethan Bass

References

O'Haver, Tom. Pragmatic Introduction to Signal Processing: Applications in scientific measurement. https://terpconnect.umd.edu/~toh/spectrum/ (Accessed January, 2022).

See Also

fit_peaks, get_peaks

Examples

data(Sa_pr)
find_peaks(Sa_pr[[1]][,"220"])

ethanbass/chromatographR documentation built on April 17, 2025, 10:55 a.m.