pheatmap 集群注释

Anj*_*jaM 2 r heatmap

我试图将基于 k-means 的聚类算法的结果显示为pheatmap。为此,我使用此处建议的程序:R draw kmeans clustering with heatmap

现在的问题是,我想向颜色方案突出集群,类似的事情在添加到“RowSideColors” -选项heatmapheatmap.2。至于pheatmap,我只找到了annotation选项,但这可以按列而不是按行工作。有没有办法突出显示 中的行集群pheatmap

我的另一个想法是在热图中添加簇列作为单独的颜色。但是,与热图的其余部分相比,我需要使用另一种配色方案,因此我不确定是否可行。

wik*_*lev 5

现在pheatmap包中有一个 annotation_row 参数:

library(pheatmap)

# define a matrix
test = matrix(rnorm(200), 20, 10)
test[1:10, seq(1, 10, 2)] = test[1:10, seq(1, 10, 2)] + 3
test[11:20, seq(2, 10, 2)] = test[11:20, seq(2, 10, 2)] + 2
test[15:20, seq(2, 10, 2)] = test[15:20, seq(2, 10, 2)] + 4
colnames(test) = paste("Test", 1:10, sep = "")
rownames(test) = paste("Gene", 1:20, sep = "")

# annotate rows
annotation_row = data.frame(
GeneClass = factor(rep(c("Path1", "Path2", "Path3"), c(10, 4, 6))))
rownames(annotation_row) = paste("Gene", 1:20, sep = "")

# plot pheatmap
pheatmap(test, annotation_row = annotation_row)
Run Code Online (Sandbox Code Playgroud)