find_peaks {fossilbrush} | R Documentation |
find_peaks
Description
Function to scan, column-wise, a matrix of per-taxon observation
density time series. This can be applied to either the histogram
or the kernel density output of densify
, but the latter is
recommended. Peaks are detected as local maxima, then smoothed
within a local window and tested to distinguish if they are
noise or significant. Strict threshold is that the peak is
greater than the mean + sd of the window
Usage
find_peaks(x, win = 5, verbose = TRUE)
Arguments
x |
A matrix as outputed by |
win |
A positive integer specifying the window length on either side of a peak (i.e. win 5 will give a total window of 11 - -5 indices + peak index + 5 indices) |
verbose |
A logical determining if function progress should be reported |
Value
A list of four, the first three positions containing lists of the peak indices for each taxon, under raw, mean + sd and mean detection regimes. The fourth item is a dataframe of counts of peaks per taxon, 1 row per taxon, 1 column per detection regime
Examples
# load dataset
data("brachios")
# subsample brachios to make for a short example runtime
set.seed(1)
brachios <- brachios[sample(1:nrow(brachios), 1000),]
# get density matrix
dens <- densify(brachios)
# run function, using kernel density matrix
pk <- find_peaks(dens$kdensity)