Possible Duplicate:
R cluster with Tanimoto/Jaccard
Input
genename treatment1 treatment2 treatment3
aaa 1 0 0
bbb 0 1 1
ccc 1 1 1
ddd 0 0 0
By doing
d <- vegdist(mytable, method = "jaccard")
from the package vegan
. Error message 开发者_JAVA百科as follows appears.
Error in rowSums(x, na.rm = TRUE) : 'x' must be numeric.
I type str(mytable), I see
'data.frame': xxx obs of xxx variables:
$ aaa : int 1 0 0
$ bbb : int 0 1 1
$ ccc : int 1 1 1
$ ddd : int 0 0 0
As gene.name are needed to interprete the result, I want to keep the aaa, bbb, ccc and ddd.
I also tried to remove the first column by the following command, however, either of these commands can solve the problem
rownames(mytable) <- mytable[,1]
mytable <-mytable[,-1]
Could you mind to teach me how to solve this problem?
Here's what I get with a dfrm I named geneRx:
> rownames(geneRx) <-geneRx[,1]
> geneRx <-geneRx[,-1]
> geneRx
treatment1 treatment2 treatment3
aaa 1 0 0
bbb 0 1 1
ccc 1 1 1
ddd 0 0 0
> d <- vegdist(geneRx, method = "jaccard")
Warning message:
In vegdist(geneRx, method = "jaccard") :
you have empty rows: their dissimilarities may be meaningless in method jaccard
> d
aaa bbb ccc
bbb 1.0000000
ccc 0.6666667 0.3333333
ddd 1.0000000 1.0000000 1.0000000
That is a warning, not an error, and it seems reasonalbly informative. If you don't have a treatment, you cannot compare to the other cases. And the rownames are used as labels. So what is the problem?
精彩评论