ANGSD: Analysis of next generation Sequencing Data
Latest tar.gz version is (0.938/0.939 on github), see Change_log for changes, and download it here.
Quick Start
This page contains some random examples that shows some aspect of the ANGSD program. There is also an old Tutorial, but this is somewhat outdated. We assume you will have SAMtools installed.
Many of the examples in the individual subpages are based on this test data set. The examples below are just some random examples.
Download and prepare
First download some test data of random small BAM files which contains some regions from different chromosomes for 10 samples from the 1000genomes project. The file size is around 100megabytes.
wget http://popgen.dk/software/download/angsd/bams.tar.gz tar xf bams.tar.gz
This has made a folder called bams/, which contains our 10 samples. Now download and install angsd you can follow the guidelines at the Installation page which basicly says:
wget http://popgen.dk/software/download/angsd/angsd0.570.tar.gz tar xfz angsd0.570.tar.gz cd angsd0.570 make cd ..
We will also index the BAM files in case we need to do random access, for this we will use SAMtools.
for i in bams/*.bam;do samtools index $i;done
We make a file containing a list of the locations of the 10 bamfiles
ls bams/*.bam > bam.filelist
Examples
Calculate Allele frequencies
Assuming you have a list of bamfiles in in file: 'bam.filelist' and you want the MAF using all reads and inferring the major and minor from the GL, we will use SAMtools genotype likelihoods, and will allow for 5 threads: See details on Allele Frequencies, Major Minor and Genotype Likelihoods.
./angsd0.570/angsd -b list -GL 1 -doMajorMinor 1 -doMaf 2 -P 5
The output is then located on angsdput.mafs.gz. We could have specified an output file name with -out. Lets remove those reads that has a mapping quality below 30, and only use the bases with a score above 19. And to simply output we only print those sites with an allele frequency above 0.05.
./angsd0.574/angsd -b bam.filelist -GL 1 -doMajorMinor 1 -doMaf 2 -P 5 -minMapQ 30 -minBaseQ 20 -minMaf 0.05
And lets look at the output:
gunzip -c angsdput.mafs.gz |head
We have 10 samples, lets only look at the sites where we have an effective sample size of at least 8.
./angsd0.574/angsd -b bam.filelist -GL 1 -doMajorMinor 1 -doMaf 2 -P 5 -minMapQ 30 -minQ 20 -minMaf 0.05 -minInd 8
And look at the output:
gunzip -c angsdput.mafs.gz |head
Generate Beagle Likelihood files
For diploid samples we have 10 possible genotypes. but we would only expect to observe to different alleles at a site. So we need to infer the major and minor allele for dumping the 3 possible genotypes for the beagle format.