pheatmap r-注释传说未显示所有值
绘制注释时,并非所有簇显示(8中只有4个)。我如何解决它的名字并查看所有颜色? 谢谢!
数据是一个相关图(COR_MARTIX),我提取了由pheatmap创建的簇,并从中提取注释。
代码:
chosen_k = 4
res = pheatmap(mat = cor_martix, breaks=seq(-1, 1, length.out=101))
myannotation = as.data.frame(cutree(res$tree_row,k = chosen_k)) #extract k clusters
names(myannotation)[1] = "cluster"
palette1 <- rainbow(chosen_k,alpha = 0) #make colors
ann_colors = list (cluster = palette1) #make annotation colors
pheatmap(mat = cor_martix, breaks=seq(-1, 1, length.out=101),annotation_col = myannotation, annotation_colors =ann_colors)
when drawing annotation, not all of the clusters are shown (only 4 out of 8). How can I solve it and see all the colors with their names?
Thanks!
The data is a correlation map (cor_martix), that I extracted the clusters that created by pheatmap, and make an annotation from them.
code:
chosen_k = 4
res = pheatmap(mat = cor_martix, breaks=seq(-1, 1, length.out=101))
myannotation = as.data.frame(cutree(res$tree_row,k = chosen_k)) #extract k clusters
names(myannotation)[1] = "cluster"
palette1 <- rainbow(chosen_k,alpha = 0) #make colors
ann_colors = list (cluster = palette1) #make annotation colors
pheatmap(mat = cor_martix, breaks=seq(-1, 1, length.out=101),annotation_col = myannotation, annotation_colors =ann_colors)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是解决您问题的解决方案。
首先,当生成
myannotation
数据框架时,cluster
列必须定义为一个因素。然后,当定义带有注释颜色的
ann_colors
列表时,每种颜色必须与相应的群集名称关联。现在,注释传说显示了正确数量的颜色。
Here is the solution to your problem.
First, when generating the
myannotation
data frame, thecluster
column must be defined as a factor.Then, when defining the
ann_colors
list with annotation colors, each color must be associated to the corresponding cluster name.Now the annotation legend shows the right number of colors.