【问题标题】:Dendrogram with Corrplot (R)带有 Corrplot (R) 的树状图
【发布时间】:2017-03-06 19:26:46
【问题描述】:

有没有人有办法用树状图装饰 R corrplot 相关图?

【问题讨论】:

  • 我很难过没有看到任何答案
  • ...2 年后,仍然悲伤:(
  • @Sosi - 如果它让你振作起来,我已经添加了一个答案。

标签: r dendrogram dendextend r-corrplot heatmaply


【解决方案1】:

我所知道的最接近的解决方案是在相关矩阵上使用热图,例如,您也可以使用 gplots::heatmap.2。

这里是使用 heatmaply R 包的方法,它还提供了一个交互式界面,您可以在其中放大并在将鼠标悬停在单元格上时获取工具提示:

# for the first time:
# install.packages("heatmaply")

library(heatmaply)
my_cor <- cor(mtcars)
heatmaply_cor(my_cor)

这是它的外观:

您可以在this vignette 中了解有关热图的更多信息。

【讨论】:

    【解决方案2】:

    heatmaply 实际上自 2017 年 12 月左右就开始使用此功能!请参阅下面的示例,取自即将发布的 v1.0 小插图:

    library("heatmaply")
    r <- cor(mtcars)
    ## We use rcorr to calculate a matrix of p-values from correlation tests
    library("Hmisc")
    mtcars.rcorr <- rcorr(as.matrix(mtcars))
    p <- mtcars.rcorr$P
    
    heatmaply_cor(
      r,
      node_type = "scatter",
      point_size_mat = -log10(p), 
      point_size_name = "-log10(p-value)",
      label_names = c("x", "y", "Correlation")
    )
    

    【讨论】:

      猜你喜欢
      • 2012-12-16
      • 2019-04-14
      • 1970-01-01
      • 2016-10-26
      • 1970-01-01
      • 2015-11-05
      • 2021-10-04
      • 2014-07-03
      相关资源
      最近更新 更多