jokergoo / ComplexHeatmap

Make Complex Heatmaps
https://jokergoo.github.io/ComplexHeatmap-reference/book/
Other
1.3k stars 227 forks source link

How to adjust the margin between title and heatmap body? #300

Closed wangyuanhao closed 5 years ago

wangyuanhao commented 5 years ago

image

Hi, guys!Is there any parameter or function we can set up to adjust the gap between title and the heatmap body? I have looked through the reference but couldn't find the answer. Am I missing something?

R version: 3.5.3 ComplexHeatmap version : 1.99.7

jokergoo commented 5 years ago

How can you have such a big space between row titles and heatmap? Can you show me the code?

wangyuanhao commented 5 years ago

How can you have such a big space between row titles and heatmap? Can you show me the code?

Hi, @jokergoo, I have attached my code here.


library(ComplexHeatmap) library(circlize)

mRNAColor <- colorRamp2(c(-6, 0, 6), c("green", "black", "red")) miRNAColor <- colorRamp2(c(-2, 0, 2), c("green", "black", "red")) methyColor <- colorRamp2(c(-3, 0, 3), c("green", "black", "red"))

subtype1 <- rep(c("subtype1"), 50) subtype2 <- rep(c("subtype2"), 20) subtype3 <- rep(c("subtype3"), 10) subtype <- c(subtype1, subtype2, subtype3)

mRNABlock1 <- matrix(rnorm(5000), 100, 50) + 5 mRNABlock2 <- matrix(rnorm(2000), 100, 20) - 5 mRNABlock3 <- matrix(rnorm(1000), 100, 10) mRNA <- cbind(mRNABlock1, mRNABlock2, mRNABlock3)

miRNABlock1 <- matrix(0.1rnorm(2500), 50, 50) miRNABlock2 <- matrix(0.1rnorm(1000), 50, 20) + 0.5 miRNABlock3 <- matrix(0.1*rnorm(500), 50, 10) - 0.5 miRNA <- cbind(miRNABlock1, miRNABlock2, miRNABlock3)

methyBlock1 <- matrix(1.4rnorm(500), 10, 50) methyBlock2 <- matrix(1.4rnorm(200), 10, 20) + 0.7 methyBlock3 <- matrix(1.4*rnorm(100), 10, 10) + 0.7 methy <- cbind(methyBlock1, methyBlock2, methyBlock3)

ht1 <- Heatmap(mRNA, name = "mRNA expression", row_title = "mRNA \nexpression", col=mRNAColor, row_title_rot=0, row_names_side = "right", show_row_names = TRUE, cluster_rows = F,cluster_columns = F, column_split = subtype, column_title = NULL, top_annotation = HeatmapAnnotation( subtype=anno_block(gp=gpar(fill=2:4), labels=c("subtype1","subtype2", "subtype3"), labels_gp=gpar(col="white", fontsize=10))) )

ht2 <- Heatmap(miRNA, name = "miRAN expression", col = miRNAColor, row_title = "miRNA \nexpression", row_title_rot=0, cluster_rows = F)

ht3 <- Heatmap(methy, name = "DNA methylation", col = methyColor, row_title = "DNA \nmethylation", row_title_rot=0, cluster_rows = F)

ht_list <- ht1 %v% ht2 %v% ht3 draw(ht_list, ht_gap=unit(1,"mm"))

jokergoo commented 5 years ago

Hi, that was a bug. Now I've fixed it. Please update the package.

Screenshot 2019-04-28 at 18 45 04
wangyuanhao commented 5 years ago

That's great!Thanks!