Skip to main content
Topic: How do I plot the EIC from an xcmsRaw object? (Read 8354 times) previous topic - next topic

How do I plot the EIC from an xcmsRaw object?

Thanks to some  helpful advice earlier, I can plot the EICs of mass features from an xcmsSet object, but I'm having trouble getting it to work for an xcmsRaw object when there isn't a groupidx to call. I want to look at one sample, QC1, and I want to see the extracted-ion chromatogram for 512.27 m/z from 705 to 740 seconds. This is what I've tried:
Code: [Select]
QC1.raw <- xcmsRaw("QC1.mzdata.xml", profstep=0.01, profmethod="bin")
QC1.eic <- getEIC(QC1.raw, mzrange=c(512.0, 512.4), rtrange=c(705,740))
plot(QC1.eic, mzrange=c(512.0, 512.4), rtrange=c(705,740))
When I try the "getEIC" command, I get this error:
    Error in vector("list", nrow(rtrange)) : invalid 'length' argument

There may also be an error in the plot command, but I haven't been able to get past getEIC, so I'm not sure whether the plot command will work the way that I want.

Ultimately, what I want to do is use my own data to get graphs like those in figure 1 from "Highly sensitive feature detection for high resolution LC/MS" by Ralf Tautenhahn, Christoph Böttcher and Steffen Neumann, 2008, BMC Bioinformatics. I can get the plotRaw function to work, which gives me the upper of the two graphs in figure 1, but I can't figure out how to make the lower graph. The help file for XCMS says that mzrange and rtrange should each be a two-column matrix, but I don't really understand what that means. I mean, for the retention time, for example, I just want to look at 705 to 740 seconds, so that would be one row. What would the other rows in the matrix be?

Thanks!

Laura

Re: How do I plot the EIC from an xcmsRaw object?

Reply #1
Hi Laura,

not 100% sure and I'm not in the office to check, but I think the getEIC functions needs a cbind.
Code: [Select]
QC1.eic <- getEIC(QC1.raw, mzrange=cbind(512.0, 512.4), rtrange=cbind(705,740))
That should work.

Carsten

Re: How do I plot the EIC from an xcmsRaw object?

Reply #2
THANKS, Carsten! That worked beautifully!

Here's the complete code I used in case anyone else had trouble with this:
Code: [Select]
MzRange <- cbind(512.0, 512.4)
RTRange <- cbind(705, 740)
QC1.raw <- xcmsRaw("QC1.mzdata.xml", profstep=0.01, profmethod="bin")
QC1.eic <- getEIC(QC1.raw, mzrange=MzRange, rtrange=RTRange)
plot(QC1.eic, mzrange=MzRange, rtrange=RTRange)

Re: How do I plot the EIC from an xcmsRaw object?

Reply #3
Ok, one last question on a similar topic: How do I limit the scanrange when creating an xcmsRaw object? From what I've read, it seems to me that this code should work:
Code: [Select]
xset.raw.08 <- xcmsRaw(Sample08, profstep=0.01, profmethod="bin", scanrange=c(1100,1150))
but when I run that, I get an error saying, "unused argument(s) (scanrange = c(1100,1150))".

I tried cbind just in case the format was supposed to be a matrix, but that didn't help. And I don't think it is supposed to be a matrix anyway.

Laura

Re: How do I plot the EIC from an xcmsRaw object?

Reply #4
Hi Laura,
this doesn't work, because scanrange is a not a parameter for the xcmsRaw constructor. ("Unused argument" means the argument didn't exists in the function definition, see ?xcmsRaw)

In general, you read the complete sample and the subsequent functions
like getEIC or findpeaks.centWave can use a subset.

Carsten

Re: How do I plot the EIC from an xcmsRaw object?

Reply #5
Aw, bummer. In the pdf help file, it lists "scanrange" as one of the parameters, but I see that "scanrange" is missing when I do as you suggest and type ?xcmsRaw in R. I was hoping I could limit the scan range so that I could look at more than one sample at a time. Currently, each xcmsRaw object is so large that I can only load one at a time into the working memory of my PC.

Thanks for the response, Carsten!

Re: How do I plot the EIC from an xcmsRaw object?

Reply #6
Quote from: "LauraShireman"
Aw, bummer. In the pdf help file, it lists "scanrange" as one of the parameters, but I see that "scanrange" is missing when I do as you suggest and type ?xcmsRaw in R. I was hoping I could limit the scan range so that I could look at more than one sample at a time. Currently, each xcmsRaw object is so large that I can only load one at a time into the working memory of my PC.

The xcmsRaw object is to large? Hmm, you could try to set profstep=0. This way no profile matrix is generated.
That should save some bytes and centWave works perfect without it.
But every function which depends on the profile matrix certainly not!

Other way could be to split the xcmsRaw file, depending on your setup, for example if the file contains MS2.
Could you provide me with some more details, if the above doesn't help?
 
Carsten

Re: How do I plot the EIC from an xcmsRaw object?

Reply #7
Thanks, Carsten. That worked perfectly. I was able to use this code to obtain the xcmsRaw objects for my 12 samples and then plot EICs for the m/z and RT ranges that I wanted and the MS plot, too, for whichever of my 12 samples I wanted. In this example, I used sample #2.

Code: [Select]
Samples.raw <- list()
for (i in 1:12) {
  Samples.raw[[i]] <- xcmsRaw(Samples[i], profstep=0, profmethod="bin")
  rm(i)
}
mzRange <- cbind(512.0, 512.4)
RTRange <- cbind(705, 740)

EIC.2 <- getEIC(Samples.raw[[2]], mzrange=mzRange, rtrange=RTRange)
plot(EIC.2, mzrange=mzRange, rtrange=RTRange)
plotRaw(Samples.raw[[2]], mzrange=mzRange, rtrange=RTRange, log=FALSE)

THANKS!

Laura

Re: How do I plot the EIC from an xcmsRaw object?

Reply #8
If you want to arrange/combine the plots you might want to use layout().