R:Corrplot() 热图操作?

海莉

我有 2 个数据集,一个是 264 列,另一个是 19 列。

在使用 Pearson 相关性运行后,cor()我尝试使用绘制热图中的输出corrplot(),但它不可读。

如何编辑我的代码来解决这个问题

我的代码如下:

    library("corrplot")
    D1=VGT5
    D2=BFT5
    CorTest=cor(D1, y=D2, use = "everything", method = "pearson")
    CorGraph=corrplot(CorTest, method = "circle", col = colorRampPalette(c("blue","white","red"))(200), title = "Pearson's Correlation of High-Fat Sugar at 12 weeks", tl.cex = .75, tl.col = "Black",diag = TRUE, cl.ratio = 2.25)
马可·桑德里

您的相关矩阵有 19 行和 264 列。这个矩阵的图形表示相当有问题。这里有两种可能的解决方案。
(1) 绘制整个矩阵

library(ggcorrplot)
png(file="CorrPlot1.png", height=10000, width=3000, res=600)
ggcorrplot(CorTest, lab_size=.1)+
theme(axis.text.y = element_text(size=6),
      axis.text.x = element_text(size=6, angle=90))
dev.off()

(2) 将矩阵切成两块

library(gridExtra)
nc <- ncol(CorTest)
png(file="CorrPlot2.png", height=7000, width=7000, res=600)
p1 <- ggcorrplot(CorTest[,1:(nc/2)], lab_size=.1)+
theme(axis.text.y = element_text(size=6),
      axis.text.x = element_text(size=6, angle=90))
p2 <- ggcorrplot(CorTest[,(nc/2+1):nc], lab_size=.1)+
theme(axis.text.y = element_text(size=6),
      axis.text.x = element_text(size=6, angle=90))
grid.arrange(p1, p2, ncol=2)
dev.off()

在此处输入图片说明

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章