R vegdist(jaccard):如何包含行名称进行聚类?
输入
genename treatment1 treatment2 treatment3
aaa 1 0 0
bbb 0 1 1
ccc 1 1 1
ddd 0 0 0
通过
d <- vegdist(mytable, method = "jaccard")
包 vegan.出现如下错误消息。
Error in rowSums(x, na.rm = TRUE) : 'x' must be numeric.
我输入 str(mytable),我看到
'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
由于需要gene.name 来解释结果,我想保留 aaa、bbb、ccc 和 ddd。
我也尝试通过以下命令删除第一列,但是,这些命令中的任何一个都可以解决问题
rownames(mytable) <- mytable[,1]
mytable <-mytable[,-1]
您介意教我如何解决这个问题吗?
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 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
以下是我使用名为geneRx 的 dfrm 得到的结果:
这是一个警告,而不是错误,而且它似乎提供了合理的信息。如果你没有接受治疗,你就无法与其他病例进行比较。行名用作标签。那么问题是什么?
Here's what I get with a dfrm I named geneRx:
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?