Question: xcms centwave roiList error
0
7 weeks ago by
roxana10
roxana10 wrote:

Hello,

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!

xcms centwave roilist xic • 123 views
modified 7 weeks ago by Johannes Rainer1.5k • written 7 weeks ago by roxana10
0
7 weeks ago by
Johannes Rainer1.5k
Italy
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

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 function...do you know if it is possible to extract multiple XICs in one window using Chromatogram? Any suggestions are appreciated !

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.

1

Right, I'm trying to do something similar to what this vignette shows : https://bioconductor.org/packages/release/bioc/vignettes/xcms/inst/doc/xcms.html , 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"]])

Thanks!

1

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.