[R] Need help for SVM code for microarray classification

Steve Lianoglou mailinglist.honeypot at gmail.com
Wed Jun 30 04:12:57 CEST 2010


> 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));
<snip>
> 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



More information about the R-help mailing list