# NOT RUN {
## the lcms.pks object is generated in the following way:
# }
# NOT RUN {
data(lcms)
pick.peaks <- function(x, span) {
span.width <- span * 2 + 1
loc.max <- span.width + 1 -
apply(embed(x, span.width), 1, which.max)
loc.max[loc.max == 1 | loc.max == span.width] <- NA
pks <- loc.max + 0:(length(loc.max)-1)
pks <- pks[!is.na(pks)]
pks.tab <- table(pks)
pks.id <- as.numeric(names(pks.tab)[pks.tab > span])
cbind(rt = pks.id, I = x[pks.id])
}
## bring all samples to the same scale, copied from ptw man page
lcms.scaled <- aperm(apply(lcms, c(1,3),
function(x) x/mean(x) ), c(2,1,3))
lcms.s.z <- aperm(apply(lcms.scaled, c(1,3),
function(x) padzeros(x, 250) ), c(2,1,3))
lcms.pks <- lapply(1:3,
function(ii) {
lapply(1:nrow(lcms.s.z[,,ii]),
function(jj)
cbind("mz" = jj,
pick.peaks(lcms.s.z[jj,,ii], 5)))
})
# }
Run the code above in your browser using DataLab