Skip to main content
Topic: How do I get data from the xcmsSet/xcmsRaw object? (Read 7235 times) previous topic - next topic

How do I get data from the xcmsSet/xcmsRaw object?

The xcmsSet object is an S4 object. If you don't know what that means, its ok, it just a defined way of hold information.

Lets open our default example set the faahko dataset.
Code: [Select]
library(xcms)
library(faahKO)
faahko

Notice that calling the object will give you some information about it but not tell you everything. This is because the object is calling a method called 'show'. We'll test this in the next bit of code. To find where this info is coming from we need to find the data in the object. This data is held in slots within the object and can be different types of data.
Code: [Select]
show(faahko) ## same as just faahko
names(attributes(faahko)) ## these are the slots within the object
class(faahko@peaks)
class(faahko@rt)
head(faahko@peaks)

Again notice that the type/classes for peaks and rt are different. If you want to access the data you need to use the @ symbol to access the slot. However, if the programmer was good then many of these slots have direct access using specified methods. The programmer for xcms was very good and so we have just that.

Code: [Select]
head(groups(faahko))
head(peaks(faahko))
phenoData(faahko)

For the moment while I'm still editing this I'm going to drop this code here, eventually this will be cleaned up :)
[code]
require(faahko) || stop("Install faahkon")

faahko<-group(faahko) ## the data needs to be grouped first to find the matching values between the samples

head(groups(faahko)) ##  gives the meta data for each variable

vals<-groupval(faahko, "medret", "into") ## returns the intensity values for each feature and each sample
dim(vals) ## features X samples

## ungrouped xcmsSet objects have the only the following slots filled:
head(faahko@peaks) ## just a peak list, sorted by sample
unique(faahko@peaks[,"sample"]) ## these number are indexes to ->
faahko@phenoData ## which is a class ->
class(faahko@phenoData)
## but method ->
sampclass(faahko) ## is a factor and is the better way to id against the peak list.

length(faahko@rt) ## one == raw rt,  2 == corrected rt
length(faahko@rt$raw) ## == number of samples
length(faahko@rt$raw[[1]]) == number of scans, element is the scan time for that run

[code]

More to come:
Explain how each slot relates to each other.
Show xcmsRaw slots
xcmsRaw -> xcmsSet via findPeaks method
and difference between @ and $
~~
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