GGally

【R作图】R语言GGally画图展示多变量之间两两的相关性

今天给大家介绍一款多变量之间两两的相关性的R包:GGally

组学分析用途: 转录组、蛋白质组还有代谢组等的质量控制,比较样品之间的相关性。

先来个简单的:

# install.packages("GGally")
# install.packages("ggsci") #科研作图的配色
library(GGally)
data(flea)
ggpairs(flea, columns = 2:4)

在这里插入图片描述

根据分类进行比较,设置了 color = “Species”:

library(GGally)
library(ggsci)
ggscatmat(data = iris, columns = 1:4, 
		 color = "Species",
		 alpha = 0.8)+
	  theme_bw(base_size = 14)+
	  ggsci::scale_color_aaas()+
	  theme(plot.title = element_text(hjust = 0.5))

在这里插入图片描述

可以自由填充每一个格子里面的东西。这个就考验自己的审美了。

## 先创建一格实例
custom_car <- ggpairs(mtcars[, c("mpg", "wt", "cyl")], upper = "blank", title = "Custom Example")
# 想在其中一格填充一个ggplot图像,先画出来
plot <- ggplot2::ggplot(mtcars, ggplot2::aes(x = wt, y = mpg, label = rownames(mtcars)))
plot <- plot +
  ggplot2::geom_text(ggplot2::aes(colour = factor(cyl)), size = 3) +
  ggplot2::scale_colour_discrete(l = 40)
# 然后在第一行的第二个格子中填充这个图像
custom\_car[1, 2] <- plot
# 再填一个
personal_plot <- ggally_text(
   "ggpairs allows you to put in your own plot. Like that one.  <---"
)
custom_car[1, 3] <- personal_plot
custom_car

在这里插入图片描述
祝科研顺利,工作顺利。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值