1.Genomic insights into the origin, domestication and diversification of Brassica juncea
注:R语言ggplot2画点和连线展示群体间Fst值和群体内Pi值
学习:1.文章的admixture图下面加各种类的实物图片
2.将组间不同多样性差异值可视化在同一张图片上
3.文章图片配色可以学习
论文中的 Figure2
a, Geographic distributions of 480 B. juncea accessions. The geographic map was drawn using R ggplot2. b, The maximum-likelihood phylogeny of 390 B. juncea accessions with over 60% genetic components to the group and model-based clustering with K from 2 to 6. The five other Brassicaceae species used to root the phylogenetic tree are shown as a single branch. Branch colors indicate different groups based on the population structure. Scale bars, 5 cm for G1 and G5; 5 mm for G2, G3, G4 and G6. c, PCA plots showing three divergent clades of 390 B. juncea accessions. d, Nucleotide diversity (π), population divergence (FST) and genetic distance (D) across the six groups. The value in each circle represents a measure of nucleotide diversity for each group; values in red on each line indicate pairwise population divergence between groups, while values in black on each line indicate pairwise genetic distances among groups. e, Group-specific LD decay plots.
图片的配色相对比较好看
Figure2d, 将不同的遗传多样性值可视化到同一张图中。
核苷酸多样性(π),种群分化(F圣)和遗传距离(D)横跨六组。每个圆圈中的值表示每个组核苷酸多样性的度量;每行上红色的值表示组之间的成对种群差异,而每行上的黑色值表示组之间的成对遗传距离。
好多有关群体遗传的论文里都有这个图,每一个点是群体内的多样性用pi来衡量,连线表示群体之间的分化程度 用fst来表示
模仿一下 论文中的 Figure2d
构造数据集
pi值数据格式
FST数据格式
读取数据集
首先是pi值
library(readxl)
dfpi<-read_excel("20210913.xlsx",
sheet = "Sheet1")
dfpi
添加坐标
dfpi$x<-2*sin(seq(0,300,60)*pi/180)
dfpi$y<-2*cos(seq(0,300,60)*pi/180)
作图
library(ggplot2)
cols<-c("#666116","#232c86","#e6eb49",
"#f1a3bc","#f48b19","#64bea0")
ggplot()+
geom_point(data=dfpi,
aes(x=x,y=y,color=Population),
size=40,
show.legend = F)+
xlim(-2.5,2.5)+ylim(-2.5,2.5)+
theme_void()+
geom_text(data=dfpi,aes(x=x,y=y,label=Population),
vjust=-0.5,
color="red")+
geom_text(data=dfpi,aes(x=x,y=y,
label=paste0(round(pi_value*1000,2),
'~x~',
'10**-3')),
vjust=1,
parse=T,
color="red")+
scale_color_manual(values=cols)
然后构造连线数据
library(tidyverse)
read_excel("20210913.xlsx",
sheet = "Sheet2") %>%
pivot_longer(!pop,
names_to = "pop2",
values_to = "Fst",
values_drop_na = T) -> dffst
merge(dffst,dfpi,by.x="pop",by.y = "Population") %>%
select(pop,pop2,Fst,x,y) %>%
rename("x1"="x",
"y1"="y") %>%
merge(dfpi,by.x = "pop2",by.y = "Population") %>%
select(pop,pop2,Fst,x,y,x1,y1) -> dffst1
将连线和点图结合到一起
ggplot()+
geom_segment(data=dffst1,
aes(x=x,y=y,xend=x1,yend=y1),
size=1,
lty="dashed")+
geom_point(data=dfpi,
aes(x=x,y=y,color=Population),
size=40,
show.legend = F)+
xlim(-2.5,2.5)+ylim(-2.5,2.5)+
theme_void()+
geom_text(data=dfpi,aes(x=x,y=y,label=Population),
vjust=-0.5,
color="red")+
geom_text(data=dfpi,aes(x=x,y=y,
label=paste0(round(pi_value*1000,2),
'~x~',
'10**-3')),
vjust=1,
parse=T,
color="red")+
scale_color_manual(values=cols)
最后将Fst的值添加到图上
这里如何将文本添加到合适的位置我还想不到比较好的办法了,只能先用代码添加 然后出图后再用AI软件来编辑了
library(ggrepel)
ggplot()+
geom_segment(data=dffst1,
aes(x=x,y=y,xend=x1,yend=y1),
size=1,
lty="dashed")+
geom_text_repel(data=dffst1,aes(x=(x+x1)/2,
y=(y+y1)/2,
label=Fst))+
geom_point(data=dfpi,
aes(x=x,y=y,color=Population),
size=40,
show.legend = F)+
xlim(-2.5,2.5)+ylim(-2.5,2.5)+
theme_void()+
geom_text(data=dfpi,aes(x=x,y=y,label=Population),
vjust=-0.5,
color="red")+
geom_text(data=dfpi,aes(x=x,y=y,
label=paste0(round(pi_value*1000,2),
'~x~',
'10**-3')),
vjust=1,
parse=T,
color="red")+
scale_color_manual(values=cols)