Population genomic analyses with sambaR - barrettlab/2021-Genomics-bootcamp GitHub Wiki
Population genomic analyses with sambaR
de Jong MJ, de Jong FJ, Hoelzel AR, Janke A. 2021. SambaR: an R package for fast, easy and reproducible population‐genetic analyses of biallelic SNP datasets, Molecular Ecology Resources.
The following two commands are run in the unix terminal
## Convert vcf to bed/map
PGDSpider2-cli -inputfile imputed.vcf -outputfile out.ped -spid VCF2PED.spid
## convert to raw/bim
plink --file out --allow-extra-chr --make-bed --recode A --out out2
## This should create a .raw and .bim file
## Edit the individual and population names in the .raw file to whatever you would like
https://github.com/mararie/SAMBAR/archive/refs/heads/master.zip
Download SambaR:OR
install.packages("devtools")
library(devtools)
devtools::install_github("mararie/SAMBAR")
The following commands are run in R
### Load SambaR, if you downloaded the package as a .zip file
source("C:/Analysis/R_analysis/SambaR-master/SAMBAR_v1.06.txt")
### load dependencies
getpackages()
### Import data (the raw/bim files here called with prefix "out4", and a geofile.txt, which contains gps coordinates for each individual
importdata(inputprefix="out4",geofile="geofile.txt",allow_edit = TRUE)
### Required: filter your data
filterdata(indmiss=0.25,snpmiss=0.1,min_mac=2)
### Conduct population structure analyses (LEA, PCoA, etc). Add 'quickrun=FALSE' for additional analyses
findstructure(Kmax=6,add_legend=TRUE, legend_pos='bottomright',legend_cex=3, symbol_size=3)
### If you get a message about the number of snps, type the following:
findstructure(do_continue=TRUE, quickrun=FALSE)
### Create maps with pie charts (LEA q-values) and TESS maps
create_sambarmaps(K_max=6,radius_ratio=50)
### Calculate distance metrics
calcdistance(nchroms=NULL)
### Calculate diversity metrics
calcdiversity(nrsites=NULL,legend_cex=2.5)
### Inbreeding and relatedness
calckinship()
### Selection analysis for Fst outliers with PCAdapt
selectionanalyses(do_pcadapt=TRUE,do_outflank=FALSE,do_fsthet=TRUE,export='pdf',dopiechart = FALSE)