带有 Corrplot (R) 的树状图

aba*_*ter 5 r dendrogram dendextend r-corrplot heatmaply

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

ala*_*han 7

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")
)
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述


Tal*_*ili 5

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

以下是如何使用 heatmaply R 包来完成此操作,该包还提供了一个交互式界面,您可以在将鼠标悬停在单元格上时放大并获取工具提示:

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

library(heatmaply)
my_cor <- cor(mtcars)
heatmaply_cor(my_cor)
Run Code Online (Sandbox Code Playgroud)

它看起来是这样的:

在此输入图像描述

您可以在此小插图中了解有关 heatmaply 的更多信息。