作者: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
类也有一个子集方法。
ht = Heatmap(mat, name = "mat")
dim(ht)
## [1] 18 24
ht[1:10, 1:10]
The annotations are subsetted accordingly as well.
注释也相应地进行了子集化。
ht = Heatmap(mat, name = "mat", row_km = 2, column_km = 3,
col = colorRamp2(c(-2, 0, 2), c("green", "white", "red")),
top_annotation = HeatmapAnnotation(foo1 = 1:24, bar1 = anno_points(runif(24))),
right_annotation = rowAnnotation(foo2 = 18:1, bar2 = anno_barplot(runif(18)))
)
ht[1:9*2 - 1, 1:12*2] # odd rows, even columns
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 forht2
.
如果热图组件是矢量样的,则它们是子集的。热图中的一些配置在子集化时保持相同,例如, 如果在原始热图中设置了 row_km
,则保留 k-means
的配置,并在子热图中执行。因此,在下面的示例中,仅在为 ht2
制作热图时执行 k 均值聚类。
ht = Heatmap(mat, name = "mat", row_km = 2)
ht2 = ht[1:10, 1:10]
ht2
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 tocluster_rows
orcluster_columns
.
子集化热图的实现是非常实验性的。它并不总是有效,例如,如果定义了 cell_fun
并使用外部矩阵,或者将 clustering 对象分配给 cluster_rows
或 cluster_columns
。
There are also subset methods for the
HeatmapAnnotation
class (Section 3.19) and theHeatmapList
class (Section 4.10), but both are very experimental as well.
HeatmapAnnotation
类(第 3.19 节)和 HeatmapList
类(第 4.10 节)也有子集方法,但两者都是非常实验性的。
——Update· 2019.07.08——