使用 pheatmap 聚类后,如何在热图中获取新的列和行顺序
How can I get the new order of column and row in a heatmap after clusting using the pheatmap
我使用 'pheatmap' 包绘制了一个热图,并用行和列聚类。但是,出于某种原因,我需要获取热图中的行顺序和列顺序。有没有方便的方法来做到这一点?这是作弊图的一个例子。
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 = "")
pheatmap(test)
我自己得到答案。
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 = "")
myheatmap <- pheatmap(test);
myheatmap$tree_row$order
#1 7 3 5 8 2 10 9 4 6 13 12 11 14 17 20 16 18 15 19
我使用 'pheatmap' 包绘制了一个热图,并用行和列聚类。但是,出于某种原因,我需要获取热图中的行顺序和列顺序。有没有方便的方法来做到这一点?这是作弊图的一个例子。
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 = "")
pheatmap(test)
我自己得到答案。
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 = "")
myheatmap <- pheatmap(test);
myheatmap$tree_row$order
#1 7 3 5 8 2 10 9 4 6 13 12 11 14 17 20 16 18 15 19