微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决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 举报,一经查实,本站将立刻删除。