-
Notifications
You must be signed in to change notification settings - Fork 12
Tutorial
Welcome! This is a short guide to population genetics analysis using ANGSD-wrapper. We will be using a test data set containing sequence from Oryza sativa and Oryza glumaepetula. First, we need to clone the ANGSD-wrapper repository. You need to have git installed to do this. Alternatively, you can download a zip file from the releases page or use the download zip button on the home page of the repository.
$ git clone https://github.com/arundurvasula/angsd-wrapper.git aw-tutorial
$ cd aw-tutorial/
ANGSD-wrapper comes with its own version of ANGSD so that changes made in ANGSD will not break compatibility with ANGSD-wrapper. Also ANGSD-wrapper is bundled with a few related programs. In order to compile these programs, you must run make:
$ cd angsd; make
$ cd ../ngsPopGen/; make
$ cd ../ngsF/; make
Great! Now we're ready to get the example data.
$ cd ../data
$ wget http://de.iplantcollaborative.org/dl/d/3A541C91-A66A-4651-949D-4E65028C4A2F/iplant.zip
$ unzip -j iplant.zip
The example data should now be in the data folder. Now we need to change the common.conf file to point to the correct paths.
$ cd ..
$ nano scripts/common.conf
Modify this line to provide the path to your cloned directory:
PROJECT_DIR=${HOME}/rilab/aw-tutorial
Also these two lines need to provide the path to the reference and ancestral sequences.
# Reference genome sequence
REF_SEQ=${DATA_DIR}/reference.Oryza_sativa.IRGSP-1.0.23.dna.genome_chr.fa.gz
# Ancestral sequence
ANC_SEQ=${DATA_DIR}/ancestral.merid_japonica_chr.fa.gz
Great! Now we're ready to calculate a site frequency spectrum on the data. The script to do this is called scripts/SFS.sh and the variables are stored in scripts/SFS.conf
In the configuration file, we need to point the TAXON variable to our test data:
TAXON=test
TAXON_LIST=${DATA_DIR}/${TAXON}_samples.txt
TAXON_INBREEDING=${DATA_DIR}/${TAXON}_F.txt
Now we can run the site frequency spectrum calculation by running the script:
$ sbatch -p bigmemm scripts/SFS.sh scripts/SFS.conf
Note that if you aren't using slurm you should submit this job to your cluster queuing system the way you usually do (sbatch is slurm's command to submit jobs). This should result in the generation of several new files in your results directory. The one that contains the site frequency spectrum to graph is called test_DerivedSFS. The other files can be used as inputs to other commands. In order to graph the site frequency spectrum, we need to open up the shiny web app. If the server you are connected to has a web browser, you can do it directly on there. If it doesn't, you need to copy the results onto your local computer and run the web app there.
If this is the case, you need to clone ANGSD-wrapper on your local computer:
$ git clone https://github.com/arundurvasula/angsd-wrapper.git aw-tutorial
$ cd aw-tutorial
And copy your results file (I use scp):
$ scp name@server.address.edu:~/sandbox/aw-tutorial/results/test_DerivedSFS ./
You need to make sure you have the dependencies installed:
> install.packages("shiny")
> install.packages("ape")
> install.packages("Hmisc")
> install.packages("lattice")
> source("http://bioconductor.org/biocLite.R")
> biocLite("genomeIntervals")
> install.packages("data.table")
Once they are installed, you can run the shiny app:
$ R
> library(shiny)
> runApp("scripts/shiny")
A webpage should open up in your browser. To graph the site frequency spectrum, click the SFS tab and choose your file. Once you upload the file you should get a graph of your site frequency spectrum. You can save this graph by right clicking and saving the image. If you are following the tutorial, you should get a funky looking graph like this:
#Theta calculation
Running estimation of theta=4Nu is very simple now that we've gotten everything set up. We need to modify one line in the THETAS.conf file:
TAXON=test
If you would like to change the window size and step amount, you can modify the following variables:
WIN=100
STEP=50
You can also turn off sliding windows with:
SLIDING_WINDOW=false
Great! Now we can run the script:
sbatch -p bigmemm scripts/THETAS.sh scripts/THETAS.conf
We can visualize this the same way as before with the site frequency spectrum. The file we are interested in is called test_Diversity.thetas.gz.pestPG:
$scp name@server.address.edu:~/sandbox/aw-tutorial/results/test_Diversity.thetas.gz.pestPG ./
Once you upload the file into the web app, you should get two graphs that look like this:

You can view these graphs interactively by using the controls on the side. You can switch between estimators of theta and neutrality statistics with the drop down menus and zoom in on regions of interest with the Base start and end position number fields. You can also add lowess curves to the graphs and include gene annotations by uploading a GFF3 file that corresponds to your species.
In order to carry out admixture analysis, we have to compile the ngsAdmix program.
cd ngsPopGen
g++ ngsadmix32.cpp -O3 -lpthread -lz -o NGSadmix
Then we just have to change one variable in the ADMIX.conf file.
TAXON=test
The variable K specifies the ending point for the number of ancestral populations to run admixture with (starting with 2). For example, if K=5, admixture will be run from K={2,3,4,5}. Now we can submit it like this:
sbatch -p bigmemm scripts/ADMIX.sh scripts/ADMIX.conf
Once this has finished running, you can copy over the results (*.qopt) and view them in the graphing application.
$scp name@server.edu:~/rilab/aw-tutorial/results/test.3.qopt ./
The results should look something like this:
##PCA
Running a PCA is pretty straightforward. The only variable you need to change is the TAXON variable in the PCA.conf file:
TAXON=test
And we can run the analysis with
sbatch -p bigmemm scripts/PCA.sh scripts/PCA.conf
We can visualize the result by copying over the .covar file:
$scp name@server.edu:~/rilab/aw-tutorial/results/test_geno.covar ./
In the graphing application, switch to the PCA tab and upload the file. You should get something like this:



