The following script requires a few pieces…broken down below:
Programs
angsd
installedNGSadmix
in your ~/bin (comes as part of NGStools, but may need to copy exec into bin)Folders
out_slurms
folder to catch the slurm outputresults_admix
folderbamlists
folderFiles
#!/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
.opt
file)You should end up with a file that ends in admix
X.qopt
, where X is the k-groups you chose. This file can be plotted a number of ways.