【问题标题】:How to make hierarchical cluster pheatmap in r?如何在 r 中制作分层集群 pheatmap?
【发布时间】:2021-07-12 16:22:17
【问题描述】:

我已使用此代码制作分层集群热图,但没有颜色出现

library(tidyverse)

Mydata <- structure(list(Location = c("Karnaphuli River", "Sangu River", "Kutubdia Channel", "Moheshkhali Channel", "Bakkhali River",  "Naf River", "St. Martin's Island", "Mean "), Cr = c(114.92,  2.75, 18.88, 27.6, 39.5, 12.8, 17.45, 33.41), Pb = c(31.29, 26.42,  52.3, 59.45, 34.65, 12.8, 9.5, 32.34), Cu = c(9.48, 54.39, 52.4, 73.28, 76.26, 19.48, 8.94, 42.03), Zn = c(66.2, 71.17, 98.7,  95.3, 127.84, 27.76, 21.78, 72.67), As = c(89.67, 9.85, 8.82, 18.54, 15.38, 7.55, 16.45, 23.75), Cd = c(1.06, 0, 0.96, 2.78, 3.12, 0.79, 0.45, 1.53)), class = "data.frame", row.names = c(NA, -8L))

library(pheatmap)

Mydata %>% column_to_rownames(var = "Location") %>% 
 as.matrix() %>% pheatmap(Mydata, cutree_cols = 6)

【问题讨论】:

    标签: r heatmap hierarchical-clustering pheatmap


    【解决方案1】:

    使用管道时无需再次传递数据。试试看:

    library(pheatmap)
    Mydata %>% 
       column_to_rownames(var = "Location") %>% 
       as.matrix() %>% pheatmap(cutree_cols = 6)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-18
      • 1970-01-01
      • 2023-03-03
      • 1970-01-01
      • 2013-11-22
      • 2022-11-28
      • 2013-07-29
      相关资源
      最近更新 更多