简体   繁体   English

ComplexHeatmap 在 rowAnnotation 中更改段/链接的方向

[英]ComplexHeatmap change direction of segment/link in rowAnnotation

I am building a large heatmap and have added a row annotation.我正在构建一个大型热图并添加了行注释。 This particular annotation must be on the left side of the heatmap, but when I add labels, the segment/link is facing the wrong direction.这个特定的注释必须在热图的左侧,但是当我添加标签时,段/链接朝向错误的方向。 Can someone help me figure out how to flip the segment to be in between the label and the annotation?有人可以帮我弄清楚如何将段翻转到 label 和注释之间吗?

Reproducible example:可重现的例子:

library(ComplexHeatmap)

mat <- matrix(sample(c(-1, 0, 1), 30, replace = T), nrow = 10, ncol = 3, dimnames = list(letters[1:10], c(LETTERS[1:3])))
labels <- c(1:10)

set.seed(123)
anno <- anno_mark(at = labels, 
                  labels = c("a", "b", "c", "d", "e", "f", "g", "h", "i", "j"), 
                  which = "row")
foo <- c("a", "b", "c", "d", "e", "f", "g", "h", "i", "j")

ha = rowAnnotation(mark = anno, 
                   foo = foo, 
                   col = list("a" = "#440154FF", "b" = "#471365FF", "c" = "#482374FF", 
                              "d" = "#46337EFF", "e" = "#424186FF", "f" = "#3C4F8AFF", 
                              "g" = "#365C8DFF", "h" = "#31688EFF", "i" = "#2C738EFF", 
                              "j" = "#277F8EFF"), 
                   show_legend = FALSE)

ht1 = Heatmap(mat, 
              name = "Example", 
              heatmap_legend_param = list(color_bar = "continuous", at = c(-1, 0, 1), 
                                          labels = c("-1", "0", "1"),
                                          legend_width = unit(15, "cm"), 
                                          labels_gp = gpar(fontsize = 22),
                                          title_gp = gpar(fontsize = 22),
                                          title_position = "topleft",
                                          direction = "horizontal"),
              cluster_rows = F, 
              cluster_columns = T, 
              show_row_names = F,
              show_column_names = F,
              use_raster = F,
              left_annotation = ha
)

png(paste0("./",format(Sys.Date(), "%Y%m%d"), "_example.png"), width = 8, height = 4, units = "in", res = 600)
draw(ht1, heatmap_legend_side = "bottom", padding = unit(c(1, 1, 1, 1), "cm"))
dev.off()

And this is the resulting figure:这是结果图: 在此处输入图像描述

I'm just looking to move the segments on the far left to be in between the letters and the annotation boxes.我只是想将最左边的段移动到字母和注释框之间。

Thanks!谢谢!

I figured out the answer to this: I had simply missed adding the side argument to anno_link as follows:我想出了答案:我只是错过了将 side 参数添加到 anno_link 如下:

anno <- anno_mark(at = labels, 
              labels = c("a", "b", "c", "d", "e", "f", "g", "h", "i", "j"), 
              which = "row", side = "left)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM