首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >从pheatmap中的cutree_rows组中提取基因/观察结果

从pheatmap中的cutree_rows组中提取基因/观察结果
EN

Stack Overflow用户
提问于 2020-12-17 07:06:51
回答 1查看 160关注 0票数 1

如何从pheatmap中的cutree_rows = 3生成的行组中提取基因/观察值?将是obj$tree_row$...

代码语言:javascript
运行
复制
obj <- pheatmap(mat, annotation_col = anno, fontsize_row = 10, show_colnames = F, show_rownames = F, cutree_cols = 3, cluster_cols = FALSE, color = col, scale = 'row',cutree_rows = 3)

我已经看到,如果您像这里的is there a way to preserve the clustering in a heatmap but reduce the number of observations?那样运行obj$kmeans$cluster来应用k方法,就可以找到基因列表

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-12-17 11:06:27

你可以在它上面再做一次cutree,例如数据是这样的:

代码语言:javascript
运行
复制
set.seed(2020)
mat = matrix(rnorm(200),20,10)
rownames(mat) = paste0("g",1:20)
obj = pheatmap(mat,cluster_cols = FALSE, scale = 'row',cutree_rows = 3)

执行cutree:

代码语言:javascript
运行
复制
cl = cutree(obj$tree_row,3)

ann = data.frame(cl)
rownames(ann) = rownames(mat)

ann
    cl
g1   1
g2   2
g3   1
g4   2
g5   3
g6   1
g7   2
g8   1
g9   1
g10  2
g11  3
g12  2
g13  2
g14  1
g15  2
g16  2
g17  1
g18  3
g19  3
g20  2

我们再绘制一次,看看它是正确的,

代码语言:javascript
运行
复制
pheatmap(mat,cluster_cols = FALSE, scale = 'row',cutree_rows = 3,annotation_row=ann)

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65332430

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档