Reputation: 28907
I have a heatmap that looks like this in R:
col<- colorRampPalette(c("red","white", "blue"))(10)
library("gplots")
heatmap.2(qq,scale="none",col=col,trace="none",density.info="none",dendrogram="column")
But then I did a separate cluster analysis based on correlation, that came out like this:
library(Hmisc)
plot(varclus(qq,similarity="spearman"))
How can I modify my heatmap so that the clustering is identical to the cluster analysis I did with correlation? I need to somehow modify the heatmap.2
function (or maybe use a different function) to be based on pearson correlation. Any ideas?
Upvotes: 1
Views: 1602
Reputation: 25306
Try
col<- colorRampPalette(c("red","white", "blue"))(10)
library("gplots")
library(Hmisc)
v <- varclus(qq,similarity="spearman")
devtools::install_github('talgalili/dendextend')
library(dendextend)
dend <- as.dendrogram(v) # comes from dendextend. The same as as.dendrogram(v$hclust)
heatmap.2(qq,scale="none",col=col,trace="none",density.info="none",dendrogram="column", Colv = dend)
(since qq does not exist, I can't reproduce the image)
Upvotes: 2