In bioinformatics, R is often used for drawing, while R is very powerful in drawing heatmap. In general, I used to use the heatmap.2 function in the gplots package for drawing. However, this function cannot adjust the clustering analysis (clustering) method. Therefore, you can use different clustering analysis methods to integrate heatmap by writing a small piece of code.
1 # There are 7 methods to make cluster in the function hclust in R 2 Cluster_Method<-c( "ward", "single", "complete", "average", "mcquitty", "median", "centroid") 3 4 for (i in 1:length(Cluster_Method)){ 5 #make a function to extract the cluster method 6 myclust<-function(x){ 7 hclust(x,method=Cluster_Method[i]) 8 } 9 #make heatmap by jpeg10 jpeg(filename=paste(Cluster_Method[i],'.jpg'),width=1024,height=728)11 heatmap.2(as.matrix(Data_Top1k_Var),12 trace='none',13 hclustfun=myclust,labRow=NA,14 ColSideColors=c('black',grey(0.4),'lightgrey')[as.factor(CellLine_Anno$Type)],15 xlab='CellLines',16 ylab='Probes',17 main=Cluster_Method[i],18 col=greenred(64))19 dev.off()20 }
In this way, seven cluster methods can be used on heatmap in sequence. By comparing the cluster tree, we can select the best and most stable cluster method from it to lay a good foundation for subsequent analysis!