I'm trying to use xcms library by manual "LC/MS Preprocessing and Analysis with xcms. Colin A. Smith. November 27, 2011" (http://http://www.bioconductor.org/packages/release/bioc/vignettes/xcms/inst/doc/xcmsPreprocess.pdf). Begin with simple. I just want to process mzXML file with MS1 data and positive polarization. Example:
files <- list.files("/home/zeleniy/workspace/mass/peaks/xcms", recursive=FALSE, full.names=TRUE)
xset <- xcmsSet(
files,
snames = NULL,
sclass = NULL,
phenoData = NULL,
profmethod = "bin",
profparam = list(),
polarity = "positive",
mslevel = NULL,
nSlaves = 0,
progressCallback = NULL
)
And then see this result:
zeleniy@zeleniy-HP-Pro-3400:~/workspace/mass/peaks$ Rscript xcms.r
Loading required package: methods
ecoli1_600_pos_1: 80:0 130:18 180:47 230:74 280:103 330:135 380:169 430:202 480:223 530:229 580:236 630:265 680:279 730:306 780:348 830:354 880:356 930:356 980:356 1030:356 1080:356 1130:356 1180:356 1230:356 1280:356 1330:356 1380:356 1430:356 1480:356 1530:356 1580:356 1630:356 1680:356 1730:356 1780:356 1830:356 1880:356 1930:356 1980:356 2030:356 2080:356 2130:356 2180:356 2230:356 2280:356 2330:356 2380:356 2430:356 2480:356 2530:356 2580:356 2630:356 2680:356 2730:356 2780:356 2830:356 2880:356 2930:356 2980:356
Works fine. But when i'm specify "mslevel" parameter i have got an error:
xset <- xcmsSet(
files,
snames = NULL,
sclass = NULL,
phenoData = NULL,
profmethod = "bin",
profparam = list(),
polarity = "positive",
mslevel = 1,
nSlaves = 0,
progressCallback = NULL
)
zeleniy@zeleniy-HP-Pro-3400:~/workspace/mass/peaks$ Rscript xcms.r
Loading required package: methods
ecoli1_600_pos_1: Error in function (classes, fdef, mtable) :
unable to find an inherited method for function "findPeaks", for signature "NULL"
Calls: xcmsSet -> findPeaks -> <Anonymous>
Execution halted
What's problem ?
Hi,
for MS1, just leave the mslevel empty.
Yours,
Steffen
Ok, thanks for reply. Let's move on and try to findPeaks:
peaks <- findPeaks.centWave(xset, ppm=20, peakwidth = c(20, 50), snthresh=5)
Result:
zeleniy@zeleniy-HP-Pro-3400:~/workspace/mass/peaks$ Rscript xcms.r
Loading required package: methods
ecoli1_600_pos_1: 80:0 130:18 180:47 230:74 280:103 330:135 380:169 430:202 480:223 530:229 580:236 630:265 680:279 730:306 780:348 830:354 880:356 930:356 980:356 1030:356 1080:356 1130:356 1180:356 1230:356 1280:356 1330:356 1380:356 1430:356 1480:356 1530:356 1580:356 1630:356 1680:356 1730:356 1780:356 1830:356 1880:356 1930:356 1980:356 2030:356 2080:356 2130:356 2180:356 2230:356 2280:356 2330:356 2380:356 2430:356 2480:356 2530:356 2580:356 2630:356 2680:356 2730:356 2780:356 2830:356 2880:356 2930:356 2980:356
Error in function (classes, fdef, mtable) :
unable to find an inherited method for function "findPeaks.centWave", for signature "xcmsSet"
Calls: findPeaks.centWave -> <Anonymous>
Execution halted
Why ? Documentation for findPeaks.centWave:
findPeaks.centWave-methods package:xcms R Documentation
Feature detection for high resolution LC/MS data
Description:
Peak density and wavelet based feature detection for high
resolution LC/MS data in centroid mode
Arguments:
object: ‘xcmsSet’ object
ppm: maxmial tolerated m/z deviation in consecutive scans, in ppm
(parts per million)
peakwidth: Chromatographic peak width, given as range (min,max) in
seconds
snthresh: signal to noise ratio cutoff, definition see below.
prefilter: ‘prefilter=c(k,I)’. Prefilter step for the first phase. Mass
traces are only retained if they contain at least ‘k’ peaks
with intensity >= ‘I’.
mzCenterFun: Function to calculate the m/z center of the feature:
‘wMean’ intensity weighted mean of the feature m/z values,
‘mean’ mean of the feature m/z values, ‘apex’ use m/z value
at peak apex, ‘wMeanApex3’ intensity weighted mean of the m/z
value at peak apex and the m/z value left and right of it,
‘meanApex3’ mean of the m/z value at peak apex and the m/z
value left and right of it.
integrate: Integration method. If ‘=1’ peak limits are found through
descent on the mexican hat filtered data, if ‘=2’ the descent
is done on the real data. Method 2 is very accurate but prone
to noise, while method 1 is more robust to noise but less
exact.
mzdiff: minimum difference in m/z for peaks with overlapping
retention times, can be negative to allow overlap
fitgauss: logical, if TRUE a Gaussian is fitted to each peak
scanrange: scan range to process
noise: optional argument which is useful for data that was
centroided without any intensity threshold, centroids with
intensity < ‘noise’ are omitted from ROI detection
sleep: number of seconds to pause between plotting peak finding
cycles
verbose.columns: logical, if TRUE additional peak meta data columns are
returned
Details:
This algorithm is most suitable for high resolution
LC/{TOF,OrbiTrap,FTICR}-MS data in centroid mode. In the first
phase of the method mass traces (characterised as regions with
less than ‘ppm’ m/z deviation in consecutive scans) in the LC/MS
map are located. In the second phase these mass traces are
further analysed. Continuous wavelet transform (CWT) is used to
locate chromatographic peaks on different scales.
Value:
A matrix with columns:
mz: weighted (by intensity) mean of peak m/z across scans
mzmin: m/z peak minimum
mzmax: m/z peak maximum
rt: retention time of peak midpoint
rtmin: leading edge of peak retention time
rtmax: trailing edge of peak retention time
into: integrated peak intensity
intb: baseline corrected integrated peak intensity
maxo: maximum peak intensity
sn: Signal/Noise ratio, defined as ‘(maxo - baseline)/sd’, where
‘maxo’ is the maximum peak intensity,
‘baseline’ the estimated baseline value and
‘sd’ the standard deviation of local chromatographic noise.
egauss: RMSE of Gaussian fit
: if ‘verbose.columns’ is ‘TRUE’ additionally :
mu: Gaussian parameter mu
sigma: Gaussian parameter sigma
h: Gaussian parameter h
f: Region number of m/z ROI where the peak was localised
dppm: m/z deviation of mass trace across scans in ppm
scale: Scale on which the peak was localised
scpos: Peak position found by wavelet analysis
scmin: Left peak limit found by wavelet analysis (scan number)
scmax: Right peak limit found by wavelet analysis (scan number)
Methods:
object = "xcmsRaw" ‘ findPeaks.centWave(object, ppm=25,
peakwidth=c(20,50), snthresh=10, prefilter=c(3,100),
mzCenterFun="wMean", integrate=1, mzdiff=-0.001,
fitgauss=FALSE, scanrange= numeric(), noise=0, sleep=0,
verbose.columns=FALSE) ’
Author(s):
Ralf Tautenhahn
References:
Ralf Tautenhahn, Christoph Böttcher, and Steffen Neumann "Highly
sensitive feature detection for high resolution LC/MS" BMC
Bioinformatics 2008, 9:504
See Also:
‘findPeaks-methods’ ‘xcmsRaw-class’
Hey zeleniy,
findPeaks only works on xcmsRaw objects.
The arguments section in the documentation contains a mistake,
thanks for pointing that out.
In the methods section it's describe correctly.
Methods:
object = "xcmsRaw"
By the way, if you use the xcmsSet constructor, your data is already processed by the default peak picker.
If you want to use the "centWave" peak picker, then change your code to
xset <- xcmsSet(
files,
snames = NULL,
sclass = NULL,
phenoData = NULL,
profmethod = "bin",
profparam = list(),
polarity = "positive",
mslevel = NULL,
nSlaves = 0,
progressCallback = NULL,
method="centWave"
)
It is very interesting. So, xcmsSet it is just a set/collection of xsmsRaw objects, which pass arguments from it constructor to constructors of it's inner xsmsRaw classes/objects ? And then automatically run findPeaks procedure width default peaker findPeaks.matchedFilter.
Ok, now i'm understand why constructions like this (http://http://www.metabolomics-forum.com/viewtopic.php?f=8&t=267) is works fine:
xcmsSet(mzXML.files, snames = snames, sclass = sclass, method = 'centWave', ppm = 10, peakwidth = c(20, 50), snthresh = 10, prefilter = c(3, 1000), integrate = 1, mzdiff = -0.001, verbose.columns = TRUE, fitgauss = FALSE)
Thank you
Zeleniy,
Essentially yes. The xcmsSet construct has pointers to the files so that xcmsRaw object can be made again but it does not store the whole object, for memory purposes. Instead we use the xcmsRaw object get the peak list and put that into the xcmsSet object.
if you look at soemthing like:
library(faahKO)
str(faahko)
## you'll see there is a slot called faahko@peaks
## this is the peak list
head(faahko@peaks) ## notice the sample in an integer pointing to
head(faahko@phenoData) ## the rows in which the file is which points to
head(faahko@filepaths) ## :)