更改 ComplexHeatmap 中图例的顺序
Changing order of legends in ComplexHeatmap
交叉-post: issues/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
这里是作者提供的解决方案:
set.seed(100)
ha <- HeatmapAnnotation(foo = rep(c("gr1", "gr2"), each = 5), annotation_label = c("col_an"),
annotation_name_side = "left")
ra <- HeatmapAnnotation(pt = rep(letters[1:2], each = 5), which = "row", annotation_label = c("row_an"))
ht = ha %v% Heatmap(matrix(rnorm(100), 10), name = "mat", left_annotation = ra)
draw(ht, merge_legend = TRUE, column_dend_side = "top")
https://github.com/jokergoo/ComplexHeatmap/issues/557#issuecomment-673404750
交叉-post: issues/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
这里是作者提供的解决方案:
set.seed(100)
ha <- HeatmapAnnotation(foo = rep(c("gr1", "gr2"), each = 5), annotation_label = c("col_an"),
annotation_name_side = "left")
ra <- HeatmapAnnotation(pt = rep(letters[1:2], each = 5), which = "row", annotation_label = c("row_an"))
ht = ha %v% Heatmap(matrix(rnorm(100), 10), name = "mat", left_annotation = ra)
draw(ht, merge_legend = TRUE, column_dend_side = "top")
https://github.com/jokergoo/ComplexHeatmap/issues/557#issuecomment-673404750