Skip to main content
Topic: Split and Merging xcmsSet object (Read 5562 times) previous topic - next topic

Split and Merging xcmsSet object

Imagine you have an experiment design with several sample classes, and possibly a large number of data files. If you want to compare the classes pairwise, you'd have to (re-)create xcmsSet's from (different) subsets of your files over and over again.
The suggestion is to read all files at once (given you don't run out of memory) and then split and merge them as required. It is also suggested to save the (large) xcmsSet for subsequent sessions.

Code: [Select]
library(xcms)
library(faahKO)

sampclass(faahko)## faahko has two sample classes:
sampclass(faahko) <- c("WT","WT","WT", "MT_1","MT_1","MT_1", "MT_2","MT_2","MT_2", "MT_3","MT_3","MT_3") ## let's pretend that it had four
table(sampclass(faahko))

 ## Now split this (not so) large xcmsSet according to their sample class
 ## resulting in a list of xcmsSet's
 xslist <- split(faahko, f=sampclass(faahko))
 length(xslist)
## and create an arbitrary combination:
myxs <- c(xslist[["WT"]], xslist[["MT_2"]])
Please note that group and retention time correction data are discarded. The 'profinfo' list is set to be equal to the first object, which might be wrong for the other xcmsSets.
Another use could be to exclude one (bad) sample from an xcmsSet:
Code: [Select]
 ## Split the xcmsSet, specifying explicitely with (arbitrary) names 
 ## which sample goes into wich list element.
 xslist <- split(faahko, c(1,1,1,1,1,1,1,1,0,1,1,1))

 xs <-xslist[["1"]] ## Continue work with the desired list element

 ## Or do the same in one line
 xs <- split(faahko, c(1,1,1,1,1,1,1,1,0,1,1,1))[["1"]]

~~
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