Rowannotation的ComplexHeatmap问题

时间:2019-01-15 13:57:10

标签: annotations heatmap

我正在尝试使用ComplexHeatmap包创建一个热图。 我想在行名之后的热图右边添加一个文本注释。 我设法添加了rowannotation文本,但令我困惑的是注释名称。 我要在注释文本的顶部添加一个名称(或标题)。 到目前为止,我通过设置以下内容在图上添加注释名称来做到这一点:

show_annotation_name=TRUE        

rowannotation()    

但是我无法使注释名称在文本注释的开头(基本上在行名旁边的列的开头)对齐。 我的矩阵只包含一个包含11个数值的列。

ht = Heatmap(df_matrix, name = "log2FC",
        show_row_names = TRUE,
        show_column_names = FALSE,
        cluster_rows =FALSE, 
        cluster_columns = FALSE,
        row_names_side = "right",
        rect_gp = gpar(col = "white", lty = 1, lwd = 1),
        width = unit(0.5, "cm"),
        heatmap_legend_param = list(title = expression("log"[2]*"FC"),
                                    title_gp = gpar(fontsize = 10),
                                    title_position = "topleft",
                                    legend_direction = "horizontal"
                                    ),
        column_title_gp = gpar(fontsize = 11, fontface = "plain")
        )

ha_row <- rowAnnotation(Annotation = row_anno_text(x = paste( df$Annotation),
                                                   just = "left", 
                                                   gp = gpar(fontsize = 11) ), 
                        show_annotation_name = TRUE,
                        annotation_name_gp = gpar(fontsize = 11, just="right"),
                        annotation_name_offset = unit(2.6, "mm"),
                        annotation_name_side = "top",
                        annotation_name_rot = c(0, 0, 0))

draw(ht + ha_row, 
     column_title = "gene ID",
     row_title = "defense related genes",
     column_title_gp = gpar(fontsize = 11, fontface = "plain"),
     row_title_gp = gpar(fontsize = 11, fontface = "plain"),
     heatmap_legend_side = "bottom"
     )

您能帮我吗? 先感谢您 瓦森

0 个答案:

没有答案