跟着Nature Communications学作图:R语言ggplot2做堆积柱形图展示群体基因组学的结果

您所在的位置:网站首页 r语言data 跟着Nature Communications学作图:R语言ggplot2做堆积柱形图展示群体基因组学的结果

跟着Nature Communications学作图:R语言ggplot2做堆积柱形图展示群体基因组学的结果

2022-12-23 10:19| 来源: 网络整理| 查看: 265

论文

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#Sec23

完整的数据分析代码 涉及到群体基因组学

作图数据 ``

https://github.com/jingwanglab/Populus_genomic_prediction_climate_vulnerability

作者的github主页还有很多其他内容 https://github.com/jingwanglab

今天的图推文重复一下论文中的figure2a

论文中提供的代码是

https://github.com/jingwanglab/Populus_genomic_prediction_climate_vulnerability/blob/main/3-Population_genetics/1structure.sh

完整代码 Q2=read.table("pk230_ldpruned.2.Q.txt",header=F) dim(Q2) Q3=read.table("pk230_ldpruned.3.Q.txt",header=F) dim(Q3) myorder % pivot_longer(-V1) %>% mutate(name=factor(name,levels = c("V3","V2"))) %>% ggplot(aes(x=V1,y=value,fill=name))+ geom_bar(stat='identity',width=1,show.legend = FALSE)+ scale_fill_manual(values = c("V3"="#e9e9e9", "V2"="#e04d72"))+ theme_bw()+ theme(panel.grid = element_blank(), axis.text.x = element_blank(), axis.ticks.x = element_blank())+ scale_y_continuous(minor_breaks=seq(0,1,0.1), expand = c(0,0), breaks=seq(0,1,0.25))+ scale_x_discrete(breaks=NULL)+ labs(x=NULL,y="k=2") p2% mutate(V1=factor(V1, levels = myorder)) %>% pivot_longer(-V1) %>% #mutate(name=factor(name,levels = c("V3","V2"))) %>% ggplot(aes(x=V1,y=value,fill=name))+ geom_bar(stat='identity',width=1,show.legend = FALSE)+ scale_fill_manual(values = c("V2"="#e9e9e9", "V3"="#3280c3", "V4"="#e04d72"))+ theme_bw()+ theme(panel.grid = element_blank(), axis.text.x = element_blank(), axis.ticks.x = element_blank())+ scale_y_continuous(minor_breaks=seq(0,1,0.1), expand = c(0,0), breaks=seq(0,1,0.25))+ scale_x_discrete(breaks=NULL)+ labs(x=NULL,y="k=3") p3% mutate(V1=factor(V1, levels = myorder)) %>% ggplot()+ geom_ribbon(aes(x=V1,ymin=0.1,ymax=1),fill="#e04d72")+ #geom_ribbon(aes(x=164:230,ymin=0.1,ymax=1),fill="#3280c3")+ theme_bw()+ theme(panel.grid = element_blank(), axis.text = element_blank(), axis.ticks = element_blank(), panel.border = element_blank(), axis.title = element_blank())+ scale_y_continuous(minor_breaks=seq(0,1,0.1), expand = c(0,0), breaks=seq(0,1,0.25))+ #scale_x_continuous(breaks=NULL)+ annotate(geom="text",x=80,y=0,label="South",vjust=-0.5)+ annotate(geom="text",x=190,y=0,label="North",vjust=-0.5)+ annotate(geom = "ribbon",x=1:165,ymin=0.5,ymax=1,fill="#e04d72")+ annotate(geom = "ribbon",x=166:230,ymin=0.5,ymax=1,fill="#3280c3") library(patchwork) p1/p2/p3+ plot_layout(heights = c(4,4,1)) 最终结果 image.png

示例数据和代码可以给公众号推文点赞,点击在看,最后留言获取

欢迎大家关注我的公众号

小明的数据分析笔记本

小明的数据分析笔记本 公众号 主要分享:1、R语言和python做数据分析和数据可视化的简单小例子;2、园艺植物相关转录组学、基因组学、群体遗传学文献阅读笔记;3、生物信息学入门学习资料及自己的学习笔记!



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3