Metabolomics Society Forum

Software => R => XCMS => Topic started by: luoluopig on September 02, 2011, 02:22:23 PM

Title: split issue
Post by: luoluopig on September 02, 2011, 02:22:23 PM
Dear all,
I tried to split my data with recipe on cookbook, however, had no success. My data is in the file called: testsplit. there are four samples in this file:HG2onedsili100,
HG2twosili100,HG2threedsili100,HG2pwm and HG2pww. Each sample has triplet runs. Here are script I used and error I got:


>sampclass(testsplit) <- c("HG2onedsili100","HG2pwm","HG2pww", "HG2threedsili100","HG2twodsili100")
Error in sampclass(testsplit) <- c("HpG2onedsili100", "HpG2pwm", "HpG2pww",  :
  object 'testsplit' not found
 
then I did following:
>sampclass<- c("HG2onedsili100","HG2pwm","HG2pww", "HG2threedsili100","HG2twodsili100")
> table(sampleclass)

no errors, however error showed up in xsplit:
>xslist <- split("HG2onedsili100","HG2pwm","HG2pww", "HG2threedsili100","HG2twodsili100", f=sampclass(HG2onedsili100","HG2pwm","HG2pww", "HG2threedsili100","HG2twodsili100"))
Error: unexpected string constant in "xslist <- split("HG2onedsili100","HG2pwm","HG2pww", "HG2threedsili100","HG2twodsili100", f=sampclass(HG2onedsili100",""

Could any one tell me how to fix it?

Thanks
Luoluopig
Title: Re: split issue
Post by: hpbenton on September 02, 2011, 02:50:15 PM
Luoluopig,

It would appear that your xcmsSet object isn't loaded from the line:
Quote
>sampclass(testsplit) <- c("HG2onedsili100","HG2pwm","HG2pww", "HG2threedsili100","HG2twodsili100")
Error in sampclass(testsplit) <- c("HpG2onedsili100", "HpG2pwm", "HpG2pww", :
object 'testsplit' not found

If you type just testsplit in R you should see your object just like if you do faahko on the example from the cookbook. Also the only reason the sampclass method was used in the example was to have a third group to split by instead of just having two. You can do this as well if you want to change your sample classes.

So first I would try:
Code: [Select]
library(xcms)
##I'll assume that testsplit has been made
testsplit
sampclass(testsplit)
xslist <- split(testsplit, f=sampclass(testsplit))

Paul
Title: Re: split issue
Post by: luoluopig on September 02, 2011, 03:09:09 PM
Hi, Paul,
When you said "testsplit"has been made", what does that mean?
Every time before I run xset, I just change work directory. Is there anything else I need do?
Thanks!
Title: Re: split issue
Post by: hpbenton on September 02, 2011, 04:59:45 PM
luoluopig,

test split should be from xcmsSet so....

Code: [Select]
library(xcms)
testsplit<-xcmsSet()
testsplit.g<-group(testsplit)

sampclass(testsplit.g)
xslist <- split(testsplit.g, f=sampclass(testsplit.g))

## or
testsplit<-xset
Title: Re: split issue
Post by: luoluopig on September 06, 2011, 12:01:11 PM
Hi, Paul,
After I typed xcmsSet().The error says " directory tree must be level". How you guys put your folders in a diretory tree? Could you please tell me the software you are using to build a directory tree?
Thanks!


Luoluopig
Title: Re: split issue
Post by: hpbenton on September 07, 2011, 10:43:09 AM
So the directory needs to be only one level deep and your R directory needs to be sitting above the folders you want to look at. For example if I have two classes KO and WT. I will have two folders called KO and WT. In each of these files I'll put the corresponding data files in them. So something like:

MS_exp
    KO
        MS-data1.mzXML
        MS-data2.mzXML
        MS-data3.mzXML
    WT
        MS-data4.mzXML
        MS-data5.mzXML
        MS-data6.mzXML

Your R directory wants to be in MS_exp. We don't use any program to make the directory structure we leave it up to you since we're not sure how you want to arrange your experiment. If you want you can always just put all of your files together into one directory, but your results will vary on how you setup the folders. This is due to the group method and the parameter minfrac.

Hope it helps,

Paul
Title: Re: split issue
Post by: luoluopig on September 08, 2011, 02:43:27 PM
Hi, Paul,
The way I put my folders was exactly same with the way you showed me. So I tried demo data (faahKO) I downloaded from bioconductor:
after I typed
> getwd()
it came out fine.
However, when I typed
>sampclass(faahKO)
I got an error saying" Error in sampclass(faahKO) : error in evaluating the argument 'object' in selecting a method for function 'sampclass': Error: object 'faahKO' not found"

I don't understand. The getwd already showed the correct path of faahKO folder. How could I still get this error?
Do you have any idea what might be wrong there?
  :(


Rui
Title: Re: split issue
Post by: hpbenton on September 08, 2011, 05:09:12 PM
ok with the faahko library you need to call the library explicitly.
Code: [Select]
library(faahKO)

R doesn't work like matlab in that it doesn't look at the directory for code. Instead you can load code from anywhere and library/packages can be loaded from any directory or space using the library function. It's pretty late here so apologies if I didn't read everything correctly or answer everything.

Paul

EDIT: also the object is called faahko , notice the lower case ko