library(pophelper)
#匹配后缀名是Q的admixture分析结果
files <- paste0("QC.",2:10,".Q")
#读取样品ID信息
ID <- read.table("all.txt",header = F)
slist <- readQ(files = files)
for(i in 1:length(slist)){
row.names(slist[[i]]) <- ID[,1]
sppos = "left"
splab = paste0("K=", 2:10)
splabangle = 180
dpi = 600
outputfilename = paste0("admixture_barplot.png")
units = "cm"
exportpath = getwd()
}
#绘制图形
plotQ(slist, imgoutput = "join",imgtype = "pdf",width = 20,height = 1.2,
showindlab = T,useindlab = T,indlabhjust = 0.5,indlabangle = 90,
indlabsize = 0.6,sortind = "all",sharedindlab = F,
panelspacer = 0.02, indlabspacer = 0,indlabcol = "black",
showtitle = T,titlelab = "Population Structure",titlecol = "black",
titlehjust = 0.5,showsp = T,exportpath=getwd())
按群体划分
plotQ(slist, imgoutput = "join",imgtype = "pdf",grplab=ID[2],width = 20,height = 1.2,
showindlab = F,useindlab = F,indlabhjust = 0.5,indlabangle = 90,
indlabsize = 0.6,sortind = "all",sharedindlab = F,showdiv = F,
panelspacer = 0.02, indlabspacer = 0,indlabcol = "black",
showtitle = T,titlelab = "Population Structure",titlecol = "black",
titlehjust = 0.5,showsp = F,exportpath=getwd())