2012-04-24 41 views
1

我想显示基于k-means的聚类算法的结果为pheatmap。对于这一点,我在这里使用建议的程序:R draw kmeans clustering with heatmappheatmap集群注释

现在的问题是,我想补充一个配色方案,突出集群,类似“RowSideColors” -option东西heatmapheatmap.2。至于pheatmap,我发现只有annotation选项,但这是工作在列而不是rowwise。有没有办法突出显示pheatmap中的行簇?

我的另一个想法是将cluster-column作为单独的颜色添加到热图中。但是,我需要使用另一种配色方案而不是其他热图,因此我不确定是否可能。

+0

你找到了一个解决方案?我正在寻找完全相同的东西! – 2014-06-19 14:48:52

+0

@ Lilith-Elina不幸的是,我还没有找到解决方案。 – AnjaM 2014-06-20 06:31:46

+0

太糟糕了。 :-(我不明白为什么pheatmap只注释列! – 2014-06-24 06:40:48

回答

2

现在有在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) 
-1

那么,你可以直接使用heatmap或heatmap.2,因为pheatmap没有这个参数。其实,我有类似的任务。 enter image description here

+0

这不是一个正确的答案,请考虑使用玩具代码提交解决方案。 – fridaymeetssunday 2018-02-05 09:46:29