This is a simple pipeline to run NGSadmix for Sarabia et al. (2024), "Potential adaptive introgression from dogs in Iberian gray wolves (Canis lupus)"
ANGSD=/path_to_angsd/angsd
filelist=/path_to_filelist/35.PCA
ref=/path_to_ref_l.pictus/safrica_edited.canfam3.1lgth
output=/path_to_input_ngsadmix
sites=/path_to_genic_regions_file
We generate beagle files for NGSadmix, excluding genic regions (with non-neutral sites)
for i in {01..38}; do
$ANGSD -P 15 -bam $filelist/chr$i.filelist -ref $ref/chr$i.fasta -out $output/chr$i.ngsadmix -r chr$i \
-uniqueOnly 1 -remove_bads 1 -only_proper_pairs 1 -trim 0 -C 50 -baq 1 \
-minMapQ 20 -minQ 20 -minInd 150 -setMinDepth 3 -setMaxDepth 3000 -doCounts 1 \
-GL 1 -doMajorMinor 4 -doMaf 1 -skipTriallelic 1 \
-doGlf 2 -SNP_pval 1e-6 -sites $SITES/chr$i.10kb.neutral_regions.corrected.txt
done
Firstly, we coalesce all chr$i.ngsadmix files into one, autosomes.ngsadmix
input=/path_to_input_ngsadmix
output=/path_to_output_ngsadmix
nadx=/path_to_ngsadmix
for i in {1..12}; do # for K between 1 and 12
for rep in {1..10}; do # 10 runs per each K
$nadx/NGSadmix -likes $input/autosomes.ngsadmix.beagle.gz -K $i -P 16 -minMaf 0.05 -seed 1 -o $output/autosomes.ngsadmix.beagle.K$i.$rep.run 2>$output/autosomes.ngsadmix.beagle.K$i.$rep.log
done; done
We coalesce all *run.log files and their information in
Ks=$((grep "best like" *run.log | cut -f4 -d'.' | cut -f2 -d'K'))
likelihoods=$((grep "best like" *run.log | cut -f2 -d'=' | awk '{print $1}'))
paste $Ks $likelihoods > clumpaK.K2_12.150
We run this file in ClumpaK (https://clumpak.tau.ac.il/bestK.html) and extract optimal K results.
Once we have all runs, we generate three files: pop, with population names and individual abbreviations. ind2pop; with individual abbreviations. filemap, with 1 of each qopt file.
==> ind2pop.6_IBGW.150.canids.txt <==
DOG.bel.844
DOG.bbs.887
DOG.gdn.557
DOG.rtt.247
DOG.sbr.386
==> pop.6_IBGW.150.canids.txt <==
DOG.bel.844 dog.belgian_sheepdog.SAMN08872844
DOG.bbs.887 dog.berger_blanc_suisse.SAMEA4506887
DOG.gdn.557 dog.great_dane.SAMEA104091557
DOG.rtt.247 dog.rottweiler.SAMN08873247
DOG.sbr.386 dog.saint_bernard.SAMN03580386
==> 6_IBGW.150gen.filemap <==
k2 2 6_IBGW.150_genomes.beagle.K2.1.run.qopt
k3 3 6_IBGW.150_genomes.beagle.K3.1.run.qopt
k4 4 6_IBGW.150_genomes.beagle.K4.1.run.qopt
k5 5 6_IBGW.150_genomes.beagle.K5.1.run.qopt
k6 6 6_IBGW.150_genomes.beagle.K6.1.run.qopt
Pong has a predefine palette with 26 colors. We define a new file "palette.46colors" with color code names from https://www.quackit.com/css/color/tools/css_random_color_generator.cfm - colors are in CSS format.
/path_to_pong/pong -m 6_IBGW.151gen.filemap -n pop.6_IBGW.151.canids.txt -i ind2pop.6_IBGW.151.canids.txt -l palette.46colors