Closed brenoliisboa closed 4 weeks ago
Can you show me your data and code?
I'm getting the same issue. If order = "original"
, then the significances and correlations line up fine, but if order = "hclust"
, then the correlations and significances no longer align. The significances remain in the original position. I shared correlation and p value matrices with my colleague, and they did not get the issue, so it might be related to version.
Here's a workaround that performs the clustering externally
# Load necessary libraries
library(corrplot)
library(Hmisc)
# Prepare correlation matrix
MS2 <- cor(data2, use = "pairwise.complete.obs", method = c("spearman"))
# Prepare matrix of statistical significance
res <- cor.mtest(data2, conf.level = 0.95, alternative = c("two.sided"), method = c("spearman"), exact = F)
# Perform hierarchical clustering on the correlation matrix
hc <- hclust(as.dist(1 - MS2), method = 'complete')
# Extract the order of rows and columns
order <- hc$order
# Reorder the correlation matrix and p-value matrix
MS2_ordered <- MS2[order, order]
res_p_ordered <- res$p[order, order]
# Plot the correlation matrix with the reordered p-value matrix
corrplot(MS2_ordered, method = "square", type = "full", diag = T, tl.cex = 0.75, tl.col = "black", na.label = "NA",
p.mat = res_p_ordered, insig = "label_sig", sig.level = c(0.001, 0.01, 0.05), pch.cex = 0.9, pch.col = "black",
order = "original", hclust.method = 'complete', tl.srt = 45, title = title, mar = c(0, 0, 1, 0), cl.cex = 1)
Many Thanks. I fixed it and will submit new version v0.95 to CRAN soon.
As written in the title, v.0.94 is having this issue (top image). Version 0.92 plots correctly p value under 0.05 (bottom image). [..] method = c("color"), tl.col = "black", order = "hclust", p.mat = p_value_matrix, sig.level = 0.05, insig = "label_sig" [..]