Using Admixture

The following script requires a few pieces…broken down below:

Programs

  • angsd installed
  • NGSadmix in your ~/bin (comes as part of NGStools, but may need to copy exec into bin)

Folders

  • I use a out_slurms folder to catch the slurm output
  • The script can/will create results_admix folder
  • assumes my bamlist lives in a bamlists folder

Files

  • a bamlist of with all samples you are interested in assessing admixture


The Script


#!/bin/bash -l

#SBATCH -o out_slurms/04_get_admix-%j.out
#SBATCH -J get_admix

mkdir results_admix # optional or comment if already have folder

pop=$1 ### bamlist ##
n1=$2 ### k number 
ref=final_contigs_300.fasta ### de novo alignment/reference
nInd=$(wc -l bamlists/${pop}_25k_thresh.bamlist | awk '{print $1}')
n=$(($nInd/2)) # can change 
mInd=${n%.*} # also can modify

### Beagle output genotype file ####
        angsd -bam bamlists/${pop}_25k_thresh.bamlist -out results_admix/${pop}_glh -ref $ref -sites bait_lengths.txt -GL 2 -doMajorMinor 1 -doMaf 2 -doPost 2 -doGLF 2 -minMapQ 10 -minQ 20 -minInd $mInd -SNP_pval 1e-6 -minMaf 0.05

### Unzip files ###

        gunzip results_admix/*${pop}_glh*.gz

### Calculate Admixture for Plot ###

x=2
while [ $x -le $n1 ] 
do
        ~/bin/NGSadmix -likes results_admix/${pop}_glh.beagle -K $x -o results_admix/${pop}_admix${x}

        x=$(( $x + 1 ))

done


The Output (.opt file)

You should end up with a file that ends in admixX.qopt, where X is the k-groups you chose. This file can be plotted a number of ways.

  • Use Rscripts to plot (see:)
  • Try the online pophelper to make admixture graphs