从 pheatmap 中的 cutree_rows 组中拉出 genes/observations
Pull out genes/observations from cutree_rows groups in pheatmap
如何从 pheatmap
中的 cutree_rows = 3
生成的行组中提取 genes/observations?会是 obj$tree_row$...
?
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)
我看到如果你通过 运行 obj$kmeans$cluster
应用 k 意味着你可以找到基因列表,就像这里 is there a way to preserve the clustering in a heatmap but reduce the number of observations?
你可以在上面再做cutree,比如数据是这样的:
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 :
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
我们再次绘制它以确保它是正确的,
pheatmap(mat,cluster_cols = FALSE, scale = 'row',cutree_rows = 3,annotation_row=ann)
如何从 pheatmap
中的 cutree_rows = 3
生成的行组中提取 genes/observations?会是 obj$tree_row$...
?
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)
我看到如果你通过 运行 obj$kmeans$cluster
应用 k 意味着你可以找到基因列表,就像这里 is there a way to preserve the clustering in a heatmap but reduce the number of observations?
你可以在上面再做cutree,比如数据是这样的:
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 :
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
我们再次绘制它以确保它是正确的,
pheatmap(mat,cluster_cols = FALSE, scale = 'row',cutree_rows = 3,annotation_row=ann)