我使用'pheatmap'包绘制热图,并使用行和cloumns。但是,出于某种原因,我需要在热图中获取行顺序和列顺序。有一种方便的方法吗?这是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)
答案 0 :(得分:2)
我自己得到了答案。
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