Does anyone have a method to adorn an R corrplot
correlation plot with a dendrogram?
Asked
Active
Viewed 5,206 times
7

Tal Galili
- 24,605
- 44
- 129
- 187

abalter
- 9,663
- 17
- 90
- 145
-
I was so sad to not see any answers to this – Sos Mar 21 '17 at 13:15
-
...2 years after, still sad :( – Sos Mar 28 '19 at 18:16
-
2@Sosi - if it cheers you up, I've added an answer. – alan ocallaghan Nov 08 '19 at 13:10
2 Answers
7
heatmaply actually has this functionality baked in since about December 2017! See the example below taken from the upcoming v1.0 vignette:
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")
)

alan ocallaghan
- 3,116
- 17
- 37
5
The closest solution I know of is to use a heatmap on a correlation matrix, for example you could also use gplots::heatmap.2.
Here is how to do it using the heatmaply R package, which also offers an interactive interface where you can zoom-in and get a tooltip when hovering over the cells:
# for the first time:
# install.packages("heatmaply")
library(heatmaply)
my_cor <- cor(mtcars)
heatmaply_cor(my_cor)
Here is how it looks:
You can learn more about heatmaply in this vignette.

Tal Galili
- 24,605
- 44
- 129
- 187