1

在 R 中使用“heatmap()”函数生成热图后,有没有办法专注于并提取特定集群的成员?

我有一张 4500 x 420 成员的热图,它会很有用。

谢谢。

4

1 回答 1

2

指定keep.dendro = TRUE并且您应该在 和 的列表元素下有可用的Rowv数据Colv

这是一个稍加修改的示例,来自?heatmap.

require(graphics); require(grDevices)
x  <- as.matrix(mtcars)
rc <- rainbow(nrow(x), start = 0, end = .3)
cc <- rainbow(ncol(x), start = 0, end = .3)
hv <- heatmap(x, col = cm.colors(256), scale = "column",
              RowSideColors = rc, ColSideColors = cc, margins = c(5,10),
              xlab = "specification variables", ylab =  "Car Models",
              main = "heatmap(<Mtcars data>, ..., scale = \"column\")",
              keep.dendro = TRUE)

hv$Rowv
'dendrogram' with 2 branches and 32 members total, at height 425.3447 

编辑

如果你想要组成员,你需要先砍树。

cutree(as.hclust(hv$Rowv), h = 200)

          Mazda RX4       Mazda RX4 Wag          Datsun 710      Hornet 4 Drive   Hornet Sportabout             Valiant 
                  1                   1                   1                   2                   3                   2 
         Duster 360           Merc 240D            Merc 230            Merc 280           Merc 280C          Merc 450SE 
                  3                   1                   1                   1                   1                   2 
         Merc 450SL         Merc 450SLC  Cadillac Fleetwood Lincoln Continental   Chrysler Imperial            Fiat 128 
                  2                   2                   3                   3                   3                   1 
        Honda Civic      Toyota Corolla       Toyota Corona    Dodge Challenger         AMC Javelin          Camaro Z28 
                  1                   1                   1                   2                   2                   3 
   Pontiac Firebird           Fiat X1-9       Porsche 914-2        Lotus Europa      Ford Pantera L        Ferrari Dino 
                  3                   1                   1                   1                   3                   1 
      Maserati Bora          Volvo 142E 
                  4                   1
于 2013-12-08T08:24:28.213 回答