vegdist 提供了多个计算差异度的算法。这些算法自然是各有各的适用范围。对于同一个数据集,其结果有什么直观上的差异呢?

library(vegan)
library(pheatmap)
library(cowplot)
data("varespec")
dist.methods <- c("manhattan", "euclidean", "canberra", "clark", "bray", "kulczynski", "jaccard", "gower", "altGower", "morisita", "horn", "mountford", "raup", "binomial", "chao", "cao" , "mahalanobis")

对于这17种方法,分别计算其距离,用 pheatmap() 比较其差异。

dist.plots <- vector("list",length(dist.methods))
for (i in seq_along(dist.methods)){
  dist <- vegdist(varespec,method = dist.methods[[i]])
  plot <- pheatmap(dist,cluster_cols = F,cluster_rows = F,main = dist.methods[[i]],silent = T)
  dist.plots[[i]] = plot[[4]]
}
## Warning in vegdist(varespec, method = dist.methods[[i]]): results may be
## meaningless with non-integer data in method "morisita"
## Warning in vegdist(varespec, method = dist.methods[[i]]): results may be
## meaningless with non-integer data in method "chao"
## Warning in vegdist(varespec, method = dist.methods[[i]]): results may be
## meaningless with non-integer data in method "cao"

差距还是挺大的。

plot_grid(plotlist = dist.plots,labels = "AUTO",ncol=4)

作者简介

Chun-Hui Gao is a Research Associate at Huazhong Agricultural University.

重复使用

Text and figures are licensed under Creative Commons Attribution CC BY 4.0. The source code is licensed under MIT. The full source is available at https://github.com/yihui/hugo-prose.

欢迎修订

如果您发现本文里含有任何错误(包括错别字和标点符号),欢迎在本站的 GitHub 项目里提交修订意见。

引用本文

如果您使用了本文的内容,请按照以下方式引用:

gaoch (2018). 比较不同差异系数的结果. BIO-SPRING. /post/2018/11/20/comparing-dissimilarity-index/

BibTeX citation

@misc{
  title = "比较不同差异系数的结果",
  author = "gaoch",
  year = "2018",
  journal = "BIO-SPRING",
  note = "/post/2018/11/20/comparing-dissimilarity-index/"
}