||||
对于heatmap.2计算样本间距离,构画聚类图,有较多的参考资料
1)https://www.rdocumentation.org/packages/gplots/versions/3.0.1/topics/heatmap.2
2)http://f.dataguru.cn/thread-116821-1-1.html
3)http://blog.sciencenet.cn/blog-1334016-809448.html
4)http://www.360doc.com/content/14/1103/10/17553313_422108323.shtml
heatmap.2需要的数据格式都有相应介绍,最近利用此软件,想尝试利用不同距离计算的策略去看看对聚类效果的影响,主要通过修改distfun参数实现,
具体修改方式:
heatmap.2(...,distfun =function(x) dist(x,method ='euclidean'),...)
对于hclustfun的修改方式类似,
heatmap.2(...,hclustfun =function(x) hclust(x,method ='centroid'),...)
代码最终如下:
library(gplots)
png("./*.png")
data<-read.table("*.csv",header=T,check.names=F)
datamatrix=data.matrix(data)
heatmap.2(datamatrix,
distfun=function(x) dist(x,method='minkowski'),
col=greenred,cexCol=1.2,cexRow=1,
margins=c(10,10),trace = "none",density.info = "none",
labRow="",dendrogram="column",keysize=1)
dev.off()
可将method修改为需要的距离计算方法
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-5-5 13:22
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社