R-Heatmap. 2 Remove the huge space left between the header and the actual board after disabling the columnar dendrogram

I draw a double matrix 759 * 12 twoway.expr.005 using a heat map .2 ()

 library(gplots) dist2 <- function(x, ...){as.dist(1-cor(t(x), method="pearson"))} heatmap.2(x=twoway.expr.005,col=bluered(75), main="Heatmap:759 genes\nTwosided Pval<0.05",tracecol= NULL, cexCol=0.8,cexRow=0.5,labCol=labs,distfun=dist2,scale="row",key=F,dendrogram='row',Colv=F) 

But because I set dendrogram='row' (the dendrogram column is off) and key=F , my heatmap leaves huge gaps between the plot title and the actual plot when I try to save it as a PDF.

enter image description here

I tried to install lhei as suggested. I used lhei = c (1,4), but it still shows me a space between the title and the plot:

 heatmap.2(x=twoway.expr.005,col=bluered(75), main="Heatmap:759 genes\nTwosided Pval<0.05",tracecol= NULL, cexCol=0.8,cexRow=0.5,labCol=labs,distfun=dist2,scale="row",key=F,dendrogram='row',Colv=F,lhei=c(1,4)) 

enter image description here

Setting lhei = c (1,5) completely discards the name:

 heatmap.2(x=twoway.expr.005,col=bluered(75), main="Heatmap:759 genes\nTwosided Pval<0.05",tracecol= NULL, cexCol=0.8,cexRow=0.5,labCol=labs,distfun=dist2,scale="row",key=F,dendrogram='row',Colv=F,lhei=c(1,5)) 

enter image description here

I think Heatmap.2 is designed in such a way that the header is always placed above the column dendrogram. Therefore, if a column dendrogram is disabled, it leaves blank space, but the header position is still above the disabled column dendrogram. Is there a way to crack the code so that the header is not placed above the column dendrogram (which could be the solution to this problem)? What else can be done to remove the space between the title and the actual plot?

+6
source share
2 answers

The lhei argument for heatmap.2 can be used to eliminate it. It takes a vector of length 2, which represents the relative height of the lines of the plot layout.

Heatmap.2 divides the area into four blocks using the layout function. In fact, you want to control the height of the first compared to the second. To do this, set lhei to something like c (1, 10). This will lead to the fact that the lower row, in which the heating card is located, is 10 times higher than the upper row, which usually has a dendrogram for rows and a colored key.

The documentation for the layout contains more detailed information.

+4
source

You can use the header instead of setting main from the heatmap .2

title("Your title", line= -2) .

You can adjust the distance by changing the value of the line. Alignment from left to right does not help, which is still turned off without dendrograms, but you will be closer.

+1
source

Source: https://habr.com/ru/post/956260/


All Articles