findPeaks {flowPloidy} | R Documentation

## findPeaks

### Description

Locate potential peaks in histogram data

### Usage

    findPeaks(fh, window = 20, smooth = 20)

    cleanPeaks(fh, window = 20, debrisLimit = 40)

### Arguments

`fh` | a `FlowHist` object
`window` | an integer, the width of the moving window to use in identifying local maxima via `runmax`
`smooth` | an integer, the width of the moving window to use in removing noise via `runmean`
`debrisLimit` | an integer value. Peaks with fluorescence values less than `debrisLimit` will be ignored by the automatic peak-finding algorithm.

### Details

Peaks are defined as local maxima in the vector of values, using a moving window. Note that these are used in the context of finding starting values - accuracy isn't important, we just need something ‘close-enough’ that the nls algorithm will be able to find the correct value.

Utility functions for use internally by flowPloidy; not exported and won't be visible to users. Usually invoked from within `FlowHist`.

Note that there is a trade-off between accuracy in detected peaks, and avoiding noise. Increasing the value of `smooth` will reduce the amount of 'noise' that is included in the peak list. However, increasing smoothing shifts the location of the actual peaks. Most of the time the default values provide an acceptable compromise, given we only need to get 'close enough' for the NLS optimization to find the true parameter values. If you'd like to explore this, the internal (unexported) function `fhPeakPlot` may be useful.

`cleanPeaks` filters the output of `findPeaks` to:

- remove duplicates, ie., peaks with the same intensity that occur within `window` positions of each other. Otherwise, `findPeaks` will consider noisy peaks without a single highest point to be multiple distinct peaks.

- drop G2 peaks. In some cases the G2 peak for one sample will have greater intensity than the G1 peak for another sample. We correct for this by removing detected peaks with means close to twice that of other peaks.

- ignore noise, by removing peaks with `fluorescence` < `debrisLimit`. The default is 40, which works well for moderate-to-large debris fields. You may need to reduce this value if you have clean histograms with peaks below 40. Note that this value does not affect peaks selected manually.

### Value

Returns a matrix with two columns:

mean

  the index position of each potential peak

height

  the height (intensity) of the peak at that index position

### Author(s)

Tyler Smith

### Examples

    ## Not run:
    set.seed(123)
    test.dat <-(cumsum(runif(1000, min = -1)))
    plot(test.dat, type = 'l')
    test.peaks <- flowPloidy::findPeaks(test.dat, window = 20)
    points(test.peaks, col = 'red', cex = 2)

    ## End(Not run)

[Package flowPloidy version 1.18.0 Index]