ComplexHeatmap 行标签最大高度 anno_mark

问题描述 投票:0回答:1

我正在尝试使用 ComplexHeatmap 创建簇标记基因的热图。然而,我有太多的基因,我只想显示某些基因,所以我发现我必须在

anno_mark()
函数中使用
rowAnnotation()
。然而,我仍然有很多想要显示的基因,当我这样做时,行注释会溢出热图。

我尝试更改行注释的字体大小,但这只是减小了文本大小,而没有更改注释标记。我还尝试添加

extend = unit(0, "mm")
以确保它不会将行注释扩展到热图之外,但这不起作用。然后我尝试将
link_height = unit(0, "mm")
参数添加到 anno_mark,但这也没有改变输出。

nlmegadegmat <- nlmeganoNA.small@[email protected][nlmega.markers_res0.8$gene, ]

nlmeglevel <- unique(nlmeganoNA$RNA_snn_res.0.8) %>% sort()

cluster_anno <- factor(nlmeganoNA.small$RNA_snn_res.0.8, levels = nlmeglevel)

myCol <- colorRampPalette(c('dodgerblue', 'black', 'yellow'))(50)
myBreaks <- seq(-2, 2, length.out = 50)

nlmegShowGenes <- nlmega.markers_res0.8$gene[c(1,2,3,11,12,14,16,22,25,28,32,36,37,40,
41,44,47,51,52,53,61,63,65,69,71,72,74,81,82,86,90,91,95,96,99,101,102,104,111,113,114,
118,121,124,131,132,134,137,141,143,144,150,151,156,158,161,163,166,167,168,171,173,181,
183,186,191,192,195,202,203,209,211,213,218,219,225,227,240,241,244,248,251,254,259,265,
267,271,273,275)]

nlmegHAright = rowAnnotation(foo = anno_mark(at = which(rownames(nlmegadegmat) %in% nlmegShowGenes),
                                     labels = rownames(nlmegadegmat[rownames(nlmegadegmat)%in%nlmegShowGenes],
                                     labels_gp = gpar(fontsize=2),
                                     extend = unit(0, "mm"),
                                     link_height = link_width))

Heatmap(nlmegadegmat, name = "Expression",  
        column_split = cluster_anno,
        cluster_columns = FALSE,
        show_column_dend = FALSE,
        cluster_column_slices = TRUE,
        column_title_gp = gpar(fontsize = 8),
        column_gap = unit(0.5, "mm"),
        cluster_rows = FALSE,
        show_row_dend = FALSE,
        col = colorRamp2(myBreaks, myCol),
        row_names_gp = gpar(fontsize = 6),
        column_title_rot = 90,
        top_annotation = HeatmapAnnotation(foo = anno_block(gp = gpar(fill = scales::hue_pal()(28)))),
        right_annotation = nlmegHAright,
        show_column_names = FALSE,
        use_raster = TRUE)

r heatmap seurat complexheatmap
1个回答
0
投票

我遇到了同样的问题,所以这里是解决方案,尽管这篇文章很旧:

https://jokergoo.github.io/ComplexHeatmap/reference/anno_mark.html

你可能可以设置如下:

nlmegHAright = rowAnnotation(foo = anno_mark(at = which(rownames(nlmegadegmat) %in% nlmegShowGenes),
labels = rownames(nlmegadegmat[rownames(nlmegadegmat)%in%nlmegShowGenes],
  labels_gp = gpar(fontsize = 4),
  extend = unit(10, "mm"),
  lines_gp = gpar(),
  padding = -0.5,
  link_width = unit(5, "mm"), 
  link_height = unit(5, "mm"))
© www.soinside.com 2019 - 2024. All rights reserved.