jokergoo / ComplexHeatmap

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

How to add 'group_block_anno' in the output of a heatmap ('draw(ht)') and export all as a png file #981

Open AlirezaTafazzol opened 1 year ago

AlirezaTafazzol commented 1 year ago

I am trying to combine the following plots/codes ht <- draw(ht, annotation_legend_list = list(lgd_pvalue, lgd_sig)) and g1 <- group_block_anno(1:3, "empty", gp = gpar(fill = "red"), label = "group 1") g2 <- group_block_anno(4:5, "empty", gp = gpar(fill = "blue"), label = "group 2") But I don't know how to add g1 and g2 to the ht and output everything in the *png.

ht + g1 draw (ht+g1) or etc. Does not work.

image image https://jokergoo.github.io/ComplexHeatmap-reference/book/heatmap-annotations.html

AlirezaTafazzol commented 1 year ago

Basically, I am trying to replicate something like this: I can make a heatmap with legends and empty annotations on top. I can plot 'group1' and 'group2' texts on the RStudio plot, but I cannot add it to the heatmap and export outputs as a png or pdf file.

image

jokergoo commented 1 year ago

What do you mean by "but I cannot add it to the heatmap and export outputs as a png or pdf file."?

If you can see the plot in the figure panel in Rstudio, then you can simply output it to a pdf file.

Qiankun-1024 commented 1 year ago

pdf() draw(ht) group_block_anno(1:3, "empty", gp = gpar(fill = "red"), label = "group 1") group_block_anno(4:5, "empty", gp = gpar(fill = "blue"), label = "group 2") dev.off()

You can try this.