You need to enable JavaScript to run this app. 如何调整ComplexHeatmap中热图及注释图例的排列顺序?
优惠活动
大模型
产品
解决方案
定价
更多

如何调整ComplexHeatmap中热图及注释图例的排列顺序?

交叉发布:ComplexHeatmap issue 557

目前尚未找到在ComplexHeatmap中调整图例排列顺序的可行解决方案。

示例

library(ComplexHeatmap)

set.seed(100)

ha <- HeatmapAnnotation(foo = rep(c("gr1", "gr2"), each = 5), annotation_label = c("col_an"))

ra <- HeatmapAnnotation(pt = rep(letters[1:2], each = 5), which = "row", annotation_label = c("row_an"))

Heatmap(matrix(rnorm(100), 10), name = "mat", top_annotation = ha, left_annotation = ra)

热图初始输出效果示意图

问询问题: 请问如何实现图例从上到下按照如下顺序排列?

  • col_an
  • row_an
  • mat

运行环境信息

xfun::session_info()
R version 4.0.2 (2020-06-22)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Mojave 10.14.6, RStudio 1.3.1056

Locale: en_US.UTF-8 / en_US.UTF-8 / en_US.UTF-8 / C / en_US.UTF-8 / en_US.UTF-8

Package version:
  assertthat_0.2.1     backports_1.1.8      base64enc_0.1.3      BiocGenerics_0.34.0  circlize_0.4.10     
  cli_2.0.2            clue_0.3-57          cluster_2.1.0        colorspace_1.4-1     compiler_4.0.2      
  ComplexHeatmap_2.5.4 crayon_1.3.4         curl_4.3             digest_0.6.25        ellipsis_0.3.1      
  evaluate_0.14        fansi_0.4.1          GetoptLong_1.0.2     GlobalOptions_0.1.2  glue_1.4.1          
  graphics_4.0.2       grDevices_4.0.2      grid_4.0.2           highr_0.8            htmltools_0.5.0     
  IRanges_2.22.2       jsonlite_1.7.0       knitr_1.29           lifecycle_0.2.0      magick_2.4.0        
  magrittr_1.5         markdown_1.1         methods_4.0.2        mime_0.9             parallel_4.0.2      
  pillar_1.4.6         pkgconfig_2.0.3      png_0.1-7            purrr_0.3.4          R.cache_0.14.0      
  R.methodsS3_1.8.0    R.oo_1.23.0          R.utils_2.9.2        RColorBrewer_1.1-2   Rcpp_1.0.5          
  rematch2_2.1.2       rjson_0.2.20         rlang_0.4.7          rmarkdown_2.3        rprojroot_1.3.2    
  rstudioapi_0.11      S4Vectors_0.26.1     shape_1.4.4          stats_4.0.2          stats4_4.0.2        
  stringi_1.4.6        stringr_1.4.0        styler_1.3.2         tibble_3.0.3         tinytex_0.25        
  tools_4.0.2          utf8_1.1.4           utils_4.0.2          vctrs_0.3.2          withr_2.2.0         
  xfun_0.16  

内容的提问来源于stack exchange,提问作者Deepak Tanwar

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.12.02 04:24:02