【问题标题】:How can I get the new order of column and row in a heatmap after clusting using the pheatmap使用 pheatmap 进行聚类后,如何在热图中获取列和行的新顺序
【发布时间】:2015-04-28 12:52:03
【问题描述】:

我使用“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)

【问题讨论】:

    标签: r cluster-analysis pheatmap


    【解决方案1】:

    我自己得到答案。

    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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-12-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-07-16
      相关资源
      最近更新 更多