I've created a corrplot using ggcorrplot with the following code:
library(ggcorrplot)
corCN <- subset(csfBL, BL_Diaggroups==1,
select=c("log_ab38", "log_ab40", "log_ab42", "ABratio", "log_YKL", "logNgcomplete", "log_NFL"))
colnames(corCN) <- c("Aß 1-38","Aß 1-40", "Aß 1-42", "Aß 42/40", "YKL-40", "Ng", "NFL")
corrCN <- cor(corCN, method=c("spearman"), use="complete.obs")
p.matCN <- cor_pmat(corCN, method=c("spearman"), use="complete.obs")
CNcorrplot <- ggcorrplot(corrCN, type="lower", lab=TRUE, ggtheme = ggplot2::theme_classic,
p.mat=p.matCN, insig ="blank")
CNcorrplot2 <- CNcorrplot + ggtitle("CN") + theme(plot.title = element_text(hjust = 0.5))
And the plot looks like this.

The only thing I want to change is that the insignificant values have "NS" in them or are totally blank (so no 0 displayed). Actually I would need some kind of code saying:
if insig=TRUE, lab=FALSE
I created a modified version of ggcorrplot called myggcorrplot with the new lab.notsig option (the label for not significant correlations).
Download the file here and save it in your working directory as myggcorrplot.r.
Then, run the following code:
library(ggcorrplot)
library(mvtnorm)
# A toy dataset
set.seed(1)
n <- 100
p <- 7
A <- matrix(runif(p^2)*2-1, ncol=p)
Sigma <- cov2cor(t(A) %*% A)
corCN <- data.frame(rmvnorm(n, mean=rep(0,p), sigma=Sigma))
colnames(corCN) <- c("Aß 1-38","Aß 1-40", "Aß 1-42", "Aß 42/40", "YKL-40", "Ng", "NFL")
corrCN <- cor(corCN, method=c("spearman"), use="complete.obs")
p.matCN <- cor_pmat(corCN, method=c("spearman"), use="complete.obs")
# Load the myggcorrplot function
source("myggcorrplot.r")
# Set in the lab.notsig option the label for not significant correlations
CNcorrplot <- myggcorrplot(corrCN, type="lower", lab=TRUE,
ggtheme = ggplot2::theme_classic,
p.mat=p.matCN, insig ="blank", lab.notsig="NS")
CNcorrplot2 <- CNcorrplot + ggtitle("CN") +
theme(plot.title = element_text(hjust = 0.5))
CNcorrplot2

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With