跟着NaturePlants学作图:R语言ggplot2分组折线图完整示例
2023-02-19 12:27:45 时间
论文
The slow-evolving Acorus tatarinowii genome sheds light on ancestral monocot evolution
https://www.nature.com/articles/s41477-022-01187-x#Sec21
本地pdf s41477-022-01187-x.pdf
论文中的数据基本都公开了,我们可以利用论文中的数据模仿论文中的图,今天的推文模仿一下论文中Figure1c 和 figure1f
image.png
figure1c
部分示例数据截图
image.png
读取数据并作图
library(readxl)
datf3c<-read_excel("data/20220807/41477_2022_1187_MOESM4_ESM.xlsx",
sheet = "Fig.1C",
skip = 1)
head(datf3c)
library(tidyverse)
datf3c %>%
select(-'4dTV_1') %>%
pivot_longer(-'4dTV_2') %>%
mutate(name = fct_relevel(name,c("Acorus-Acorus",
"Acorus-Zostera",
"Acorus-Oryza",
"Acorus-Asparagus"))) -> new.datf3c
#install.packages("latex2exp")
library(latex2exp)
ggplot(data=new.datf3c,
aes(x=`4dTV_2`,y=value,color=name))+
geom_line(size=1)+
scale_color_manual(values = c("#ff0000","#7030a0",
"#00b050","#5b9bd5"),
name=NULL)+
theme_classic()+
theme(legend.position = c(0.8,0.8),
legend.text = element_text(face = "italic"))+
scale_x_continuous(expand = expansion(mult = c(0,0)),
limits = c(0,2),
breaks = seq(0,2,0.2))+
scale_y_continuous(expand = expansion(mult = c(0,0)),
limits = c(0,300))+
labs(x="4dTV",y="No.of gene pairs") -> p1
p1
image.png
figure1f
部分示例数据截图
image.png
读取数据并作图
datf3f<-read_excel("data/20220807/41477_2022_1187_MOESM4_ESM.xlsx",
sheet = "Fig.1F",
skip = 1)
head(datf3f)
datf3f %>%
pivot_longer(-"Distance to Gene Start") %>%
ggplot(aes(x=`Distance to Gene Start`,
y=value,
color=name))+
geom_line()+
scale_color_manual(values = c("#ff0000","#00b0f0"))+
theme_classic()+
theme(legend.position = c(0.9,0.2),
plot.margin = unit(c(0.1,0.5,0.1,0.1),'cm'),
legend.title = element_blank())+
scale_x_continuous(expand = expansion(mult = c(0,0)),
labels = c("-2 kb","Start","",
"Stop","+2 kb"))+
scale_y_continuous(expand = expansion(mult = c(0,0)),
limits = c(0,0.4))+
labs(x=NULL,y="Ratio of TEs") -> p2
p2
image.png
最后是拼图
p1+p2+
plot_annotation(tag_levels = list(c("c","f")))
image.png
示例数据可以在论文中去下载,代码直接在推文中复制
相关文章
- Jgit的使用笔记
- 利用Github Action实现Tornadofx/JavaFx打包
- 叹息!GitHub Trending 即将成为历史!
- 微软软了?开源社区讨论炸锅,GitHub CEO 亲自来答
- GitHub Trending 列表频现重复项,前后端都没去重?
- Photoshop Elements 2021版本软件安装教程(mac+windows全版本都有)
- (ps全版本)Photoshop 2020的安装与破解教程(mac+windows全版本都有)
- (ps全版本)Photoshop cc2018的安装与破解教程(mac+windows全版本,包括2023
- 环境搭建:Oracle GoldenGate 大数据迁移到 Redshift/Flat file/Flume/Kafka测试流程
- 每个开发人员都要掌握的:最小 Linux 基础课
- 来撸羊毛了!Windows 环境下 Hexo 博客搭建,并部署到 GitHub Pages
- 超实用!手把手入门 MongoDB:这些坑点请一定远离
- 【GitHub日报】22-10-09 zustand、neovim、webtorrent、express 等4款App今日上新
- 【GitHub日报】22-10-10 brew、minio、vite、seaweedfs、dbeaver 等8款App今日上新
- 【GitHub日报】22-10-11 cobra、grafana、vue、ToolJet、redwood 等13款App今日上新
- Photoshop 2018 下载及安装教程(mac+windows全版本都有,包括最新的2023)
- Photoshop 2017 下载及安装教程(mac+windows全版本都有,包括最新的2023)
- Photoshop 2020 下载及安装教程(mac+windows全版本都有,包括最新的2023)
- Photoshop 2023 资源免费下载(mac+windows全版本都有,包括最新的2023)
- 最新版本Photoshop CC2018软件安装教程(mac+windows全版本都有,包括2023