jokergoo / ComplexHeatmap

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

guess `which` automatically for HeatmapAnnotation #1140

Open Yunuuuu opened 10 months ago

Yunuuuu commented 10 months ago

Now, it's no need to set which in HeatmapAnnotation function, we just guess it by argument, top_annotation, bottom_annotation, left_annotation and right_annotation, these can give exact which.

library(ggplot2)
library(ComplexHeatmap)
#> Loading required package: grid
#> ========================================
#> ComplexHeatmap version 2.15.4
#> Bioconductor page: http://bioconductor.org/packages/ComplexHeatmap/
#> Github page: https://github.com/jokergoo/ComplexHeatmap
#> Documentation: http://jokergoo.github.io/ComplexHeatmap-reference
#> 
#> If you use it in published research, please cite either one:
#> - Gu, Z. Complex Heatmap Visualization. iMeta 2022.
#> - Gu, Z. Complex heatmaps reveal patterns and correlations in multidimensional 
#>     genomic data. Bioinformatics 2016.
#> 
#> 
#> The new InteractiveComplexHeatmap package can directly export static 
#> complex heatmaps into an interactive Shiny app with zero effort. Have a try!
#> 
#> This message can be suppressed by:
#>   suppressPackageStartupMessages(library(ComplexHeatmap))
#> ========================================
x <- sample(1:10, 10L)
m <- matrix(rnorm(100), nrow = 10L)
rownames(m) <- paste0("row ", seq_len(nrow(m)))
colnames(m) <- paste0("col ", seq_len(ncol(m)))
draw(Heatmap(m,
  top_annotation = HeatmapAnnotation(
    foo = anno_points(x, height = unit(5, "cm"))
  )
))

image

draw(Heatmap(m,
  bottom_annotation = HeatmapAnnotation(
    foo = anno_points(x, height = unit(5, "cm"))
  )
))

image

draw(Heatmap(m,
  left_annotation = HeatmapAnnotation(
    foo = anno_points(x, width = unit(5, "cm"))
  )
))

image

draw(Heatmap(m,
  right_annotation = HeatmapAnnotation(
    foo = anno_points(x, width = unit(5, "cm"))
  )
))

image

Created on 2023-11-24 with reprex v2.0.2