Center multiple pheatmap
1
0
Entering edit mode
3.4 years ago
5utr ▴ 370

I have two versions of the same heatmap, clustered and unclustered. The unclustered version doesn't have the dendrogram on top and when I combine them with patchwork the don't align. How can I center the second heatmap so it aligns with the first one?

library(ggplot2)
library(ggplotify)
library(pheatmap)
library(patchwork)

# dummy df
mat = data.frame(matrix(rnorm(100), nrow=20))
# pheatmap as ggplot
g1 <- as.ggplot(pheatmap(mat))
g2 <- as.ggplot(pheatmap(mat,cluster_cols = F))
# combine 
g1+g2
pheatmap patchwork • 1.3k views
ADD COMMENT
1
Entering edit mode
3.4 years ago
prabin.dm ▴ 260

I think you can use CompleHeatmap package

library(ComplexHeatmap)
mat = data.frame(matrix(rnorm(100), nrow=20))
a <- pheatmap(as.matrix(mat))
b <- pheatmap(as.matrix(mat), cluster_cols = F)
a + b

This aligns very well.

ADD COMMENT
0
Entering edit mode

Indeed. ComplexHeatmap renders all other heatmap packages useless by providing any features one might want. pheatmap especially is pretty obsolete, as CH was built to address its shortcomings - as the developer puts it:

The ComplexHeatmap package is inspired from the pheatmap package. You can find many arguments in ComplexHeatmap have the same names as in pheatmap. Also you can find this old package that I tried to develop by modifying pheatmap.

ADD REPLY

Login before adding your answer.

Traffic: 2394 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6