https://grunwaldlab.github.io/Population_Genetics_in_R/Data_Preparation.html
在这个链接里有介绍
如果有了这个格式的数据可以用R语言的poppr包做主成分分分析。
公众号有读者留言问到如何将vcf格式的数据转换成 genalex格式
我查了一下找到一个链接
https://rdrr.io/github/green-striped-gecko/dartR/man/gl2genalex.html
如何获取 genlight object
找到了一个参考链接
https://cran.r-project.org/web/packages/vcfR/vignettes/converting_data.html
这里需要用到vcfR这个R包
install.packages("vcfR")
BiocManager::install("SNPRelate")
install.packages("dartR")
install.packages("poppr")
library(vcfR)
library(dartR)
library(poppr)
vcf<-read.vcfR("D:/Jupyter/practice/rMVP_GWAS/smoove.filtered.impute.vcf.gz")
x <- vcfR2genlight(vcf)
x$ind.names ## 按照这个顺序准备一个群体分组
pop(x)<-sample(c("pop1","pop2","pop3"),102,replace = TRUE) ## 我这里的群体分组是随便给的
gl2genalex(x,outfile = "smoove.csv",outpath = "D:/Jupyter/practice/rMVP_GWAS")