Re: [R] Need help for SVM code for microarray classification

2010-06-29 Thread Aadhithya

Hello Steve 
   Thanks for quick responses its really helping me out .Ya I made the
necessary changes you had mentioned. I was not sure of that 'type' argument
where u had told me to set it to SVM . Do you mean I have to give that
argument in this line "cl <- c(c(rep("ALL",10), rep("AML",10)));" and when I
ran the code the following output I had got : 
result: 
pred  ALL AML 
  ALL   7   5 
  AML   3   5
Does this mean that 7 samples of ALL from test file has been classified as
ALL and 5 samples of ALL are classified as AML and so on or is there any
other way we can interpret this result . I had done one more thing I had
taken the transpose of both my test and train files as given below: 
model<- svm(t(train),cl); 
pred <- predict(model,t(test)); 
And the result I had got is : 
Result: 
pred   ALL     AML 
  ALL   10       0 
  AML   0       10 

why is there a difference in the result which I had given in the before
post?does this mean doing transpose classifies the samples better? or is
there any reason for this? 
I am sorry I am troubling you a lot  but seriously its a very timely help I
am really thankful to you. 

-Aadhithya
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Need-help-for-SVM-code-for-microarray-classification-tp2271652p2272658.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help for SVM code for microarray classification

2010-06-29 Thread Steve Lianoglou
> Hello Steve
>   Thanks for quick responses its really helping me out .Ya I made the
> necessary changes you had mentioned. I was not sure of that 'type' argument
> where u had told me to set it to SVM . Do you mean I have to give that
> argument in this line "cl <- c(c(rep("ALL",10), rep("AML",10)));"

No, look at the help for svm: ?svm

There is an argument in the `svm` function called "type" where you
tell the svm *what* it is that you are trying to do. Among other
things, SVMs can do classification and regression, and they can do so
in slightly different ways (like C-classification vs.
nu-classification).

If you don't specify what you want to do, the `svm` function takes a
guess. From the error output you gave from your last email, you see
that the SVM guessed incorrectly, eg:

> Error in svm.default(train, cl) :
> Need numeric dependent variable for regression.

You see that the SVM guessed regression, when you expected it to do
something else.

Had you specified that you wanted to do some type of classification, I
suspect you would have gotten a more informative error.

(and from your second email)

> I had done one more thing I had taken the transpose of both my test and
> train files as given below:
> model<- svm(t(train),cl);
> pred <- predict(model,t(test));

> why is there a difference in the result which I had given in the before
> post?does this mean doing transpose classifies the samples better? or is

