Metabolomics Society Forum

Software => XCMS => R => XCMS - Cookbook => Topic started by: hpbenton on August 11, 2011, 07:33:41 AM

Title: Split xcmsRaw objects
Post by: hpbenton on August 11, 2011, 07:33:41 AM
You might have a file measured with complex MS2 of different precursor masses possibly even with different collision energies. Now you want to separate those into individual xcmsRaw objects, based on the MS2 parameters.

Code: [Select]
 library(xcms)
 library(msdata)
 filename <- system.file('iontrap/extracted.mzData', package = "msdata")
 x1 <- xcmsRaw(filename, includeMSn=TRUE)

 ## Catenate the (nominal) precursor mass and collision energy
 index <- paste(round(x1@msnPrecursorMz),x1@msnCollisionEnergy, sep="@")

 ## and split x1 into multiple xraws with data in the "normal" MS1 slots
 xraws <- split(x1, f=index)

 ## Access the resulting data:
 names(xraws)
 xraws[["672@35"]]