d3-peaks
Find peaks in an array based on "Improved peak detection" [1]
[1] Du, Pan, Warren A. Kibbe, and Simon M. Lin. "Improved peak detection in mass spectrum by incorporating continuous wavelet transform-based pattern matching." Bioinformatics 22.17 (2006): 2059-2065.
For examples, please see:
Installing
If you use NPM, npm install d3-peaks
. Otherwise, download the latest release.
API Reference
Find Peaks
# d3_peaks.findPeaks([signal])
If specified, returns an array of points that represents the peaks in the signal. Otherwise, returns a function to find peaks. An example point returned is:
index: 10 width: 2 snr: 15
Where index represents the index of the peak in the original signal, width is the width of the peak, and snr is the signal to noise ratio.
# widths([w])
If specified, [w] is an array of expected peak widths that the algorithm should find. Otherwise, returns the current values.
var findPeaks = d3_peaks;
# kernel(kernel)
If specified, changes the kernel function or "smoother". Otherwise, returns the current value.
var ricker = d3_peaksricker;var findPeaks = d3_peaks;
# gapThreshold(gap)
If specified, gap represents the maximum allowed number of gaps in the ridgeline. The higher is this number the more connected peaks we will find. Otherwise, returns the current value.
var findPeaks = d3_peaks;
# minLineLength(length)
If specified, length represents the minimum ridgeline length. The higher is this number the more constrained are the lines and we will find fewer peaks. Otherwise, returns the current value.
var findPeaks = d3_peaks;
# minSNR(snr)
If specified, snr represents the minimum signal to noise ratio the ridge lines should have. Otherwise, returns the current value. By default the minimum snr is 1.0 for peaks of width 1. This number should be higher for bigger widths.
var findPeaks = d3_peaks;
Convolution
# d3_peaks.convolve([signal])
If specified, convolve the signal array with the smoother. Otherwise, returns a function to convolve a signal with the smoother.
# kernel(kernel)
If specified, changes the kernel function or "smoother". Otherwise, returns the current kernel.
var convolve = d3_peaks ;var signal = ;
Kernels
# d3_peaks.ricker(x)
If specified , it returns φ(x). Otherwise, returns a function to compute the ricker wavelet with default standard deviation 1.0.
# std(value)
If specified, it sets the standard deviation of the curve to value. Otherwise, returns the "width" or standard deviation of the wavelet.
# reach()
Returns the range value reach such that φ(reach) ~ 0.
var y = d3_peaks ;var output = ;var reach = y;