论文
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
完整代码
代码语言:javascript复制
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 <- c("ZHY-03-1","ZHY-03-10",
"ZHY-03-12","ZHY-03-17",
"ZHY-03-2","ZHY-03-3",
"ZHY-03-4","ZHY-03-6",
"ZHY-03-7","ZHY-03-9",
"ZHY-09-1","ZHY-09-11","ZHY-09-15",
"ZHY-09-16","ZHY-09-17","ZHY-09-18",
"ZHY-09-2","ZHY-09-6","ZHY-09-8","ZHY-10-1",
"ZHY-10-11","ZHY-10-13","ZHY-10-14",
"ZHY-10-15","ZHY-10-16","ZHY-10-3",
"ZHY-10-4","ZHY-10-6","ZHY-10-9",
"LiuJQ-MZL-2013-249-1","LiuJQ-MZL-2013-249-10",
"LiuJQ-MZL-2013-249-3","LiuJQ-MZL-2013-249-4",
"LiuJQ-MZL-2013-249-5","LiuJQ-MZL-2013-249-6",
"LiuJQ-MZL-2013-249-7","LiuJQ-MZL-2013-249-8",
"LiuJQ-MZL-2013-249-9","LiuJQ-MZL-2013-262-1",
"LiuJQ-MZL-2013-262-10","LiuJQ-MZL-2013-262-11",
"LiuJQ-MZL-2013-262-3","LiuJQ-MZL-2013-262-5",
"LiuJQ-MZL-2013-262-6","LiuJQ-MZL-2013-262-7",
"LiuJQ-MZL-2013-262-8","LiuJQ-MZL-2013-262-9",
"LiuJQ-MZL-2013-283-1","LiuJQ-MZL-2013-283-10",
"LiuJQ-MZL-2013-283-12","LiuJQ-MZL-2013-283-15","LiuJQ-MZL-2013-283-3","LiuJQ-MZL-2013-283-4","LiuJQ-MZL-2013-283-5","LiuJQ-MZL-2013-283-6","LiuJQ-MZL-2013-283-8","LiuJQ-MZL-2013-283-9","LiuJQ-MZL-2013-297-1","LiuJQ-MZL-2013-297-10","LiuJQ-MZL-2013-297-2","LiuJQ-MZL-2013-297-3","LiuJQ-MZL-2013-297-4","LiuJQ-MZL-2013-297-5","LiuJQ-MZL-2013-297-6","LiuJQ-MZL-2013-297-7","LiuJQ-MZL-2013-297-8","LiuJQ-MZL-2013-297-9","ZHY-14-1","ZHY-14-12","ZHY-14-13","ZHY-14-2","ZHY-14-3","ZHY-14-4","ZHY-14-5","ZHY-14-6","ZHY-14-7","ZHY-14-9","ZHY-16-1","ZHY-16-12","ZHY-16-13","ZHY-16-14","ZHY-16-15","ZHY-16-2","ZHY-16-3","ZHY-16-4","ZHY-16-6","ZHY-16-8","ZHY-17-1","ZHY-17-12","ZHY-17-13","ZHY-17-14","ZHY-17-15","ZHY-17-5","ZHY-17-6","ZHY-17-8","ZHY-17-9","ZHY-18-10","ZHY-18-13","ZHY-18-2","ZHY-18-3","ZHY-18-4","ZHY-18-5","ZHY-18-7","ZHY-18-8","ZHY-18-9","ZHY-19-10","ZHY-19-11","ZHY-19-12","ZHY-19-13","ZHY-19-14","ZHY-19-15","ZHY-19-5","ZHY-19-6","ZHY-19-8","ZHY-19-9","ZHY-21-1","ZHY-21-11","ZHY-21-12","ZHY-21-14","ZHY-21-2","ZHY-21-3","ZHY-21-4","ZHY-21-5","ZHY-21-7","ZHY-21-8","ZHY-22-1","ZHY-22-10","ZHY-22-11","ZHY-22-12","ZHY-22-3","ZHY-22-6","ZHY-22-7","ZHY-22-8","ZHY-22-9","LiuJQ-MZL-2013-323-0","LiuJQ-MZL-2013-323-10","LiuJQ-MZL-2013-323-11","LiuJQ-MZL-2013-323-12","LiuJQ-MZL-2013-323-13","LiuJQ-MZL-2013-323-4","LiuJQ-MZL-2013-323-5","LiuJQ-MZL-2013-323-6","LiuJQ-MZL-2013-323-7","LiuJQ-MZL-2013-323-9","ZHY-25-10","ZHY-25-11","ZHY-25-12","ZHY-25-13","ZHY-25-14","ZHY-25-3","ZHY-25-4","ZHY-25-7","ZHY-25-8","ZHY-25-9","ZHY-26-1","ZHY-26-10","ZHY-26-11","ZHY-26-12","ZHY-26-13","ZHY-26-15","ZHY-26-2","ZHY-26-3","ZHY-26-4","ZHY-26-8","ZHY-31-1","ZHY-31-10","ZHY-31-11","ZHY-31-12","ZHY-31-2","ZHY-31-3","ZHY-31-4","ZHY-31-7","ZHY-31-8","ZHY-33-1","ZHY-33-10","ZHY-33-11","ZHY-33-12","ZHY-33-3","ZHY-33-6","ZHY-33-7","ZHY-33-8","ZHY-33-9","ZHY-34-1","ZHY-34-11","ZHY-34-12","ZHY-34-13","ZHY-34-14","ZHY-34-2","ZHY-34-4","ZHY-34-5","ZHY-34-7","ZHY-34-9","ZHY-35-1","ZHY-35-10","ZHY-35-2","ZHY-35-3","ZHY-35-4","ZHY-35-5","ZHY-35-6","ZHY-35-7","ZHY-35-8","ZHY-35-9","ZHY-37-10","ZHY-37-11","ZHY-37-12","ZHY-37-15","ZHY-37-2","ZHY-37-3","ZHY-37-4","ZHY-37-6","ZHY-37-8","ZHY-37-9","ZHY-41-1","ZHY-41-10","ZHY-41-11","ZHY-41-12","ZHY-41-13","ZHY-41-2","ZHY-41-4","ZHY-41-6","ZHY-41-7","ZHY-41-9","ZHY-44-1","ZHY-44-10","ZHY-44-2","ZHY-44-3","ZHY-44-4","ZHY-44-5","ZHY-44-6","ZHY-44-9")
length(myorder)
library(tidyverse)
p1<-Q2 %>%
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("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<-Q3 %>%
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<-Q2 %>%
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))