Description Usage Arguments Details Value Note Author(s) See Also Examples
Find chromatographic peaks, and fit peak parameters using a gaussian profile. The algorithm is extremely simple and could be replaced by a more sophisticated algorithm. In particular one can expect bad fits if peaks are overlapping significantly.
1 2 |
y |
response (numerical vector) |
span |
number of points used in the definition of what constitutes a "local" maximum. If not given, a default value of 20 percent of the number of time points is used. |
pos |
locations of local maxima in vector y |
Finding peaks with function findpeaks
is based on the position
of local maxima within a window of width span
.
Peak parameters are calculated using fitpeaks
, assuming a
normal distribution. Peak width is given as a standard deviation,
calculated from the full width at half maximum (FWHM); the peak area
is given by the ratio of the peak height and the density.
Function findpeaks
simply returns the locations of the local
maxima, expressed as indices.
Function fitpeaks
returns a matrix, whose columns contain the
following information:
rt |
location of the maximum of the peak (x) |
sd |
width of the peak (x) |
FWHM |
full width at half maximum (x) |
height |
height of the peak (y) |
area |
peak area |
Again, the first three elements (rt, sd and FWHM) are expressed as
indices, so not in terms of the real retention times. The
transformation to "real" time is done in function getAllPeaks
.
Function findpeaks
was modelled after code suggested by
Brian Ripley on the R help list.
Ron Wehrens
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | data(tea)
new.lambdas <- seq(260, 500, by = 2)
tea <- lapply(tea.raw, preprocess, dim2 = new.lambdas)
tea.split <- splitTimeWindow(tea, c(12, 14), overlap = 10)
Xl <- tea.split[[2]]
Xl.opa <- opa(Xl, 4)
Xl.als <- doALS(Xl, Xl.opa)
tpoints <- getTime(Xl.als)
plot(tpoints, Xl.als$CList[[2]][,2], type = "l", col = "gray")
pk.pos <- findpeaks(Xl.als$CList[[2]][,2], span = 11)
abline(v = tpoints[pk.pos], col = 4)
pks <- fitpeaks(Xl.als$CList[[2]][,2], pk.pos)
apply(pks, 1,
function(pkmodel) {
lines(tpoints,
dnorm(1:length(tpoints), pkmodel["rt"], pkmodel["sd"]) *
pkmodel["area"],
col = 2)
invisible()
})
## reasonably close fit, apart from the small peak in the middle...
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.