R相关性分析:尝试使用ggcorrplot2来重现带有变量子集和不同子集的ggcorrplot

问题描述

我试图用变量的子集与不同的子集进行相关图。

使用mtcars数据,我使用ggcorrplot执行以下操作:

data(mtcars)
corrtest <- psych::corr.test(mtcars[,1:7],adjust="none")
all_matrix <- corrtest$r
all_pmat <- corrtest$p

pheno_markers <- names(mtcars)[1:4]
serol_markers <- names(mtcars)[5:7]
sub_matrix <- all_matrix[pheno_markers,serol_markers]
sub_pmat <- all_pmat[pheno_markers,serol_markers]

Grdevices::pdf(file="heat_duo.pdf",height=4,width=4)
print(
  ggcorrplot::ggcorrplot(sub_matrix,p.mat=sub_pmat,method="circle")
)
Grdevices::dev.off()

这将产生以下图表,这是很好的:

test1

现在,我想用ggcorrplot2重现相同的图,因为它允许我将比较的有效值覆盖为***。我通常可以毫无问题地使用此程序包,但这种情况我似乎并没有得到解决。看来只能用colnames == rownames ...

处理对称矩阵

我尝试了以下操作:

Grdevices::pdf(file="heat_duo2.pdf",width=4)
print(
  ggcorrplot2::ggcorrplot(sub_matrix,method="circle",insig = "label_sig",sig.lvl = c(0.05,0.01,0.001))
)
Grdevices::dev.off()

但是结果显然是错误的:

test2

ggcorrplot2中如何处理这样的案件有任何想法(ggcorrplot如此简单)?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)