hist_find_peaks.slope: Find peaks in given histgram by checking the valley of the...

View source: R/histgram.R

hist_find_peaks.slopeR Documentation

Find peaks in given histgram by checking the valley of the data

Description

Find peaks in given histgram. The peaks are devided by the valley which are detected by the sloop.

Usage

hist_find_peaks.slope(hist.data, min.ratio = 0.3, min.value = NA, interval = 1)

Arguments

hist.data

The target histgram

min.ratio

The minmum ratio for being detected as a valley. The ratio is calculated by the min([peaks values in both sides]/[valley value]).

min.value

The minmum value for being detected as a valley.

interval

The step of the slope.

Value

Table of the peaks with lower number, upper number, top number (maximum position within the peak) and frequency of each peaks.

Examples

hist.data = c(1,5,7,5,5,4,3,1,0,0,0,4,4,8,5,5,5,5,3,3,3,7,7,8,3,3,1,3,5,0,0,2,3,3,0)
peaks = hist_find_peaks.slope(hist.data,0.5)
plot(hist.data,type="b",lwd=2)
for(i in 1:nrow(peaks)){
	segments(peaks$top[i],-1,peaks$top[i],10,col="red")
	polygon(
		c(peaks$lower[i],peaks$lower[i],peaks$upper[i],peaks$upper[i]),c(-1,10,10,-1),
		col=rgb(1,0,0,0.2),border=NA
	)
}

hmito/hmRLib documentation built on March 13, 2024, 9:41 p.m.