Pregunta

Is there a simple way to get the list/array of retention times from a xcmsRaw object?

Example Code:

xraw <- xcmsRaw(cdfFile) 

So for example getting information from it :

xraw@env$intensity 

or

xraw@env$mz 
¿Fue útil?

Solución

You can see what slots are available in your xcmsRaw instance with

> slotNames(xraw)
 [1] "env"                   "tic"                   "scantime"             
 [4] "scanindex"             "polarity"              "acquisitionNum"       
 [7] "profmethod"            "profparam"             "mzrange"              
[10] "gradient"              "msnScanindex"          "msnAcquisitionNum"    
[13] "msnPrecursorScan"      "msnLevel"              "msnRt"                
[16] "msnPrecursorMz"        "msnPrecursorIntensity" "msnPrecursorCharge"   
[19] "msnCollisionEnergy"    "filepath"

What you want is xraw@msnRt - it is a vector of numeric.

The env slot is a environment that stores 3 variables:

> ls(xraw@env)
[1] "intensity" "mz"        "profile"

More details on the class itself at class?xcmsRaw.

EDIT: The msnRt slot is populated only if you specify includeMSn = TRUE and your input file must be in mzXML or mzML, not in cdf; if you use the faahKO example from ?xcmasRaw, you will see that

xr <- xcmsRaw(cdffiles[1], includeMSn = TRUE)
Warning message:
In xcmsRaw(cdffiles[1], includeMSn = TRUE) :
  Reading of MSn spectra for NetCDF not supported

Also, xr@msnRt will only store the retention times for MSn scans, with n > 1. See the xset@rt where xset is an xcmsSet instance for the raw/corrected MS1 retention times as provided by xcms.

EDIT2: Alternatively, have a go with the mzR package

> library(mzR)
> cdffiles[1]
[2] "/home/lgatto/R/x86_64-unknown-linux-gnu-library/2.16/faahKO/cdf/KO/ko15.CDF"
> xx <- openMSfile(cdffiles[1])
> xx
Mass Spectrometry file handle.
Filename:  /home/lgatto/R/x86_64-unknown-linux-gnu-library/2.16/faahKO/cdf/KO/ko15.CDF 
Number of scans:  1278 
> hd <- header(xx)
> names(hd)
 [1] "seqNum"                   "acquisitionNum"          
 [3] "msLevel"                  "peaksCount"              
 [5] "totIonCurrent"            "retentionTime"           
 [7] "basePeakMZ"               "basePeakIntensity"       
 [9] "collisionEnergy"          "ionisationEnergy"        
[11] "highMZ"                   "precursorScanNum"        
[13] "precursorMZ"              "precursorCharge"         
[15] "precursorIntensity"       "mergedScan"              
[17] "mergedResultScanNum"      "mergedResultStartScanNum"
[19] "mergedResultEndScanNum"  
> class(hd)
[1] "data.frame"
> dim(hd)
[1] 1278   19

but you will be outside of the default xcms pipeline if you take this route (although Steffen Neumann, from xcms, does know mzR very well, oubviously).

Finally, you are better of to use the Bioconductor mailing list of the xcms online forum if you want to maximise your chances to get feedback from the xcms developers.

Hope this helps.

Otros consejos

Good answer but i was looking for this :

xraw <- xcmsRaw(cdfFile)
dp_index <- which(duplicated(rawMat(xraw)[,1]))
xraw_rt_dp <- rawMat(xraw)[,1]
xrawData.rt <- xraw_rt_dp[-dp_index]

Now :

xrawData.rt #contains the retention time.

Observation --> Using mzr package:

nc     <- mzR:::netCDFOpen(cdfFile)
ncData <- mzR:::netCDFRawData(nc)
mzR:::netCDFClose(nc)

ncData$rt #contains the same retention time for the same input !!!
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top