作者:Zuguang Gu8
    编译:Steven Shen
    原文:Subset a heatmap


    Since heatmap is a representation of a matrix, there is also a subset method for the Heatmap class.

    由于热图是矩阵的表示,因此 Heatmap 类也有一个子集方法。

    1. ht = Heatmap(mat, name = "mat")
    2. dim(ht)
    3. ## [1] 18 24
    1. ht[1:10, 1:10]

    2.13 子集化热图 - 图1

    The annotations are subsetted accordingly as well.

    注释也相应地进行了子集化。

    1. ht = Heatmap(mat, name = "mat", row_km = 2, column_km = 3,
    2. col = colorRamp2(c(-2, 0, 2), c("green", "white", "red")),
    3. top_annotation = HeatmapAnnotation(foo1 = 1:24, bar1 = anno_points(runif(24))),
    4. right_annotation = rowAnnotation(foo2 = 18:1, bar2 = anno_barplot(runif(18)))
    5. )
    6. ht[1:9*2 - 1, 1:12*2] # odd rows, even columns

    2.13 子集化热图 - 图2

    The heatmap components are subsetted if they are vector-like. Some configurations in the heatmap keep the same when subsetting, e.g. if row_km is set in the original heatmap, the configuration of k-means is kept and it is performed in the sub-heatmap. So in following example, k-means clustering is only performed when making heatmap for ht2.

    如果热图组件是矢量样的,则它们是子集的。热图中的一些配置在子集化时保持相同,例如, 如果在原始热图中设置了 row_km ,则保留 k-means 的配置,并在子热图中执行。因此,在下面的示例中,仅在为 ht2 制作热图时执行 k 均值聚类。

    1. ht = Heatmap(mat, name = "mat", row_km = 2)
    2. ht2 = ht[1:10, 1:10]
    3. ht2

    2.13 子集化热图 - 图3

    The implementation of subsetting heatmaps is very experimental. It is not always working, e.g. if cell_fun is defined and uses an external matrix, or clustering objects are assigned to cluster_rows or cluster_columns.

    子集化热图的实现是非常实验性的。它并不总是有效,例如,如果定义了 cell_fun 并使用外部矩阵,或者将 clustering 对象分配给 cluster_rowscluster_columns

    There are also subset methods for the HeatmapAnnotation class (Section 3.19) and the HeatmapList class (Section 4.10), but both are very experimental as well.

    HeatmapAnnotation 类(第 3.19 节)和 HeatmapList 类(第 4.10 节)也有子集方法,但两者都是非常实验性的。

    ——Update· 2019.07.08——