Question: xcms centwave roiList error
gravatar for roxana
3 months ago by
roxana10 wrote:


I'm using find xcms::findChromPeaks with centwave algorithm to extract XICs for which I need to input a roilist, I was testing using just one ROI or m/z Trypto<-data.frame("mz"=216.1341,"rtmin"= 50, "rtmax"= 900,"mz"=216.1341,"scmin"=51,"scmax"=800,"mzmin"=216.1321,"mzmax"=216.1361,"length"=20,"intensity"=1000)

but I keep getting the following error...Error in validObject(.Object) : invalid class “CentWaveParam” object: 'roiList' does not provide all required fields!

I don't know what I am missing! please help

xcms centwave roilist xic • 164 views
ADD COMMENTlink modified 3 months ago by Johannes Rainer1.5k • written 3 months ago by roxana10
Answer: xcms centwave roiList error
gravatar for Johannes Rainer
3 months ago by
Johannes Rainer1.5k
Johannes Rainer1.5k wrote:

The roiList parameter should be a list. So what you should do is to provide the ROI as:

Trypto <- list(c(scmin = 51, scmax = 800, mzmin = 216.1321, mzmax = 216.1361, length = 20, intensity = 1000))
cwp <- CentWaveParam(roiList = Trypto)

Note however that it would be much easier to extract the ion chromatogram for your compound of interest in the following manner (assuming that data is your data object, i.e. the data you read with readMSData):

trypto <- chromatogram(data, rt = c(50, 900), mz = c(216.1321, 216.1361))

Parameters rt and mz allow to define the retention time and m/z range from which you want to extract the data. The data is then returned as a Chromatograms object. You can simply call plot on that object to plot the data, or you could also run findChromPeaks on that object to perform a chromatographic peak detection on that extracted chromatogram.

hope this helps

cheers, jo

ADD COMMENTlink written 3 months ago by Johannes Rainer1.5k

ADD REPLYlink modified 3 months ago • written 3 months ago by roxana10

Thank you Johannes. The ROIlist error is gone after using a list as you suggested! but for some reason is not finding the ROIs (which are definitely in there)...I have also tried using chromatogram to extract the ion of interest, but I decided to go with findChrompeaks/centwave so that I could run multiple files "onDisk" and also be able to plot multiple XICs or extract multiple m/z s in one chromatogram window, which it seems is not possible using the chromatogram you know if it is possible to extract multiple XICs in one window using Chromatogram? Any suggestions are appreciated !

ADD REPLYlink written 3 months ago by roxana10

The findChromPeaks function is really only intended to identify chromatographic peaks - not to extract ion chromatograms. To extract ion chromatograms you have to use the chromatogram function on the on disk data. It will extract the chromatogram for each file in your data. If you call plot on the object returned by chromatogram (which in fact is a Chromatograms object), it will plot the ion chromatogram of every file into the same plot (one line for each file). Have a look at xcms vignette for an example how to use it.

ADD REPLYlink written 3 months ago by Johannes Rainer1.5k

Right, I'm trying to do something similar to what this vignette shows : , something like this below, which was working OK, but I figured I needed to use the ROIlist to make "targeted peak detection" , perhaps I need to make a ROIlist from the chromatogram object?

chrraw <- chromatogram(rawdata, mz = mzr, rt = rtr)

xchr <- findChromPeaks(chr_raw, param = CentWaveParam(snthresh = 2))

plot(xchr, col = samplecolors, peakBg = samplecolors[chromPeaks(xchr)[, "column"]])


ADD REPLYlink written 3 months ago by roxana10

Note that you can also provide a matrix with arguments mz and rt (two columns with lower and upper boundary, each row defining the region in wich you expect the data from one ion). With that you could extract multiple XIC at once and you could also run the findChromPeaks on all of them. That might be an alternative to the ROIlist.

ADD REPLYlink written 3 months ago by Johannes Rainer1.5k
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 16.09
Traffic: 222 users visited in the last hour