Skip to content

Conversation

@Yunuuuu
Copy link

@Yunuuuu Yunuuuu commented Nov 24, 2023

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

@Yunuuuu Yunuuuu changed the title guess which automatically for Heat guess which automatically for HeatmapAnnotation Nov 24, 2023
@jokergoo
Copy link
Owner

Thank you very much! That is indeed a nice direction to think.

I still need more tests. HeatmapAnnotation can be a component of a Heatmap where which can be obtained when calling Heatmap(). But annotations can also be independently added to heatmaps (ht + ha + ...), which means the value of which will be updated when applying +.

I will give you feedback after I have more mature thoughts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants