Learn R Programming

nucleR (version 2.4.0)

peakDetection: Detect peaks (local maximum) from values series

Description

This function allows a efficient recognition of the local maximums (peaks) in a given numeric vector. It's recommended to smooth the input with filterFFT prior the detection.

Usage

"peakDetection"(data, threshold="25%", width=1, score=TRUE, mc.cores=1) "peakDetection"(data, threshold="25%", width=1, score=TRUE, mc.cores=1)

Arguments

data
Input numeric values, or a list of them
threshold
Threshold value from which the peaks will be selected. Can be given as a percentage string (i.e., "25%" will use the value in the 1st quantile of data) or as an absolute coverage numeric value (i.e., 20 will not look for peaks in regions without less than 20 reads (or reads per milion)).
width
If a positive integer > 1 is given, the peaks are returned as a range of the given width centered in the local maximum. Useful for nucleosome calling from a coverage peak in the dyad.
score
If TRUE, the results will be scored using peakScoring function
mc.cores
If multicore support, the number of cores available

Value

The type of the return depends on the input parameters:numeric (or a list of them) if width==1 & score==FALSE containing the position of the peaksdata.frame (or list of them) if width==1 & score==TRUE containing a 'peak' column with the position of the peak plus a 'score' column with its score.IRanges (or IRangesList) if width>1 & score==FALSE containing the ranges of the peaks.RangedData if width>1 & score==TRUE containing the ranges of the peaks and the assigned score.

See Also

filterFFT, peakScoring

Examples

Run this code
	
	#Generate a random peaks profile
	reads = syntheticNucMap(nuc.len=40, lin.len=130)$syn.reads
	cover = coverage(reads)
	
	#Filter them
	cover_fft = filterFFT(cover)
	
	#Detect and plot peaks (up a bit the threshold for accounting synthetic data)
	peaks = peakDetection(cover_fft, threshold="40%", score=TRUE)
	plotPeaks(peaks, cover_fft, threshold="40%", start=10000, end=15000)

	#Now use ranges version, which accounts for fuzziness when scoring
  peaks = peakDetection(cover_fft, threshold="40%", score=TRUE, width=147)
  plotPeaks(peaks, cover_fft, threshold="40%", start=10000, end=15000)

Run the code above in your browser using DataLab