跟着Nature学作图:R语言ggplot2频率分布直方图和散点图添加误差线
2023-02-19 12:27:48 时间
论文
A saturated map of common genetic variants associated with human height
https://www.nature.com/articles/s41586-022-05275-y
s41586-022-05275-y.pdf
代码没有公开,但是作图数据基本都公开了,争取把每个图都重复一遍
今天的推文重复论文中的extended Figure4 频率分布直方图和散点图添加误差线
首先是图a频率分布直方图
library(readxl)
dat<-read_excel("extendFig4.xlsx",
sheet = "Panel a")
dat
colnames(dat)<-"Var1"
library(ggplot2)
library(ggh4x)
ggplot(data=dat,aes(x=Var1))+
geom_histogram(bins = 25,
color="white",
fill="#aadbe9")+
scale_x_continuous(limits = c(0.5,3),
breaks = seq(0.5,3,by=0.5))+
scale_y_continuous(limits = c(0,300),
breaks = seq(0,300,50))+
geom_vline(xintercept = 0.75,lty="dashed",color="#aadbe9")+
geom_vline(xintercept = 2.25,lty="dashed",color="#aadbe9")+
geom_segment(aes(x=2.5,xend=2.5,y=50,yend=0),
arrow = arrow(),
color="red")+
annotate(geom = "text",x=2.5,y=50,label="Observed",
vjust=-1)+
geom_segment(aes(x=0.75,xend=2.25,y=250,yend=250),
arrow = arrow(ends = "both",
angle=20,
length = unit(3,'mm')),
color="#aadbe9")+
annotate(geom = "text",x=1.5,y=250,
label="Null distribution (1,000 draws)",
vjust=-1)+
theme_classic()+
guides(x=guide_axis_truncated(trunc_lower = 0.5,
trunc_upper = 3),
y=guide_axis_truncated(trunc_lower = 0,
trunc_upper = 300))+
labs(y="Frequency",
x="Enrichment folde of OMIM genes\nnear GWS SNPs with a density > 1")
第二个图b
datb<-read_excel("extendFig4.xlsx",
sheet = "Panel b")
datb
ggplot(data=datb,aes(x=`Minimum Signal Density`,
y=`Enrichment statistic`))+
geom_point()+
geom_errorbar(aes(ymin=`Enrichment statistic`-`Standard Error of Enrichment Statistic`,
ymax=`Enrichment statistic`+`Standard Error of Enrichment Statistic`),
width=0.4)+
scale_x_continuous(limits = c(0.5,10.5),
breaks = 1:10)+
scale_y_continuous(limits = c(0,9),
breaks = 0:8)+
theme_classic()+
guides(x=guide_axis_truncated(trunc_lower = 1,
trunc_upper = 10),
y=guide_axis_truncated(trunc_lower = 0,
trunc_upper = 8))+
labs(x="Minimum Signal Density",
y="Enrichment-fold of OMIM genes\nnear GWS SNPs")
最后是拼图
library(patchwork)
p1+p2
相关文章
- 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