【问题标题】:Why does hclust gives a different cluster than pvclust in r?为什么 hclust 在 r 中给出与 pvclust 不同的集群?
【发布时间】:2016-12-16 18:14:37
【问题描述】:

我正在尝试获取以下数据集的层次聚类分析的p值。pvclust和hclust生成的树状图完全不同。因为pvclust提到它们使用与hclust相同的方法,所以应该是相同的。

require(vegan) 
test

  S1 S2 S3 S4 S5 S6 S7 S8 S9 S10
1  1  1  1  1  1  1  0  1  1   0
2  0  0  1  0  0  0  0  0  0   0
3  1  0  0  1  1  0  0  0  1   1
4  1  0  1  0  1  1  0  1  0   1
5  0  1  0  1  0  0  0  0  1   0
6  1  0  1  0  1  1  0  0  0   1
7  1  1  0  1  0  0  1  0  1   0
8  1  1  0  1  0  1  1  0  1   0
9  1  0  1  0  1  1  0  1  0   0

div.norm=decostand(test,"normalize")
div.ch=vegdist(div.norm,"bray")
div.ch.UPGMA=hclust(div.ch,method = "average")
plot(div.ch.UPGMA)

这会生成以下树状图: Cluster using hclust 然后我尝试使用 pvclust 运行相同的数据集。

require(pvclust)
test.tr=t(test)
result=pvclust(test.tr, method.dist="cor", method.hclust="average", nboot=1000)
plot(result)

我得到以下树状图,它与 hclust 生成的树状图不同。 cluster using pvclust

有人建议我不应该转置数据。但这会产生一个树状图,其中列聚集在一起(我不希望这样)。

任何帮助将不胜感激!

【问题讨论】:

  • 欢迎来到 SO!请使用dput 以可重复的方式共享您的数据(请参阅 R 标签说明)。此外,为了将来参考,我们希望您在显示代码时不要包含>,以便无需编辑即可复制和粘贴。
  • 您的代码显示您使用标准化数据来表示 hclust 和“bray”距离。在 pvclust 中,距离为“cor”且数据未标准化。相同的方法和数据预处理问题是否仍然存在?
  • @nya:它不接受 pvclust 中的“bray”作为 method.dist 的有效条目。
  • @user127213 然后需要根据分析需求选择方法。如果你使用不同的方法,函数应该返回不同的结果。

标签: r hierarchical-clustering


【解决方案1】:

您正在使用的pvclust 分层集群实现依赖于引导重采样。这引入了一定程度的随机性,您可能会在两次运行 pvclust 之间得到不同的结果,因此您应该期望它与 hclust 完全相同。

此外,您在运行pvclust 时可能已经注意到一些相当严重的警告:

Bootstrap (r = 0.5)... Done.
Bootstrap (r = 0.6)... Done.
Bootstrap (r = 0.7)... Done.
Bootstrap (r = 0.8)... Done.
Bootstrap (r = 0.9)... Done.
Bootstrap (r = 1.0)... Done.
Bootstrap (r = 1.1)... Done.
Bootstrap (r = 1.2)... Done.
Bootstrap (r = 1.3)... Done.
Bootstrap (r = 1.4)... Done.
Warning messages:
1: inappropriate distance matrices are omitted in computation: r =  0.5 
2: inappropriate distance matrices are omitted in computation: r =  0.6 
3: inappropriate distance matrices are omitted in computation: r =  0.7 
4: inappropriate distance matrices are omitted in computation: r =  0.8 
5: inappropriate distance matrices are omitted in computation: r =  0.9 
6: inappropriate distance matrices are omitted in computation: r =  1 
7: inappropriate distance matrices are omitted in computation: r =  1.1 
8: inappropriate distance matrices are omitted in computation: r =  1.2 
9: inappropriate distance matrices are omitted in computation: r =  1.3 
10: inappropriate distance matrices are omitted in computation: r =  1.4

由于pvclust 的每次迭代都有一个不可用的距离矩阵,因此应极其谨慎地解释结果,这可能会使它们无效并显着改变它们。

【讨论】:

  • 非常感谢您的帮助。
  • 非常感谢您的帮助。但是,我不确定这是迭代的问题。如果我运行它超过 15 次,我希望至少能找到一次相同的结果。有趣的是,使用 pvclust 创建的树状图非常一致,并且不会更改配置。它们是独一无二的,与 hclust 生成的不同。
  • @user127213 不客气,但除了每次采样的随机性之外,别忘了由于距离矩阵不合适,结果完全无效。这绝对是不平凡的。此外,您可能有点过于乐观地认为仅仅因为它运行了 15(或 1,500)次就可以获得相同的结果。如果不是因为距离矩阵而导致算法中断,您可能会得到 close 结果,但没有理由会是 相同
猜你喜欢
  • 2016-06-03
  • 1970-01-01
  • 2017-09-20
  • 1970-01-01
  • 2022-01-08
  • 2016-07-24
  • 2016-09-21
  • 1970-01-01
  • 2016-04-29
相关资源
最近更新 更多