使用pheatmap进行集群注释

时间:2015-09-17 13:02:34

标签: r annotations pheatmap

所以,我正在尝试在R中创建一个带有pheatmap函数的漂亮热图。

我想在树形图停止的情况下使用彩色条,图形开始以便注释不同的簇。就像穿过列的水平粗线一样,当它传递到另一个簇时会改变颜色。我认为这很常见。但我无法弄清楚pheatmap中的“注释”。有什么想法吗?

    structure<-matrix(rnorm(10000),ncol=100,nrow=100)
    dist_structue<-dist(structure)
    clustering<-hclust(dist)   
    cols2 = colorRampPalette(c('green','white','red'))(20) 
    annotation <- data.frame(Var1 = factor(cutree(clustering, k = 4))    
    heat_chem <- pheatmap(as.matrix(dist_structure),
                 clustering_distance_rows=dist_structure, 
                 cellwidth = 4, cellheight = 4, cluster_rows=T,cluster_cols=T, legend = T,
                 clustering_distance_cols = dist_structure, show_rownames = TRUE,
                 fontsize_row = 5, annotation_row = annotation,
                 show_colnames = FALSE, cutree_cols = 4, cutree_rows=4, 
                 color = cols2,
                 main = 'Heatmap')

1 个答案:

答案 0 :(得分:2)

annotation的rownames与as.matrix(dist_structure)

的rownames不匹配
相关问题