I wanted to ask is it possible to customize the p value representation in ggcorrplot such that instead of having insignificant correlations marked with a cross, the significant p values are marked with an asterisk instead? Which would hopefully look something like so:
Update: So I decided to look at the source code and tinkered a bit with it to produce the format I wanted to achieve. If you copy the whole code for the ggcorrplot()
function, then on line 215 the original code is:
p.mat <- subset(p.mat, p.mat$value > sig.level)
Substitute this with:
p.mat <- subset(p.mat, p.mat$value <= sig.level & p.mat$value != 0)
The != 0 part is assuming you would choose the full correlation plot and is there to prevent the diagonal in the middle from having the asterisk and I believe no p value should practically be 0 so it should be fine.
Then on line 295 I added the position argument inside the function:
# matrix cell glyphs
if (!is.null(p.mat) & insig == "pch") {
p <- p + ggplot2::geom_point(
data = p.mat,
mapping = ggplot2::aes_string(x = "Var1", y = "Var2"),
shape = pch,
size = pch.cex,
color = pch.col,
position = position_nudge(x=0.35,y=0.16)
)
}
The original would look something like:
While the modified one would be something like: Of course, depending on visual preference, the nudge can be customized through the x and y argument. Then in the function, just choose pch = 8 (this is the asterisk) and pch.cex = 1 (size of asterisk) and that should basically achieve the objective of showing asterisk for significant correlations instead of showing crosses for insignificant correlations. Hopefully it can be of use in the future!