Hi Ralf,
since I do not currently have the "otium" (is there an English word for that? German is "Musse" more or less) to accustom myself to Rcpp style, I did something in-between...
I coded the routine in R vector-operation style instead of using loops. It's not as fast as the original Java implementation or as Rcpp would be, but it's not terribly bad, and since the subsequent centWave takes much longer anyway, it's not a bottleneck for me.
I wrote the routine primarily for my own use, and it's not really tested or anything, but if anyone wants to use it, feel free to do with it whatever you want. Don't blame me if your computer explodes and buries all your valuable data never to be found again
deprofile.R: http://pastebin.com/rvPCEDg2
Usage:
# from xcmsRaw:
xraw <- xcmsRaw("myfile.mzML")
# by FWHM method:
xraw.sticked <- deprofile.xcmsRaw(xraw, copy=T, method="deprofile.fwhm")
# local maximum: faster, but less accurate especially for "low" resolution
xraw.sticked <- deprofile.xcmsRaw(xraw, copy=T, method="deprofile.localMax")
scan.xraw.profile <- getScan(xraw, 50)
scan.xraw <- getScan(xraw.sticked, 50)
# alternatively directly from scan:
scan.xraw.direct <- deprofile.scan(scan.xraw.profile)
# this can be peakpicked:
xpeaks <- findPeaks(xraw.sticked, method="centWave", ppm=5, snthresh=10, noise=3000, prefilter=c(3,5000))
# the same scan from mzR:
mzrFile <- openMSfile("myfile.mzML")
acqNo <- xraw@acquisitionNum[[50]]
scan.mzML.profile <- mzR::peaks(mzrFile, acqNo)
scan.mzML <- deprofile.scan(scan.mzML.profile)
close(mzrFile)
(Why is the extension ".R" (or ".txt", for that matter) not allowed for attachments in an R-centered forum? )