Dear Fellows,
I have reviewed the complex heatmap tutorial,but could not replicate it with my data.
https://jokergoo.github.io/ComplexHeatmap-reference/book/heatmap-annotations.html
Point is I am trying to annotate the heatmap from columns 1:5 (Group 1), 6:10 (Group 2), 11:15 (Group 3) up to group 5.
my first attempt to generate heatmap worked:
#complex heatmap
## Heatmap_1
library(ComplexHeatmap)
Heatmap(heatmap, name = "cytokine", rect_gp = gpar(col = "white", lwd =3),
column_title = "Cytokine panel",
column_names_gp = grid::gpar(fontsize= 10),
row_names_gp = grid::gpar(fontsize= 6),
cluster_rows = FALSE,
cluster_columns = FALSE)
However, once I attempted to annotate every 5 five column, I got weird output and columns number is no longer in order. I tried to adjust the parameters, but could not get what I wanted.
## Heatmap_2
Heatmap(heatmap, name = "cytokine", rect_gp = gpar(col = "white", lwd =3),
column_title = "Cytokine panel",
column_names_gp = grid::gpar(fontsize= 10),
row_names_gp = grid::gpar(fontsize= 6),
cluster_rows = FALSE,
cluster_columns = FALSE,
top_annotation = HeatmapAnnotation(foo= anno_block(gp= gpar(fill= 1:25),
labels = c("group1", "group2", "group3", "group4", "group5"),
labels_gp = gpar(col= "white", fontsize= 10))), column_km =5)
I would just simply need to annotate every five columns and like them to be in order: Tumor-1, Tumor-2 etc. If anyone could have a look and help, that would be great.
Thanks!
1 answer
Please do not use column_km = 5 for your second Heatmap instead use split function because you have turned cluster_rows = FALSE, cluster_columns = FALSE for the first Heatmap. You should be able to generate your Heatmap using code below-
split = rep(1:5, each = 5)
ha = HeatmapAnnotation(
empty = anno_empty(border = FALSE),
foo = anno_block(gp = gpar(fill = 2:6), labels = c("group1","group2","group3","group4","group5"))
)
Heatmap(heatmap, name = "cytokine", rect_gp = gpar(col = "white", lwd =3),
column_title = "Cytokine panel",
column_names_gp = grid::gpar(fontsize= 10),
row_names_gp = grid::gpar(fontsize= 6),
cluster_rows = FALSE,
cluster_columns = FALSE, column_split = split, top_annotation = ha)
Log in to answer this question.
pheatmapcan easily do this. https://davetang.org/muse/2018/05/15/making-a-heatmap-in-r-with-the-pheatmap-package/