作者:Zuguang Gu8
    编译:Steven Shen
    原文:Adjust blank space caused by annotations


    Heatmap annotations may have annotation names and axes, for which the spaces are also taken into account when arranging heatmap components in the final layout. Sometimes, this adjustment is not smart that you may see blank areas in the plot that are not necessary.

    One scenario is for a matrix with no row names, the space to the right of the heatmap is determined by the size of annotation name, which results in blank space between the heatmap and the legend. Also the heatmap list level row title is plotted to the left of the annotation axis, which gives blank area if there is no row dendrogram.

    adjust_annotation_extension controls whether to take account of the space of annotation names and axes for the layout. Compare following two plots.

    1. m = matrix(rnorm(100), 10)
    2. ht = Heatmap(m, name = "mat",
    3. top_annotation = HeatmapAnnotation(foo = anno_points(1:10)),
    4. show_row_dend = FALSE)
    5. draw(ht, row_title = "fooooooooooo", adjust_annotation_extension = TRUE, # default
    6. column_title = "adjust_annotation_extension = TRUE")
    7. draw(ht, row_title = "fooooooooooo", adjust_annotation_extension = FALSE,
    8. column_title = "adjust_annotation_extension = FALSE")

    4.14 调整由注释引起的空白 - 图1

    Another way to partially solve the space problem is to move the annotation name to the left and use heamtap-level row title.

    1. Heatmap(m, name = "mat",
    2. top_annotation = HeatmapAnnotation(foo = anno_points(1:10),
    3. annotation_name_side = "left"),
    4. row_title = "fooooooooooo",
    5. show_row_dend = FALSE)

    4.14 调整由注释引起的空白 - 图2

    However, this adjustment for annotations sometimes is also necessary, e.g. when the heatmap is very short:

    1. ht = Heatmap(m, name = "mat",
    2. top_annotation = HeatmapAnnotation(foo = anno_points(1:10)),
    3. show_row_dend = FALSE)
    4. draw(ht, row_title = "fooooooooooo", adjust_annotation_extension = TRUE,
    5. column_title = "adjust_annotation_extension = TRUE")

    4.14 调整由注释引起的空白 - 图3

    Therefore, we set TRUE as the default of adjust_annotation_extension and users can configure it based on specific scenarios.