I have been using heatmap.2
for a while, but just discovered pheatmap
. In heatmap.2
, you can specify clustering settings via distfun
and hclustfun
. In pheatmap
, you have clustering_distance_rows
and clustering_method
. However, if I set those parameters to use the same algorithms, the resulting heatmaps do not look similar. How can that be? Does pheatmap
perform additional manipulations that heatmap.2
does not?
My code:
# pheatmap
pheatmap(vals, color=colors, scale="row", cluster_rows=T, cluster_cols=T, clustering_distance_rows = "euclidean", clustering_distance_cols = "euclidean", clustering_method = "complete")
# heatmap.2
hclust_fun = function(x) hclust(x, method="complete")
dist_fun = function(x) dist(x, method="euclidean")
heatmap.2( as.matrix(vals), scale="row", trace="none", dendrogram="both", Rowv=TRUE, Colv=TRUE, distfun=dist_fun, hclustfun=hclust_fun, col=colors)
A related thread about scaling data and these 2 heatmap functions: cannot replicate the pheatmap scale function
Sorry to comment on this old post, I also just have noticed this difference when trying to create heatmaps. Do you have any suggestion on which is the better way? Clustering then scaling (like heatmap / heatmap.2) or scaling then clustering (like pheatmap), because the cluster results is quite different.