binpeaks: Peak Processing

View source: R/signal.R

binpeaksR Documentation

Peak Processing

Description

Combine peaks from multiple signals.

Usage

# Bin a list of peaks
binpeaks(peaklist, domain = NULL, xlist = peaklist,
    tol = NA_real_, tol.ref = "abs", merge = FALSE,
    na.drop = TRUE)

# Merge peaks
mergepeaks(peaks, n = nobs(peaks), x = peaks,
    tol = NA_real_, tol.ref = "abs",
    na.drop = TRUE)

Arguments

peaklist, xlist

A list of vectors of peak indices (or domain values), and the values to be binned according to the peak locations.

peaks, x

The indices (or domain values) of peaks which should be merged, or for which the corresponding values should be averaged. If n is not provided, this should be a numeric stream_stat vector produced by binpeaks().

domain

The domain variable of the signal.

tol, tol.ref

A tolerance specifying the maximum allowed distance between binned or merged peaks. See bsearch for details. For binpeaks, this is used to determine whether a peak should be binned to a domain value. For mergepeaks, peaks closer than this are merged unless a local minimum in their counts (n) indicates that they should be separate peaks. If missing, binpeaks estimates it as one half the minimum gap between same-signal peaks, and mergepeaks estimates it as one hundredth of the average gap beteen peaks.

merge

Should the binned peaks be merged?

na.drop

Should missing values be dropped from the result?

n

The count of times each peak was observed. This is used to weight the averaging. Local minima in counts are also used to separate distinct peaks that are closer together than tol.

Details

binpeaks() is used to bin a list of peaks from multiple signals to a set of common peaks. The peaks (or their corresponding values) are binned to the given domain values and are averaged within each bin. If domain is not given, then the bins are created from the range of the peak locations and the specified tol.

mergepeaks() is used to merge any peaks with gaps smaller than the given tolerance and whose counts (n) do not indicate that they should be considered separate peaks. The merged peaks are averaged together.

Value

A numeric stream_stat vector, giving the average locations of each peak.

Author(s)

Kylie A. Bemis

Examples

x <- c(0, 1, 1, 2, 3, 2, 1, 4, 5, 1, 1, 0)
y <- c(0, 1, 1, 3, 2, 2, 1, 5, 4, 1, 1, 0)

p1 <- findpeaks(x)
p2 <- findpeaks(y)
binpeaks(list(p1, p2), merge=FALSE)

kuwisdelu/matter documentation built on May 1, 2024, 5:17 a.m.