You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何调整ComplexHeatmap中anno_barplot标题角度以避免重叠?

解决ComplexHeatmap条形图注释标题重叠问题

要将log10(FDR)的注释标题旋转90度以避免重叠,你可以在rowAnnotation中通过annotation_name_rot参数为每个注释单独设置标题旋转角度:给第一个注释指定90度旋转,第二个保持默认水平即可。

修改后的完整代码如下:

aa <- rowAnnotation(
  "log10(FDR)" = anno_barplot(fdr), 
  "log2(Fold Change)" = anno_barplot(fc, gp = gpar(fill = fc_color(fc))),
  width = unit(3, 'cm'),
  gap = unit(10, "points"),
  annotation_name_rot = c(90, 0)  # 第一个注释标题旋转90度,第二个保持水平
)
Heatmap(matrix = mtx, 
        border = T, 
        column_order = ordered_sample, 
        heatmap_legend_param = list(title = "", 
                                    legend_height = unit(4, "cm")), 
        column_names_rot = -90, 
        row_names_gp = gpar(fontsize = 8), 
        column_names_gp = gpar(fontsize = 8), 
        clustering_method_rows = "ward.D2", 
        name = "Scale(exp)", 
        cluster_column_slices = T, 
        row_split = rr_,
        cluster_rows = T, 
        cluster_columns = F, 
        clustering_method_columns = "ward.D2",
        col = htmp_color, 
        right_annotation = aa
)

说明

  • annotation_name_rot参数接受向量输入,向量长度与注释数量一致,每个元素对应对应注释标题的旋转角度(单位:度)。
  • 垂直排列的log10(FDR)标题不会与右侧较长的log2(Fold Change)标题重叠,同时能保持注释区域的布局整洁。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.25 05:40:20