Skip to main content
Topic: how to get RT-Values for a peak (Read 5329 times) previous topic - next topic

how to get RT-Values for a peak

Hy all!

How do I get rtmin and rtmax values (raw as well as corrected) for a specific peak? I know that there are columns for rtmin and rtmax in xcmsSet@peaks. Are those raw or corrected RTs? I also know that there are xcmsSet@rt$raw and xcmsSet@rt$corrected values but I dont know how to link those values to a peak neither how to get rtmin and rtmax from those values. It also seems that in xcmsSet@rt are less values than peaks.

As for xcms settings I build the xcmsSet as follows:
xset <- xcmsSet(...)
xset <- retcor(xset, method = "obiwarp")
xset <- group(xset,...)
xset <- fillPeaks(xset)

Thanks
Gunnar

Re: how to get RT-Values for a peak

Reply #1
Gunnar,

By far the simples way of doing this is to cheat. I normally make a separate object for each method. I can then go back and get the times from each object. Something like this:
Code: [Select]
library(xcms)
library(faahKO)
gxs<-group(faahko)
#262 325 387 450 512 575
ret<-retcor(gxs, p="d", f="s")
#Retention Time Correction Groups: 132
head(ret@peaks)
head(gxs@peaks)

Notice that the rtmed, rtmin and rtmax have shifted. This is as I say the simplest way of doing it. Otherwise you're looking at accessing the rt slot. The rt slot in xcmsSet holds both raw and corrected retention times. So xset@rt$raw has a length of the number of samples, in each of these are the original retention times from each scan. This is a bit of a pain because it means that you can't just get the peak index and call it the same as the rt$corrected/rt$raw. You need to look and see which which retention time is closer in either the raw or corrected depending on your object. I'll try a little code but it's untested so there might be error/bug/warnings.
Code: [Select]
minRT<-ret@peaks[1,"rtmin"]
maxRT<-ret@peaks[1,"rtmax"]

inx<-which(ret@rt$corrected[[ret@peaks[1,"sample]]] > minRT & ret@rt$corrected[[ret@peaks[1,"sample"]]] <maxRT )
## this is the corrected rt index so the raw should be :

ret@rt$raw[[ret@peaks[1,"sample"]]][inx]
~~
H. Paul Benton
Scripps Research Institute
If you have an error with XCMS Online please send me the JOBID and submit an error via the XCMS Online contact page

Re: how to get RT-Values for a peak

Reply #2
Hello!

I think the simple way is just fine for me, since i also need raw and corrected rtmin and rtmax values.
Thanks for your help.

Gunnar