I already mentioned in my previous email that the `svm` function
expects the rows of the data that you supply it to represent different
*observations* your dataset (in your case, the different "people" in
your sample). The columns represent the *features* (or dimensions) of
the data (in your case, the expression level of different genes for
each person (I assume).

Given that explanation, the reason why transposing your data (or not)
has a profound result on your result should be clear.

Hope that helps.

-- 
Steve Lianoglou
Graduate Student: Computational Systems Biology
 | Memorial Sloan-Kettering Cancer Center
 | Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help for SVM code for microarray classification

2010-06-29 Thread Aadhithya

Hi Steve
I had done one more thing I had taken the transpose of both my test and
train files as given below:
model<- svm(t(train),cl);
pred <- predict(model,t(test));
And the result I had got is :
Result:
pred   ALL AML
  ALL   10   0
  AML   0   10

why is there a difference in the result which I had given in the before
post?does this mean doing transpose classifies the samples better? or is
there any reason for this?
Thanks a ton in advance.
-Aadhithya
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Need-help-for-SVM-code-for-microarray-classification-tp2271652p2272590.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help for SVM code for microarray classification

2010-06-29 Thread Aadhithya

Hello Steve 
   Thanks for quick responses its really helping me out .Ya I made the
necessary changes you had mentioned. I was not sure of that 'type' argument
where u had told me to set it to SVM . Do you mean I have to give that
argument in this line "cl <- c(c(rep("ALL",10), rep("AML",10)));" and when I
ran the code the following output I had got :
result:
pred  ALL AML
  ALL   7   5
  AML   3   5
Does this mean that 7 samples of ALL from test file has been classified as
ALL and 5 samples of ALL are classified as AML and so on or is there any
other way we can interpret this result .  I am sorry I am troubling you a
lot  but seriously its a very timely help I am really thankful to you.

-Aadhithya
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Need-help-for-SVM-code-for-microarray-classification-tp2271652p2272563.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help for SVM code for microarray classification

2010-06-29 Thread Steve Lianoglou
Hi,

On Tue, Jun 29, 2010 at 7:16 AM, Aadhithya  wrote:
>
> Following is the error I am getting:
> Error in svm.default(train, cl) :
>  Need numeric dependent variable for regression.

Here's a problem that you may not even know you had yet.

By the looks of your code, it seems as if you want to do
classification, but the SVM is trying to do regression.

You have to make sure that all of the columns in your data.frames are
of the right type. If you're doing classification, change your label
column to a factor. In your case, where you are explicitly passing a y
vector, instead of this:

R> model<- svm(train,cl);

do this

R> cl <- factor(cl)
R> model <- svm(train, cl)

Also, explicitly set the `type` argument in your call to `svm` so you
are doing the right thing (ie. 'C-classifiction', 'nu-classificatino',
etc).

Also, be sure that there aren't any NA values in your data.

> My dataset looks like this in both training and testing:

If both of your datasets look the same, why are you transposing your
`test` matrix when passing it to `predict` (I'm looking at the code in
your original post)?

-- 
Steve Lianoglou
Graduate Student: Computational Systems Biology
 | Memorial Sloan-Kettering Cancer Center
 | Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help for SVM code for microarray classification

2010-06-29 Thread Aadhithya

Following is the error I am getting:
Error in svm.default(train, cl) : 
  Need numeric dependent variable for regression.
My dataset looks like this in both training and testing:
ALL ALL ALL ALL ALL ALL ALL ALL ALL ALL 
AML AML AML AML AML AML AML AML AML
AML
0.9389671   1.0892019   0.24647887  0.57042253  0.10798122  
0.58685446  0.0
0.5399061   0.20422535  0.2488263   0.84976524  0.7910798   
0.39906102  0.5633803
1.0938967   0.86384976  1.0633802   0.7136150.5375587   
0.07042254
1.7179487   0.0 0.32051283  0.012820513 0.0 0.0 
0.2820513   0.98717946  0.26923078
0.07692308  0.0 0.0 0.24358974  0.0 0.0 0.46153846  
0.0 0.20512821  0.20512821
0.0
1.4024506   0.20640905  0.10084826  0.09142318  0.037700284 
0.07257304  0.1206409
0.14514609  2.0 0.11310085  0.030160226 0.15834118  
0.00282752121.1630538
0.14137606  0.31479737  0.2544769   0.12629595  0.24222432  
0.0028275212
 first line Has the class whether it is ALL or AML class and from the next
line I have the expression values
is this the right way to give the dataset to R for SVM classification?
Thanks a lot for immediate reply. I am really grateful.
- Aadhithya
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Need-help-for-SVM-code-for-microarray-classification-tp2271652p2272045.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help for SVM code for microarray classification

2010-06-28 Thread Steve Lianoglou
Hi,

On Mon, Jun 28, 2010 at 9:55 PM, Aadhithya  wrote:
>
> Hi I am Aadhithya I am trying to write a code to classify microarray data
> (AML and ALL) using SVM in R
> my code goes like this :
> library(e1071)
> train<-read.table("Z:/Documents/train.txt",header=T);
> test<-read.table("Z:/Documents/test.txt",header=T);
> cl <- c(c(rep("ALL",10), rep("AML",10)));
> model<- svm(train,cl);
> pred <- predict(model,t(test));
> table(pred,t(cl));
>
> But I am not able to run it its giving me error . I will be really grateful
> if someone can help me.Thanks in advance

1. Please give the error that it's giving you
2. Are the number of features/columns in your training and testing
matrices the same? Remember that like most other model-building-type
functions in R, the rows of the data represent the different
observations, and the columns of the data represent the different
features/dimensions/predictor-variabls of each observation.

-- 
Steve Lianoglou
Graduate Student: Computational Systems Biology
 | Memorial Sloan-Kettering Cancer Center
 | Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Need help for SVM code for microarray classification

2010-06-28 Thread Aadhithya

Hi I am Aadhithya I am trying to write a code to classify microarray data
(AML and ALL) using SVM in R 
my code goes like this :
library(e1071)
train<-read.table("Z:/Documents/train.txt",header=T);
test<-read.table("Z:/Documents/test.txt",header=T);
cl <- c(c(rep("ALL",10), rep("AML",10)));
model<- svm(train,cl);
pred <- predict(model,t(test));
table(pred,t(cl));

But I am not able to run it its giving me error . I will be really grateful
if someone can help me.Thanks in advance
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Need-help-for-SVM-code-for-microarray-classification-tp2271652p2271652.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.