有人知道为什么ggcorrplot2会显示不同的重要星号而不是ggcorrplot吗?对我来说很迷惑。


https://github.com/caijun/ggcorrplot2
data(mtcars)
ct <- corr.test(mtcars)
corr <- ct$r
p.mat <- ct$p
ggcorrplot(corr, type= "lower", p.mat = p.mat,
insig = "label_sig", sig.lvl = c(0.05, 0.01, 0.001),show.diag=F)
ggcorrplot.mixed(corr, upper = "number", lower = "circle", p.mat = p.mat,
insig = "label_sig", sig.lvl = c(0.05, 0.01, 0.001))更新:好的,我想我终于弄明白了。这是因为corr.test()写了一个不对称的p.values矩阵。“对角线上方的条目将针对多个测试进行调整。”我用p.mat[lower.tri(p.mat)] <- t(p.mat)[lower.tri(p.mat)]修复了这个问题。此外,如果您想要使用调整后的p.Values,重要的是镜像p.Value矩阵对角线上方的三角形。如果您需要未调整的p.Values,则需要镜像较低的三角形(需要相应地更改代码)。
data(mtcars)
cor.matrix <- corr.test(mtcars,method = "spearman", adjust = "BH", alpha = 0.05, ci = F)
corr <- cor.matrix[["r"]]
p.mat <- cor.matrix[["p"]]
p.mat[lower.tri(p.mat)] <- t(p.mat)[lower.tri(p.mat)] #to get only the adjusted p.Values symmetrically over the plot
p.mat[lower.tri(p.mat, diag = T)] <- 1 #to set the lower triangle to 1
corrplot.mixed(corr, order= "original",mar=c(0,0,2,0), tl.col = 'black', p.mat = p.mat, insig = "label_sig", sig.level = c(.001, .01, .05), pch.cex=1.5, tl.cex = .8, number.font=2, number.cex=0.8)

发布于 2021-10-13 07:40:05
data(mtcars)
cor.matrix <- corr.test(mtcars,method = "spearman", adjust = "BH", alpha = 0.05, ci = F)
corr <- cor.matrix[["r"]]
p.mat <- cor.matrix[["p"]]
p.mat[lower.tri(p.mat)] <- t(p.mat)[lower.tri(p.mat)] #to get only the adjusted p.Values symmetrically over the plot
p.mat[lower.tri(p.mat, diag = T)] <- 1 #to set the lower triangle to 1 (this way the asterisks wont be displayed on this part of the graph)
corrplot.mixed(corr, order= "original",mar=c(0,0,2,0), tl.col = 'black', p.mat = p.mat, insig = "label_sig", sig.level = c(.001, .01, .05), pch.cex=1.5, tl.cex = .8, number.font=2, number.cex=0.8)https://stackoverflow.com/questions/69539460
复制相似问题