前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >跟着Nature Communications学作图:R语言ggplot2散点图/折线图/误差线展示基因表达量

跟着Nature Communications学作图:R语言ggplot2散点图/折线图/误差线展示基因表达量

作者头像
用户7010445
发布2023-11-21 17:16:49
3680
发布2023-11-21 17:16:49
举报

论文

Genomic insights into local adaptation and future climate-induced vulnerability of a keystone forest tree in East Asia

https://www.nature.com/articles/s41467-022-34206-8

论文的代码链接

https://github.com/jingwanglab/Populus_genomic_prediction_climate_vulnerability

今天的推文我们尝试复现一下论文中的figure3e和figure3i

image.png

image.png

figure3e的示例数据

image.png

读取数据并作图

代码语言:javascript
复制
p1<-ggplot(data = dat.fig3e,aes(x=hour,y=relative_expression))+
  geom_point(aes(color=base),size=5)+
  geom_line(aes(color=base),
            show.legend = FALSE)+
  geom_errorbar(aes(ymin=relative_expression-STD,
                    ymax=relative_expression+STD,color=base),
                width=0.4)+
  theme_bw(base_size = 20)+
  theme(panel.grid = element_blank(),
        legend.position = c(0.2,0.8))+
  scale_color_manual(values = c("ALT"="#a2c0e4",
                                "REF"="#2d52a2"),
                     labels=c("CC","TC"),
                     name=NULL)+
  labs(x="Time since submergence stress",
       y="Expression")

p1

image.png

figure3i 数据截图

image.png

作图代码基本和fig3e的一致

但是这里的时间跨度从0,1,2,3突然跨到24,这样出图不是很好看,我们把24改成4,然后在坐标轴标签上再改为24

代码语言:javascript
复制
p2<-ggplot(data = dat.fig3i,aes(x=hour,y=relative_expression))+
  geom_point(aes(color=base),size=5)+
  geom_line(aes(color=base),
            show.legend = FALSE)+
  geom_errorbar(aes(ymin=relative_expression-STD,
                    ymax=relative_expression+STD,color=base),
                width=0.2)+
  theme_bw(base_size = 20)+
  theme(panel.grid = element_blank(),
        legend.position = c(0.2,0.8))+
  scale_color_manual(values = c("ALT"="#e1c4c4",
                                "REF"="#b0383f"),
                     labels=c("AA","GG"),
                     name=NULL)+
  labs(x="Time since heat stress",
       y="Expression")+
  scale_x_continuous(breaks = 0:4,
                     labels = paste0(c(0,1,2,3,24),"h"))
p2

image.png

最后是将两个图组合到一起

代码语言:javascript
复制
library(patchwork)

p1+p2

image.png

本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2023-11-21,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 小明的数据分析笔记本 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 论文
  • figure3e的示例数据
  • 读取数据并作图
  • figure3i 数据截图
  • 最后是将两个图组合到一起
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档