<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.popgen.dk/software/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Genis</id>
	<title>software - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://www.popgen.dk/software/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Genis"/>
	<link rel="alternate" type="text/html" href="https://www.popgen.dk/software/index.php/Special:Contributions/Genis"/>
	<updated>2026-05-01T18:36:58Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.40.1</generator>
	<entry>
		<id>https://www.popgen.dk/software/index.php?title=EvalAdmix&amp;diff=1468</id>
		<title>EvalAdmix</title>
		<link rel="alternate" type="text/html" href="https://www.popgen.dk/software/index.php?title=EvalAdmix&amp;diff=1468"/>
		<updated>2022-10-06T09:37:04Z</updated>

		<summary type="html">&lt;p&gt;Genis: /* Low depth sequencing data */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''IMPORTANT''': version 0.95 (updated on 30/06/2021) fixes a bug in the implementation for genotype data, which caused displacement of genotypes between samples when a site had missing data. When all sites have some missingness this would result in the last samples from the analyses having a correlation of nan with all other samples; but might have some more subtle effects whenever there is some level of missingness. If you have analyses from previous versions based on genotype data with any missingness might be a good idea to re-run them after updating. The bug did not affect the genotype likelihoods implementation so if you based the analyses on genotype likelihoods you do not need to worry. If you applied it to gentoype data without any missingness you also do not need to worry.&lt;br /&gt;
&lt;br /&gt;
evalAdmix allows to evaluate the results of an admixture analysis (i.e. the result of applying [https://genome.cshlp.org/content/19/9/1655.long ADMIXTURE], [https://web.stanford.edu/group/pritchardlab/structure.html STRUCTURE], [http://www.popgen.dk/software/index.php/NgsAdmix NGSadmix] and similar). It only needs the input genotype data used for the previous admixture analysis and the output of that analysis (admixture proportions and ancestral population frequencies). The genotype input data can either be called genotypes in [https://www.cog-genomics.org/plink/1.9/formats#bed binary plink format] or genotype likelihoods in [http://www.popgen.dk/angsd/index.php/Genotype_Likelihoods#Beagle_format beagle format].&lt;br /&gt;
&lt;br /&gt;
The output is a pairwise correlation of residuals matrix between individuals. The correlation will be close to 0 in case of a good fit of the data to the admixture model. When individuals do not fit the model, individuals with similar demographic histories (i.e. usually individuals from the same population) will be positively correlated; and individuals with different histories but that are modelled as sharing one or more ancestral populations as admixture sources will have a negative correlation. Positive correlation between a pair of individuals might also be due to relatedness.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:evalAdmix.png|thumb|550px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Download and Installation==&lt;br /&gt;
&lt;br /&gt;
evalAdmix can be installed from [https://github.com/GenisGE/evalAdmix github] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;git clone https://github.com/GenisGE/evalAdmix.git&lt;br /&gt;
cd evalAdmix&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Quick start==&lt;br /&gt;
:&amp;lt;code&amp;gt; ./evalAdmix -beagle inputBeagleFile.gz  -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -o evaladmixOut.corres -P 10  &amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt; ./evalAdmix -plink inputPlinkPrefix  -fname inputPlinkPrefix.K.P -qname inputPlinkPrefix.K.Q -o evaladmixOut.corres -P 10  &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''-beagle''' beagle file of genotype likelihoods&lt;br /&gt;
* '''-plink''' binary plink file prefix with genotype data&lt;br /&gt;
* '''-fname''' file with ancestral frequencies (space delimited, rows are sites and columns ancestral populations)&lt;br /&gt;
* '''-qname''' file with admixture proportions (space delimited, rows are individuals and columns ancestral populations)&lt;br /&gt;
* '''-o''' prefix of output file names&lt;br /&gt;
* '''-P''' Number of threads used&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix  &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Arguments:&lt;br /&gt;
	Required:&lt;br /&gt;
		-plink path to binary plink file (excluding the .bed)&lt;br /&gt;
		or&lt;br /&gt;
	      	-beagle path to beagle file containing genotype likelihoods (alternative to -plink)&lt;br /&gt;
		&lt;br /&gt;
		-fname path to ancestral population frequencies file&lt;br /&gt;
	       	-qname path to admixture proportions file&lt;br /&gt;
		&lt;br /&gt;
	Optional:       &lt;br /&gt;
	&lt;br /&gt;
	       -o name of the output file&lt;br /&gt;
	       &lt;br /&gt;
	 Setup (optional):&lt;br /&gt;
	 &lt;br /&gt;
	       -P 1 number of threads&lt;br /&gt;
	       -autosomeMax 23	 autosome ends with this chromsome&lt;br /&gt;
	       -nIts 5	 number of iterations to do for frequency correction; if set to 0 calculates correlation without correction (fast but biased)&lt;br /&gt;
	       -useSites 1.0	 proportion of sites to use to calculate correlation of residuals&lt;br /&gt;
	       -useInds filename     path to tab delimited file with first column containing all individuals ID and second column with 1 to include individual in analysis and 0 otherwise (default all individuals are included)&lt;br /&gt;
	       -misTol 0.05 	 tolerance for considering site as missing when using genotype likelihoods. Use same value as used in NGSadmix to keep compatibility when using genotype likelihoods (-beagle)&lt;br /&gt;
	       -minMaf 0.05 	 minimum minor allele frequency to keep site. Use same value as used in NGSadmix to keep compatibility when using genotype likelihoods (-beagle)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Input Files==&lt;br /&gt;
&lt;br /&gt;
===Plink===&lt;br /&gt;
Genotype data files in binary PLINK format (.bed .fam .bim).&lt;br /&gt;
===Beagle genotype likelhoods===&lt;br /&gt;
The input file contains genotype likelihoods in a .beagle file format [http://faculty.washington.edu/browning/beagle/beagle.html].&lt;br /&gt;
and can be compressed with gzip.&lt;br /&gt;
==== BAM files  ====&lt;br /&gt;
If you have BAM files you can use [[ANGSD]] to produce genotype likelihoods in .beagle format. Please &lt;br /&gt;
see [http://www.popgen.dk/angsd/index.php/Beagle_input Creation of Beagle files with ANGSD]&lt;br /&gt;
&lt;br /&gt;
==== VCF files ====&lt;br /&gt;
If you already have made a VCF file that contains genotype likehood information then  it should be possible to convert .vcf files with genotype likelihoods to .beagle file via vcftools [https://vcftools.github.io/man_latest.html] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vcftools --vcf input.vcf --out test --BEAGLE-GL --chr 1,2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Chromosome has to be specified.&lt;br /&gt;
&lt;br /&gt;
You can also use bcftools' [https://samtools.github.io/bcftools/bcftools.html] 'query' option for generating a .beagle file from a .vcf file.&lt;br /&gt;
&lt;br /&gt;
==Output File==&lt;br /&gt;
The analysis performed by evalAdmix produces one file, containing a tab delimited N times N symmetric correlation matrix, where column i in line j contains the correlation of residuals between individual i and j, and the diagonal values (self-correlation) are set to NA:&lt;br /&gt;
&lt;br /&gt;
NA      0.008609        -0.006919       0.002731        0.020224&amp;lt;br /&amp;gt;&lt;br /&gt;
0.008609        NA      0.000033        0.004968        -0.008470&amp;lt;br /&amp;gt;&lt;br /&gt;
-0.006919       0.000033        NA      0.006982        0.005664&amp;lt;br /&amp;gt;&lt;br /&gt;
0.002731        0.004968        0.006982        NA      0.000521&amp;lt;br /&amp;gt;&lt;br /&gt;
0.020224        -0.008470       0.005664        0.000521        NA&lt;br /&gt;
&lt;br /&gt;
==Run command example==&lt;br /&gt;
&lt;br /&gt;
=== Genotype data ===&lt;br /&gt;
Download the input file containing genotypes in binary plink format&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.bed&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.bim&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.fam&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run ADMIXTURE [http://software.genetics.ucla.edu/admixture/] to obtain admixture proprotions&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;admixture admixTjeck2.bed 3&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
::Genotypes file prefix admixTjeck2.bed&lt;br /&gt;
::Ancestral Populations K = 3&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Run evalAdmix&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix -plink admixTjeck2 -fname admixTjeck2.3.P -qname admixTjeck2.3.Q -P 20 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
::Genotypes file prefix admixTjeck2 (-plink admixTjeck2).&lt;br /&gt;
::Ancestral Populations frequency file admixTjeck2.3.P (-fname admixTjeck2.3.P).&lt;br /&gt;
::Admixture proportions file admixTjeck2.3.Q (-qname admixTjeck2.3.Q).&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
&lt;br /&gt;
Plot results in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source(&amp;quot;visFuns.R&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# read population labels and estimated admixture proportions&lt;br /&gt;
pop&amp;lt;-read.table(&amp;quot;admixTjeck2.fam&amp;quot;)&lt;br /&gt;
q&amp;lt;-read.table(&amp;quot;admixTjeck2.3.Q&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# order according to population and plot the ADMIXTURE reults&lt;br /&gt;
ord&amp;lt;-orderInds(pop = as.vector(pop[,2]), q = q)&lt;br /&gt;
barplot(t(q)[,ord],col=2:10,space=0,border=NA,xlab=&amp;quot;Individuals&amp;quot;,ylab=&amp;quot;Demo2 Admixture proportions for K=3&amp;quot;)&lt;br /&gt;
text(sort(tapply(1:nrow(pop),pop[ord,2],mean)),-0.05,unique(pop[ord,2]),xpd=T)&lt;br /&gt;
abline(v=cumsum(sapply(unique(pop[ord,2]),function(x){sum(pop[ord,2]==x)})),col=1,lwd=1.2)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
r&amp;lt;-as.matrix(read.table(&amp;quot;output.corres.txt&amp;quot;))&lt;br /&gt;
&lt;br /&gt;
# Plot correlation of residuals&lt;br /&gt;
plotCorRes(cor_mat = r, pop = as.vector(pop[,2]), ord=ord, title=&amp;quot;Evaluation of 1000G admixture proportions with K=3&amp;quot;, max_z=0.1, min_z=-0.1)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Low depth sequencing data ===&lt;br /&gt;
Download the input file containing genotype likelihoods in beagle format&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget popgen.dk/software/download/NGSadmix/data/Demo2input.gz&lt;br /&gt;
wget popgen.dk/software/download/NGSadmix/data/Demo2pop.info&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Execute [[NgsAdmix |NGSadmix]] to obtain admixture proportions&lt;br /&gt;
&amp;lt;pre&amp;gt;./NGSadmix -likes Demo2input.gz -K 3 -P 20 -o myoutfiles -minMaf 0.05&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
::Input file = Demo2input.gz&lt;br /&gt;
::Ancestral Populations K=3&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
::Output prefix = myoutfiles (-o myoutfiles) &lt;br /&gt;
::SNPs with MAF &amp;gt; 5%  (-minMaf 0.05)&lt;br /&gt;
&lt;br /&gt;
Run evalAdmix&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix -beagle Demo2input.gz -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 20 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
::Genotype likelihoods file Demo2input.gz (-beagle Demo2input.gz).&lt;br /&gt;
::Ancestral Populations frequency file myoutfiles.fopt.gz (-fname myoutfiles.fopt.gz).&lt;br /&gt;
::Admixture proportions file  myoutfiles.qopt(-qname myoutfiles.qopt).&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
&lt;br /&gt;
Plot results in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source(&amp;quot;visFuns.R&amp;quot;)&lt;br /&gt;
# read population labels and estimated admixture proportions&lt;br /&gt;
pop&amp;lt;-read.table(&amp;quot;Demo2pop.info&amp;quot;,as.is=T)&lt;br /&gt;
q&amp;lt;-read.table(&amp;quot;myoutfiles.qopt&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# order according to population and plot the NGSadmix reults&lt;br /&gt;
ord&amp;lt;-orderInds(pop = as.vector(pop[,1]), q = q)&lt;br /&gt;
barplot(t(q)[,ord],col=2:10,space=0,border=NA,xlab=&amp;quot;Individuals&amp;quot;,ylab=&amp;quot;Demo2 Admixture proportions for K=3&amp;quot;)&lt;br /&gt;
text(sort(tapply(1:nrow(pop),pop[ord,1],mean)),-0.05,unique(pop[ord,1]),xpd=T)&lt;br /&gt;
abline(v=cumsum(sapply(unique(pop[ord,1]),function(x){sum(pop[ord,1]==x)})),col=1,lwd=1.2)&lt;br /&gt;
&lt;br /&gt;
r&amp;lt;-read.table(&amp;quot;output.corres.txt&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Plot correlation of residuals&lt;br /&gt;
&lt;br /&gt;
plotCorRes(cor_mat = r, pop = as.vector(pop[,1]), ord = ord, title=&amp;quot;Evaluation of 1000G admixture proportions with K=3&amp;quot;, max_z=0.1, min_z=-0.1)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Citation==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[https://doi.org/10.1111/1755-0998.13171 Evaluation of Model Fit of Inferred Admixture Proportions]&lt;/div&gt;</summary>
		<author><name>Genis</name></author>
	</entry>
	<entry>
		<id>https://www.popgen.dk/software/index.php?title=EvalAdmix&amp;diff=1467</id>
		<title>EvalAdmix</title>
		<link rel="alternate" type="text/html" href="https://www.popgen.dk/software/index.php?title=EvalAdmix&amp;diff=1467"/>
		<updated>2022-10-06T09:36:50Z</updated>

		<summary type="html">&lt;p&gt;Genis: /* Genotype data */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''IMPORTANT''': version 0.95 (updated on 30/06/2021) fixes a bug in the implementation for genotype data, which caused displacement of genotypes between samples when a site had missing data. When all sites have some missingness this would result in the last samples from the analyses having a correlation of nan with all other samples; but might have some more subtle effects whenever there is some level of missingness. If you have analyses from previous versions based on genotype data with any missingness might be a good idea to re-run them after updating. The bug did not affect the genotype likelihoods implementation so if you based the analyses on genotype likelihoods you do not need to worry. If you applied it to gentoype data without any missingness you also do not need to worry.&lt;br /&gt;
&lt;br /&gt;
evalAdmix allows to evaluate the results of an admixture analysis (i.e. the result of applying [https://genome.cshlp.org/content/19/9/1655.long ADMIXTURE], [https://web.stanford.edu/group/pritchardlab/structure.html STRUCTURE], [http://www.popgen.dk/software/index.php/NgsAdmix NGSadmix] and similar). It only needs the input genotype data used for the previous admixture analysis and the output of that analysis (admixture proportions and ancestral population frequencies). The genotype input data can either be called genotypes in [https://www.cog-genomics.org/plink/1.9/formats#bed binary plink format] or genotype likelihoods in [http://www.popgen.dk/angsd/index.php/Genotype_Likelihoods#Beagle_format beagle format].&lt;br /&gt;
&lt;br /&gt;
The output is a pairwise correlation of residuals matrix between individuals. The correlation will be close to 0 in case of a good fit of the data to the admixture model. When individuals do not fit the model, individuals with similar demographic histories (i.e. usually individuals from the same population) will be positively correlated; and individuals with different histories but that are modelled as sharing one or more ancestral populations as admixture sources will have a negative correlation. Positive correlation between a pair of individuals might also be due to relatedness.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:evalAdmix.png|thumb|550px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Download and Installation==&lt;br /&gt;
&lt;br /&gt;
evalAdmix can be installed from [https://github.com/GenisGE/evalAdmix github] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;git clone https://github.com/GenisGE/evalAdmix.git&lt;br /&gt;
cd evalAdmix&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Quick start==&lt;br /&gt;
:&amp;lt;code&amp;gt; ./evalAdmix -beagle inputBeagleFile.gz  -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -o evaladmixOut.corres -P 10  &amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt; ./evalAdmix -plink inputPlinkPrefix  -fname inputPlinkPrefix.K.P -qname inputPlinkPrefix.K.Q -o evaladmixOut.corres -P 10  &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''-beagle''' beagle file of genotype likelihoods&lt;br /&gt;
* '''-plink''' binary plink file prefix with genotype data&lt;br /&gt;
* '''-fname''' file with ancestral frequencies (space delimited, rows are sites and columns ancestral populations)&lt;br /&gt;
* '''-qname''' file with admixture proportions (space delimited, rows are individuals and columns ancestral populations)&lt;br /&gt;
* '''-o''' prefix of output file names&lt;br /&gt;
* '''-P''' Number of threads used&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix  &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Arguments:&lt;br /&gt;
	Required:&lt;br /&gt;
		-plink path to binary plink file (excluding the .bed)&lt;br /&gt;
		or&lt;br /&gt;
	      	-beagle path to beagle file containing genotype likelihoods (alternative to -plink)&lt;br /&gt;
		&lt;br /&gt;
		-fname path to ancestral population frequencies file&lt;br /&gt;
	       	-qname path to admixture proportions file&lt;br /&gt;
		&lt;br /&gt;
	Optional:       &lt;br /&gt;
	&lt;br /&gt;
	       -o name of the output file&lt;br /&gt;
	       &lt;br /&gt;
	 Setup (optional):&lt;br /&gt;
	 &lt;br /&gt;
	       -P 1 number of threads&lt;br /&gt;
	       -autosomeMax 23	 autosome ends with this chromsome&lt;br /&gt;
	       -nIts 5	 number of iterations to do for frequency correction; if set to 0 calculates correlation without correction (fast but biased)&lt;br /&gt;
	       -useSites 1.0	 proportion of sites to use to calculate correlation of residuals&lt;br /&gt;
	       -useInds filename     path to tab delimited file with first column containing all individuals ID and second column with 1 to include individual in analysis and 0 otherwise (default all individuals are included)&lt;br /&gt;
	       -misTol 0.05 	 tolerance for considering site as missing when using genotype likelihoods. Use same value as used in NGSadmix to keep compatibility when using genotype likelihoods (-beagle)&lt;br /&gt;
	       -minMaf 0.05 	 minimum minor allele frequency to keep site. Use same value as used in NGSadmix to keep compatibility when using genotype likelihoods (-beagle)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Input Files==&lt;br /&gt;
&lt;br /&gt;
===Plink===&lt;br /&gt;
Genotype data files in binary PLINK format (.bed .fam .bim).&lt;br /&gt;
===Beagle genotype likelhoods===&lt;br /&gt;
The input file contains genotype likelihoods in a .beagle file format [http://faculty.washington.edu/browning/beagle/beagle.html].&lt;br /&gt;
and can be compressed with gzip.&lt;br /&gt;
==== BAM files  ====&lt;br /&gt;
If you have BAM files you can use [[ANGSD]] to produce genotype likelihoods in .beagle format. Please &lt;br /&gt;
see [http://www.popgen.dk/angsd/index.php/Beagle_input Creation of Beagle files with ANGSD]&lt;br /&gt;
&lt;br /&gt;
==== VCF files ====&lt;br /&gt;
If you already have made a VCF file that contains genotype likehood information then  it should be possible to convert .vcf files with genotype likelihoods to .beagle file via vcftools [https://vcftools.github.io/man_latest.html] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vcftools --vcf input.vcf --out test --BEAGLE-GL --chr 1,2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Chromosome has to be specified.&lt;br /&gt;
&lt;br /&gt;
You can also use bcftools' [https://samtools.github.io/bcftools/bcftools.html] 'query' option for generating a .beagle file from a .vcf file.&lt;br /&gt;
&lt;br /&gt;
==Output File==&lt;br /&gt;
The analysis performed by evalAdmix produces one file, containing a tab delimited N times N symmetric correlation matrix, where column i in line j contains the correlation of residuals between individual i and j, and the diagonal values (self-correlation) are set to NA:&lt;br /&gt;
&lt;br /&gt;
NA      0.008609        -0.006919       0.002731        0.020224&amp;lt;br /&amp;gt;&lt;br /&gt;
0.008609        NA      0.000033        0.004968        -0.008470&amp;lt;br /&amp;gt;&lt;br /&gt;
-0.006919       0.000033        NA      0.006982        0.005664&amp;lt;br /&amp;gt;&lt;br /&gt;
0.002731        0.004968        0.006982        NA      0.000521&amp;lt;br /&amp;gt;&lt;br /&gt;
0.020224        -0.008470       0.005664        0.000521        NA&lt;br /&gt;
&lt;br /&gt;
==Run command example==&lt;br /&gt;
&lt;br /&gt;
=== Genotype data ===&lt;br /&gt;
Download the input file containing genotypes in binary plink format&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.bed&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.bim&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.fam&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run ADMIXTURE [http://software.genetics.ucla.edu/admixture/] to obtain admixture proprotions&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;admixture admixTjeck2.bed 3&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
::Genotypes file prefix admixTjeck2.bed&lt;br /&gt;
::Ancestral Populations K = 3&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Run evalAdmix&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix -plink admixTjeck2 -fname admixTjeck2.3.P -qname admixTjeck2.3.Q -P 20 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
::Genotypes file prefix admixTjeck2 (-plink admixTjeck2).&lt;br /&gt;
::Ancestral Populations frequency file admixTjeck2.3.P (-fname admixTjeck2.3.P).&lt;br /&gt;
::Admixture proportions file admixTjeck2.3.Q (-qname admixTjeck2.3.Q).&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
&lt;br /&gt;
Plot results in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source(&amp;quot;visFuns.R&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# read population labels and estimated admixture proportions&lt;br /&gt;
pop&amp;lt;-read.table(&amp;quot;admixTjeck2.fam&amp;quot;)&lt;br /&gt;
q&amp;lt;-read.table(&amp;quot;admixTjeck2.3.Q&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# order according to population and plot the ADMIXTURE reults&lt;br /&gt;
ord&amp;lt;-orderInds(pop = as.vector(pop[,2]), q = q)&lt;br /&gt;
barplot(t(q)[,ord],col=2:10,space=0,border=NA,xlab=&amp;quot;Individuals&amp;quot;,ylab=&amp;quot;Demo2 Admixture proportions for K=3&amp;quot;)&lt;br /&gt;
text(sort(tapply(1:nrow(pop),pop[ord,2],mean)),-0.05,unique(pop[ord,2]),xpd=T)&lt;br /&gt;
abline(v=cumsum(sapply(unique(pop[ord,2]),function(x){sum(pop[ord,2]==x)})),col=1,lwd=1.2)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
r&amp;lt;-as.matrix(read.table(&amp;quot;output.corres.txt&amp;quot;))&lt;br /&gt;
&lt;br /&gt;
# Plot correlation of residuals&lt;br /&gt;
plotCorRes(cor_mat = r, pop = as.vector(pop[,2]), ord=ord, title=&amp;quot;Evaluation of 1000G admixture proportions with K=3&amp;quot;, max_z=0.1, min_z=-0.1)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Low depth sequencing data ===&lt;br /&gt;
Download the input file containing genotype likelihoods in beagle format&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget popgen.dk/software/download/NGSadmix/data/Demo2input.gz&lt;br /&gt;
wget popgen.dk/software/download/NGSadmix/data/Demo2pop.info&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Execute [[NgsAdmix |NGSadmix]] to obtain admixture proportions&lt;br /&gt;
&amp;lt;pre&amp;gt;./NGSadmix -likes Demo2input.gz -K 3 -P 20 -o myoutfiles -minMaf 0.05&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
::Input file = Demo2input.gz&lt;br /&gt;
::Ancestral Populations K=3&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
::Output prefix = myoutfiles (-o myoutfiles) &lt;br /&gt;
::SNPs with MAF &amp;gt; 5%  (-minMaf 0.05)&lt;br /&gt;
&lt;br /&gt;
Run evalAdmix&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix -beagle Demo2input.gz -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 20 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
::Genotype likelihoods file Demo2input.gz (-beagle Demo2input.gz).&lt;br /&gt;
::Ancestral Populations frequency file myoutfiles.fopt.gz (-fname myoutfiles.fopt.gz).&lt;br /&gt;
::Admixture proportions file  myoutfiles.qopt(-qname myoutfiles.qopt).&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
&lt;br /&gt;
Plot results in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source(&amp;quot;visFuns.R&amp;quot;)&lt;br /&gt;
# read population labels and estimated admixture proportions&lt;br /&gt;
pop&amp;lt;-read.table(&amp;quot;Demo2pop.info&amp;quot;,as.is=T)&lt;br /&gt;
q&amp;lt;-read.table(&amp;quot;myoutfiles.qopt&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# order according to population and plot the NGSadmix reults&lt;br /&gt;
ord&amp;lt;-orderInds(pop = as.vector(pop[,1]), q = q)&lt;br /&gt;
barplot(t(q)[,ord],col=2:10,space=0,border=NA,xlab=&amp;quot;Individuals&amp;quot;,ylab=&amp;quot;Demo2 Admixture proportions for K=3&amp;quot;)&lt;br /&gt;
text(tapply(1:nrow(pop),pop[ord,1],mean),-0.05,unique(pop[ord,1]),xpd=T)&lt;br /&gt;
abline(v=cumsum(sapply(unique(pop[ord,1]),function(x){sum(pop[ord,1]==x)})),col=1,lwd=1.2)&lt;br /&gt;
&lt;br /&gt;
r&amp;lt;-read.table(&amp;quot;output.corres.txt&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Plot correlation of residuals&lt;br /&gt;
&lt;br /&gt;
plotCorRes(cor_mat = r, pop = as.vector(pop[,1]), ord = ord, title=&amp;quot;Evaluation of 1000G admixture proportions with K=3&amp;quot;, max_z=0.1, min_z=-0.1)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Citation==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[https://doi.org/10.1111/1755-0998.13171 Evaluation of Model Fit of Inferred Admixture Proportions]&lt;/div&gt;</summary>
		<author><name>Genis</name></author>
	</entry>
	<entry>
		<id>https://www.popgen.dk/software/index.php?title=EvalAdmix&amp;diff=1462</id>
		<title>EvalAdmix</title>
		<link rel="alternate" type="text/html" href="https://www.popgen.dk/software/index.php?title=EvalAdmix&amp;diff=1462"/>
		<updated>2021-06-30T12:52:46Z</updated>

		<summary type="html">&lt;p&gt;Genis: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''IMPORTANT''': version 0.95 (updated on 30/06/2021) fixes a bug in the implementation for genotype data, which caused displacement of genotypes between samples when a site had missing data. When all sites have some missingness this would result in the last samples from the analyses having a correlation of nan with all other samples; but might have some more subtle effects whenever there is some level of missingness. If you have analyses from previous versions based on genotype data with any missingness might be a good idea to re-run them after updating. The bug did not affect the genotype likelihoods implementation so if you based the analyses on genotype likelihoods you do not need to worry. If you applied it to gentoype data without any missingness you also do not need to worry.&lt;br /&gt;
&lt;br /&gt;
evalAdmix allows to evaluate the results of an admixture analysis (i.e. the result of applying [https://genome.cshlp.org/content/19/9/1655.long ADMIXTURE], [https://web.stanford.edu/group/pritchardlab/structure.html STRUCTURE], [http://www.popgen.dk/software/index.php/NgsAdmix NGSadmix] and similar). It only needs the input genotype data used for the previous admixture analysis and the output of that analysis (admixture proportions and ancestral population frequencies). The genotype input data can either be called genotypes in [https://www.cog-genomics.org/plink/1.9/formats#bed binary plink format] or genotype likelihoods in [http://www.popgen.dk/angsd/index.php/Genotype_Likelihoods#Beagle_format beagle format].&lt;br /&gt;
&lt;br /&gt;
The output is a pairwise correlation of residuals matrix between individuals. The correlation will be close to 0 in case of a good fit of the data to the admixture model. When individuals do not fit the model, individuals with similar demographic histories (i.e. usually individuals from the same population) will be positively correlated; and individuals with different histories but that are modelled as sharing one or more ancestral populations as admixture sources will have a negative correlation. Positive correlation between a pair of individuals might also be due to relatedness.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:evalAdmix.png|thumb|550px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Download and Installation==&lt;br /&gt;
&lt;br /&gt;
evalAdmix can be installed from [https://github.com/GenisGE/evalAdmix github] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;git clone https://github.com/GenisGE/evalAdmix.git&lt;br /&gt;
cd evalAdmix&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Quick start==&lt;br /&gt;
:&amp;lt;code&amp;gt; ./evalAdmix -beagle inputBeagleFile.gz  -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -o evaladmixOut.corres -P 10  &amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt; ./evalAdmix -plink inputPlinkPrefix  -fname inputPlinkPrefix.K.P -qname inputPlinkPrefix.K.Q -o evaladmixOut.corres -P 10  &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''-beagle''' beagle file of genotype likelihoods&lt;br /&gt;
* '''-plink''' binary plink file prefix with genotype data&lt;br /&gt;
* '''-fname''' file with ancestral frequencies (space delimited, rows are sites and columns ancestral populations)&lt;br /&gt;
* '''-qname''' file with admixture proportions (space delimited, rows are individuals and columns ancestral populations)&lt;br /&gt;
* '''-o''' prefix of output file names&lt;br /&gt;
* '''-P''' Number of threads used&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix  &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Arguments:&lt;br /&gt;
	Required:&lt;br /&gt;
		-plink path to binary plink file (excluding the .bed)&lt;br /&gt;
		or&lt;br /&gt;
	      	-beagle path to beagle file containing genotype likelihoods (alternative to -plink)&lt;br /&gt;
		&lt;br /&gt;
		-fname path to ancestral population frequencies file&lt;br /&gt;
	       	-qname path to admixture proportions file&lt;br /&gt;
		&lt;br /&gt;
	Optional:       &lt;br /&gt;
	&lt;br /&gt;
	       -o name of the output file&lt;br /&gt;
	       &lt;br /&gt;
	 Setup (optional):&lt;br /&gt;
	 &lt;br /&gt;
	       -P 1 number of threads&lt;br /&gt;
	       -autosomeMax 23	 autosome ends with this chromsome&lt;br /&gt;
	       -nIts 5	 number of iterations to do for frequency correction; if set to 0 calculates correlation without correction (fast but biased)&lt;br /&gt;
	       -useSites 1.0	 proportion of sites to use to calculate correlation of residuals&lt;br /&gt;
	       -useInds filename     path to tab delimited file with first column containing all individuals ID and second column with 1 to include individual in analysis and 0 otherwise (default all individuals are included)&lt;br /&gt;
	       -misTol 0.05 	 tolerance for considering site as missing when using genotype likelihoods. Use same value as used in NGSadmix to keep compatibility when using genotype likelihoods (-beagle)&lt;br /&gt;
	       -minMaf 0.05 	 minimum minor allele frequency to keep site. Use same value as used in NGSadmix to keep compatibility when using genotype likelihoods (-beagle)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Input Files==&lt;br /&gt;
&lt;br /&gt;
===Plink===&lt;br /&gt;
Genotype data files in binary PLINK format (.bed .fam .bim).&lt;br /&gt;
===Beagle genotype likelhoods===&lt;br /&gt;
The input file contains genotype likelihoods in a .beagle file format [http://faculty.washington.edu/browning/beagle/beagle.html].&lt;br /&gt;
and can be compressed with gzip.&lt;br /&gt;
==== BAM files  ====&lt;br /&gt;
If you have BAM files you can use [[ANGSD]] to produce genotype likelihoods in .beagle format. Please &lt;br /&gt;
see [http://www.popgen.dk/angsd/index.php/Beagle_input Creation of Beagle files with ANGSD]&lt;br /&gt;
&lt;br /&gt;
==== VCF files ====&lt;br /&gt;
If you already have made a VCF file that contains genotype likehood information then  it should be possible to convert .vcf files with genotype likelihoods to .beagle file via vcftools [https://vcftools.github.io/man_latest.html] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vcftools --vcf input.vcf --out test --BEAGLE-GL --chr 1,2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Chromosome has to be specified.&lt;br /&gt;
&lt;br /&gt;
You can also use bcftools' [https://samtools.github.io/bcftools/bcftools.html] 'query' option for generating a .beagle file from a .vcf file.&lt;br /&gt;
&lt;br /&gt;
==Output File==&lt;br /&gt;
The analysis performed by evalAdmix produces one file, containing a tab delimited N times N symmetric correlation matrix, where column i in line j contains the correlation of residuals between individual i and j, and the diagonal values (self-correlation) are set to NA:&lt;br /&gt;
&lt;br /&gt;
NA      0.008609        -0.006919       0.002731        0.020224&amp;lt;br /&amp;gt;&lt;br /&gt;
0.008609        NA      0.000033        0.004968        -0.008470&amp;lt;br /&amp;gt;&lt;br /&gt;
-0.006919       0.000033        NA      0.006982        0.005664&amp;lt;br /&amp;gt;&lt;br /&gt;
0.002731        0.004968        0.006982        NA      0.000521&amp;lt;br /&amp;gt;&lt;br /&gt;
0.020224        -0.008470       0.005664        0.000521        NA&lt;br /&gt;
&lt;br /&gt;
==Run command example==&lt;br /&gt;
&lt;br /&gt;
=== Genotype data ===&lt;br /&gt;
Download the input file containing genotypes in binary plink format&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.bed&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.bim&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.fam&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run ADMIXTURE [http://software.genetics.ucla.edu/admixture/] to obtain admixture proprotions&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;admixture admixTjeck2.bed 3&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
::Genotypes file prefix admixTjeck2.bed&lt;br /&gt;
::Ancestral Populations K = 3&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Run evalAdmix&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix -plink admixTjeck2 -fname admixTjeck2.3.P -qname admixTjeck2.3.Q -P 20 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
::Genotypes file prefix admixTjeck2 (-plink admixTjeck2).&lt;br /&gt;
::Ancestral Populations frequency file admixTjeck2.3.P (-fname admixTjeck2.3.P).&lt;br /&gt;
::Admixture proportions file admixTjeck2.3.Q (-qname admixTjeck2.3.Q).&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
&lt;br /&gt;
Plot results in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source(&amp;quot;visFuns.R&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# read population labels and estimated admixture proportions&lt;br /&gt;
pop&amp;lt;-read.table(&amp;quot;admixTjeck2.fam&amp;quot;)&lt;br /&gt;
q&amp;lt;-read.table(&amp;quot;admixTjeck2.3.Q&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# order according to population and plot the ADMIXTURE reults&lt;br /&gt;
ord&amp;lt;-orderInds(pop = as.vector(pop[,2]), q = q)&lt;br /&gt;
barplot(t(q)[,ord],col=2:10,space=0,border=NA,xlab=&amp;quot;Individuals&amp;quot;,ylab=&amp;quot;Demo2 Admixture proportions for K=3&amp;quot;)&lt;br /&gt;
text(tapply(1:nrow(pop),pop[ord,2],mean),-0.05,unique(pop[ord,2]),xpd=T)&lt;br /&gt;
abline(v=cumsum(sapply(unique(pop[ord,2]),function(x){sum(pop[ord,2]==x)})),col=1,lwd=1.2)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
r&amp;lt;-as.matrix(read.table(&amp;quot;output.corres.txt&amp;quot;))&lt;br /&gt;
&lt;br /&gt;
# Plot correlation of residuals&lt;br /&gt;
plotCorRes(cor_mat = r, pop = as.vector(pop[,2]), ord=ord, title=&amp;quot;Evaluation of 1000G admixture proportions with K=3&amp;quot;, max_z=0.1, min_z=-0.1)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Low depth sequencing data ===&lt;br /&gt;
Download the input file containing genotype likelihoods in beagle format&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget popgen.dk/software/download/NGSadmix/data/Demo2input.gz&lt;br /&gt;
wget popgen.dk/software/download/NGSadmix/data/Demo2pop.info&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Execute [[NgsAdmix |NGSadmix]] to obtain admixture proportions&lt;br /&gt;
&amp;lt;pre&amp;gt;./NGSadmix -likes Demo2input.gz -K 3 -P 20 -o myoutfiles -minMaf 0.05&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
::Input file = Demo2input.gz&lt;br /&gt;
::Ancestral Populations K=3&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
::Output prefix = myoutfiles (-o myoutfiles) &lt;br /&gt;
::SNPs with MAF &amp;gt; 5%  (-minMaf 0.05)&lt;br /&gt;
&lt;br /&gt;
Run evalAdmix&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix -beagle Demo2input.gz -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 20 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
::Genotype likelihoods file Demo2input.gz (-beagle Demo2input.gz).&lt;br /&gt;
::Ancestral Populations frequency file myoutfiles.fopt.gz (-fname myoutfiles.fopt.gz).&lt;br /&gt;
::Admixture proportions file  myoutfiles.qopt(-qname myoutfiles.qopt).&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
&lt;br /&gt;
Plot results in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source(&amp;quot;visFuns.R&amp;quot;)&lt;br /&gt;
# read population labels and estimated admixture proportions&lt;br /&gt;
pop&amp;lt;-read.table(&amp;quot;Demo2pop.info&amp;quot;,as.is=T)&lt;br /&gt;
q&amp;lt;-read.table(&amp;quot;myoutfiles.qopt&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# order according to population and plot the NGSadmix reults&lt;br /&gt;
ord&amp;lt;-orderInds(pop = as.vector(pop[,1]), q = q)&lt;br /&gt;
barplot(t(q)[,ord],col=2:10,space=0,border=NA,xlab=&amp;quot;Individuals&amp;quot;,ylab=&amp;quot;Demo2 Admixture proportions for K=3&amp;quot;)&lt;br /&gt;
text(tapply(1:nrow(pop),pop[ord,1],mean),-0.05,unique(pop[ord,1]),xpd=T)&lt;br /&gt;
abline(v=cumsum(sapply(unique(pop[ord,1]),function(x){sum(pop[ord,1]==x)})),col=1,lwd=1.2)&lt;br /&gt;
&lt;br /&gt;
r&amp;lt;-read.table(&amp;quot;output.corres.txt&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Plot correlation of residuals&lt;br /&gt;
&lt;br /&gt;
plotCorRes(cor_mat = r, pop = as.vector(pop[,1]), ord = ord, title=&amp;quot;Evaluation of 1000G admixture proportions with K=3&amp;quot;, max_z=0.1, min_z=-0.1)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Citation==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[https://doi.org/10.1111/1755-0998.13171 Evaluation of Model Fit of Inferred Admixture Proportions]&lt;/div&gt;</summary>
		<author><name>Genis</name></author>
	</entry>
	<entry>
		<id>https://www.popgen.dk/software/index.php?title=EvalAdmix&amp;diff=1461</id>
		<title>EvalAdmix</title>
		<link rel="alternate" type="text/html" href="https://www.popgen.dk/software/index.php?title=EvalAdmix&amp;diff=1461"/>
		<updated>2021-03-08T09:26:34Z</updated>

		<summary type="html">&lt;p&gt;Genis: /* Quick start */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;evalAdmix allows to evaluate the results of an admixture analysis (i.e. the result of applying [https://genome.cshlp.org/content/19/9/1655.long ADMIXTURE], [https://web.stanford.edu/group/pritchardlab/structure.html STRUCTURE], [http://www.popgen.dk/software/index.php/NgsAdmix NGSadmix] and similar). It only needs the input genotype data used for the previous admixture analysis and the output of that analysis (admixture proportions and ancestral population frequencies). The genotype input data can either be called genotypes in [https://www.cog-genomics.org/plink/1.9/formats#bed binary plink format] or genotype likelihoods in [http://www.popgen.dk/angsd/index.php/Genotype_Likelihoods#Beagle_format beagle format].&lt;br /&gt;
&lt;br /&gt;
The output is a pairwise correlation of residuals matrix between individuals. The correlation will be close to 0 in case of a good fit of the data to the admixture model. When individuals do not fit the model, individuals with similar demographic histories (i.e. usually individuals from the same population) will be positively correlated; and individuals with different histories but that are modelled as sharing one or more ancestral populations as admixture sources will have a negative correlation. Positive correlation between a pair of individuals might also be due to relatedness.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:evalAdmix.png|thumb|550px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Download and Installation==&lt;br /&gt;
&lt;br /&gt;
evalAdmix can be installed from [https://github.com/GenisGE/evalAdmix github] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;git clone https://github.com/GenisGE/evalAdmix.git&lt;br /&gt;
cd evalAdmix&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Quick start==&lt;br /&gt;
:&amp;lt;code&amp;gt; ./evalAdmix -beagle inputBeagleFile.gz  -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -o evaladmixOut.corres -P 10  &amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt; ./evalAdmix -plink inputPlinkPrefix  -fname inputPlinkPrefix.K.P -qname inputPlinkPrefix.K.Q -o evaladmixOut.corres -P 10  &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''-beagle''' beagle file of genotype likelihoods&lt;br /&gt;
* '''-plink''' binary plink file prefix with genotype data&lt;br /&gt;
* '''-fname''' file with ancestral frequencies (space delimited, rows are sites and columns ancestral populations)&lt;br /&gt;
* '''-qname''' file with admixture proportions (space delimited, rows are individuals and columns ancestral populations)&lt;br /&gt;
* '''-o''' prefix of output file names&lt;br /&gt;
* '''-P''' Number of threads used&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix  &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Arguments:&lt;br /&gt;
	Required:&lt;br /&gt;
		-plink path to binary plink file (excluding the .bed)&lt;br /&gt;
		or&lt;br /&gt;
	      	-beagle path to beagle file containing genotype likelihoods (alternative to -plink)&lt;br /&gt;
		&lt;br /&gt;
		-fname path to ancestral population frequencies file&lt;br /&gt;
	       	-qname path to admixture proportions file&lt;br /&gt;
		&lt;br /&gt;
	Optional:       &lt;br /&gt;
	&lt;br /&gt;
	       -o name of the output file&lt;br /&gt;
	       &lt;br /&gt;
	 Setup (optional):&lt;br /&gt;
	 &lt;br /&gt;
	       -P 1 number of threads&lt;br /&gt;
	       -autosomeMax 23	 autosome ends with this chromsome&lt;br /&gt;
	       -nIts 5	 number of iterations to do for frequency correction; if set to 0 calculates correlation without correction (fast but biased)&lt;br /&gt;
	       -useSites 1.0	 proportion of sites to use to calculate correlation of residuals&lt;br /&gt;
	       -useInds filename     path to tab delimited file with first column containing all individuals ID and second column with 1 to include individual in analysis and 0 otherwise (default all individuals are included)&lt;br /&gt;
	       -misTol 0.05 	 tolerance for considering site as missing when using genotype likelihoods. Use same value as used in NGSadmix to keep compatibility when using genotype likelihoods (-beagle)&lt;br /&gt;
	       -minMaf 0.05 	 minimum minor allele frequency to keep site. Use same value as used in NGSadmix to keep compatibility when using genotype likelihoods (-beagle)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Input Files==&lt;br /&gt;
&lt;br /&gt;
===Plink===&lt;br /&gt;
Genotype data files in binary PLINK format (.bed .fam .bim).&lt;br /&gt;
===Beagle genotype likelhoods===&lt;br /&gt;
The input file contains genotype likelihoods in a .beagle file format [http://faculty.washington.edu/browning/beagle/beagle.html].&lt;br /&gt;
and can be compressed with gzip.&lt;br /&gt;
==== BAM files  ====&lt;br /&gt;
If you have BAM files you can use [[ANGSD]] to produce genotype likelihoods in .beagle format. Please &lt;br /&gt;
see [http://www.popgen.dk/angsd/index.php/Beagle_input Creation of Beagle files with ANGSD]&lt;br /&gt;
&lt;br /&gt;
==== VCF files ====&lt;br /&gt;
If you already have made a VCF file that contains genotype likehood information then  it should be possible to convert .vcf files with genotype likelihoods to .beagle file via vcftools [https://vcftools.github.io/man_latest.html] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vcftools --vcf input.vcf --out test --BEAGLE-GL --chr 1,2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Chromosome has to be specified.&lt;br /&gt;
&lt;br /&gt;
You can also use bcftools' [https://samtools.github.io/bcftools/bcftools.html] 'query' option for generating a .beagle file from a .vcf file.&lt;br /&gt;
&lt;br /&gt;
==Output File==&lt;br /&gt;
The analysis performed by evalAdmix produces one file, containing a tab delimited N times N symmetric correlation matrix, where column i in line j contains the correlation of residuals between individual i and j, and the diagonal values (self-correlation) are set to NA:&lt;br /&gt;
&lt;br /&gt;
NA      0.008609        -0.006919       0.002731        0.020224&amp;lt;br /&amp;gt;&lt;br /&gt;
0.008609        NA      0.000033        0.004968        -0.008470&amp;lt;br /&amp;gt;&lt;br /&gt;
-0.006919       0.000033        NA      0.006982        0.005664&amp;lt;br /&amp;gt;&lt;br /&gt;
0.002731        0.004968        0.006982        NA      0.000521&amp;lt;br /&amp;gt;&lt;br /&gt;
0.020224        -0.008470       0.005664        0.000521        NA&lt;br /&gt;
&lt;br /&gt;
==Run command example==&lt;br /&gt;
&lt;br /&gt;
=== Genotype data ===&lt;br /&gt;
Download the input file containing genotypes in binary plink format&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.bed&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.bim&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.fam&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run ADMIXTURE [http://software.genetics.ucla.edu/admixture/] to obtain admixture proprotions&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;admixture admixTjeck2.bed 3&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
::Genotypes file prefix admixTjeck2.bed&lt;br /&gt;
::Ancestral Populations K = 3&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Run evalAdmix&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix -plink admixTjeck2 -fname admixTjeck2.3.P -qname admixTjeck2.3.Q -P 20 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
::Genotypes file prefix admixTjeck2 (-plink admixTjeck2).&lt;br /&gt;
::Ancestral Populations frequency file admixTjeck2.3.P (-fname admixTjeck2.3.P).&lt;br /&gt;
::Admixture proportions file admixTjeck2.3.Q (-qname admixTjeck2.3.Q).&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
&lt;br /&gt;
Plot results in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source(&amp;quot;visFuns.R&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# read population labels and estimated admixture proportions&lt;br /&gt;
pop&amp;lt;-read.table(&amp;quot;admixTjeck2.fam&amp;quot;)&lt;br /&gt;
q&amp;lt;-read.table(&amp;quot;admixTjeck2.3.Q&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# order according to population and plot the ADMIXTURE reults&lt;br /&gt;
ord&amp;lt;-orderInds(pop = as.vector(pop[,2]), q = q)&lt;br /&gt;
barplot(t(q)[,ord],col=2:10,space=0,border=NA,xlab=&amp;quot;Individuals&amp;quot;,ylab=&amp;quot;Demo2 Admixture proportions for K=3&amp;quot;)&lt;br /&gt;
text(tapply(1:nrow(pop),pop[ord,2],mean),-0.05,unique(pop[ord,2]),xpd=T)&lt;br /&gt;
abline(v=cumsum(sapply(unique(pop[ord,2]),function(x){sum(pop[ord,2]==x)})),col=1,lwd=1.2)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
r&amp;lt;-as.matrix(read.table(&amp;quot;output.corres.txt&amp;quot;))&lt;br /&gt;
&lt;br /&gt;
# Plot correlation of residuals&lt;br /&gt;
plotCorRes(cor_mat = r, pop = as.vector(pop[,2]), ord=ord, title=&amp;quot;Evaluation of 1000G admixture proportions with K=3&amp;quot;, max_z=0.1, min_z=-0.1)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Low depth sequencing data ===&lt;br /&gt;
Download the input file containing genotype likelihoods in beagle format&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget popgen.dk/software/download/NGSadmix/data/Demo2input.gz&lt;br /&gt;
wget popgen.dk/software/download/NGSadmix/data/Demo2pop.info&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Execute [[NgsAdmix |NGSadmix]] to obtain admixture proportions&lt;br /&gt;
&amp;lt;pre&amp;gt;./NGSadmix -likes Demo2input.gz -K 3 -P 20 -o myoutfiles -minMaf 0.05&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
::Input file = Demo2input.gz&lt;br /&gt;
::Ancestral Populations K=3&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
::Output prefix = myoutfiles (-o myoutfiles) &lt;br /&gt;
::SNPs with MAF &amp;gt; 5%  (-minMaf 0.05)&lt;br /&gt;
&lt;br /&gt;
Run evalAdmix&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix -beagle Demo2input.gz -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 20 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
::Genotype likelihoods file Demo2input.gz (-beagle Demo2input.gz).&lt;br /&gt;
::Ancestral Populations frequency file myoutfiles.fopt.gz (-fname myoutfiles.fopt.gz).&lt;br /&gt;
::Admixture proportions file  myoutfiles.qopt(-qname myoutfiles.qopt).&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
&lt;br /&gt;
Plot results in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source(&amp;quot;visFuns.R&amp;quot;)&lt;br /&gt;
# read population labels and estimated admixture proportions&lt;br /&gt;
pop&amp;lt;-read.table(&amp;quot;Demo2pop.info&amp;quot;,as.is=T)&lt;br /&gt;
q&amp;lt;-read.table(&amp;quot;myoutfiles.qopt&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# order according to population and plot the NGSadmix reults&lt;br /&gt;
ord&amp;lt;-orderInds(pop = as.vector(pop[,1]), q = q)&lt;br /&gt;
barplot(t(q)[,ord],col=2:10,space=0,border=NA,xlab=&amp;quot;Individuals&amp;quot;,ylab=&amp;quot;Demo2 Admixture proportions for K=3&amp;quot;)&lt;br /&gt;
text(tapply(1:nrow(pop),pop[ord,1],mean),-0.05,unique(pop[ord,1]),xpd=T)&lt;br /&gt;
abline(v=cumsum(sapply(unique(pop[ord,1]),function(x){sum(pop[ord,1]==x)})),col=1,lwd=1.2)&lt;br /&gt;
&lt;br /&gt;
r&amp;lt;-read.table(&amp;quot;output.corres.txt&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Plot correlation of residuals&lt;br /&gt;
&lt;br /&gt;
plotCorRes(cor_mat = r, pop = as.vector(pop[,1]), ord = ord, title=&amp;quot;Evaluation of 1000G admixture proportions with K=3&amp;quot;, max_z=0.1, min_z=-0.1)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Citation==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[https://doi.org/10.1111/1755-0998.13171 Evaluation of Model Fit of Inferred Admixture Proportions]&lt;/div&gt;</summary>
		<author><name>Genis</name></author>
	</entry>
	<entry>
		<id>https://www.popgen.dk/software/index.php?title=EvalAdmix&amp;diff=1460</id>
		<title>EvalAdmix</title>
		<link rel="alternate" type="text/html" href="https://www.popgen.dk/software/index.php?title=EvalAdmix&amp;diff=1460"/>
		<updated>2021-03-08T09:24:50Z</updated>

		<summary type="html">&lt;p&gt;Genis: /* Quick start */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;evalAdmix allows to evaluate the results of an admixture analysis (i.e. the result of applying [https://genome.cshlp.org/content/19/9/1655.long ADMIXTURE], [https://web.stanford.edu/group/pritchardlab/structure.html STRUCTURE], [http://www.popgen.dk/software/index.php/NgsAdmix NGSadmix] and similar). It only needs the input genotype data used for the previous admixture analysis and the output of that analysis (admixture proportions and ancestral population frequencies). The genotype input data can either be called genotypes in [https://www.cog-genomics.org/plink/1.9/formats#bed binary plink format] or genotype likelihoods in [http://www.popgen.dk/angsd/index.php/Genotype_Likelihoods#Beagle_format beagle format].&lt;br /&gt;
&lt;br /&gt;
The output is a pairwise correlation of residuals matrix between individuals. The correlation will be close to 0 in case of a good fit of the data to the admixture model. When individuals do not fit the model, individuals with similar demographic histories (i.e. usually individuals from the same population) will be positively correlated; and individuals with different histories but that are modelled as sharing one or more ancestral populations as admixture sources will have a negative correlation. Positive correlation between a pair of individuals might also be due to relatedness.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:evalAdmix.png|thumb|550px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Download and Installation==&lt;br /&gt;
&lt;br /&gt;
evalAdmix can be installed from [https://github.com/GenisGE/evalAdmix github] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;git clone https://github.com/GenisGE/evalAdmix.git&lt;br /&gt;
cd evalAdmix&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Quick start==&lt;br /&gt;
:&amp;lt;code&amp;gt; ./evalAdmix -beagle inputBeagleFile.gz  -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -o evaladmixOut -P 10  &amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt; ./evalAdmix -plink inputPlinkPrefix  -fname inputPlinkPrefix.K.P -qname inputPlinkPrefix.K.Q -o evaladmixOut -P 10  &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''-beagle''' beagle file of genotype likelihoods&lt;br /&gt;
* '''-plink''' binary plink file prefix with genotype data&lt;br /&gt;
* '''-fname''' file with ancestral frequencies (space delimited, rows are sites and columns ancestral populations)&lt;br /&gt;
* '''-qname''' file with admixture proportions (space delimited, rows are individuals and columns ancestral populations)&lt;br /&gt;
* '''-o''' prefix of output file names&lt;br /&gt;
* '''-P''' Number of threads used&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix  &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Arguments:&lt;br /&gt;
	Required:&lt;br /&gt;
		-plink path to binary plink file (excluding the .bed)&lt;br /&gt;
		or&lt;br /&gt;
	      	-beagle path to beagle file containing genotype likelihoods (alternative to -plink)&lt;br /&gt;
		&lt;br /&gt;
		-fname path to ancestral population frequencies file&lt;br /&gt;
	       	-qname path to admixture proportions file&lt;br /&gt;
		&lt;br /&gt;
	Optional:       &lt;br /&gt;
	&lt;br /&gt;
	       -o name of the output file&lt;br /&gt;
	       &lt;br /&gt;
	 Setup (optional):&lt;br /&gt;
	 &lt;br /&gt;
	       -P 1 number of threads&lt;br /&gt;
	       -autosomeMax 23	 autosome ends with this chromsome&lt;br /&gt;
	       -nIts 5	 number of iterations to do for frequency correction; if set to 0 calculates correlation without correction (fast but biased)&lt;br /&gt;
	       -useSites 1.0	 proportion of sites to use to calculate correlation of residuals&lt;br /&gt;
	       -useInds filename     path to tab delimited file with first column containing all individuals ID and second column with 1 to include individual in analysis and 0 otherwise (default all individuals are included)&lt;br /&gt;
	       -misTol 0.05 	 tolerance for considering site as missing when using genotype likelihoods. Use same value as used in NGSadmix to keep compatibility when using genotype likelihoods (-beagle)&lt;br /&gt;
	       -minMaf 0.05 	 minimum minor allele frequency to keep site. Use same value as used in NGSadmix to keep compatibility when using genotype likelihoods (-beagle)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Input Files==&lt;br /&gt;
&lt;br /&gt;
===Plink===&lt;br /&gt;
Genotype data files in binary PLINK format (.bed .fam .bim).&lt;br /&gt;
===Beagle genotype likelhoods===&lt;br /&gt;
The input file contains genotype likelihoods in a .beagle file format [http://faculty.washington.edu/browning/beagle/beagle.html].&lt;br /&gt;
and can be compressed with gzip.&lt;br /&gt;
==== BAM files  ====&lt;br /&gt;
If you have BAM files you can use [[ANGSD]] to produce genotype likelihoods in .beagle format. Please &lt;br /&gt;
see [http://www.popgen.dk/angsd/index.php/Beagle_input Creation of Beagle files with ANGSD]&lt;br /&gt;
&lt;br /&gt;
==== VCF files ====&lt;br /&gt;
If you already have made a VCF file that contains genotype likehood information then  it should be possible to convert .vcf files with genotype likelihoods to .beagle file via vcftools [https://vcftools.github.io/man_latest.html] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vcftools --vcf input.vcf --out test --BEAGLE-GL --chr 1,2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Chromosome has to be specified.&lt;br /&gt;
&lt;br /&gt;
You can also use bcftools' [https://samtools.github.io/bcftools/bcftools.html] 'query' option for generating a .beagle file from a .vcf file.&lt;br /&gt;
&lt;br /&gt;
==Output File==&lt;br /&gt;
The analysis performed by evalAdmix produces one file, containing a tab delimited N times N symmetric correlation matrix, where column i in line j contains the correlation of residuals between individual i and j, and the diagonal values (self-correlation) are set to NA:&lt;br /&gt;
&lt;br /&gt;
NA      0.008609        -0.006919       0.002731        0.020224&amp;lt;br /&amp;gt;&lt;br /&gt;
0.008609        NA      0.000033        0.004968        -0.008470&amp;lt;br /&amp;gt;&lt;br /&gt;
-0.006919       0.000033        NA      0.006982        0.005664&amp;lt;br /&amp;gt;&lt;br /&gt;
0.002731        0.004968        0.006982        NA      0.000521&amp;lt;br /&amp;gt;&lt;br /&gt;
0.020224        -0.008470       0.005664        0.000521        NA&lt;br /&gt;
&lt;br /&gt;
==Run command example==&lt;br /&gt;
&lt;br /&gt;
=== Genotype data ===&lt;br /&gt;
Download the input file containing genotypes in binary plink format&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.bed&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.bim&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.fam&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run ADMIXTURE [http://software.genetics.ucla.edu/admixture/] to obtain admixture proprotions&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;admixture admixTjeck2.bed 3&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
::Genotypes file prefix admixTjeck2.bed&lt;br /&gt;
::Ancestral Populations K = 3&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Run evalAdmix&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix -plink admixTjeck2 -fname admixTjeck2.3.P -qname admixTjeck2.3.Q -P 20 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
::Genotypes file prefix admixTjeck2 (-plink admixTjeck2).&lt;br /&gt;
::Ancestral Populations frequency file admixTjeck2.3.P (-fname admixTjeck2.3.P).&lt;br /&gt;
::Admixture proportions file admixTjeck2.3.Q (-qname admixTjeck2.3.Q).&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
&lt;br /&gt;
Plot results in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source(&amp;quot;visFuns.R&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# read population labels and estimated admixture proportions&lt;br /&gt;
pop&amp;lt;-read.table(&amp;quot;admixTjeck2.fam&amp;quot;)&lt;br /&gt;
q&amp;lt;-read.table(&amp;quot;admixTjeck2.3.Q&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# order according to population and plot the ADMIXTURE reults&lt;br /&gt;
ord&amp;lt;-orderInds(pop = as.vector(pop[,2]), q = q)&lt;br /&gt;
barplot(t(q)[,ord],col=2:10,space=0,border=NA,xlab=&amp;quot;Individuals&amp;quot;,ylab=&amp;quot;Demo2 Admixture proportions for K=3&amp;quot;)&lt;br /&gt;
text(tapply(1:nrow(pop),pop[ord,2],mean),-0.05,unique(pop[ord,2]),xpd=T)&lt;br /&gt;
abline(v=cumsum(sapply(unique(pop[ord,2]),function(x){sum(pop[ord,2]==x)})),col=1,lwd=1.2)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
r&amp;lt;-as.matrix(read.table(&amp;quot;output.corres.txt&amp;quot;))&lt;br /&gt;
&lt;br /&gt;
# Plot correlation of residuals&lt;br /&gt;
plotCorRes(cor_mat = r, pop = as.vector(pop[,2]), ord=ord, title=&amp;quot;Evaluation of 1000G admixture proportions with K=3&amp;quot;, max_z=0.1, min_z=-0.1)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Low depth sequencing data ===&lt;br /&gt;
Download the input file containing genotype likelihoods in beagle format&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget popgen.dk/software/download/NGSadmix/data/Demo2input.gz&lt;br /&gt;
wget popgen.dk/software/download/NGSadmix/data/Demo2pop.info&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Execute [[NgsAdmix |NGSadmix]] to obtain admixture proportions&lt;br /&gt;
&amp;lt;pre&amp;gt;./NGSadmix -likes Demo2input.gz -K 3 -P 20 -o myoutfiles -minMaf 0.05&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
::Input file = Demo2input.gz&lt;br /&gt;
::Ancestral Populations K=3&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
::Output prefix = myoutfiles (-o myoutfiles) &lt;br /&gt;
::SNPs with MAF &amp;gt; 5%  (-minMaf 0.05)&lt;br /&gt;
&lt;br /&gt;
Run evalAdmix&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix -beagle Demo2input.gz -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 20 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
::Genotype likelihoods file Demo2input.gz (-beagle Demo2input.gz).&lt;br /&gt;
::Ancestral Populations frequency file myoutfiles.fopt.gz (-fname myoutfiles.fopt.gz).&lt;br /&gt;
::Admixture proportions file  myoutfiles.qopt(-qname myoutfiles.qopt).&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
&lt;br /&gt;
Plot results in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source(&amp;quot;visFuns.R&amp;quot;)&lt;br /&gt;
# read population labels and estimated admixture proportions&lt;br /&gt;
pop&amp;lt;-read.table(&amp;quot;Demo2pop.info&amp;quot;,as.is=T)&lt;br /&gt;
q&amp;lt;-read.table(&amp;quot;myoutfiles.qopt&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# order according to population and plot the NGSadmix reults&lt;br /&gt;
ord&amp;lt;-orderInds(pop = as.vector(pop[,1]), q = q)&lt;br /&gt;
barplot(t(q)[,ord],col=2:10,space=0,border=NA,xlab=&amp;quot;Individuals&amp;quot;,ylab=&amp;quot;Demo2 Admixture proportions for K=3&amp;quot;)&lt;br /&gt;
text(tapply(1:nrow(pop),pop[ord,1],mean),-0.05,unique(pop[ord,1]),xpd=T)&lt;br /&gt;
abline(v=cumsum(sapply(unique(pop[ord,1]),function(x){sum(pop[ord,1]==x)})),col=1,lwd=1.2)&lt;br /&gt;
&lt;br /&gt;
r&amp;lt;-read.table(&amp;quot;output.corres.txt&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Plot correlation of residuals&lt;br /&gt;
&lt;br /&gt;
plotCorRes(cor_mat = r, pop = as.vector(pop[,1]), ord = ord, title=&amp;quot;Evaluation of 1000G admixture proportions with K=3&amp;quot;, max_z=0.1, min_z=-0.1)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Citation==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[https://doi.org/10.1111/1755-0998.13171 Evaluation of Model Fit of Inferred Admixture Proportions]&lt;/div&gt;</summary>
		<author><name>Genis</name></author>
	</entry>
	<entry>
		<id>https://www.popgen.dk/software/index.php?title=EvalAdmix&amp;diff=1459</id>
		<title>EvalAdmix</title>
		<link rel="alternate" type="text/html" href="https://www.popgen.dk/software/index.php?title=EvalAdmix&amp;diff=1459"/>
		<updated>2021-03-08T09:24:11Z</updated>

		<summary type="html">&lt;p&gt;Genis: /* Quick start */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;evalAdmix allows to evaluate the results of an admixture analysis (i.e. the result of applying [https://genome.cshlp.org/content/19/9/1655.long ADMIXTURE], [https://web.stanford.edu/group/pritchardlab/structure.html STRUCTURE], [http://www.popgen.dk/software/index.php/NgsAdmix NGSadmix] and similar). It only needs the input genotype data used for the previous admixture analysis and the output of that analysis (admixture proportions and ancestral population frequencies). The genotype input data can either be called genotypes in [https://www.cog-genomics.org/plink/1.9/formats#bed binary plink format] or genotype likelihoods in [http://www.popgen.dk/angsd/index.php/Genotype_Likelihoods#Beagle_format beagle format].&lt;br /&gt;
&lt;br /&gt;
The output is a pairwise correlation of residuals matrix between individuals. The correlation will be close to 0 in case of a good fit of the data to the admixture model. When individuals do not fit the model, individuals with similar demographic histories (i.e. usually individuals from the same population) will be positively correlated; and individuals with different histories but that are modelled as sharing one or more ancestral populations as admixture sources will have a negative correlation. Positive correlation between a pair of individuals might also be due to relatedness.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:evalAdmix.png|thumb|550px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Download and Installation==&lt;br /&gt;
&lt;br /&gt;
evalAdmix can be installed from [https://github.com/GenisGE/evalAdmix github] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;git clone https://github.com/GenisGE/evalAdmix.git&lt;br /&gt;
cd evalAdmix&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Quick start==&lt;br /&gt;
:&amp;lt;code&amp;gt; ./evalAdmix -beagle inputBeagleFile.gz  -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -o evaladmixOut -P 10  &amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt; ./evalAdmix -plink inputPlinkPrefix  -fname inputPlinkPrefix.K.F -qname inputPlinkPrefix.K.Q -o evaladmixOut -P 10  &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''-beagle''' beagle file of genotype likelihoods&lt;br /&gt;
* '''-plink''' binary plink file prefix with genotype data&lt;br /&gt;
* '''-fname''' file with ancestral frequencies (space delimited, rows are sites and columns ancestral populations)&lt;br /&gt;
* '''-qname''' file with admixture proportions (space delimited, rows are individuals and columns ancestral populations)&lt;br /&gt;
* '''-o''' prefix of output file names&lt;br /&gt;
* '''-P''' Number of threads used&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix  &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Arguments:&lt;br /&gt;
	Required:&lt;br /&gt;
		-plink path to binary plink file (excluding the .bed)&lt;br /&gt;
		or&lt;br /&gt;
	      	-beagle path to beagle file containing genotype likelihoods (alternative to -plink)&lt;br /&gt;
		&lt;br /&gt;
		-fname path to ancestral population frequencies file&lt;br /&gt;
	       	-qname path to admixture proportions file&lt;br /&gt;
		&lt;br /&gt;
	Optional:       &lt;br /&gt;
	&lt;br /&gt;
	       -o name of the output file&lt;br /&gt;
	       &lt;br /&gt;
	 Setup (optional):&lt;br /&gt;
	 &lt;br /&gt;
	       -P 1 number of threads&lt;br /&gt;
	       -autosomeMax 23	 autosome ends with this chromsome&lt;br /&gt;
	       -nIts 5	 number of iterations to do for frequency correction; if set to 0 calculates correlation without correction (fast but biased)&lt;br /&gt;
	       -useSites 1.0	 proportion of sites to use to calculate correlation of residuals&lt;br /&gt;
	       -useInds filename     path to tab delimited file with first column containing all individuals ID and second column with 1 to include individual in analysis and 0 otherwise (default all individuals are included)&lt;br /&gt;
	       -misTol 0.05 	 tolerance for considering site as missing when using genotype likelihoods. Use same value as used in NGSadmix to keep compatibility when using genotype likelihoods (-beagle)&lt;br /&gt;
	       -minMaf 0.05 	 minimum minor allele frequency to keep site. Use same value as used in NGSadmix to keep compatibility when using genotype likelihoods (-beagle)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Input Files==&lt;br /&gt;
&lt;br /&gt;
===Plink===&lt;br /&gt;
Genotype data files in binary PLINK format (.bed .fam .bim).&lt;br /&gt;
===Beagle genotype likelhoods===&lt;br /&gt;
The input file contains genotype likelihoods in a .beagle file format [http://faculty.washington.edu/browning/beagle/beagle.html].&lt;br /&gt;
and can be compressed with gzip.&lt;br /&gt;
==== BAM files  ====&lt;br /&gt;
If you have BAM files you can use [[ANGSD]] to produce genotype likelihoods in .beagle format. Please &lt;br /&gt;
see [http://www.popgen.dk/angsd/index.php/Beagle_input Creation of Beagle files with ANGSD]&lt;br /&gt;
&lt;br /&gt;
==== VCF files ====&lt;br /&gt;
If you already have made a VCF file that contains genotype likehood information then  it should be possible to convert .vcf files with genotype likelihoods to .beagle file via vcftools [https://vcftools.github.io/man_latest.html] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vcftools --vcf input.vcf --out test --BEAGLE-GL --chr 1,2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Chromosome has to be specified.&lt;br /&gt;
&lt;br /&gt;
You can also use bcftools' [https://samtools.github.io/bcftools/bcftools.html] 'query' option for generating a .beagle file from a .vcf file.&lt;br /&gt;
&lt;br /&gt;
==Output File==&lt;br /&gt;
The analysis performed by evalAdmix produces one file, containing a tab delimited N times N symmetric correlation matrix, where column i in line j contains the correlation of residuals between individual i and j, and the diagonal values (self-correlation) are set to NA:&lt;br /&gt;
&lt;br /&gt;
NA      0.008609        -0.006919       0.002731        0.020224&amp;lt;br /&amp;gt;&lt;br /&gt;
0.008609        NA      0.000033        0.004968        -0.008470&amp;lt;br /&amp;gt;&lt;br /&gt;
-0.006919       0.000033        NA      0.006982        0.005664&amp;lt;br /&amp;gt;&lt;br /&gt;
0.002731        0.004968        0.006982        NA      0.000521&amp;lt;br /&amp;gt;&lt;br /&gt;
0.020224        -0.008470       0.005664        0.000521        NA&lt;br /&gt;
&lt;br /&gt;
==Run command example==&lt;br /&gt;
&lt;br /&gt;
=== Genotype data ===&lt;br /&gt;
Download the input file containing genotypes in binary plink format&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.bed&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.bim&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.fam&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run ADMIXTURE [http://software.genetics.ucla.edu/admixture/] to obtain admixture proprotions&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;admixture admixTjeck2.bed 3&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
::Genotypes file prefix admixTjeck2.bed&lt;br /&gt;
::Ancestral Populations K = 3&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Run evalAdmix&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix -plink admixTjeck2 -fname admixTjeck2.3.P -qname admixTjeck2.3.Q -P 20 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
::Genotypes file prefix admixTjeck2 (-plink admixTjeck2).&lt;br /&gt;
::Ancestral Populations frequency file admixTjeck2.3.P (-fname admixTjeck2.3.P).&lt;br /&gt;
::Admixture proportions file admixTjeck2.3.Q (-qname admixTjeck2.3.Q).&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
&lt;br /&gt;
Plot results in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source(&amp;quot;visFuns.R&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# read population labels and estimated admixture proportions&lt;br /&gt;
pop&amp;lt;-read.table(&amp;quot;admixTjeck2.fam&amp;quot;)&lt;br /&gt;
q&amp;lt;-read.table(&amp;quot;admixTjeck2.3.Q&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# order according to population and plot the ADMIXTURE reults&lt;br /&gt;
ord&amp;lt;-orderInds(pop = as.vector(pop[,2]), q = q)&lt;br /&gt;
barplot(t(q)[,ord],col=2:10,space=0,border=NA,xlab=&amp;quot;Individuals&amp;quot;,ylab=&amp;quot;Demo2 Admixture proportions for K=3&amp;quot;)&lt;br /&gt;
text(tapply(1:nrow(pop),pop[ord,2],mean),-0.05,unique(pop[ord,2]),xpd=T)&lt;br /&gt;
abline(v=cumsum(sapply(unique(pop[ord,2]),function(x){sum(pop[ord,2]==x)})),col=1,lwd=1.2)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
r&amp;lt;-as.matrix(read.table(&amp;quot;output.corres.txt&amp;quot;))&lt;br /&gt;
&lt;br /&gt;
# Plot correlation of residuals&lt;br /&gt;
plotCorRes(cor_mat = r, pop = as.vector(pop[,2]), ord=ord, title=&amp;quot;Evaluation of 1000G admixture proportions with K=3&amp;quot;, max_z=0.1, min_z=-0.1)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Low depth sequencing data ===&lt;br /&gt;
Download the input file containing genotype likelihoods in beagle format&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget popgen.dk/software/download/NGSadmix/data/Demo2input.gz&lt;br /&gt;
wget popgen.dk/software/download/NGSadmix/data/Demo2pop.info&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Execute [[NgsAdmix |NGSadmix]] to obtain admixture proportions&lt;br /&gt;
&amp;lt;pre&amp;gt;./NGSadmix -likes Demo2input.gz -K 3 -P 20 -o myoutfiles -minMaf 0.05&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
::Input file = Demo2input.gz&lt;br /&gt;
::Ancestral Populations K=3&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
::Output prefix = myoutfiles (-o myoutfiles) &lt;br /&gt;
::SNPs with MAF &amp;gt; 5%  (-minMaf 0.05)&lt;br /&gt;
&lt;br /&gt;
Run evalAdmix&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix -beagle Demo2input.gz -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 20 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
::Genotype likelihoods file Demo2input.gz (-beagle Demo2input.gz).&lt;br /&gt;
::Ancestral Populations frequency file myoutfiles.fopt.gz (-fname myoutfiles.fopt.gz).&lt;br /&gt;
::Admixture proportions file  myoutfiles.qopt(-qname myoutfiles.qopt).&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
&lt;br /&gt;
Plot results in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source(&amp;quot;visFuns.R&amp;quot;)&lt;br /&gt;
# read population labels and estimated admixture proportions&lt;br /&gt;
pop&amp;lt;-read.table(&amp;quot;Demo2pop.info&amp;quot;,as.is=T)&lt;br /&gt;
q&amp;lt;-read.table(&amp;quot;myoutfiles.qopt&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# order according to population and plot the NGSadmix reults&lt;br /&gt;
ord&amp;lt;-orderInds(pop = as.vector(pop[,1]), q = q)&lt;br /&gt;
barplot(t(q)[,ord],col=2:10,space=0,border=NA,xlab=&amp;quot;Individuals&amp;quot;,ylab=&amp;quot;Demo2 Admixture proportions for K=3&amp;quot;)&lt;br /&gt;
text(tapply(1:nrow(pop),pop[ord,1],mean),-0.05,unique(pop[ord,1]),xpd=T)&lt;br /&gt;
abline(v=cumsum(sapply(unique(pop[ord,1]),function(x){sum(pop[ord,1]==x)})),col=1,lwd=1.2)&lt;br /&gt;
&lt;br /&gt;
r&amp;lt;-read.table(&amp;quot;output.corres.txt&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Plot correlation of residuals&lt;br /&gt;
&lt;br /&gt;
plotCorRes(cor_mat = r, pop = as.vector(pop[,1]), ord = ord, title=&amp;quot;Evaluation of 1000G admixture proportions with K=3&amp;quot;, max_z=0.1, min_z=-0.1)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Citation==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[https://doi.org/10.1111/1755-0998.13171 Evaluation of Model Fit of Inferred Admixture Proportions]&lt;/div&gt;</summary>
		<author><name>Genis</name></author>
	</entry>
	<entry>
		<id>https://www.popgen.dk/software/index.php?title=EvalAdmix&amp;diff=1458</id>
		<title>EvalAdmix</title>
		<link rel="alternate" type="text/html" href="https://www.popgen.dk/software/index.php?title=EvalAdmix&amp;diff=1458"/>
		<updated>2021-03-08T09:23:39Z</updated>

		<summary type="html">&lt;p&gt;Genis: /* Quick start */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;evalAdmix allows to evaluate the results of an admixture analysis (i.e. the result of applying [https://genome.cshlp.org/content/19/9/1655.long ADMIXTURE], [https://web.stanford.edu/group/pritchardlab/structure.html STRUCTURE], [http://www.popgen.dk/software/index.php/NgsAdmix NGSadmix] and similar). It only needs the input genotype data used for the previous admixture analysis and the output of that analysis (admixture proportions and ancestral population frequencies). The genotype input data can either be called genotypes in [https://www.cog-genomics.org/plink/1.9/formats#bed binary plink format] or genotype likelihoods in [http://www.popgen.dk/angsd/index.php/Genotype_Likelihoods#Beagle_format beagle format].&lt;br /&gt;
&lt;br /&gt;
The output is a pairwise correlation of residuals matrix between individuals. The correlation will be close to 0 in case of a good fit of the data to the admixture model. When individuals do not fit the model, individuals with similar demographic histories (i.e. usually individuals from the same population) will be positively correlated; and individuals with different histories but that are modelled as sharing one or more ancestral populations as admixture sources will have a negative correlation. Positive correlation between a pair of individuals might also be due to relatedness.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:evalAdmix.png|thumb|550px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Download and Installation==&lt;br /&gt;
&lt;br /&gt;
evalAdmix can be installed from [https://github.com/GenisGE/evalAdmix github] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;git clone https://github.com/GenisGE/evalAdmix.git&lt;br /&gt;
cd evalAdmix&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Quick start==&lt;br /&gt;
:&amp;lt;code&amp;gt; ./evalAdmix -beagle inputBeagleFile.gz  -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -o evaladmixOut -P 10  &amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt; ./evalAdmix -plink inputPlinkPrefix  -fname myoutfiles.F -qname myoutfiles.Q -o evaladmixOut -P 10  &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''-beagle''' beagle file of genotype likelihoods&lt;br /&gt;
* '''-plink''' binary plink file prefix with genotype data&lt;br /&gt;
* '''-fname''' file with ancestral frequencies (space delimited, rows are sites and columns ancestral populations)&lt;br /&gt;
* '''-qname''' file with admixture proportions (space delimited, rows are individuals and columns ancestral populations)&lt;br /&gt;
* '''-o''' prefix of output file names&lt;br /&gt;
* '''-P''' Number of threads used&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix  &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Arguments:&lt;br /&gt;
	Required:&lt;br /&gt;
		-plink path to binary plink file (excluding the .bed)&lt;br /&gt;
		or&lt;br /&gt;
	      	-beagle path to beagle file containing genotype likelihoods (alternative to -plink)&lt;br /&gt;
		&lt;br /&gt;
		-fname path to ancestral population frequencies file&lt;br /&gt;
	       	-qname path to admixture proportions file&lt;br /&gt;
		&lt;br /&gt;
	Optional:       &lt;br /&gt;
	&lt;br /&gt;
	       -o name of the output file&lt;br /&gt;
	       &lt;br /&gt;
	 Setup (optional):&lt;br /&gt;
	 &lt;br /&gt;
	       -P 1 number of threads&lt;br /&gt;
	       -autosomeMax 23	 autosome ends with this chromsome&lt;br /&gt;
	       -nIts 5	 number of iterations to do for frequency correction; if set to 0 calculates correlation without correction (fast but biased)&lt;br /&gt;
	       -useSites 1.0	 proportion of sites to use to calculate correlation of residuals&lt;br /&gt;
	       -useInds filename     path to tab delimited file with first column containing all individuals ID and second column with 1 to include individual in analysis and 0 otherwise (default all individuals are included)&lt;br /&gt;
	       -misTol 0.05 	 tolerance for considering site as missing when using genotype likelihoods. Use same value as used in NGSadmix to keep compatibility when using genotype likelihoods (-beagle)&lt;br /&gt;
	       -minMaf 0.05 	 minimum minor allele frequency to keep site. Use same value as used in NGSadmix to keep compatibility when using genotype likelihoods (-beagle)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Input Files==&lt;br /&gt;
&lt;br /&gt;
===Plink===&lt;br /&gt;
Genotype data files in binary PLINK format (.bed .fam .bim).&lt;br /&gt;
===Beagle genotype likelhoods===&lt;br /&gt;
The input file contains genotype likelihoods in a .beagle file format [http://faculty.washington.edu/browning/beagle/beagle.html].&lt;br /&gt;
and can be compressed with gzip.&lt;br /&gt;
==== BAM files  ====&lt;br /&gt;
If you have BAM files you can use [[ANGSD]] to produce genotype likelihoods in .beagle format. Please &lt;br /&gt;
see [http://www.popgen.dk/angsd/index.php/Beagle_input Creation of Beagle files with ANGSD]&lt;br /&gt;
&lt;br /&gt;
==== VCF files ====&lt;br /&gt;
If you already have made a VCF file that contains genotype likehood information then  it should be possible to convert .vcf files with genotype likelihoods to .beagle file via vcftools [https://vcftools.github.io/man_latest.html] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vcftools --vcf input.vcf --out test --BEAGLE-GL --chr 1,2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Chromosome has to be specified.&lt;br /&gt;
&lt;br /&gt;
You can also use bcftools' [https://samtools.github.io/bcftools/bcftools.html] 'query' option for generating a .beagle file from a .vcf file.&lt;br /&gt;
&lt;br /&gt;
==Output File==&lt;br /&gt;
The analysis performed by evalAdmix produces one file, containing a tab delimited N times N symmetric correlation matrix, where column i in line j contains the correlation of residuals between individual i and j, and the diagonal values (self-correlation) are set to NA:&lt;br /&gt;
&lt;br /&gt;
NA      0.008609        -0.006919       0.002731        0.020224&amp;lt;br /&amp;gt;&lt;br /&gt;
0.008609        NA      0.000033        0.004968        -0.008470&amp;lt;br /&amp;gt;&lt;br /&gt;
-0.006919       0.000033        NA      0.006982        0.005664&amp;lt;br /&amp;gt;&lt;br /&gt;
0.002731        0.004968        0.006982        NA      0.000521&amp;lt;br /&amp;gt;&lt;br /&gt;
0.020224        -0.008470       0.005664        0.000521        NA&lt;br /&gt;
&lt;br /&gt;
==Run command example==&lt;br /&gt;
&lt;br /&gt;
=== Genotype data ===&lt;br /&gt;
Download the input file containing genotypes in binary plink format&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.bed&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.bim&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.fam&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run ADMIXTURE [http://software.genetics.ucla.edu/admixture/] to obtain admixture proprotions&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;admixture admixTjeck2.bed 3&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
::Genotypes file prefix admixTjeck2.bed&lt;br /&gt;
::Ancestral Populations K = 3&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Run evalAdmix&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix -plink admixTjeck2 -fname admixTjeck2.3.P -qname admixTjeck2.3.Q -P 20 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
::Genotypes file prefix admixTjeck2 (-plink admixTjeck2).&lt;br /&gt;
::Ancestral Populations frequency file admixTjeck2.3.P (-fname admixTjeck2.3.P).&lt;br /&gt;
::Admixture proportions file admixTjeck2.3.Q (-qname admixTjeck2.3.Q).&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
&lt;br /&gt;
Plot results in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source(&amp;quot;visFuns.R&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# read population labels and estimated admixture proportions&lt;br /&gt;
pop&amp;lt;-read.table(&amp;quot;admixTjeck2.fam&amp;quot;)&lt;br /&gt;
q&amp;lt;-read.table(&amp;quot;admixTjeck2.3.Q&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# order according to population and plot the ADMIXTURE reults&lt;br /&gt;
ord&amp;lt;-orderInds(pop = as.vector(pop[,2]), q = q)&lt;br /&gt;
barplot(t(q)[,ord],col=2:10,space=0,border=NA,xlab=&amp;quot;Individuals&amp;quot;,ylab=&amp;quot;Demo2 Admixture proportions for K=3&amp;quot;)&lt;br /&gt;
text(tapply(1:nrow(pop),pop[ord,2],mean),-0.05,unique(pop[ord,2]),xpd=T)&lt;br /&gt;
abline(v=cumsum(sapply(unique(pop[ord,2]),function(x){sum(pop[ord,2]==x)})),col=1,lwd=1.2)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
r&amp;lt;-as.matrix(read.table(&amp;quot;output.corres.txt&amp;quot;))&lt;br /&gt;
&lt;br /&gt;
# Plot correlation of residuals&lt;br /&gt;
plotCorRes(cor_mat = r, pop = as.vector(pop[,2]), ord=ord, title=&amp;quot;Evaluation of 1000G admixture proportions with K=3&amp;quot;, max_z=0.1, min_z=-0.1)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Low depth sequencing data ===&lt;br /&gt;
Download the input file containing genotype likelihoods in beagle format&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget popgen.dk/software/download/NGSadmix/data/Demo2input.gz&lt;br /&gt;
wget popgen.dk/software/download/NGSadmix/data/Demo2pop.info&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Execute [[NgsAdmix |NGSadmix]] to obtain admixture proportions&lt;br /&gt;
&amp;lt;pre&amp;gt;./NGSadmix -likes Demo2input.gz -K 3 -P 20 -o myoutfiles -minMaf 0.05&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
::Input file = Demo2input.gz&lt;br /&gt;
::Ancestral Populations K=3&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
::Output prefix = myoutfiles (-o myoutfiles) &lt;br /&gt;
::SNPs with MAF &amp;gt; 5%  (-minMaf 0.05)&lt;br /&gt;
&lt;br /&gt;
Run evalAdmix&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix -beagle Demo2input.gz -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 20 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
::Genotype likelihoods file Demo2input.gz (-beagle Demo2input.gz).&lt;br /&gt;
::Ancestral Populations frequency file myoutfiles.fopt.gz (-fname myoutfiles.fopt.gz).&lt;br /&gt;
::Admixture proportions file  myoutfiles.qopt(-qname myoutfiles.qopt).&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
&lt;br /&gt;
Plot results in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source(&amp;quot;visFuns.R&amp;quot;)&lt;br /&gt;
# read population labels and estimated admixture proportions&lt;br /&gt;
pop&amp;lt;-read.table(&amp;quot;Demo2pop.info&amp;quot;,as.is=T)&lt;br /&gt;
q&amp;lt;-read.table(&amp;quot;myoutfiles.qopt&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# order according to population and plot the NGSadmix reults&lt;br /&gt;
ord&amp;lt;-orderInds(pop = as.vector(pop[,1]), q = q)&lt;br /&gt;
barplot(t(q)[,ord],col=2:10,space=0,border=NA,xlab=&amp;quot;Individuals&amp;quot;,ylab=&amp;quot;Demo2 Admixture proportions for K=3&amp;quot;)&lt;br /&gt;
text(tapply(1:nrow(pop),pop[ord,1],mean),-0.05,unique(pop[ord,1]),xpd=T)&lt;br /&gt;
abline(v=cumsum(sapply(unique(pop[ord,1]),function(x){sum(pop[ord,1]==x)})),col=1,lwd=1.2)&lt;br /&gt;
&lt;br /&gt;
r&amp;lt;-read.table(&amp;quot;output.corres.txt&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Plot correlation of residuals&lt;br /&gt;
&lt;br /&gt;
plotCorRes(cor_mat = r, pop = as.vector(pop[,1]), ord = ord, title=&amp;quot;Evaluation of 1000G admixture proportions with K=3&amp;quot;, max_z=0.1, min_z=-0.1)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Citation==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[https://doi.org/10.1111/1755-0998.13171 Evaluation of Model Fit of Inferred Admixture Proportions]&lt;/div&gt;</summary>
		<author><name>Genis</name></author>
	</entry>
	<entry>
		<id>https://www.popgen.dk/software/index.php?title=EvalAdmix&amp;diff=1437</id>
		<title>EvalAdmix</title>
		<link rel="alternate" type="text/html" href="https://www.popgen.dk/software/index.php?title=EvalAdmix&amp;diff=1437"/>
		<updated>2020-04-27T09:02:49Z</updated>

		<summary type="html">&lt;p&gt;Genis: /* Run command example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;evalAdmix allows to evaluate the results of an admixture analysis (i.e. the result of applying [https://genome.cshlp.org/content/19/9/1655.long ADMIXTURE], [https://web.stanford.edu/group/pritchardlab/structure.html STRUCTURE], [http://www.popgen.dk/software/index.php/NgsAdmix NGSadmix] and similar). It only needs the input genotype data used for the previous admixture analysis and the output of that analysis (admixture proportions and ancestral population frequencies). The genotype input data can either be called genotypes in [https://www.cog-genomics.org/plink/1.9/formats#bed binary plink format] or genotype likelihoods in [http://www.popgen.dk/angsd/index.php/Genotype_Likelihoods#Beagle_format beagle format].&lt;br /&gt;
&lt;br /&gt;
The output is a pairwise correlation of residuals matrix between individuals. The correlation will be close to 0 in case of a good fit of the data to the admixture model. When individuals do not fit the model, individuals with similar demographic histories (i.e. usually individuals from the same population) will be positively correlated; and individuals with different histories but that are modelled as sharing one or more ancestral populations as admixture sources will have a negative correlation. Positive correlation between a pair of individuals might also be due to relatedness.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:evalAdmix.png|thumb|550px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Download and Installation==&lt;br /&gt;
&lt;br /&gt;
evalAdmix can be installed from [https://github.com/GenisGE/evalAdmix github] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;git clone https://github.com/GenisGE/evalAdmix.git&lt;br /&gt;
cd evalAdmix&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Quick start==&lt;br /&gt;
:&amp;lt;code&amp;gt; ./evalAdmix -beagle inputBeagleFile.gz  -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 10  &amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt; ./evalAdmix -plink inputPlinkPrefix  -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 10  &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''-beagle''' beagle file of genotype likelihoods&lt;br /&gt;
* '''-plink''' binary plink file prefix with genotype data&lt;br /&gt;
* '''-fname''' file with ancestral frequencies (space delimited, rows are sites and columns ancestral populations)&lt;br /&gt;
* '''-qname''' file with admixture proportions (space delimited, rows are individuals and columns ancestral populations)&lt;br /&gt;
* '''-o''' prefix of output file names&lt;br /&gt;
* '''-P''' Number of threads used&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix  &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Arguments:&lt;br /&gt;
	Required:&lt;br /&gt;
		-plink path to binary plink file (excluding the .bed)&lt;br /&gt;
		or&lt;br /&gt;
	      	-beagle path to beagle file containing genotype likelihoods (alternative to -plink)&lt;br /&gt;
		&lt;br /&gt;
		-fname path to ancestral population frequencies file&lt;br /&gt;
	       	-qname path to admixture proportions file&lt;br /&gt;
		&lt;br /&gt;
	Optional:       &lt;br /&gt;
	&lt;br /&gt;
	       -o name of the output file&lt;br /&gt;
	       &lt;br /&gt;
	 Setup (optional):&lt;br /&gt;
	 &lt;br /&gt;
	       -P 1 number of threads&lt;br /&gt;
	       -autosomeMax 23	 autosome ends with this chromsome&lt;br /&gt;
	       -nIts 5	 number of iterations to do for frequency correction; if set to 0 calculates correlation without correction (fast but biased)&lt;br /&gt;
	       -useSites 1.0	 proportion of sites to use to calculate correlation of residuals&lt;br /&gt;
	       -useInds filename     path to tab delimited file with first column containing all individuals ID and second column with 1 to include individual in analysis and 0 otherwise (default all individuals are included)&lt;br /&gt;
	       -misTol 0.05 	 tolerance for considering site as missing when using genotype likelihoods. Use same value as used in NGSadmix to keep compatibility when using genotype likelihoods (-beagle)&lt;br /&gt;
	       -minMaf 0.05 	 minimum minor allele frequency to keep site. Use same value as used in NGSadmix to keep compatibility when using genotype likelihoods (-beagle)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Input Files==&lt;br /&gt;
&lt;br /&gt;
===Plink===&lt;br /&gt;
Genotype data files in binary PLINK format (.bed .fam .bim).&lt;br /&gt;
===Beagle genotype likelhoods===&lt;br /&gt;
The input file contains genotype likelihoods in a .beagle file format [http://faculty.washington.edu/browning/beagle/beagle.html].&lt;br /&gt;
and can be compressed with gzip.&lt;br /&gt;
==== BAM files  ====&lt;br /&gt;
If you have BAM files you can use [[ANGSD]] to produce genotype likelihoods in .beagle format. Please &lt;br /&gt;
see [http://www.popgen.dk/angsd/index.php/Beagle_input Creation of Beagle files with ANGSD]&lt;br /&gt;
&lt;br /&gt;
==== VCF files ====&lt;br /&gt;
If you already have made a VCF file that contains genotype likehood information then  it should be possible to convert .vcf files with genotype likelihoods to .beagle file via vcftools [https://vcftools.github.io/man_latest.html] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vcftools --vcf input.vcf --out test --BEAGLE-GL --chr 1,2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Chromosome has to be specified.&lt;br /&gt;
&lt;br /&gt;
You can also use bcftools' [https://samtools.github.io/bcftools/bcftools.html] 'query' option for generating a .beagle file from a .vcf file.&lt;br /&gt;
&lt;br /&gt;
==Output File==&lt;br /&gt;
The analysis performed by evalAdmix produces one file, containing a tab delimited N times N symmetric correlation matrix, where column i in line j contains the correlation of residuals between individual i and j, and the diagonal values (self-correlation) are set to NA:&lt;br /&gt;
&lt;br /&gt;
NA      0.008609        -0.006919       0.002731        0.020224&amp;lt;br /&amp;gt;&lt;br /&gt;
0.008609        NA      0.000033        0.004968        -0.008470&amp;lt;br /&amp;gt;&lt;br /&gt;
-0.006919       0.000033        NA      0.006982        0.005664&amp;lt;br /&amp;gt;&lt;br /&gt;
0.002731        0.004968        0.006982        NA      0.000521&amp;lt;br /&amp;gt;&lt;br /&gt;
0.020224        -0.008470       0.005664        0.000521        NA&lt;br /&gt;
&lt;br /&gt;
==Run command example==&lt;br /&gt;
&lt;br /&gt;
=== Genotype data ===&lt;br /&gt;
Download the input file containing genotypes in binary plink format&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.bed&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.bim&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.fam&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run ADMIXTURE [http://software.genetics.ucla.edu/admixture/] to obtain admixture proprotions&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;admixture admixTjeck2.bed 3&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
::Genotypes file prefix admixTjeck2.bed&lt;br /&gt;
::Ancestral Populations K = 3&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Run evalAdmix&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix -plink admixTjeck2 -fname admixTjeck2.3.P -qname admixTjeck2.3.Q -P 20 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
::Genotypes file prefix admixTjeck2 (-plink admixTjeck2).&lt;br /&gt;
::Ancestral Populations frequency file admixTjeck2.3.P (-fname admixTjeck2.3.P).&lt;br /&gt;
::Admixture proportions file admixTjeck2.3.Q (-qname admixTjeck2.3.Q).&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
&lt;br /&gt;
Plot results in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source(&amp;quot;visFuns.R&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# read population labels and estimated admixture proportions&lt;br /&gt;
pop&amp;lt;-read.table(&amp;quot;admixTjeck2.fam&amp;quot;)&lt;br /&gt;
q&amp;lt;-read.table(&amp;quot;admixTjeck2.3.Q&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# order according to population and plot the ADMIXTURE reults&lt;br /&gt;
ord&amp;lt;-orderInds(pop = as.vector(pop[,2]), q = q)&lt;br /&gt;
barplot(t(q)[,ord],col=2:10,space=0,border=NA,xlab=&amp;quot;Individuals&amp;quot;,ylab=&amp;quot;Demo2 Admixture proportions for K=3&amp;quot;)&lt;br /&gt;
text(tapply(1:nrow(pop),pop[ord,2],mean),-0.05,unique(pop[ord,2]),xpd=T)&lt;br /&gt;
abline(v=cumsum(sapply(unique(pop[ord,2]),function(x){sum(pop[ord,2]==x)})),col=1,lwd=1.2)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
r&amp;lt;-as.matrix(read.table(&amp;quot;output.corres.txt&amp;quot;))&lt;br /&gt;
&lt;br /&gt;
# Plot correlation of residuals&lt;br /&gt;
plotCorRes(cor_mat = r, pop = as.vector(pop[,2]), ord=ord, title=&amp;quot;Evaluation of 1000G admixture proportions with K=3&amp;quot;, max_z=0.1, min_z=-0.1)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Low depth sequencing data ===&lt;br /&gt;
Download the input file containing genotype likelihoods in beagle format&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget popgen.dk/software/download/NGSadmix/data/Demo2input.gz&lt;br /&gt;
wget popgen.dk/software/download/NGSadmix/data/Demo2pop.info&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Execute [[NgsAdmix |NGSadmix]] to obtain admixture proportions&lt;br /&gt;
&amp;lt;pre&amp;gt;./NGSadmix -likes Demo2input.gz -K 3 -P 20 -o myoutfiles -minMaf 0.05&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
::Input file = Demo2input.gz&lt;br /&gt;
::Ancestral Populations K=3&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
::Output prefix = myoutfiles (-o myoutfiles) &lt;br /&gt;
::SNPs with MAF &amp;gt; 5%  (-minMaf 0.05)&lt;br /&gt;
&lt;br /&gt;
Run evalAdmix&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix -beagle Demo2input.gz -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 20 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
::Genotype likelihoods file Demo2input.gz (-beagle Demo2input.gz).&lt;br /&gt;
::Ancestral Populations frequency file myoutfiles.fopt.gz (-fname myoutfiles.fopt.gz).&lt;br /&gt;
::Admixture proportions file  myoutfiles.qopt(-qname myoutfiles.qopt).&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
&lt;br /&gt;
Plot results in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source(&amp;quot;visFuns.R&amp;quot;)&lt;br /&gt;
# read population labels and estimated admixture proportions&lt;br /&gt;
pop&amp;lt;-read.table(&amp;quot;Demo2pop.info&amp;quot;,as.is=T)&lt;br /&gt;
q&amp;lt;-read.table(&amp;quot;myoutfiles.qopt&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# order according to population and plot the NGSadmix reults&lt;br /&gt;
ord&amp;lt;-orderInds(pop = as.vector(pop[,1]), q = q)&lt;br /&gt;
barplot(t(q)[,ord],col=2:10,space=0,border=NA,xlab=&amp;quot;Individuals&amp;quot;,ylab=&amp;quot;Demo2 Admixture proportions for K=3&amp;quot;)&lt;br /&gt;
text(tapply(1:nrow(pop),pop[ord,1],mean),-0.05,unique(pop[ord,1]),xpd=T)&lt;br /&gt;
abline(v=cumsum(sapply(unique(pop[ord,1]),function(x){sum(pop[ord,1]==x)})),col=1,lwd=1.2)&lt;br /&gt;
&lt;br /&gt;
r&amp;lt;-read.table(&amp;quot;output.corres.txt&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Plot correlation of residuals&lt;br /&gt;
&lt;br /&gt;
plotCorRes(cor_mat = r, pop = as.vector(pop[,1]), ord = ord, title=&amp;quot;Evaluation of 1000G admixture proportions with K=3&amp;quot;, max_z=0.1, min_z=-0.1)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Citation==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[https://doi.org/10.1111/1755-0998.13171 Evaluation of Model Fit of Inferred Admixture Proportions]&lt;/div&gt;</summary>
		<author><name>Genis</name></author>
	</entry>
	<entry>
		<id>https://www.popgen.dk/software/index.php?title=EvalAdmix&amp;diff=1436</id>
		<title>EvalAdmix</title>
		<link rel="alternate" type="text/html" href="https://www.popgen.dk/software/index.php?title=EvalAdmix&amp;diff=1436"/>
		<updated>2020-04-27T09:01:44Z</updated>

		<summary type="html">&lt;p&gt;Genis: /* Citation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;evalAdmix allows to evaluate the results of an admixture analysis (i.e. the result of applying [https://genome.cshlp.org/content/19/9/1655.long ADMIXTURE], [https://web.stanford.edu/group/pritchardlab/structure.html STRUCTURE], [http://www.popgen.dk/software/index.php/NgsAdmix NGSadmix] and similar). It only needs the input genotype data used for the previous admixture analysis and the output of that analysis (admixture proportions and ancestral population frequencies). The genotype input data can either be called genotypes in [https://www.cog-genomics.org/plink/1.9/formats#bed binary plink format] or genotype likelihoods in [http://www.popgen.dk/angsd/index.php/Genotype_Likelihoods#Beagle_format beagle format].&lt;br /&gt;
&lt;br /&gt;
The output is a pairwise correlation of residuals matrix between individuals. The correlation will be close to 0 in case of a good fit of the data to the admixture model. When individuals do not fit the model, individuals with similar demographic histories (i.e. usually individuals from the same population) will be positively correlated; and individuals with different histories but that are modelled as sharing one or more ancestral populations as admixture sources will have a negative correlation. Positive correlation between a pair of individuals might also be due to relatedness.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:evalAdmix.png|thumb|550px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Download and Installation==&lt;br /&gt;
&lt;br /&gt;
evalAdmix can be installed from [https://github.com/GenisGE/evalAdmix github] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;git clone https://github.com/GenisGE/evalAdmix.git&lt;br /&gt;
cd evalAdmix&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Quick start==&lt;br /&gt;
:&amp;lt;code&amp;gt; ./evalAdmix -beagle inputBeagleFile.gz  -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 10  &amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt; ./evalAdmix -plink inputPlinkPrefix  -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 10  &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''-beagle''' beagle file of genotype likelihoods&lt;br /&gt;
* '''-plink''' binary plink file prefix with genotype data&lt;br /&gt;
* '''-fname''' file with ancestral frequencies (space delimited, rows are sites and columns ancestral populations)&lt;br /&gt;
* '''-qname''' file with admixture proportions (space delimited, rows are individuals and columns ancestral populations)&lt;br /&gt;
* '''-o''' prefix of output file names&lt;br /&gt;
* '''-P''' Number of threads used&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix  &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Arguments:&lt;br /&gt;
	Required:&lt;br /&gt;
		-plink path to binary plink file (excluding the .bed)&lt;br /&gt;
		or&lt;br /&gt;
	      	-beagle path to beagle file containing genotype likelihoods (alternative to -plink)&lt;br /&gt;
		&lt;br /&gt;
		-fname path to ancestral population frequencies file&lt;br /&gt;
	       	-qname path to admixture proportions file&lt;br /&gt;
		&lt;br /&gt;
	Optional:       &lt;br /&gt;
	&lt;br /&gt;
	       -o name of the output file&lt;br /&gt;
	       &lt;br /&gt;
	 Setup (optional):&lt;br /&gt;
	 &lt;br /&gt;
	       -P 1 number of threads&lt;br /&gt;
	       -autosomeMax 23	 autosome ends with this chromsome&lt;br /&gt;
	       -nIts 5	 number of iterations to do for frequency correction; if set to 0 calculates correlation without correction (fast but biased)&lt;br /&gt;
	       -useSites 1.0	 proportion of sites to use to calculate correlation of residuals&lt;br /&gt;
	       -useInds filename     path to tab delimited file with first column containing all individuals ID and second column with 1 to include individual in analysis and 0 otherwise (default all individuals are included)&lt;br /&gt;
	       -misTol 0.05 	 tolerance for considering site as missing when using genotype likelihoods. Use same value as used in NGSadmix to keep compatibility when using genotype likelihoods (-beagle)&lt;br /&gt;
	       -minMaf 0.05 	 minimum minor allele frequency to keep site. Use same value as used in NGSadmix to keep compatibility when using genotype likelihoods (-beagle)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Input Files==&lt;br /&gt;
&lt;br /&gt;
===Plink===&lt;br /&gt;
Genotype data files in binary PLINK format (.bed .fam .bim).&lt;br /&gt;
===Beagle genotype likelhoods===&lt;br /&gt;
The input file contains genotype likelihoods in a .beagle file format [http://faculty.washington.edu/browning/beagle/beagle.html].&lt;br /&gt;
and can be compressed with gzip.&lt;br /&gt;
==== BAM files  ====&lt;br /&gt;
If you have BAM files you can use [[ANGSD]] to produce genotype likelihoods in .beagle format. Please &lt;br /&gt;
see [http://www.popgen.dk/angsd/index.php/Beagle_input Creation of Beagle files with ANGSD]&lt;br /&gt;
&lt;br /&gt;
==== VCF files ====&lt;br /&gt;
If you already have made a VCF file that contains genotype likehood information then  it should be possible to convert .vcf files with genotype likelihoods to .beagle file via vcftools [https://vcftools.github.io/man_latest.html] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vcftools --vcf input.vcf --out test --BEAGLE-GL --chr 1,2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Chromosome has to be specified.&lt;br /&gt;
&lt;br /&gt;
You can also use bcftools' [https://samtools.github.io/bcftools/bcftools.html] 'query' option for generating a .beagle file from a .vcf file.&lt;br /&gt;
&lt;br /&gt;
==Output File==&lt;br /&gt;
The analysis performed by evalAdmix produces one file, containing a tab delimited N times N symmetric correlation matrix, where column i in line j contains the correlation of residuals between individual i and j, and the diagonal values (self-correlation) are set to NA:&lt;br /&gt;
&lt;br /&gt;
NA      0.008609        -0.006919       0.002731        0.020224&amp;lt;br /&amp;gt;&lt;br /&gt;
0.008609        NA      0.000033        0.004968        -0.008470&amp;lt;br /&amp;gt;&lt;br /&gt;
-0.006919       0.000033        NA      0.006982        0.005664&amp;lt;br /&amp;gt;&lt;br /&gt;
0.002731        0.004968        0.006982        NA      0.000521&amp;lt;br /&amp;gt;&lt;br /&gt;
0.020224        -0.008470       0.005664        0.000521        NA&lt;br /&gt;
&lt;br /&gt;
==Run command example==&lt;br /&gt;
&lt;br /&gt;
=== Genotype data ===&lt;br /&gt;
Download the input file containing genotypes in binary plink format&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.bed&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.bim&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.fam&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run ADMIXTURE [http://software.genetics.ucla.edu/admixture/] to obtain admixture proprotions&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;admixture admixTjeck2.bed 3&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
::Genotypes file prefix admixTjeck2.bed&lt;br /&gt;
::Ancestral Populations K = 3&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Run evalAdmix&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix -plink admixTjeck2 -fname admixTjeck2.3.P -qname admixTjeck2.3.Q -P 20 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
::Genotypes file prefix admixTjeck2 (-plink admixTjeck2).&lt;br /&gt;
::Ancestral Populations frequency file admixTjeck2.3.P (-fname admixTjeck2.3.P).&lt;br /&gt;
::Admixture proportions file admixTjeck2.3.Q (-qname admixTjeck2.3.Q).&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
&lt;br /&gt;
Plot results in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source(&amp;quot;visFuns.R&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# read population labels and estimated admixture proportions&lt;br /&gt;
pop&amp;lt;-read.table(&amp;quot;admixTjeck2.fam&amp;quot;)&lt;br /&gt;
q&amp;lt;-read.table(&amp;quot;admixTjeck2.3.Q&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# order according to population and plot the ADMIXTURE reults&lt;br /&gt;
ord&amp;lt;-orderInds(pop = pop, q = q)&lt;br /&gt;
barplot(t(q)[,ord],col=2:10,space=0,border=NA,xlab=&amp;quot;Individuals&amp;quot;,ylab=&amp;quot;Demo2 Admixture proportions for K=3&amp;quot;)&lt;br /&gt;
text(tapply(1:nrow(pop),pop[ord,2],mean),-0.05,unique(pop[ord,2]),xpd=T)&lt;br /&gt;
abline(v=cumsum(sapply(unique(pop[ord,2]),function(x){sum(pop[ord,2]==x)})),col=1,lwd=1.2)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
r&amp;lt;-as.matrix(read.table(&amp;quot;output.corres.txt&amp;quot;))&lt;br /&gt;
&lt;br /&gt;
# Plot correlation of residuals&lt;br /&gt;
plotCorRes(cor_mat = r, pop = as.vector(pop[,2]), ord=ord, title=&amp;quot;Evaluation of 1000G admixture proportions with K=3&amp;quot;, max_z=0.1, min_z=-0.1)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Low depth sequencing data ===&lt;br /&gt;
Download the input file containing genotype likelihoods in beagle format&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget popgen.dk/software/download/NGSadmix/data/Demo2input.gz&lt;br /&gt;
wget popgen.dk/software/download/NGSadmix/data/Demo2pop.info&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Execute [[NgsAdmix |NGSadmix]] to obtain admixture proportions&lt;br /&gt;
&amp;lt;pre&amp;gt;./NGSadmix -likes Demo2input.gz -K 3 -P 20 -o myoutfiles -minMaf 0.05&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
::Input file = Demo2input.gz&lt;br /&gt;
::Ancestral Populations K=3&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
::Output prefix = myoutfiles (-o myoutfiles) &lt;br /&gt;
::SNPs with MAF &amp;gt; 5%  (-minMaf 0.05)&lt;br /&gt;
&lt;br /&gt;
Run evalAdmix&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix -beagle Demo2input.gz -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 20 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
::Genotype likelihoods file Demo2input.gz (-beagle Demo2input.gz).&lt;br /&gt;
::Ancestral Populations frequency file myoutfiles.fopt.gz (-fname myoutfiles.fopt.gz).&lt;br /&gt;
::Admixture proportions file  myoutfiles.qopt(-qname myoutfiles.qopt).&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
&lt;br /&gt;
Plot results in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source(&amp;quot;visFuns.R&amp;quot;)&lt;br /&gt;
# read population labels and estimated admixture proportions&lt;br /&gt;
pop&amp;lt;-read.table(&amp;quot;Demo2pop.info&amp;quot;,as.is=T)&lt;br /&gt;
q&amp;lt;-read.table(&amp;quot;myoutfiles.qopt&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# order according to population and plot the NGSadmix reults&lt;br /&gt;
ord&amp;lt;-orderInds(pop = pop, q = q)&lt;br /&gt;
barplot(t(q)[,ord],col=2:10,space=0,border=NA,xlab=&amp;quot;Individuals&amp;quot;,ylab=&amp;quot;Demo2 Admixture proportions for K=3&amp;quot;)&lt;br /&gt;
text(tapply(1:nrow(pop),pop[ord,1],mean),-0.05,unique(pop[ord,1]),xpd=T)&lt;br /&gt;
abline(v=cumsum(sapply(unique(pop[ord,1]),function(x){sum(pop[ord,1]==x)})),col=1,lwd=1.2)&lt;br /&gt;
&lt;br /&gt;
r&amp;lt;-read.table(&amp;quot;output.corres.txt&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Plot correlation of residuals&lt;br /&gt;
&lt;br /&gt;
plotCorRes(cor_mat = r, pop = as.vector(pop[,1]), ord = ord, title=&amp;quot;Evaluation of 1000G admixture proportions with K=3&amp;quot;, max_z=0.1, min_z=-0.1)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Citation==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[https://doi.org/10.1111/1755-0998.13171 Evaluation of Model Fit of Inferred Admixture Proportions]&lt;/div&gt;</summary>
		<author><name>Genis</name></author>
	</entry>
	<entry>
		<id>https://www.popgen.dk/software/index.php?title=EvalAdmix&amp;diff=1435</id>
		<title>EvalAdmix</title>
		<link rel="alternate" type="text/html" href="https://www.popgen.dk/software/index.php?title=EvalAdmix&amp;diff=1435"/>
		<updated>2020-04-27T08:59:34Z</updated>

		<summary type="html">&lt;p&gt;Genis: /* Genotype data */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;evalAdmix allows to evaluate the results of an admixture analysis (i.e. the result of applying [https://genome.cshlp.org/content/19/9/1655.long ADMIXTURE], [https://web.stanford.edu/group/pritchardlab/structure.html STRUCTURE], [http://www.popgen.dk/software/index.php/NgsAdmix NGSadmix] and similar). It only needs the input genotype data used for the previous admixture analysis and the output of that analysis (admixture proportions and ancestral population frequencies). The genotype input data can either be called genotypes in [https://www.cog-genomics.org/plink/1.9/formats#bed binary plink format] or genotype likelihoods in [http://www.popgen.dk/angsd/index.php/Genotype_Likelihoods#Beagle_format beagle format].&lt;br /&gt;
&lt;br /&gt;
The output is a pairwise correlation of residuals matrix between individuals. The correlation will be close to 0 in case of a good fit of the data to the admixture model. When individuals do not fit the model, individuals with similar demographic histories (i.e. usually individuals from the same population) will be positively correlated; and individuals with different histories but that are modelled as sharing one or more ancestral populations as admixture sources will have a negative correlation. Positive correlation between a pair of individuals might also be due to relatedness.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:evalAdmix.png|thumb|550px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Download and Installation==&lt;br /&gt;
&lt;br /&gt;
evalAdmix can be installed from [https://github.com/GenisGE/evalAdmix github] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;git clone https://github.com/GenisGE/evalAdmix.git&lt;br /&gt;
cd evalAdmix&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Quick start==&lt;br /&gt;
:&amp;lt;code&amp;gt; ./evalAdmix -beagle inputBeagleFile.gz  -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 10  &amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt; ./evalAdmix -plink inputPlinkPrefix  -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 10  &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''-beagle''' beagle file of genotype likelihoods&lt;br /&gt;
* '''-plink''' binary plink file prefix with genotype data&lt;br /&gt;
* '''-fname''' file with ancestral frequencies (space delimited, rows are sites and columns ancestral populations)&lt;br /&gt;
* '''-qname''' file with admixture proportions (space delimited, rows are individuals and columns ancestral populations)&lt;br /&gt;
* '''-o''' prefix of output file names&lt;br /&gt;
* '''-P''' Number of threads used&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix  &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Arguments:&lt;br /&gt;
	Required:&lt;br /&gt;
		-plink path to binary plink file (excluding the .bed)&lt;br /&gt;
		or&lt;br /&gt;
	      	-beagle path to beagle file containing genotype likelihoods (alternative to -plink)&lt;br /&gt;
		&lt;br /&gt;
		-fname path to ancestral population frequencies file&lt;br /&gt;
	       	-qname path to admixture proportions file&lt;br /&gt;
		&lt;br /&gt;
	Optional:       &lt;br /&gt;
	&lt;br /&gt;
	       -o name of the output file&lt;br /&gt;
	       &lt;br /&gt;
	 Setup (optional):&lt;br /&gt;
	 &lt;br /&gt;
	       -P 1 number of threads&lt;br /&gt;
	       -autosomeMax 23	 autosome ends with this chromsome&lt;br /&gt;
	       -nIts 5	 number of iterations to do for frequency correction; if set to 0 calculates correlation without correction (fast but biased)&lt;br /&gt;
	       -useSites 1.0	 proportion of sites to use to calculate correlation of residuals&lt;br /&gt;
	       -useInds filename     path to tab delimited file with first column containing all individuals ID and second column with 1 to include individual in analysis and 0 otherwise (default all individuals are included)&lt;br /&gt;
	       -misTol 0.05 	 tolerance for considering site as missing when using genotype likelihoods. Use same value as used in NGSadmix to keep compatibility when using genotype likelihoods (-beagle)&lt;br /&gt;
	       -minMaf 0.05 	 minimum minor allele frequency to keep site. Use same value as used in NGSadmix to keep compatibility when using genotype likelihoods (-beagle)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Input Files==&lt;br /&gt;
&lt;br /&gt;
===Plink===&lt;br /&gt;
Genotype data files in binary PLINK format (.bed .fam .bim).&lt;br /&gt;
===Beagle genotype likelhoods===&lt;br /&gt;
The input file contains genotype likelihoods in a .beagle file format [http://faculty.washington.edu/browning/beagle/beagle.html].&lt;br /&gt;
and can be compressed with gzip.&lt;br /&gt;
==== BAM files  ====&lt;br /&gt;
If you have BAM files you can use [[ANGSD]] to produce genotype likelihoods in .beagle format. Please &lt;br /&gt;
see [http://www.popgen.dk/angsd/index.php/Beagle_input Creation of Beagle files with ANGSD]&lt;br /&gt;
&lt;br /&gt;
==== VCF files ====&lt;br /&gt;
If you already have made a VCF file that contains genotype likehood information then  it should be possible to convert .vcf files with genotype likelihoods to .beagle file via vcftools [https://vcftools.github.io/man_latest.html] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vcftools --vcf input.vcf --out test --BEAGLE-GL --chr 1,2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Chromosome has to be specified.&lt;br /&gt;
&lt;br /&gt;
You can also use bcftools' [https://samtools.github.io/bcftools/bcftools.html] 'query' option for generating a .beagle file from a .vcf file.&lt;br /&gt;
&lt;br /&gt;
==Output File==&lt;br /&gt;
The analysis performed by evalAdmix produces one file, containing a tab delimited N times N symmetric correlation matrix, where column i in line j contains the correlation of residuals between individual i and j, and the diagonal values (self-correlation) are set to NA:&lt;br /&gt;
&lt;br /&gt;
NA      0.008609        -0.006919       0.002731        0.020224&amp;lt;br /&amp;gt;&lt;br /&gt;
0.008609        NA      0.000033        0.004968        -0.008470&amp;lt;br /&amp;gt;&lt;br /&gt;
-0.006919       0.000033        NA      0.006982        0.005664&amp;lt;br /&amp;gt;&lt;br /&gt;
0.002731        0.004968        0.006982        NA      0.000521&amp;lt;br /&amp;gt;&lt;br /&gt;
0.020224        -0.008470       0.005664        0.000521        NA&lt;br /&gt;
&lt;br /&gt;
==Run command example==&lt;br /&gt;
&lt;br /&gt;
=== Genotype data ===&lt;br /&gt;
Download the input file containing genotypes in binary plink format&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.bed&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.bim&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.fam&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run ADMIXTURE [http://software.genetics.ucla.edu/admixture/] to obtain admixture proprotions&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;admixture admixTjeck2.bed 3&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
::Genotypes file prefix admixTjeck2.bed&lt;br /&gt;
::Ancestral Populations K = 3&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Run evalAdmix&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix -plink admixTjeck2 -fname admixTjeck2.3.P -qname admixTjeck2.3.Q -P 20 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
::Genotypes file prefix admixTjeck2 (-plink admixTjeck2).&lt;br /&gt;
::Ancestral Populations frequency file admixTjeck2.3.P (-fname admixTjeck2.3.P).&lt;br /&gt;
::Admixture proportions file admixTjeck2.3.Q (-qname admixTjeck2.3.Q).&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
&lt;br /&gt;
Plot results in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source(&amp;quot;visFuns.R&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# read population labels and estimated admixture proportions&lt;br /&gt;
pop&amp;lt;-read.table(&amp;quot;admixTjeck2.fam&amp;quot;)&lt;br /&gt;
q&amp;lt;-read.table(&amp;quot;admixTjeck2.3.Q&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# order according to population and plot the ADMIXTURE reults&lt;br /&gt;
ord&amp;lt;-orderInds(pop = pop, q = q)&lt;br /&gt;
barplot(t(q)[,ord],col=2:10,space=0,border=NA,xlab=&amp;quot;Individuals&amp;quot;,ylab=&amp;quot;Demo2 Admixture proportions for K=3&amp;quot;)&lt;br /&gt;
text(tapply(1:nrow(pop),pop[ord,2],mean),-0.05,unique(pop[ord,2]),xpd=T)&lt;br /&gt;
abline(v=cumsum(sapply(unique(pop[ord,2]),function(x){sum(pop[ord,2]==x)})),col=1,lwd=1.2)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
r&amp;lt;-as.matrix(read.table(&amp;quot;output.corres.txt&amp;quot;))&lt;br /&gt;
&lt;br /&gt;
# Plot correlation of residuals&lt;br /&gt;
plotCorRes(cor_mat = r, pop = as.vector(pop[,2]), ord=ord, title=&amp;quot;Evaluation of 1000G admixture proportions with K=3&amp;quot;, max_z=0.1, min_z=-0.1)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Low depth sequencing data ===&lt;br /&gt;
Download the input file containing genotype likelihoods in beagle format&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget popgen.dk/software/download/NGSadmix/data/Demo2input.gz&lt;br /&gt;
wget popgen.dk/software/download/NGSadmix/data/Demo2pop.info&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Execute [[NgsAdmix |NGSadmix]] to obtain admixture proportions&lt;br /&gt;
&amp;lt;pre&amp;gt;./NGSadmix -likes Demo2input.gz -K 3 -P 20 -o myoutfiles -minMaf 0.05&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
::Input file = Demo2input.gz&lt;br /&gt;
::Ancestral Populations K=3&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
::Output prefix = myoutfiles (-o myoutfiles) &lt;br /&gt;
::SNPs with MAF &amp;gt; 5%  (-minMaf 0.05)&lt;br /&gt;
&lt;br /&gt;
Run evalAdmix&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix -beagle Demo2input.gz -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 20 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
::Genotype likelihoods file Demo2input.gz (-beagle Demo2input.gz).&lt;br /&gt;
::Ancestral Populations frequency file myoutfiles.fopt.gz (-fname myoutfiles.fopt.gz).&lt;br /&gt;
::Admixture proportions file  myoutfiles.qopt(-qname myoutfiles.qopt).&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
&lt;br /&gt;
Plot results in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source(&amp;quot;visFuns.R&amp;quot;)&lt;br /&gt;
# read population labels and estimated admixture proportions&lt;br /&gt;
pop&amp;lt;-read.table(&amp;quot;Demo2pop.info&amp;quot;,as.is=T)&lt;br /&gt;
q&amp;lt;-read.table(&amp;quot;myoutfiles.qopt&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# order according to population and plot the NGSadmix reults&lt;br /&gt;
ord&amp;lt;-orderInds(pop = pop, q = q)&lt;br /&gt;
barplot(t(q)[,ord],col=2:10,space=0,border=NA,xlab=&amp;quot;Individuals&amp;quot;,ylab=&amp;quot;Demo2 Admixture proportions for K=3&amp;quot;)&lt;br /&gt;
text(tapply(1:nrow(pop),pop[ord,1],mean),-0.05,unique(pop[ord,1]),xpd=T)&lt;br /&gt;
abline(v=cumsum(sapply(unique(pop[ord,1]),function(x){sum(pop[ord,1]==x)})),col=1,lwd=1.2)&lt;br /&gt;
&lt;br /&gt;
r&amp;lt;-read.table(&amp;quot;output.corres.txt&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Plot correlation of residuals&lt;br /&gt;
&lt;br /&gt;
plotCorRes(cor_mat = r, pop = as.vector(pop[,1]), ord = ord, title=&amp;quot;Evaluation of 1000G admixture proportions with K=3&amp;quot;, max_z=0.1, min_z=-0.1)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Citation==&lt;br /&gt;
&lt;br /&gt;
evalAdmix has a preprint&lt;br /&gt;
&lt;br /&gt;
[https://doi.org/10.1101/708883 Evaluation of Model Fit of Inferred Admixture Proportions]&lt;/div&gt;</summary>
		<author><name>Genis</name></author>
	</entry>
	<entry>
		<id>https://www.popgen.dk/software/index.php?title=EvalAdmix&amp;diff=1434</id>
		<title>EvalAdmix</title>
		<link rel="alternate" type="text/html" href="https://www.popgen.dk/software/index.php?title=EvalAdmix&amp;diff=1434"/>
		<updated>2020-04-27T08:43:14Z</updated>

		<summary type="html">&lt;p&gt;Genis: /* Run command example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;evalAdmix allows to evaluate the results of an admixture analysis (i.e. the result of applying [https://genome.cshlp.org/content/19/9/1655.long ADMIXTURE], [https://web.stanford.edu/group/pritchardlab/structure.html STRUCTURE], [http://www.popgen.dk/software/index.php/NgsAdmix NGSadmix] and similar). It only needs the input genotype data used for the previous admixture analysis and the output of that analysis (admixture proportions and ancestral population frequencies). The genotype input data can either be called genotypes in [https://www.cog-genomics.org/plink/1.9/formats#bed binary plink format] or genotype likelihoods in [http://www.popgen.dk/angsd/index.php/Genotype_Likelihoods#Beagle_format beagle format].&lt;br /&gt;
&lt;br /&gt;
The output is a pairwise correlation of residuals matrix between individuals. The correlation will be close to 0 in case of a good fit of the data to the admixture model. When individuals do not fit the model, individuals with similar demographic histories (i.e. usually individuals from the same population) will be positively correlated; and individuals with different histories but that are modelled as sharing one or more ancestral populations as admixture sources will have a negative correlation. Positive correlation between a pair of individuals might also be due to relatedness.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:evalAdmix.png|thumb|550px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Download and Installation==&lt;br /&gt;
&lt;br /&gt;
evalAdmix can be installed from [https://github.com/GenisGE/evalAdmix github] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;git clone https://github.com/GenisGE/evalAdmix.git&lt;br /&gt;
cd evalAdmix&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Quick start==&lt;br /&gt;
:&amp;lt;code&amp;gt; ./evalAdmix -beagle inputBeagleFile.gz  -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 10  &amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt; ./evalAdmix -plink inputPlinkPrefix  -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 10  &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''-beagle''' beagle file of genotype likelihoods&lt;br /&gt;
* '''-plink''' binary plink file prefix with genotype data&lt;br /&gt;
* '''-fname''' file with ancestral frequencies (space delimited, rows are sites and columns ancestral populations)&lt;br /&gt;
* '''-qname''' file with admixture proportions (space delimited, rows are individuals and columns ancestral populations)&lt;br /&gt;
* '''-o''' prefix of output file names&lt;br /&gt;
* '''-P''' Number of threads used&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix  &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Arguments:&lt;br /&gt;
	Required:&lt;br /&gt;
		-plink path to binary plink file (excluding the .bed)&lt;br /&gt;
		or&lt;br /&gt;
	      	-beagle path to beagle file containing genotype likelihoods (alternative to -plink)&lt;br /&gt;
		&lt;br /&gt;
		-fname path to ancestral population frequencies file&lt;br /&gt;
	       	-qname path to admixture proportions file&lt;br /&gt;
		&lt;br /&gt;
	Optional:       &lt;br /&gt;
	&lt;br /&gt;
	       -o name of the output file&lt;br /&gt;
	       &lt;br /&gt;
	 Setup (optional):&lt;br /&gt;
	 &lt;br /&gt;
	       -P 1 number of threads&lt;br /&gt;
	       -autosomeMax 23	 autosome ends with this chromsome&lt;br /&gt;
	       -nIts 5	 number of iterations to do for frequency correction; if set to 0 calculates correlation without correction (fast but biased)&lt;br /&gt;
	       -useSites 1.0	 proportion of sites to use to calculate correlation of residuals&lt;br /&gt;
	       -useInds filename     path to tab delimited file with first column containing all individuals ID and second column with 1 to include individual in analysis and 0 otherwise (default all individuals are included)&lt;br /&gt;
	       -misTol 0.05 	 tolerance for considering site as missing when using genotype likelihoods. Use same value as used in NGSadmix to keep compatibility when using genotype likelihoods (-beagle)&lt;br /&gt;
	       -minMaf 0.05 	 minimum minor allele frequency to keep site. Use same value as used in NGSadmix to keep compatibility when using genotype likelihoods (-beagle)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Input Files==&lt;br /&gt;
&lt;br /&gt;
===Plink===&lt;br /&gt;
Genotype data files in binary PLINK format (.bed .fam .bim).&lt;br /&gt;
===Beagle genotype likelhoods===&lt;br /&gt;
The input file contains genotype likelihoods in a .beagle file format [http://faculty.washington.edu/browning/beagle/beagle.html].&lt;br /&gt;
and can be compressed with gzip.&lt;br /&gt;
==== BAM files  ====&lt;br /&gt;
If you have BAM files you can use [[ANGSD]] to produce genotype likelihoods in .beagle format. Please &lt;br /&gt;
see [http://www.popgen.dk/angsd/index.php/Beagle_input Creation of Beagle files with ANGSD]&lt;br /&gt;
&lt;br /&gt;
==== VCF files ====&lt;br /&gt;
If you already have made a VCF file that contains genotype likehood information then  it should be possible to convert .vcf files with genotype likelihoods to .beagle file via vcftools [https://vcftools.github.io/man_latest.html] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vcftools --vcf input.vcf --out test --BEAGLE-GL --chr 1,2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Chromosome has to be specified.&lt;br /&gt;
&lt;br /&gt;
You can also use bcftools' [https://samtools.github.io/bcftools/bcftools.html] 'query' option for generating a .beagle file from a .vcf file.&lt;br /&gt;
&lt;br /&gt;
==Output File==&lt;br /&gt;
The analysis performed by evalAdmix produces one file, containing a tab delimited N times N symmetric correlation matrix, where column i in line j contains the correlation of residuals between individual i and j, and the diagonal values (self-correlation) are set to NA:&lt;br /&gt;
&lt;br /&gt;
NA      0.008609        -0.006919       0.002731        0.020224&amp;lt;br /&amp;gt;&lt;br /&gt;
0.008609        NA      0.000033        0.004968        -0.008470&amp;lt;br /&amp;gt;&lt;br /&gt;
-0.006919       0.000033        NA      0.006982        0.005664&amp;lt;br /&amp;gt;&lt;br /&gt;
0.002731        0.004968        0.006982        NA      0.000521&amp;lt;br /&amp;gt;&lt;br /&gt;
0.020224        -0.008470       0.005664        0.000521        NA&lt;br /&gt;
&lt;br /&gt;
==Run command example==&lt;br /&gt;
&lt;br /&gt;
=== Genotype data ===&lt;br /&gt;
Download the input file containing genotypes in binary plink format&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.bed&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.bim&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.fam&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run ADMIXTURE [http://software.genetics.ucla.edu/admixture/] to obtain admixture proprotions&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;admixture admixTjeck2.bed 3&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run evalAdmix&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix -plink admixTjeck2 -fname admixTjeck2.3.P -qname admixTjeck2.3.Q -P 20 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
::Genotypes file prefix admixTjeck2 (-plink admixTjeck2).&lt;br /&gt;
::Ancestral Populations frequency file admixTjeck2.3.P (-fname admixTjeck2.3.P).&lt;br /&gt;
::Admixture proportions file admixTjeck2.3.Q (-qname admixTjeck2.3.Q).&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
&lt;br /&gt;
Plot results in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source(&amp;quot;visFuns.R&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# read population labels and estimated admixture proportions&lt;br /&gt;
pop&amp;lt;-read.table(&amp;quot;admixTjeck2.fam&amp;quot;)&lt;br /&gt;
q&amp;lt;-read.table(&amp;quot;admixTjeck2.3.Q&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# order according to population and plot the ADMIXTURE reults&lt;br /&gt;
ord&amp;lt;-orderInds(pop = pop, q = q)&lt;br /&gt;
barplot(t(q)[,ord],col=2:10,space=0,border=NA,xlab=&amp;quot;Individuals&amp;quot;,ylab=&amp;quot;Demo2 Admixture proportions for K=3&amp;quot;)&lt;br /&gt;
text(tapply(1:nrow(pop),pop[ord,2],mean),-0.05,unique(pop[ord,2]),xpd=T)&lt;br /&gt;
abline(v=cumsum(sapply(unique(pop[ord,2]),function(x){sum(pop[ord,2]==x)})),col=1,lwd=1.2)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
r&amp;lt;-as.matrix(read.table(&amp;quot;output.corres.txt&amp;quot;))&lt;br /&gt;
&lt;br /&gt;
# Plot correlation of residuals&lt;br /&gt;
plotCorRes(cor_mat = r, pop = as.vector(pop[,2]), ord=ord, title=&amp;quot;Evaluation of 1000G admixture proportions with K=3&amp;quot;, max_z=0.1, min_z=-0.1)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Low depth sequencing data ===&lt;br /&gt;
Download the input file containing genotype likelihoods in beagle format&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget popgen.dk/software/download/NGSadmix/data/Demo2input.gz&lt;br /&gt;
wget popgen.dk/software/download/NGSadmix/data/Demo2pop.info&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Execute [[NgsAdmix |NGSadmix]] to obtain admixture proportions&lt;br /&gt;
&amp;lt;pre&amp;gt;./NGSadmix -likes Demo2input.gz -K 3 -P 20 -o myoutfiles -minMaf 0.05&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
::Input file = Demo2input.gz&lt;br /&gt;
::Ancestral Populations K=3&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
::Output prefix = myoutfiles (-o myoutfiles) &lt;br /&gt;
::SNPs with MAF &amp;gt; 5%  (-minMaf 0.05)&lt;br /&gt;
&lt;br /&gt;
Run evalAdmix&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix -beagle Demo2input.gz -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 20 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
::Genotype likelihoods file Demo2input.gz (-beagle Demo2input.gz).&lt;br /&gt;
::Ancestral Populations frequency file myoutfiles.fopt.gz (-fname myoutfiles.fopt.gz).&lt;br /&gt;
::Admixture proportions file  myoutfiles.qopt(-qname myoutfiles.qopt).&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
&lt;br /&gt;
Plot results in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source(&amp;quot;visFuns.R&amp;quot;)&lt;br /&gt;
# read population labels and estimated admixture proportions&lt;br /&gt;
pop&amp;lt;-read.table(&amp;quot;Demo2pop.info&amp;quot;,as.is=T)&lt;br /&gt;
q&amp;lt;-read.table(&amp;quot;myoutfiles.qopt&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# order according to population and plot the NGSadmix reults&lt;br /&gt;
ord&amp;lt;-orderInds(pop = pop, q = q)&lt;br /&gt;
barplot(t(q)[,ord],col=2:10,space=0,border=NA,xlab=&amp;quot;Individuals&amp;quot;,ylab=&amp;quot;Demo2 Admixture proportions for K=3&amp;quot;)&lt;br /&gt;
text(tapply(1:nrow(pop),pop[ord,1],mean),-0.05,unique(pop[ord,1]),xpd=T)&lt;br /&gt;
abline(v=cumsum(sapply(unique(pop[ord,1]),function(x){sum(pop[ord,1]==x)})),col=1,lwd=1.2)&lt;br /&gt;
&lt;br /&gt;
r&amp;lt;-read.table(&amp;quot;output.corres.txt&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Plot correlation of residuals&lt;br /&gt;
&lt;br /&gt;
plotCorRes(cor_mat = r, pop = as.vector(pop[,1]), ord = ord, title=&amp;quot;Evaluation of 1000G admixture proportions with K=3&amp;quot;, max_z=0.1, min_z=-0.1)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Citation==&lt;br /&gt;
&lt;br /&gt;
evalAdmix has a preprint&lt;br /&gt;
&lt;br /&gt;
[https://doi.org/10.1101/708883 Evaluation of Model Fit of Inferred Admixture Proportions]&lt;/div&gt;</summary>
		<author><name>Genis</name></author>
	</entry>
	<entry>
		<id>https://www.popgen.dk/software/index.php?title=EvalAdmix&amp;diff=1433</id>
		<title>EvalAdmix</title>
		<link rel="alternate" type="text/html" href="https://www.popgen.dk/software/index.php?title=EvalAdmix&amp;diff=1433"/>
		<updated>2020-04-27T08:41:48Z</updated>

		<summary type="html">&lt;p&gt;Genis: /* Quick start */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;evalAdmix allows to evaluate the results of an admixture analysis (i.e. the result of applying [https://genome.cshlp.org/content/19/9/1655.long ADMIXTURE], [https://web.stanford.edu/group/pritchardlab/structure.html STRUCTURE], [http://www.popgen.dk/software/index.php/NgsAdmix NGSadmix] and similar). It only needs the input genotype data used for the previous admixture analysis and the output of that analysis (admixture proportions and ancestral population frequencies). The genotype input data can either be called genotypes in [https://www.cog-genomics.org/plink/1.9/formats#bed binary plink format] or genotype likelihoods in [http://www.popgen.dk/angsd/index.php/Genotype_Likelihoods#Beagle_format beagle format].&lt;br /&gt;
&lt;br /&gt;
The output is a pairwise correlation of residuals matrix between individuals. The correlation will be close to 0 in case of a good fit of the data to the admixture model. When individuals do not fit the model, individuals with similar demographic histories (i.e. usually individuals from the same population) will be positively correlated; and individuals with different histories but that are modelled as sharing one or more ancestral populations as admixture sources will have a negative correlation. Positive correlation between a pair of individuals might also be due to relatedness.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:evalAdmix.png|thumb|550px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Download and Installation==&lt;br /&gt;
&lt;br /&gt;
evalAdmix can be installed from [https://github.com/GenisGE/evalAdmix github] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;git clone https://github.com/GenisGE/evalAdmix.git&lt;br /&gt;
cd evalAdmix&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Quick start==&lt;br /&gt;
:&amp;lt;code&amp;gt; ./evalAdmix -beagle inputBeagleFile.gz  -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 10  &amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt; ./evalAdmix -plink inputPlinkPrefix  -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 10  &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''-beagle''' beagle file of genotype likelihoods&lt;br /&gt;
* '''-plink''' binary plink file prefix with genotype data&lt;br /&gt;
* '''-fname''' file with ancestral frequencies (space delimited, rows are sites and columns ancestral populations)&lt;br /&gt;
* '''-qname''' file with admixture proportions (space delimited, rows are individuals and columns ancestral populations)&lt;br /&gt;
* '''-o''' prefix of output file names&lt;br /&gt;
* '''-P''' Number of threads used&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix  &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Arguments:&lt;br /&gt;
	Required:&lt;br /&gt;
		-plink path to binary plink file (excluding the .bed)&lt;br /&gt;
		or&lt;br /&gt;
	      	-beagle path to beagle file containing genotype likelihoods (alternative to -plink)&lt;br /&gt;
		&lt;br /&gt;
		-fname path to ancestral population frequencies file&lt;br /&gt;
	       	-qname path to admixture proportions file&lt;br /&gt;
		&lt;br /&gt;
	Optional:       &lt;br /&gt;
	&lt;br /&gt;
	       -o name of the output file&lt;br /&gt;
	       &lt;br /&gt;
	 Setup (optional):&lt;br /&gt;
	 &lt;br /&gt;
	       -P 1 number of threads&lt;br /&gt;
	       -autosomeMax 23	 autosome ends with this chromsome&lt;br /&gt;
	       -nIts 5	 number of iterations to do for frequency correction; if set to 0 calculates correlation without correction (fast but biased)&lt;br /&gt;
	       -useSites 1.0	 proportion of sites to use to calculate correlation of residuals&lt;br /&gt;
	       -useInds filename     path to tab delimited file with first column containing all individuals ID and second column with 1 to include individual in analysis and 0 otherwise (default all individuals are included)&lt;br /&gt;
	       -misTol 0.05 	 tolerance for considering site as missing when using genotype likelihoods. Use same value as used in NGSadmix to keep compatibility when using genotype likelihoods (-beagle)&lt;br /&gt;
	       -minMaf 0.05 	 minimum minor allele frequency to keep site. Use same value as used in NGSadmix to keep compatibility when using genotype likelihoods (-beagle)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Input Files==&lt;br /&gt;
&lt;br /&gt;
===Plink===&lt;br /&gt;
Genotype data files in binary PLINK format (.bed .fam .bim).&lt;br /&gt;
===Beagle genotype likelhoods===&lt;br /&gt;
The input file contains genotype likelihoods in a .beagle file format [http://faculty.washington.edu/browning/beagle/beagle.html].&lt;br /&gt;
and can be compressed with gzip.&lt;br /&gt;
==== BAM files  ====&lt;br /&gt;
If you have BAM files you can use [[ANGSD]] to produce genotype likelihoods in .beagle format. Please &lt;br /&gt;
see [http://www.popgen.dk/angsd/index.php/Beagle_input Creation of Beagle files with ANGSD]&lt;br /&gt;
&lt;br /&gt;
==== VCF files ====&lt;br /&gt;
If you already have made a VCF file that contains genotype likehood information then  it should be possible to convert .vcf files with genotype likelihoods to .beagle file via vcftools [https://vcftools.github.io/man_latest.html] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vcftools --vcf input.vcf --out test --BEAGLE-GL --chr 1,2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Chromosome has to be specified.&lt;br /&gt;
&lt;br /&gt;
You can also use bcftools' [https://samtools.github.io/bcftools/bcftools.html] 'query' option for generating a .beagle file from a .vcf file.&lt;br /&gt;
&lt;br /&gt;
==Output File==&lt;br /&gt;
The analysis performed by evalAdmix produces one file, containing a tab delimited N times N symmetric correlation matrix, where column i in line j contains the correlation of residuals between individual i and j, and the diagonal values (self-correlation) are set to NA:&lt;br /&gt;
&lt;br /&gt;
NA      0.008609        -0.006919       0.002731        0.020224&amp;lt;br /&amp;gt;&lt;br /&gt;
0.008609        NA      0.000033        0.004968        -0.008470&amp;lt;br /&amp;gt;&lt;br /&gt;
-0.006919       0.000033        NA      0.006982        0.005664&amp;lt;br /&amp;gt;&lt;br /&gt;
0.002731        0.004968        0.006982        NA      0.000521&amp;lt;br /&amp;gt;&lt;br /&gt;
0.020224        -0.008470       0.005664        0.000521        NA&lt;br /&gt;
&lt;br /&gt;
==Run command example==&lt;br /&gt;
&lt;br /&gt;
=== Genotype data ===&lt;br /&gt;
Download the input file containing genotypes in binary plink format&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.bed&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.bim&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.fam&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run ADMIXTURE [http://software.genetics.ucla.edu/admixture/] to obtain admixture proprotions&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;admixture admixTjeck2.bed 3&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run evalAdmix&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix -plink admixTjeck2 -fname admixTjeck2.3.P -qname admixTjeck2.3.Q -P 20 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
::Genotypes file prefix admixTjeck2 (-plink admixTjeck2).&lt;br /&gt;
::Ancestral Populations frequency file (space delimited matrix where rows are sites and columns ancestral populations) (-fname admixTjeck2.3.P).&lt;br /&gt;
::Admixture proportions file (space delimited matrix where rows are individuals and columns ancestral populations) myoutfiles.fopt.gz (-qname admixTjeck2.3.Q).&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
&lt;br /&gt;
Plot results in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source(&amp;quot;visFuns.R&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# read population labels and estimated admixture proportions&lt;br /&gt;
pop&amp;lt;-read.table(&amp;quot;admixTjeck2.fam&amp;quot;)&lt;br /&gt;
q&amp;lt;-read.table(&amp;quot;admixTjeck2.3.Q&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# order according to population and plot the ADMIXTURE reults&lt;br /&gt;
ord&amp;lt;-orderInds(pop = pop, q = q)&lt;br /&gt;
barplot(t(q)[,ord],col=2:10,space=0,border=NA,xlab=&amp;quot;Individuals&amp;quot;,ylab=&amp;quot;Demo2 Admixture proportions for K=3&amp;quot;)&lt;br /&gt;
text(tapply(1:nrow(pop),pop[ord,2],mean),-0.05,unique(pop[ord,2]),xpd=T)&lt;br /&gt;
abline(v=cumsum(sapply(unique(pop[ord,2]),function(x){sum(pop[ord,2]==x)})),col=1,lwd=1.2)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
r&amp;lt;-as.matrix(read.table(&amp;quot;output.corres.txt&amp;quot;))&lt;br /&gt;
&lt;br /&gt;
# Plot correlation of residuals&lt;br /&gt;
plotCorRes(cor_mat = r, pop = as.vector(pop[,2]), ord=ord, title=&amp;quot;Evaluation of 1000G admixture proportions with K=3&amp;quot;, max_z=0.1, min_z=-0.1)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Low depth sequencing data ===&lt;br /&gt;
Download the input file containing genotype likelihoods in beagle format&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget popgen.dk/software/download/NGSadmix/data/Demo2input.gz&lt;br /&gt;
wget popgen.dk/software/download/NGSadmix/data/Demo2pop.info&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Execute [[NgsAdmix |NGSadmix]] to obtain admixture proportions&lt;br /&gt;
&amp;lt;pre&amp;gt;./NGSadmix -likes Demo2input.gz -K 3 -P 20 -o myoutfiles -minMaf 0.05&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
::Input file = Demo2input.gz&lt;br /&gt;
::Ancestral Populations K=3&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
::Output prefix = myoutfiles (-o myoutfiles) &lt;br /&gt;
::SNPs with MAF &amp;gt; 5%  (-minMaf 0.05)&lt;br /&gt;
&lt;br /&gt;
Run evalAdmix&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix -beagle Demo2input.gz -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 20 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
::Genotype likelihoods file Demo2input.gz (-beagle Demo2input.gz).&lt;br /&gt;
::Ancestral Populations frequency file (space delimited matrix where rows are sites and columns ancestral populations) (-fname myoutfiles.fopt.gz).&lt;br /&gt;
::Admixture proportions file (space delimited matrix where rows are individuals and columns ancestral populations) myoutfiles.fopt.gz (-qname myoutfiles.qopt).&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
&lt;br /&gt;
Plot results in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source(&amp;quot;visFuns.R&amp;quot;)&lt;br /&gt;
# read population labels and estimated admixture proportions&lt;br /&gt;
pop&amp;lt;-read.table(&amp;quot;Demo2pop.info&amp;quot;,as.is=T)&lt;br /&gt;
q&amp;lt;-read.table(&amp;quot;myoutfiles.qopt&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# order according to population and plot the NGSadmix reults&lt;br /&gt;
ord&amp;lt;-orderInds(pop = pop, q = q)&lt;br /&gt;
barplot(t(q)[,ord],col=2:10,space=0,border=NA,xlab=&amp;quot;Individuals&amp;quot;,ylab=&amp;quot;Demo2 Admixture proportions for K=3&amp;quot;)&lt;br /&gt;
text(tapply(1:nrow(pop),pop[ord,1],mean),-0.05,unique(pop[ord,1]),xpd=T)&lt;br /&gt;
abline(v=cumsum(sapply(unique(pop[ord,1]),function(x){sum(pop[ord,1]==x)})),col=1,lwd=1.2)&lt;br /&gt;
&lt;br /&gt;
r&amp;lt;-read.table(&amp;quot;output.corres.txt&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Plot correlation of residuals&lt;br /&gt;
&lt;br /&gt;
plotCorRes(cor_mat = r, pop = as.vector(pop[,1]), ord = ord, title=&amp;quot;Evaluation of 1000G admixture proportions with K=3&amp;quot;, max_z=0.1, min_z=-0.1)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Citation==&lt;br /&gt;
&lt;br /&gt;
evalAdmix has a preprint&lt;br /&gt;
&lt;br /&gt;
[https://doi.org/10.1101/708883 Evaluation of Model Fit of Inferred Admixture Proportions]&lt;/div&gt;</summary>
		<author><name>Genis</name></author>
	</entry>
	<entry>
		<id>https://www.popgen.dk/software/index.php?title=EvalAdmix&amp;diff=1432</id>
		<title>EvalAdmix</title>
		<link rel="alternate" type="text/html" href="https://www.popgen.dk/software/index.php?title=EvalAdmix&amp;diff=1432"/>
		<updated>2020-04-27T08:40:47Z</updated>

		<summary type="html">&lt;p&gt;Genis: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;evalAdmix allows to evaluate the results of an admixture analysis (i.e. the result of applying [https://genome.cshlp.org/content/19/9/1655.long ADMIXTURE], [https://web.stanford.edu/group/pritchardlab/structure.html STRUCTURE], [http://www.popgen.dk/software/index.php/NgsAdmix NGSadmix] and similar). It only needs the input genotype data used for the previous admixture analysis and the output of that analysis (admixture proportions and ancestral population frequencies). The genotype input data can either be called genotypes in [https://www.cog-genomics.org/plink/1.9/formats#bed binary plink format] or genotype likelihoods in [http://www.popgen.dk/angsd/index.php/Genotype_Likelihoods#Beagle_format beagle format].&lt;br /&gt;
&lt;br /&gt;
The output is a pairwise correlation of residuals matrix between individuals. The correlation will be close to 0 in case of a good fit of the data to the admixture model. When individuals do not fit the model, individuals with similar demographic histories (i.e. usually individuals from the same population) will be positively correlated; and individuals with different histories but that are modelled as sharing one or more ancestral populations as admixture sources will have a negative correlation. Positive correlation between a pair of individuals might also be due to relatedness.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:evalAdmix.png|thumb|550px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Download and Installation==&lt;br /&gt;
&lt;br /&gt;
evalAdmix can be installed from [https://github.com/GenisGE/evalAdmix github] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;git clone https://github.com/GenisGE/evalAdmix.git&lt;br /&gt;
cd evalAdmix&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Quick start==&lt;br /&gt;
:&amp;lt;code&amp;gt; ./evalAdmix -beagle inputBeagleFile.gz  -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 10  &amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt; ./evalAdmix -plink inputPlinkPrefix  -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 10  &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''-beagle''' beagle file of genotype likelihoods&lt;br /&gt;
* '''-plink''' binary plink file prefix with genotype data&lt;br /&gt;
* '''-fname''' file with ancestral frequencies&lt;br /&gt;
* '''-qname''' file with admixture proportions&lt;br /&gt;
* '''-o''' prefix of output file names&lt;br /&gt;
* '''-P''' Number of threads used&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix  &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Arguments:&lt;br /&gt;
	Required:&lt;br /&gt;
		-plink path to binary plink file (excluding the .bed)&lt;br /&gt;
		or&lt;br /&gt;
	      	-beagle path to beagle file containing genotype likelihoods (alternative to -plink)&lt;br /&gt;
		&lt;br /&gt;
		-fname path to ancestral population frequencies file&lt;br /&gt;
	       	-qname path to admixture proportions file&lt;br /&gt;
		&lt;br /&gt;
	Optional:       &lt;br /&gt;
	&lt;br /&gt;
	       -o name of the output file&lt;br /&gt;
	       &lt;br /&gt;
	 Setup (optional):&lt;br /&gt;
	 &lt;br /&gt;
	       -P 1 number of threads&lt;br /&gt;
	       -autosomeMax 23	 autosome ends with this chromsome&lt;br /&gt;
	       -nIts 5	 number of iterations to do for frequency correction; if set to 0 calculates correlation without correction (fast but biased)&lt;br /&gt;
	       -useSites 1.0	 proportion of sites to use to calculate correlation of residuals&lt;br /&gt;
	       -useInds filename     path to tab delimited file with first column containing all individuals ID and second column with 1 to include individual in analysis and 0 otherwise (default all individuals are included)&lt;br /&gt;
	       -misTol 0.05 	 tolerance for considering site as missing when using genotype likelihoods. Use same value as used in NGSadmix to keep compatibility when using genotype likelihoods (-beagle)&lt;br /&gt;
	       -minMaf 0.05 	 minimum minor allele frequency to keep site. Use same value as used in NGSadmix to keep compatibility when using genotype likelihoods (-beagle)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Input Files==&lt;br /&gt;
&lt;br /&gt;
===Plink===&lt;br /&gt;
Genotype data files in binary PLINK format (.bed .fam .bim).&lt;br /&gt;
===Beagle genotype likelhoods===&lt;br /&gt;
The input file contains genotype likelihoods in a .beagle file format [http://faculty.washington.edu/browning/beagle/beagle.html].&lt;br /&gt;
and can be compressed with gzip.&lt;br /&gt;
==== BAM files  ====&lt;br /&gt;
If you have BAM files you can use [[ANGSD]] to produce genotype likelihoods in .beagle format. Please &lt;br /&gt;
see [http://www.popgen.dk/angsd/index.php/Beagle_input Creation of Beagle files with ANGSD]&lt;br /&gt;
&lt;br /&gt;
==== VCF files ====&lt;br /&gt;
If you already have made a VCF file that contains genotype likehood information then  it should be possible to convert .vcf files with genotype likelihoods to .beagle file via vcftools [https://vcftools.github.io/man_latest.html] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vcftools --vcf input.vcf --out test --BEAGLE-GL --chr 1,2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Chromosome has to be specified.&lt;br /&gt;
&lt;br /&gt;
You can also use bcftools' [https://samtools.github.io/bcftools/bcftools.html] 'query' option for generating a .beagle file from a .vcf file.&lt;br /&gt;
&lt;br /&gt;
==Output File==&lt;br /&gt;
The analysis performed by evalAdmix produces one file, containing a tab delimited N times N symmetric correlation matrix, where column i in line j contains the correlation of residuals between individual i and j, and the diagonal values (self-correlation) are set to NA:&lt;br /&gt;
&lt;br /&gt;
NA      0.008609        -0.006919       0.002731        0.020224&amp;lt;br /&amp;gt;&lt;br /&gt;
0.008609        NA      0.000033        0.004968        -0.008470&amp;lt;br /&amp;gt;&lt;br /&gt;
-0.006919       0.000033        NA      0.006982        0.005664&amp;lt;br /&amp;gt;&lt;br /&gt;
0.002731        0.004968        0.006982        NA      0.000521&amp;lt;br /&amp;gt;&lt;br /&gt;
0.020224        -0.008470       0.005664        0.000521        NA&lt;br /&gt;
&lt;br /&gt;
==Run command example==&lt;br /&gt;
&lt;br /&gt;
=== Genotype data ===&lt;br /&gt;
Download the input file containing genotypes in binary plink format&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.bed&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.bim&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.fam&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run ADMIXTURE [http://software.genetics.ucla.edu/admixture/] to obtain admixture proprotions&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;admixture admixTjeck2.bed 3&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run evalAdmix&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix -plink admixTjeck2 -fname admixTjeck2.3.P -qname admixTjeck2.3.Q -P 20 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
::Genotypes file prefix admixTjeck2 (-plink admixTjeck2).&lt;br /&gt;
::Ancestral Populations frequency file (space delimited matrix where rows are sites and columns ancestral populations) (-fname admixTjeck2.3.P).&lt;br /&gt;
::Admixture proportions file (space delimited matrix where rows are individuals and columns ancestral populations) myoutfiles.fopt.gz (-qname admixTjeck2.3.Q).&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
&lt;br /&gt;
Plot results in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source(&amp;quot;visFuns.R&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# read population labels and estimated admixture proportions&lt;br /&gt;
pop&amp;lt;-read.table(&amp;quot;admixTjeck2.fam&amp;quot;)&lt;br /&gt;
q&amp;lt;-read.table(&amp;quot;admixTjeck2.3.Q&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# order according to population and plot the ADMIXTURE reults&lt;br /&gt;
ord&amp;lt;-orderInds(pop = pop, q = q)&lt;br /&gt;
barplot(t(q)[,ord],col=2:10,space=0,border=NA,xlab=&amp;quot;Individuals&amp;quot;,ylab=&amp;quot;Demo2 Admixture proportions for K=3&amp;quot;)&lt;br /&gt;
text(tapply(1:nrow(pop),pop[ord,2],mean),-0.05,unique(pop[ord,2]),xpd=T)&lt;br /&gt;
abline(v=cumsum(sapply(unique(pop[ord,2]),function(x){sum(pop[ord,2]==x)})),col=1,lwd=1.2)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
r&amp;lt;-as.matrix(read.table(&amp;quot;output.corres.txt&amp;quot;))&lt;br /&gt;
&lt;br /&gt;
# Plot correlation of residuals&lt;br /&gt;
plotCorRes(cor_mat = r, pop = as.vector(pop[,2]), ord=ord, title=&amp;quot;Evaluation of 1000G admixture proportions with K=3&amp;quot;, max_z=0.1, min_z=-0.1)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Low depth sequencing data ===&lt;br /&gt;
Download the input file containing genotype likelihoods in beagle format&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget popgen.dk/software/download/NGSadmix/data/Demo2input.gz&lt;br /&gt;
wget popgen.dk/software/download/NGSadmix/data/Demo2pop.info&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Execute [[NgsAdmix |NGSadmix]] to obtain admixture proportions&lt;br /&gt;
&amp;lt;pre&amp;gt;./NGSadmix -likes Demo2input.gz -K 3 -P 20 -o myoutfiles -minMaf 0.05&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
::Input file = Demo2input.gz&lt;br /&gt;
::Ancestral Populations K=3&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
::Output prefix = myoutfiles (-o myoutfiles) &lt;br /&gt;
::SNPs with MAF &amp;gt; 5%  (-minMaf 0.05)&lt;br /&gt;
&lt;br /&gt;
Run evalAdmix&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix -beagle Demo2input.gz -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 20 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
::Genotype likelihoods file Demo2input.gz (-beagle Demo2input.gz).&lt;br /&gt;
::Ancestral Populations frequency file (space delimited matrix where rows are sites and columns ancestral populations) (-fname myoutfiles.fopt.gz).&lt;br /&gt;
::Admixture proportions file (space delimited matrix where rows are individuals and columns ancestral populations) myoutfiles.fopt.gz (-qname myoutfiles.qopt).&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
&lt;br /&gt;
Plot results in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source(&amp;quot;visFuns.R&amp;quot;)&lt;br /&gt;
# read population labels and estimated admixture proportions&lt;br /&gt;
pop&amp;lt;-read.table(&amp;quot;Demo2pop.info&amp;quot;,as.is=T)&lt;br /&gt;
q&amp;lt;-read.table(&amp;quot;myoutfiles.qopt&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# order according to population and plot the NGSadmix reults&lt;br /&gt;
ord&amp;lt;-orderInds(pop = pop, q = q)&lt;br /&gt;
barplot(t(q)[,ord],col=2:10,space=0,border=NA,xlab=&amp;quot;Individuals&amp;quot;,ylab=&amp;quot;Demo2 Admixture proportions for K=3&amp;quot;)&lt;br /&gt;
text(tapply(1:nrow(pop),pop[ord,1],mean),-0.05,unique(pop[ord,1]),xpd=T)&lt;br /&gt;
abline(v=cumsum(sapply(unique(pop[ord,1]),function(x){sum(pop[ord,1]==x)})),col=1,lwd=1.2)&lt;br /&gt;
&lt;br /&gt;
r&amp;lt;-read.table(&amp;quot;output.corres.txt&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Plot correlation of residuals&lt;br /&gt;
&lt;br /&gt;
plotCorRes(cor_mat = r, pop = as.vector(pop[,1]), ord = ord, title=&amp;quot;Evaluation of 1000G admixture proportions with K=3&amp;quot;, max_z=0.1, min_z=-0.1)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Citation==&lt;br /&gt;
&lt;br /&gt;
evalAdmix has a preprint&lt;br /&gt;
&lt;br /&gt;
[https://doi.org/10.1101/708883 Evaluation of Model Fit of Inferred Admixture Proportions]&lt;/div&gt;</summary>
		<author><name>Genis</name></author>
	</entry>
	<entry>
		<id>https://www.popgen.dk/software/index.php?title=File:EvalAdmix.png&amp;diff=1431</id>
		<title>File:EvalAdmix.png</title>
		<link rel="alternate" type="text/html" href="https://www.popgen.dk/software/index.php?title=File:EvalAdmix.png&amp;diff=1431"/>
		<updated>2020-04-27T08:07:46Z</updated>

		<summary type="html">&lt;p&gt;Genis: Genis uploaded a new version of File:EvalAdmix.png&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Genis</name></author>
	</entry>
	<entry>
		<id>https://www.popgen.dk/software/index.php?title=EvalAdmix&amp;diff=1223</id>
		<title>EvalAdmix</title>
		<link rel="alternate" type="text/html" href="https://www.popgen.dk/software/index.php?title=EvalAdmix&amp;diff=1223"/>
		<updated>2019-07-21T12:25:17Z</updated>

		<summary type="html">&lt;p&gt;Genis: /* Genotype data */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;evalAdmix allows to evaluate the model fit of an admixture analysis. It takes as input the genotype data (either called genotypes in plink files or genotype likelihoods beagle files) used in the admixture analysis and the estimated ancestral frequency and admixture propotions files (P and Q files).&lt;br /&gt;
&lt;br /&gt;
The output is a pairwise correlation of residuals matrix between individuals. The correlation will be 0 in case of a good fit of the data to the admixture model. When something is wrong, individuals from the same population will be positively correlated; and individuals from different populationts but that share one or more ancestral populations as admixture sources will have a negative correlation. Positive correlation between a pair of individuals might also be due to relatedness.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:evalAdmix.png|thumb|550px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Download and Installation==&lt;br /&gt;
&lt;br /&gt;
evalAdmix can be installed from [https://github.com/GenisGE/evalAdmix github] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;git clone https://github.com/GenisGE/evalAdmix.git&lt;br /&gt;
cd evalAdmix&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Quick start==&lt;br /&gt;
:&amp;lt;code&amp;gt; ./evalAdmix -beagle inputBeagleFile.gz  -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 10  &amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt; ./evalAdmix -plink inputPlinkPrefix  -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 10  &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''-beagle''' beagle file of genotype likelihoods&lt;br /&gt;
* '''-plink''' binary plink file prefix with genotype data&lt;br /&gt;
* '''-fname''' file with ancestral frequencies&lt;br /&gt;
* '''-qname''' file with admixture proportions&lt;br /&gt;
* '''-o''' prefix of output file names&lt;br /&gt;
* '''-P''' Number of threads used&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix  &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Arguments:&lt;br /&gt;
	Required:&lt;br /&gt;
		-plink path to binary plink file (excluding the .bed)&lt;br /&gt;
		or&lt;br /&gt;
	      	-beagle path to beagle file containing genotype likelihoods (alternative to -plink)&lt;br /&gt;
		&lt;br /&gt;
		-fname path to ancestral population frequencies file&lt;br /&gt;
	       	-qname path to admixture proportions file&lt;br /&gt;
		&lt;br /&gt;
	Optional:       &lt;br /&gt;
	&lt;br /&gt;
	       -o name of the output file&lt;br /&gt;
	       &lt;br /&gt;
	 Setup (optional):&lt;br /&gt;
	 &lt;br /&gt;
	       -P 1 number of threads&lt;br /&gt;
	       -autosomeMax 23	 autosome ends with this chromsome&lt;br /&gt;
	       -nIts 5	 number of iterations to do for frequency correction; if set to 0 calculates correlation without correction (fast but biased)&lt;br /&gt;
	       -useSites 1.0	 proportion of sites to use to calculate correlation of residuals&lt;br /&gt;
	       -useInds filename     path to tab delimited file with first column containing all individuals ID and second column with 1 to include individual in analysis and 0 otherwise (default all individuals are included)&lt;br /&gt;
	       -misTol 0.05 	 tolerance for considering site as missing when using genotype likelihoods. Use same value as used in NGSadmix to keep compatibility when using genotype likelihoods (-beagle)&lt;br /&gt;
	       -minMaf 0.05 	 minimum minor allele frequency to keep site. Use same value as used in NGSadmix to keep compatibility when using genotype likelihoods (-beagle)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Input Files==&lt;br /&gt;
&lt;br /&gt;
===Plink===&lt;br /&gt;
Genotype data files in binary PLINK format (.bed .fam .bim).&lt;br /&gt;
===Beagle genotype likelhoods===&lt;br /&gt;
The input file contains genotype likelihoods in a .beagle file format [http://faculty.washington.edu/browning/beagle/beagle.html].&lt;br /&gt;
and can be compressed with gzip.&lt;br /&gt;
==== BAM files  ====&lt;br /&gt;
If you have BAM files you can use [[ANGSD]] to produce genotype likelihoods in .beagle format. Please &lt;br /&gt;
see [http://www.popgen.dk/angsd/index.php/Beagle_input Creation of Beagle files with ANGSD]&lt;br /&gt;
&lt;br /&gt;
==== VCF files ====&lt;br /&gt;
If you already have made a VCF file that contains genotype likehood information then  it should be possible to convert .vcf files with genotype likelihoods to .beagle file via vcftools [https://vcftools.github.io/man_latest.html] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vcftools --vcf input.vcf --out test --BEAGLE-GL --chr 1,2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Chromosome has to be specified.&lt;br /&gt;
&lt;br /&gt;
You can also use bcftools' [https://samtools.github.io/bcftools/bcftools.html] 'query' option for generating a .beagle file from a .vcf file.&lt;br /&gt;
&lt;br /&gt;
==Output File==&lt;br /&gt;
The analysis performed by evalAdmix produces one file, containing a tab delimited N times N symmetric correlation matrix, where column i in line j contains the correlation of residuals between individual i and j, and the diagonal values (self-correlation) are set to NA:&lt;br /&gt;
&lt;br /&gt;
NA      0.008609        -0.006919       0.002731        0.020224&amp;lt;br /&amp;gt;&lt;br /&gt;
0.008609        NA      0.000033        0.004968        -0.008470&amp;lt;br /&amp;gt;&lt;br /&gt;
-0.006919       0.000033        NA      0.006982        0.005664&amp;lt;br /&amp;gt;&lt;br /&gt;
0.002731        0.004968        0.006982        NA      0.000521&amp;lt;br /&amp;gt;&lt;br /&gt;
0.020224        -0.008470       0.005664        0.000521        NA&lt;br /&gt;
&lt;br /&gt;
==Run command example==&lt;br /&gt;
&lt;br /&gt;
=== Genotype data ===&lt;br /&gt;
Download the input file containing genotypes in binary plink format&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.bed&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.bim&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.fam&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run ADMIXTURE [http://software.genetics.ucla.edu/admixture/] to obtain admixture proprotions&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;admixture admixTjeck2.bed 3&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run evalAdmix&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix -plink admixTjeck2 -fname admixTjeck2.3.P -qname admixTjeck2.3.Q -P 20 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Plot results in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# read population labels and estimated admixture proportions&lt;br /&gt;
pop&amp;lt;-read.table(&amp;quot;admixTjeck2.fam&amp;quot;)&lt;br /&gt;
q&amp;lt;-read.table(&amp;quot;admixTjeck2.3.Q&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# order according to population and plot the ADMIXTURE reults&lt;br /&gt;
ord&amp;lt;-order(pop[,2])&lt;br /&gt;
barplot(t(q)[,ord],col=2:10,space=0,border=NA,xlab=&amp;quot;Individuals&amp;quot;,ylab=&amp;quot;Demo2 Admixture proportions for K=3&amp;quot;)&lt;br /&gt;
text(tapply(1:nrow(pop),pop[ord,2],mean),-0.05,unique(pop[ord,2]),xpd=T)&lt;br /&gt;
abline(v=cumsum(sapply(unique(pop[ord,2]),function(x){sum(pop[ord,2]==x)})),col=1,lwd=1.2)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
r&amp;lt;-as.matrix(read.table(&amp;quot;output.corres.txt&amp;quot;))&lt;br /&gt;
&lt;br /&gt;
# Plot correlation of residuals&lt;br /&gt;
source(&amp;quot;NicePlotCorRes.R&amp;quot;)&lt;br /&gt;
plotCorRes(cor_mat = r, pop = as.vector(pop[,2]), title=&amp;quot;Evaluation of 1000G admixture proportions with K=3&amp;quot;, max_z=0.1, min_z=-0.1)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Low depth sequencing data ===&lt;br /&gt;
Download the input file containing genotype likelihoods in beagle format&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget popgen.dk/software/download/NGSadmix/data/Demo2input.gz&lt;br /&gt;
wget popgen.dk/software/download/NGSadmix/data/Demo2pop.info&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Execute [[NgsAdmix |NGSadmix]] to obtain admixture proportions&lt;br /&gt;
&amp;lt;pre&amp;gt;./NGSadmix -likes Demo2input.gz -K 3 -P 20 -o myoutfiles -minMaf 0.05&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
::Input file = Demo2input.gz&lt;br /&gt;
::Ancestral Populations K=3&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
::Output prefix = myoutfiles (-o myoutfiles) &lt;br /&gt;
::SNPs with MAF &amp;gt; 5%  (-minMaf 0.05)&lt;br /&gt;
&lt;br /&gt;
Run evalAdmix&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix -beagle Demo2input.gz -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 20 &amp;lt;/pre&amp;gt;&lt;br /&gt;
::Input file = input.gz&lt;br /&gt;
::Ancestral Populations frequency file myoutfiles.fopt.gz&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
&lt;br /&gt;
Plot results in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# read population labels and estimated admixture proportions&lt;br /&gt;
pop&amp;lt;-read.table(&amp;quot;Demo2pop.info&amp;quot;,as.is=T)&lt;br /&gt;
q&amp;lt;-read.table(&amp;quot;myoutfiles.qopt&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# order according to population and plot the NGSadmix reults&lt;br /&gt;
ord&amp;lt;-order(pop[,1])&lt;br /&gt;
barplot(t(q)[,ord],col=2:10,space=0,border=NA,xlab=&amp;quot;Individuals&amp;quot;,ylab=&amp;quot;Demo2 Admixture proportions for K=3&amp;quot;)&lt;br /&gt;
text(tapply(1:nrow(pop),pop[ord,1],mean),-0.05,unique(pop[ord,1]),xpd=T)&lt;br /&gt;
abline(v=cumsum(sapply(unique(pop[ord,1]),function(x){sum(pop[ord,1]==x)})),col=1,lwd=1.2)&lt;br /&gt;
&lt;br /&gt;
r&amp;lt;-read.table(&amp;quot;output.corres.txt&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Plot correlation of residuals&lt;br /&gt;
source(&amp;quot;NicePlotCorRes.R&amp;quot;)&lt;br /&gt;
plotCorRes(cor_mat = r, pop = as.vector(pop[,1]), title=&amp;quot;Evaluation of 1000G admixture proportions with K=3&amp;quot;, max_z=0.1, min_z=-0.1)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Citation==&lt;br /&gt;
&lt;br /&gt;
evalAdmix has a preprint&lt;br /&gt;
&lt;br /&gt;
[https://doi.org/10.1101/708883 Evaluation of Model Fit of Inferred Admixture Proportions]&lt;/div&gt;</summary>
		<author><name>Genis</name></author>
	</entry>
	<entry>
		<id>https://www.popgen.dk/software/index.php?title=EvalAdmix&amp;diff=1222</id>
		<title>EvalAdmix</title>
		<link rel="alternate" type="text/html" href="https://www.popgen.dk/software/index.php?title=EvalAdmix&amp;diff=1222"/>
		<updated>2019-07-21T12:24:54Z</updated>

		<summary type="html">&lt;p&gt;Genis: /* Output Files */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;evalAdmix allows to evaluate the model fit of an admixture analysis. It takes as input the genotype data (either called genotypes in plink files or genotype likelihoods beagle files) used in the admixture analysis and the estimated ancestral frequency and admixture propotions files (P and Q files).&lt;br /&gt;
&lt;br /&gt;
The output is a pairwise correlation of residuals matrix between individuals. The correlation will be 0 in case of a good fit of the data to the admixture model. When something is wrong, individuals from the same population will be positively correlated; and individuals from different populationts but that share one or more ancestral populations as admixture sources will have a negative correlation. Positive correlation between a pair of individuals might also be due to relatedness.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:evalAdmix.png|thumb|550px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Download and Installation==&lt;br /&gt;
&lt;br /&gt;
evalAdmix can be installed from [https://github.com/GenisGE/evalAdmix github] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;git clone https://github.com/GenisGE/evalAdmix.git&lt;br /&gt;
cd evalAdmix&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Quick start==&lt;br /&gt;
:&amp;lt;code&amp;gt; ./evalAdmix -beagle inputBeagleFile.gz  -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 10  &amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt; ./evalAdmix -plink inputPlinkPrefix  -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 10  &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''-beagle''' beagle file of genotype likelihoods&lt;br /&gt;
* '''-plink''' binary plink file prefix with genotype data&lt;br /&gt;
* '''-fname''' file with ancestral frequencies&lt;br /&gt;
* '''-qname''' file with admixture proportions&lt;br /&gt;
* '''-o''' prefix of output file names&lt;br /&gt;
* '''-P''' Number of threads used&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix  &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Arguments:&lt;br /&gt;
	Required:&lt;br /&gt;
		-plink path to binary plink file (excluding the .bed)&lt;br /&gt;
		or&lt;br /&gt;
	      	-beagle path to beagle file containing genotype likelihoods (alternative to -plink)&lt;br /&gt;
		&lt;br /&gt;
		-fname path to ancestral population frequencies file&lt;br /&gt;
	       	-qname path to admixture proportions file&lt;br /&gt;
		&lt;br /&gt;
	Optional:       &lt;br /&gt;
	&lt;br /&gt;
	       -o name of the output file&lt;br /&gt;
	       &lt;br /&gt;
	 Setup (optional):&lt;br /&gt;
	 &lt;br /&gt;
	       -P 1 number of threads&lt;br /&gt;
	       -autosomeMax 23	 autosome ends with this chromsome&lt;br /&gt;
	       -nIts 5	 number of iterations to do for frequency correction; if set to 0 calculates correlation without correction (fast but biased)&lt;br /&gt;
	       -useSites 1.0	 proportion of sites to use to calculate correlation of residuals&lt;br /&gt;
	       -useInds filename     path to tab delimited file with first column containing all individuals ID and second column with 1 to include individual in analysis and 0 otherwise (default all individuals are included)&lt;br /&gt;
	       -misTol 0.05 	 tolerance for considering site as missing when using genotype likelihoods. Use same value as used in NGSadmix to keep compatibility when using genotype likelihoods (-beagle)&lt;br /&gt;
	       -minMaf 0.05 	 minimum minor allele frequency to keep site. Use same value as used in NGSadmix to keep compatibility when using genotype likelihoods (-beagle)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Input Files==&lt;br /&gt;
&lt;br /&gt;
===Plink===&lt;br /&gt;
Genotype data files in binary PLINK format (.bed .fam .bim).&lt;br /&gt;
===Beagle genotype likelhoods===&lt;br /&gt;
The input file contains genotype likelihoods in a .beagle file format [http://faculty.washington.edu/browning/beagle/beagle.html].&lt;br /&gt;
and can be compressed with gzip.&lt;br /&gt;
==== BAM files  ====&lt;br /&gt;
If you have BAM files you can use [[ANGSD]] to produce genotype likelihoods in .beagle format. Please &lt;br /&gt;
see [http://www.popgen.dk/angsd/index.php/Beagle_input Creation of Beagle files with ANGSD]&lt;br /&gt;
&lt;br /&gt;
==== VCF files ====&lt;br /&gt;
If you already have made a VCF file that contains genotype likehood information then  it should be possible to convert .vcf files with genotype likelihoods to .beagle file via vcftools [https://vcftools.github.io/man_latest.html] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vcftools --vcf input.vcf --out test --BEAGLE-GL --chr 1,2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Chromosome has to be specified.&lt;br /&gt;
&lt;br /&gt;
You can also use bcftools' [https://samtools.github.io/bcftools/bcftools.html] 'query' option for generating a .beagle file from a .vcf file.&lt;br /&gt;
&lt;br /&gt;
==Output File==&lt;br /&gt;
The analysis performed by evalAdmix produces one file, containing a tab delimited N times N symmetric correlation matrix, where column i in line j contains the correlation of residuals between individual i and j, and the diagonal values (self-correlation) are set to NA:&lt;br /&gt;
&lt;br /&gt;
NA      0.008609        -0.006919       0.002731        0.020224&amp;lt;br /&amp;gt;&lt;br /&gt;
0.008609        NA      0.000033        0.004968        -0.008470&amp;lt;br /&amp;gt;&lt;br /&gt;
-0.006919       0.000033        NA      0.006982        0.005664&amp;lt;br /&amp;gt;&lt;br /&gt;
0.002731        0.004968        0.006982        NA      0.000521&amp;lt;br /&amp;gt;&lt;br /&gt;
0.020224        -0.008470       0.005664        0.000521        NA&lt;br /&gt;
&lt;br /&gt;
==Run command example==&lt;br /&gt;
&lt;br /&gt;
=== Genotype data ===&lt;br /&gt;
Download the input file containing genotype in binary plink format&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.bed&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.bim&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.fam&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run ADMIXTURE [http://software.genetics.ucla.edu/admixture/] to obtain admixture proprotions&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;admixture admixTjeck2.bed 3&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run evalAdmix&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix -plink admixTjeck2 -fname admixTjeck2.3.P -qname admixTjeck2.3.Q -P 20 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Plot results in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# read population labels and estimated admixture proportions&lt;br /&gt;
pop&amp;lt;-read.table(&amp;quot;admixTjeck2.fam&amp;quot;)&lt;br /&gt;
q&amp;lt;-read.table(&amp;quot;admixTjeck2.3.Q&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# order according to population and plot the ADMIXTURE reults&lt;br /&gt;
ord&amp;lt;-order(pop[,2])&lt;br /&gt;
barplot(t(q)[,ord],col=2:10,space=0,border=NA,xlab=&amp;quot;Individuals&amp;quot;,ylab=&amp;quot;Demo2 Admixture proportions for K=3&amp;quot;)&lt;br /&gt;
text(tapply(1:nrow(pop),pop[ord,2],mean),-0.05,unique(pop[ord,2]),xpd=T)&lt;br /&gt;
abline(v=cumsum(sapply(unique(pop[ord,2]),function(x){sum(pop[ord,2]==x)})),col=1,lwd=1.2)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
r&amp;lt;-as.matrix(read.table(&amp;quot;output.corres.txt&amp;quot;))&lt;br /&gt;
&lt;br /&gt;
# Plot correlation of residuals&lt;br /&gt;
source(&amp;quot;NicePlotCorRes.R&amp;quot;)&lt;br /&gt;
plotCorRes(cor_mat = r, pop = as.vector(pop[,2]), title=&amp;quot;Evaluation of 1000G admixture proportions with K=3&amp;quot;, max_z=0.1, min_z=-0.1)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Low depth sequencing data ===&lt;br /&gt;
Download the input file containing genotype likelihoods in beagle format&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget popgen.dk/software/download/NGSadmix/data/Demo2input.gz&lt;br /&gt;
wget popgen.dk/software/download/NGSadmix/data/Demo2pop.info&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Execute [[NgsAdmix |NGSadmix]] to obtain admixture proportions&lt;br /&gt;
&amp;lt;pre&amp;gt;./NGSadmix -likes Demo2input.gz -K 3 -P 20 -o myoutfiles -minMaf 0.05&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
::Input file = Demo2input.gz&lt;br /&gt;
::Ancestral Populations K=3&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
::Output prefix = myoutfiles (-o myoutfiles) &lt;br /&gt;
::SNPs with MAF &amp;gt; 5%  (-minMaf 0.05)&lt;br /&gt;
&lt;br /&gt;
Run evalAdmix&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix -beagle Demo2input.gz -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 20 &amp;lt;/pre&amp;gt;&lt;br /&gt;
::Input file = input.gz&lt;br /&gt;
::Ancestral Populations frequency file myoutfiles.fopt.gz&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
&lt;br /&gt;
Plot results in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# read population labels and estimated admixture proportions&lt;br /&gt;
pop&amp;lt;-read.table(&amp;quot;Demo2pop.info&amp;quot;,as.is=T)&lt;br /&gt;
q&amp;lt;-read.table(&amp;quot;myoutfiles.qopt&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# order according to population and plot the NGSadmix reults&lt;br /&gt;
ord&amp;lt;-order(pop[,1])&lt;br /&gt;
barplot(t(q)[,ord],col=2:10,space=0,border=NA,xlab=&amp;quot;Individuals&amp;quot;,ylab=&amp;quot;Demo2 Admixture proportions for K=3&amp;quot;)&lt;br /&gt;
text(tapply(1:nrow(pop),pop[ord,1],mean),-0.05,unique(pop[ord,1]),xpd=T)&lt;br /&gt;
abline(v=cumsum(sapply(unique(pop[ord,1]),function(x){sum(pop[ord,1]==x)})),col=1,lwd=1.2)&lt;br /&gt;
&lt;br /&gt;
r&amp;lt;-read.table(&amp;quot;output.corres.txt&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Plot correlation of residuals&lt;br /&gt;
source(&amp;quot;NicePlotCorRes.R&amp;quot;)&lt;br /&gt;
plotCorRes(cor_mat = r, pop = as.vector(pop[,1]), title=&amp;quot;Evaluation of 1000G admixture proportions with K=3&amp;quot;, max_z=0.1, min_z=-0.1)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Citation==&lt;br /&gt;
&lt;br /&gt;
evalAdmix has a preprint&lt;br /&gt;
&lt;br /&gt;
[https://doi.org/10.1101/708883 Evaluation of Model Fit of Inferred Admixture Proportions]&lt;/div&gt;</summary>
		<author><name>Genis</name></author>
	</entry>
	<entry>
		<id>https://www.popgen.dk/software/index.php?title=EvalAdmix&amp;diff=1221</id>
		<title>EvalAdmix</title>
		<link rel="alternate" type="text/html" href="https://www.popgen.dk/software/index.php?title=EvalAdmix&amp;diff=1221"/>
		<updated>2019-07-21T12:24:31Z</updated>

		<summary type="html">&lt;p&gt;Genis: /* Input File */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;evalAdmix allows to evaluate the model fit of an admixture analysis. It takes as input the genotype data (either called genotypes in plink files or genotype likelihoods beagle files) used in the admixture analysis and the estimated ancestral frequency and admixture propotions files (P and Q files).&lt;br /&gt;
&lt;br /&gt;
The output is a pairwise correlation of residuals matrix between individuals. The correlation will be 0 in case of a good fit of the data to the admixture model. When something is wrong, individuals from the same population will be positively correlated; and individuals from different populationts but that share one or more ancestral populations as admixture sources will have a negative correlation. Positive correlation between a pair of individuals might also be due to relatedness.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:evalAdmix.png|thumb|550px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Download and Installation==&lt;br /&gt;
&lt;br /&gt;
evalAdmix can be installed from [https://github.com/GenisGE/evalAdmix github] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;git clone https://github.com/GenisGE/evalAdmix.git&lt;br /&gt;
cd evalAdmix&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Quick start==&lt;br /&gt;
:&amp;lt;code&amp;gt; ./evalAdmix -beagle inputBeagleFile.gz  -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 10  &amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt; ./evalAdmix -plink inputPlinkPrefix  -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 10  &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''-beagle''' beagle file of genotype likelihoods&lt;br /&gt;
* '''-plink''' binary plink file prefix with genotype data&lt;br /&gt;
* '''-fname''' file with ancestral frequencies&lt;br /&gt;
* '''-qname''' file with admixture proportions&lt;br /&gt;
* '''-o''' prefix of output file names&lt;br /&gt;
* '''-P''' Number of threads used&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix  &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Arguments:&lt;br /&gt;
	Required:&lt;br /&gt;
		-plink path to binary plink file (excluding the .bed)&lt;br /&gt;
		or&lt;br /&gt;
	      	-beagle path to beagle file containing genotype likelihoods (alternative to -plink)&lt;br /&gt;
		&lt;br /&gt;
		-fname path to ancestral population frequencies file&lt;br /&gt;
	       	-qname path to admixture proportions file&lt;br /&gt;
		&lt;br /&gt;
	Optional:       &lt;br /&gt;
	&lt;br /&gt;
	       -o name of the output file&lt;br /&gt;
	       &lt;br /&gt;
	 Setup (optional):&lt;br /&gt;
	 &lt;br /&gt;
	       -P 1 number of threads&lt;br /&gt;
	       -autosomeMax 23	 autosome ends with this chromsome&lt;br /&gt;
	       -nIts 5	 number of iterations to do for frequency correction; if set to 0 calculates correlation without correction (fast but biased)&lt;br /&gt;
	       -useSites 1.0	 proportion of sites to use to calculate correlation of residuals&lt;br /&gt;
	       -useInds filename     path to tab delimited file with first column containing all individuals ID and second column with 1 to include individual in analysis and 0 otherwise (default all individuals are included)&lt;br /&gt;
	       -misTol 0.05 	 tolerance for considering site as missing when using genotype likelihoods. Use same value as used in NGSadmix to keep compatibility when using genotype likelihoods (-beagle)&lt;br /&gt;
	       -minMaf 0.05 	 minimum minor allele frequency to keep site. Use same value as used in NGSadmix to keep compatibility when using genotype likelihoods (-beagle)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Input Files==&lt;br /&gt;
&lt;br /&gt;
===Plink===&lt;br /&gt;
Genotype data files in binary PLINK format (.bed .fam .bim).&lt;br /&gt;
===Beagle genotype likelhoods===&lt;br /&gt;
The input file contains genotype likelihoods in a .beagle file format [http://faculty.washington.edu/browning/beagle/beagle.html].&lt;br /&gt;
and can be compressed with gzip.&lt;br /&gt;
==== BAM files  ====&lt;br /&gt;
If you have BAM files you can use [[ANGSD]] to produce genotype likelihoods in .beagle format. Please &lt;br /&gt;
see [http://www.popgen.dk/angsd/index.php/Beagle_input Creation of Beagle files with ANGSD]&lt;br /&gt;
&lt;br /&gt;
==== VCF files ====&lt;br /&gt;
If you already have made a VCF file that contains genotype likehood information then  it should be possible to convert .vcf files with genotype likelihoods to .beagle file via vcftools [https://vcftools.github.io/man_latest.html] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vcftools --vcf input.vcf --out test --BEAGLE-GL --chr 1,2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Chromosome has to be specified.&lt;br /&gt;
&lt;br /&gt;
You can also use bcftools' [https://samtools.github.io/bcftools/bcftools.html] 'query' option for generating a .beagle file from a .vcf file.&lt;br /&gt;
&lt;br /&gt;
==Output Files==&lt;br /&gt;
The analysis performed by evalAdmix produces 1 file, containing a tab delimited N times N symmetric correlation matrix, where column i in line j contains the correlation of residuals between individual i and j, and the diagonal values (self-correlation) are set to NA:&lt;br /&gt;
&lt;br /&gt;
NA      0.008609        -0.006919       0.002731        0.020224&amp;lt;br /&amp;gt;&lt;br /&gt;
0.008609        NA      0.000033        0.004968        -0.008470&amp;lt;br /&amp;gt;&lt;br /&gt;
-0.006919       0.000033        NA      0.006982        0.005664&amp;lt;br /&amp;gt;&lt;br /&gt;
0.002731        0.004968        0.006982        NA      0.000521&amp;lt;br /&amp;gt;&lt;br /&gt;
0.020224        -0.008470       0.005664        0.000521        NA&lt;br /&gt;
&lt;br /&gt;
==Run command example==&lt;br /&gt;
&lt;br /&gt;
=== Genotype data ===&lt;br /&gt;
Download the input file containing genotype in binary plink format&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.bed&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.bim&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.fam&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run ADMIXTURE [http://software.genetics.ucla.edu/admixture/] to obtain admixture proprotions&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;admixture admixTjeck2.bed 3&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run evalAdmix&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix -plink admixTjeck2 -fname admixTjeck2.3.P -qname admixTjeck2.3.Q -P 20 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Plot results in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# read population labels and estimated admixture proportions&lt;br /&gt;
pop&amp;lt;-read.table(&amp;quot;admixTjeck2.fam&amp;quot;)&lt;br /&gt;
q&amp;lt;-read.table(&amp;quot;admixTjeck2.3.Q&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# order according to population and plot the ADMIXTURE reults&lt;br /&gt;
ord&amp;lt;-order(pop[,2])&lt;br /&gt;
barplot(t(q)[,ord],col=2:10,space=0,border=NA,xlab=&amp;quot;Individuals&amp;quot;,ylab=&amp;quot;Demo2 Admixture proportions for K=3&amp;quot;)&lt;br /&gt;
text(tapply(1:nrow(pop),pop[ord,2],mean),-0.05,unique(pop[ord,2]),xpd=T)&lt;br /&gt;
abline(v=cumsum(sapply(unique(pop[ord,2]),function(x){sum(pop[ord,2]==x)})),col=1,lwd=1.2)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
r&amp;lt;-as.matrix(read.table(&amp;quot;output.corres.txt&amp;quot;))&lt;br /&gt;
&lt;br /&gt;
# Plot correlation of residuals&lt;br /&gt;
source(&amp;quot;NicePlotCorRes.R&amp;quot;)&lt;br /&gt;
plotCorRes(cor_mat = r, pop = as.vector(pop[,2]), title=&amp;quot;Evaluation of 1000G admixture proportions with K=3&amp;quot;, max_z=0.1, min_z=-0.1)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Low depth sequencing data ===&lt;br /&gt;
Download the input file containing genotype likelihoods in beagle format&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget popgen.dk/software/download/NGSadmix/data/Demo2input.gz&lt;br /&gt;
wget popgen.dk/software/download/NGSadmix/data/Demo2pop.info&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Execute [[NgsAdmix |NGSadmix]] to obtain admixture proportions&lt;br /&gt;
&amp;lt;pre&amp;gt;./NGSadmix -likes Demo2input.gz -K 3 -P 20 -o myoutfiles -minMaf 0.05&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
::Input file = Demo2input.gz&lt;br /&gt;
::Ancestral Populations K=3&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
::Output prefix = myoutfiles (-o myoutfiles) &lt;br /&gt;
::SNPs with MAF &amp;gt; 5%  (-minMaf 0.05)&lt;br /&gt;
&lt;br /&gt;
Run evalAdmix&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix -beagle Demo2input.gz -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 20 &amp;lt;/pre&amp;gt;&lt;br /&gt;
::Input file = input.gz&lt;br /&gt;
::Ancestral Populations frequency file myoutfiles.fopt.gz&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
&lt;br /&gt;
Plot results in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# read population labels and estimated admixture proportions&lt;br /&gt;
pop&amp;lt;-read.table(&amp;quot;Demo2pop.info&amp;quot;,as.is=T)&lt;br /&gt;
q&amp;lt;-read.table(&amp;quot;myoutfiles.qopt&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# order according to population and plot the NGSadmix reults&lt;br /&gt;
ord&amp;lt;-order(pop[,1])&lt;br /&gt;
barplot(t(q)[,ord],col=2:10,space=0,border=NA,xlab=&amp;quot;Individuals&amp;quot;,ylab=&amp;quot;Demo2 Admixture proportions for K=3&amp;quot;)&lt;br /&gt;
text(tapply(1:nrow(pop),pop[ord,1],mean),-0.05,unique(pop[ord,1]),xpd=T)&lt;br /&gt;
abline(v=cumsum(sapply(unique(pop[ord,1]),function(x){sum(pop[ord,1]==x)})),col=1,lwd=1.2)&lt;br /&gt;
&lt;br /&gt;
r&amp;lt;-read.table(&amp;quot;output.corres.txt&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Plot correlation of residuals&lt;br /&gt;
source(&amp;quot;NicePlotCorRes.R&amp;quot;)&lt;br /&gt;
plotCorRes(cor_mat = r, pop = as.vector(pop[,1]), title=&amp;quot;Evaluation of 1000G admixture proportions with K=3&amp;quot;, max_z=0.1, min_z=-0.1)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Citation==&lt;br /&gt;
&lt;br /&gt;
evalAdmix has a preprint&lt;br /&gt;
&lt;br /&gt;
[https://doi.org/10.1101/708883 Evaluation of Model Fit of Inferred Admixture Proportions]&lt;/div&gt;</summary>
		<author><name>Genis</name></author>
	</entry>
	<entry>
		<id>https://www.popgen.dk/software/index.php?title=EvalAdmix&amp;diff=1220</id>
		<title>EvalAdmix</title>
		<link rel="alternate" type="text/html" href="https://www.popgen.dk/software/index.php?title=EvalAdmix&amp;diff=1220"/>
		<updated>2019-07-21T12:01:03Z</updated>

		<summary type="html">&lt;p&gt;Genis: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;evalAdmix allows to evaluate the model fit of an admixture analysis. It takes as input the genotype data (either called genotypes in plink files or genotype likelihoods beagle files) used in the admixture analysis and the estimated ancestral frequency and admixture propotions files (P and Q files).&lt;br /&gt;
&lt;br /&gt;
The output is a pairwise correlation of residuals matrix between individuals. The correlation will be 0 in case of a good fit of the data to the admixture model. When something is wrong, individuals from the same population will be positively correlated; and individuals from different populationts but that share one or more ancestral populations as admixture sources will have a negative correlation. Positive correlation between a pair of individuals might also be due to relatedness.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:evalAdmix.png|thumb|550px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Download and Installation==&lt;br /&gt;
&lt;br /&gt;
evalAdmix can be installed from [https://github.com/GenisGE/evalAdmix github] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;git clone https://github.com/GenisGE/evalAdmix.git&lt;br /&gt;
cd evalAdmix&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Quick start==&lt;br /&gt;
:&amp;lt;code&amp;gt; ./evalAdmix -beagle inputBeagleFile.gz  -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 10  &amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt; ./evalAdmix -plink inputPlinkPrefix  -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 10  &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''-beagle''' beagle file of genotype likelihoods&lt;br /&gt;
* '''-plink''' binary plink file prefix with genotype data&lt;br /&gt;
* '''-fname''' file with ancestral frequencies&lt;br /&gt;
* '''-qname''' file with admixture proportions&lt;br /&gt;
* '''-o''' prefix of output file names&lt;br /&gt;
* '''-P''' Number of threads used&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix  &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Arguments:&lt;br /&gt;
	Required:&lt;br /&gt;
		-plink path to binary plink file (excluding the .bed)&lt;br /&gt;
		or&lt;br /&gt;
	      	-beagle path to beagle file containing genotype likelihoods (alternative to -plink)&lt;br /&gt;
		&lt;br /&gt;
		-fname path to ancestral population frequencies file&lt;br /&gt;
	       	-qname path to admixture proportions file&lt;br /&gt;
		&lt;br /&gt;
	Optional:       &lt;br /&gt;
	&lt;br /&gt;
	       -o name of the output file&lt;br /&gt;
	       &lt;br /&gt;
	 Setup (optional):&lt;br /&gt;
	 &lt;br /&gt;
	       -P 1 number of threads&lt;br /&gt;
	       -autosomeMax 23	 autosome ends with this chromsome&lt;br /&gt;
	       -nIts 5	 number of iterations to do for frequency correction; if set to 0 calculates correlation without correction (fast but biased)&lt;br /&gt;
	       -useSites 1.0	 proportion of sites to use to calculate correlation of residuals&lt;br /&gt;
	       -useInds filename     path to tab delimited file with first column containing all individuals ID and second column with 1 to include individual in analysis and 0 otherwise (default all individuals are included)&lt;br /&gt;
	       -misTol 0.05 	 tolerance for considering site as missing when using genotype likelihoods. Use same value as used in NGSadmix to keep compatibility when using genotype likelihoods (-beagle)&lt;br /&gt;
	       -minMaf 0.05 	 minimum minor allele frequency to keep site. Use same value as used in NGSadmix to keep compatibility when using genotype likelihoods (-beagle)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Input File==&lt;br /&gt;
&lt;br /&gt;
===Plink===&lt;br /&gt;
Genotype data files in binary PLINK format (.bed .fam .bim).&lt;br /&gt;
===Beagle genotype likelhoods===&lt;br /&gt;
The input file contains genotype likelihoods in a .beagle file format [http://faculty.washington.edu/browning/beagle/beagle.html].&lt;br /&gt;
and can be compressed with gzip.&lt;br /&gt;
==== BAM files  ====&lt;br /&gt;
If you have BAM files you can use [[ANGSD]] to produce genotype likelihoods in .beagle format. Please &lt;br /&gt;
see [http://www.popgen.dk/angsd/index.php/Beagle_input Creation of Beagle files with ANGSD]&lt;br /&gt;
&lt;br /&gt;
==== VCF files ====&lt;br /&gt;
If you already have made a VCF file that contains genotype likehood information then  it should be possible to convert .vcf files with genotype likelihoods to .beagle file via vcftools [https://vcftools.github.io/man_latest.html] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vcftools --vcf input.vcf --out test --BEAGLE-GL --chr 1,2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Chromosome has to be specified.&lt;br /&gt;
&lt;br /&gt;
You can also use bcftools' [https://samtools.github.io/bcftools/bcftools.html] 'query' option for generating a .beagle file from a .vcf file.&lt;br /&gt;
&lt;br /&gt;
==Output Files==&lt;br /&gt;
The analysis performed by evalAdmix produces 1 file, containing a tab delimited N times N symmetric correlation matrix, where column i in line j contains the correlation of residuals between individual i and j, and the diagonal values (self-correlation) are set to NA:&lt;br /&gt;
&lt;br /&gt;
NA      0.008609        -0.006919       0.002731        0.020224&amp;lt;br /&amp;gt;&lt;br /&gt;
0.008609        NA      0.000033        0.004968        -0.008470&amp;lt;br /&amp;gt;&lt;br /&gt;
-0.006919       0.000033        NA      0.006982        0.005664&amp;lt;br /&amp;gt;&lt;br /&gt;
0.002731        0.004968        0.006982        NA      0.000521&amp;lt;br /&amp;gt;&lt;br /&gt;
0.020224        -0.008470       0.005664        0.000521        NA&lt;br /&gt;
&lt;br /&gt;
==Run command example==&lt;br /&gt;
&lt;br /&gt;
=== Genotype data ===&lt;br /&gt;
Download the input file containing genotype in binary plink format&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.bed&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.bim&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.fam&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run ADMIXTURE [http://software.genetics.ucla.edu/admixture/] to obtain admixture proprotions&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;admixture admixTjeck2.bed 3&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run evalAdmix&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix -plink admixTjeck2 -fname admixTjeck2.3.P -qname admixTjeck2.3.Q -P 20 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Plot results in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# read population labels and estimated admixture proportions&lt;br /&gt;
pop&amp;lt;-read.table(&amp;quot;admixTjeck2.fam&amp;quot;)&lt;br /&gt;
q&amp;lt;-read.table(&amp;quot;admixTjeck2.3.Q&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# order according to population and plot the ADMIXTURE reults&lt;br /&gt;
ord&amp;lt;-order(pop[,2])&lt;br /&gt;
barplot(t(q)[,ord],col=2:10,space=0,border=NA,xlab=&amp;quot;Individuals&amp;quot;,ylab=&amp;quot;Demo2 Admixture proportions for K=3&amp;quot;)&lt;br /&gt;
text(tapply(1:nrow(pop),pop[ord,2],mean),-0.05,unique(pop[ord,2]),xpd=T)&lt;br /&gt;
abline(v=cumsum(sapply(unique(pop[ord,2]),function(x){sum(pop[ord,2]==x)})),col=1,lwd=1.2)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
r&amp;lt;-as.matrix(read.table(&amp;quot;output.corres.txt&amp;quot;))&lt;br /&gt;
&lt;br /&gt;
# Plot correlation of residuals&lt;br /&gt;
source(&amp;quot;NicePlotCorRes.R&amp;quot;)&lt;br /&gt;
plotCorRes(cor_mat = r, pop = as.vector(pop[,2]), title=&amp;quot;Evaluation of 1000G admixture proportions with K=3&amp;quot;, max_z=0.1, min_z=-0.1)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Low depth sequencing data ===&lt;br /&gt;
Download the input file containing genotype likelihoods in beagle format&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget popgen.dk/software/download/NGSadmix/data/Demo2input.gz&lt;br /&gt;
wget popgen.dk/software/download/NGSadmix/data/Demo2pop.info&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Execute [[NgsAdmix |NGSadmix]] to obtain admixture proportions&lt;br /&gt;
&amp;lt;pre&amp;gt;./NGSadmix -likes Demo2input.gz -K 3 -P 20 -o myoutfiles -minMaf 0.05&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
::Input file = Demo2input.gz&lt;br /&gt;
::Ancestral Populations K=3&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
::Output prefix = myoutfiles (-o myoutfiles) &lt;br /&gt;
::SNPs with MAF &amp;gt; 5%  (-minMaf 0.05)&lt;br /&gt;
&lt;br /&gt;
Run evalAdmix&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix -beagle Demo2input.gz -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 20 &amp;lt;/pre&amp;gt;&lt;br /&gt;
::Input file = input.gz&lt;br /&gt;
::Ancestral Populations frequency file myoutfiles.fopt.gz&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
&lt;br /&gt;
Plot results in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# read population labels and estimated admixture proportions&lt;br /&gt;
pop&amp;lt;-read.table(&amp;quot;Demo2pop.info&amp;quot;,as.is=T)&lt;br /&gt;
q&amp;lt;-read.table(&amp;quot;myoutfiles.qopt&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# order according to population and plot the NGSadmix reults&lt;br /&gt;
ord&amp;lt;-order(pop[,1])&lt;br /&gt;
barplot(t(q)[,ord],col=2:10,space=0,border=NA,xlab=&amp;quot;Individuals&amp;quot;,ylab=&amp;quot;Demo2 Admixture proportions for K=3&amp;quot;)&lt;br /&gt;
text(tapply(1:nrow(pop),pop[ord,1],mean),-0.05,unique(pop[ord,1]),xpd=T)&lt;br /&gt;
abline(v=cumsum(sapply(unique(pop[ord,1]),function(x){sum(pop[ord,1]==x)})),col=1,lwd=1.2)&lt;br /&gt;
&lt;br /&gt;
r&amp;lt;-read.table(&amp;quot;output.corres.txt&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Plot correlation of residuals&lt;br /&gt;
source(&amp;quot;NicePlotCorRes.R&amp;quot;)&lt;br /&gt;
plotCorRes(cor_mat = r, pop = as.vector(pop[,1]), title=&amp;quot;Evaluation of 1000G admixture proportions with K=3&amp;quot;, max_z=0.1, min_z=-0.1)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Citation==&lt;br /&gt;
&lt;br /&gt;
evalAdmix has a preprint&lt;br /&gt;
&lt;br /&gt;
[https://doi.org/10.1101/708883 Evaluation of Model Fit of Inferred Admixture Proportions]&lt;/div&gt;</summary>
		<author><name>Genis</name></author>
	</entry>
	<entry>
		<id>https://www.popgen.dk/software/index.php?title=File:EvalAdmix.png&amp;diff=1219</id>
		<title>File:EvalAdmix.png</title>
		<link rel="alternate" type="text/html" href="https://www.popgen.dk/software/index.php?title=File:EvalAdmix.png&amp;diff=1219"/>
		<updated>2019-07-21T11:55:52Z</updated>

		<summary type="html">&lt;p&gt;Genis: Genis uploaded a new version of File:EvalAdmix.png&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Genis</name></author>
	</entry>
	<entry>
		<id>https://www.popgen.dk/software/index.php?title=EvalAdmix&amp;diff=1218</id>
		<title>EvalAdmix</title>
		<link rel="alternate" type="text/html" href="https://www.popgen.dk/software/index.php?title=EvalAdmix&amp;diff=1218"/>
		<updated>2019-07-21T11:49:47Z</updated>

		<summary type="html">&lt;p&gt;Genis: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;evalAdmix allows to evaluate the model fit of an admixture analysis. It takes as input the genotype data (either called genotypes in plink files or genotype likelihoods beagle files) used in the admixture analysis and the estimated ancestral frequency and admixture propotions files (P and Q files).&lt;br /&gt;
&lt;br /&gt;
The output is a pairwise correlation of residuals matrix between individuals. The correlation will be 0 in case of a good fit of the data to the admixture model. When something is wrong, individuals from the same population will be positively correlated; and individuals from different populationts but that share one or more ancestral populations as admixture sources will have a negative correlation. Positive correlation between a pair of individuals might also be due to relatedness.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:evalAdmix.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Download and Installation==&lt;br /&gt;
&lt;br /&gt;
evalAdmix can be installed from [https://github.com/GenisGE/evalAdmix github] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;git clone https://github.com/GenisGE/evalAdmix.git&lt;br /&gt;
cd evalAdmix&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Quick start==&lt;br /&gt;
:&amp;lt;code&amp;gt; ./evalAdmix -beagle inputBeagleFile.gz  -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 10  &amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt; ./evalAdmix -plink inputPlinkPrefix  -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 10  &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''-beagle''' beagle file of genotype likelihoods&lt;br /&gt;
* '''-plink''' binary plink file prefix with genotype data&lt;br /&gt;
* '''-fname''' file with ancestral frequencies&lt;br /&gt;
* '''-qname''' file with admixture proportions&lt;br /&gt;
* '''-o''' prefix of output file names&lt;br /&gt;
* '''-P''' Number of threads used&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix  &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Arguments:&lt;br /&gt;
	Required:&lt;br /&gt;
		-plink path to binary plink file (excluding the .bed)&lt;br /&gt;
		or&lt;br /&gt;
	      	-beagle path to beagle file containing genotype likelihoods (alternative to -plink)&lt;br /&gt;
		&lt;br /&gt;
		-fname path to ancestral population frequencies file&lt;br /&gt;
	       	-qname path to admixture proportions file&lt;br /&gt;
		&lt;br /&gt;
	Optional:       &lt;br /&gt;
	&lt;br /&gt;
	       -o name of the output file&lt;br /&gt;
	       &lt;br /&gt;
	 Setup (optional):&lt;br /&gt;
	 &lt;br /&gt;
	       -P 1 number of threads&lt;br /&gt;
	       -autosomeMax 23	 autosome ends with this chromsome&lt;br /&gt;
	       -nIts 5	 number of iterations to do for frequency correction; if set to 0 calculates correlation without correction (fast but biased)&lt;br /&gt;
	       -useSites 1.0	 proportion of sites to use to calculate correlation of residuals&lt;br /&gt;
	       -useInds filename     path to tab delimited file with first column containing all individuals ID and second column with 1 to include individual in analysis and 0 otherwise (default all individuals are included)&lt;br /&gt;
	       -misTol 0.05 	 tolerance for considering site as missing when using genotype likelihoods. Use same value as used in NGSadmix to keep compatibility when using genotype likelihoods (-beagle)&lt;br /&gt;
	       -minMaf 0.05 	 minimum minor allele frequency to keep site. Use same value as used in NGSadmix to keep compatibility when using genotype likelihoods (-beagle)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Input File==&lt;br /&gt;
&lt;br /&gt;
===Plink===&lt;br /&gt;
Genotype data files in binary PLINK format (.bed .fam .bim).&lt;br /&gt;
===Beagle genotype likelhoods===&lt;br /&gt;
The input file contains genotype likelihoods in a .beagle file format [http://faculty.washington.edu/browning/beagle/beagle.html].&lt;br /&gt;
and can be compressed with gzip.&lt;br /&gt;
==== BAM files  ====&lt;br /&gt;
If you have BAM files you can use [[ANGSD]] to produce genotype likelihoods in .beagle format. Please &lt;br /&gt;
see [http://www.popgen.dk/angsd/index.php/Beagle_input Creation of Beagle files with ANGSD]&lt;br /&gt;
&lt;br /&gt;
==== VCF files ====&lt;br /&gt;
If you already have made a VCF file that contains genotype likehood information then  it should be possible to convert .vcf files with genotype likelihoods to .beagle file via vcftools [https://vcftools.github.io/man_latest.html] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vcftools --vcf input.vcf --out test --BEAGLE-GL --chr 1,2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Chromosome has to be specified.&lt;br /&gt;
&lt;br /&gt;
You can also use bcftools' [https://samtools.github.io/bcftools/bcftools.html] 'query' option for generating a .beagle file from a .vcf file.&lt;br /&gt;
&lt;br /&gt;
==Output Files==&lt;br /&gt;
The analysis performed by evalAdmix produces 1 file, containing a tab delimited N times N symmetric correlation matrix, where column i in line j contains the correlation of residuals between individual i and j, and the diagonal values (self-correlation) are set to NA:&lt;br /&gt;
&lt;br /&gt;
NA      0.008609        -0.006919       0.002731        0.020224&amp;lt;br /&amp;gt;&lt;br /&gt;
0.008609        NA      0.000033        0.004968        -0.008470&amp;lt;br /&amp;gt;&lt;br /&gt;
-0.006919       0.000033        NA      0.006982        0.005664&amp;lt;br /&amp;gt;&lt;br /&gt;
0.002731        0.004968        0.006982        NA      0.000521&amp;lt;br /&amp;gt;&lt;br /&gt;
0.020224        -0.008470       0.005664        0.000521        NA&lt;br /&gt;
&lt;br /&gt;
==Run command example==&lt;br /&gt;
&lt;br /&gt;
=== Genotype data ===&lt;br /&gt;
Download the input file containing genotype in binary plink format&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.bed&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.bim&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.fam&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run ADMIXTURE [http://software.genetics.ucla.edu/admixture/] to obtain admixture proprotions&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;admixture admixTjeck2.bed 3&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run evalAdmix&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix -plink admixTjeck2 -fname admixTjeck2.3.P -qname admixTjeck2.3.Q -P 20 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Plot results in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# read population labels and estimated admixture proportions&lt;br /&gt;
pop&amp;lt;-read.table(&amp;quot;admixTjeck2.fam&amp;quot;)&lt;br /&gt;
q&amp;lt;-read.table(&amp;quot;admixTjeck2.3.Q&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# order according to population and plot the ADMIXTURE reults&lt;br /&gt;
ord&amp;lt;-order(pop[,2])&lt;br /&gt;
barplot(t(q)[,ord],col=2:10,space=0,border=NA,xlab=&amp;quot;Individuals&amp;quot;,ylab=&amp;quot;Demo2 Admixture proportions for K=3&amp;quot;)&lt;br /&gt;
text(tapply(1:nrow(pop),pop[ord,2],mean),-0.05,unique(pop[ord,2]),xpd=T)&lt;br /&gt;
abline(v=cumsum(sapply(unique(pop[ord,2]),function(x){sum(pop[ord,2]==x)})),col=1,lwd=1.2)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
r&amp;lt;-as.matrix(read.table(&amp;quot;output.corres.txt&amp;quot;))&lt;br /&gt;
&lt;br /&gt;
# Plot correlation of residuals&lt;br /&gt;
source(&amp;quot;NicePlotCorRes.R&amp;quot;)&lt;br /&gt;
plotCorRes(cor_mat = r, pop = as.vector(pop[,2]), title=&amp;quot;Evaluation of 1000G admixture proportions with K=3&amp;quot;, max_z=0.1, min_z=-0.1)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Low depth sequencing data ===&lt;br /&gt;
Download the input file containing genotype likelihoods in beagle format&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget popgen.dk/software/download/NGSadmix/data/Demo2input.gz&lt;br /&gt;
wget popgen.dk/software/download/NGSadmix/data/Demo2pop.info&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Execute [[NgsAdmix |NGSadmix]] to obtain admixture proportions&lt;br /&gt;
&amp;lt;pre&amp;gt;./NGSadmix -likes Demo2input.gz -K 3 -P 20 -o myoutfiles -minMaf 0.05&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
::Input file = Demo2input.gz&lt;br /&gt;
::Ancestral Populations K=3&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
::Output prefix = myoutfiles (-o myoutfiles) &lt;br /&gt;
::SNPs with MAF &amp;gt; 5%  (-minMaf 0.05)&lt;br /&gt;
&lt;br /&gt;
Run evalAdmix&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix -beagle Demo2input.gz -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 20 &amp;lt;/pre&amp;gt;&lt;br /&gt;
::Input file = input.gz&lt;br /&gt;
::Ancestral Populations frequency file myoutfiles.fopt.gz&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
&lt;br /&gt;
Plot results in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# read population labels and estimated admixture proportions&lt;br /&gt;
pop&amp;lt;-read.table(&amp;quot;Demo2pop.info&amp;quot;,as.is=T)&lt;br /&gt;
q&amp;lt;-read.table(&amp;quot;myoutfiles.qopt&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# order according to population and plot the NGSadmix reults&lt;br /&gt;
ord&amp;lt;-order(pop[,1])&lt;br /&gt;
barplot(t(q)[,ord],col=2:10,space=0,border=NA,xlab=&amp;quot;Individuals&amp;quot;,ylab=&amp;quot;Demo2 Admixture proportions for K=3&amp;quot;)&lt;br /&gt;
text(tapply(1:nrow(pop),pop[ord,1],mean),-0.05,unique(pop[ord,1]),xpd=T)&lt;br /&gt;
abline(v=cumsum(sapply(unique(pop[ord,1]),function(x){sum(pop[ord,1]==x)})),col=1,lwd=1.2)&lt;br /&gt;
&lt;br /&gt;
r&amp;lt;-read.table(&amp;quot;output.corres.txt&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Plot correlation of residuals&lt;br /&gt;
source(&amp;quot;NicePlotCorRes.R&amp;quot;)&lt;br /&gt;
plotCorRes(cor_mat = r, pop = as.vector(pop[,1]), title=&amp;quot;Evaluation of 1000G admixture proportions with K=3&amp;quot;, max_z=0.1, min_z=-0.1)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Citation==&lt;br /&gt;
&lt;br /&gt;
evalAdmix has a preprint&lt;br /&gt;
&lt;br /&gt;
[https://doi.org/10.1101/708883 Evaluation of Model Fit of Inferred Admixture Proportions]&lt;/div&gt;</summary>
		<author><name>Genis</name></author>
	</entry>
	<entry>
		<id>https://www.popgen.dk/software/index.php?title=EvalAdmix&amp;diff=1217</id>
		<title>EvalAdmix</title>
		<link rel="alternate" type="text/html" href="https://www.popgen.dk/software/index.php?title=EvalAdmix&amp;diff=1217"/>
		<updated>2019-07-21T11:47:00Z</updated>

		<summary type="html">&lt;p&gt;Genis: /* Download and Installation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;evalAdmix allows to evaluate the results of an admixture analysis. It takes as input the genotype data (either called genotypes in plink files or genotype likelihoods beagle files) used in the admixture analysis and the frequency&lt;br /&gt;
and admixture propotions (P and Q files) generated.&lt;br /&gt;
&lt;br /&gt;
The output is a pairwise correlation of residuals matrix between individuals The correlation will be 0 in case of a good fit of the data to the admixture model. When something is wrong, individuals from the same population will be positively correlated; and individuals from different populationts but that share one or more ancestral populations as admixture sources will have a negative correlation. Positive correlation between a pair of individuals might also be due to relatedness.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:evalAdmix.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Download and Installation==&lt;br /&gt;
&lt;br /&gt;
evalAdmix can be installed from [https://github.com/GenisGE/evalAdmix github] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;git clone https://github.com/GenisGE/evalAdmix.git&lt;br /&gt;
cd evalAdmix&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Quick start==&lt;br /&gt;
:&amp;lt;code&amp;gt; ./evalAdmix -beagle inputBeagleFile.gz  -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 10  &amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt; ./evalAdmix -plink inputPlinkPrefix  -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 10  &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''-beagle''' beagle file of genotype likelihoods&lt;br /&gt;
* '''-plink''' binary plink file prefix with genotype data&lt;br /&gt;
* '''-fname''' file with ancestral frequencies&lt;br /&gt;
* '''-qname''' file with admixture proportions&lt;br /&gt;
* '''-o''' prefix of output file names&lt;br /&gt;
* '''-P''' Number of threads used&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix  &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Arguments:&lt;br /&gt;
	Required:&lt;br /&gt;
		-plink path to binary plink file (excluding the .bed)&lt;br /&gt;
		or&lt;br /&gt;
	      	-beagle path to beagle file containing genotype likelihoods (alternative to -plink)&lt;br /&gt;
		&lt;br /&gt;
		-fname path to ancestral population frequencies file&lt;br /&gt;
	       	-qname path to admixture proportions file&lt;br /&gt;
		&lt;br /&gt;
	Optional:       &lt;br /&gt;
	&lt;br /&gt;
	       -o name of the output file&lt;br /&gt;
	       &lt;br /&gt;
	 Setup (optional):&lt;br /&gt;
	 &lt;br /&gt;
	       -P 1 number of threads&lt;br /&gt;
	       -autosomeMax 23	 autosome ends with this chromsome&lt;br /&gt;
	       -nIts 5	 number of iterations to do for frequency correction; if set to 0 calculates correlation without correction (fast but biased)&lt;br /&gt;
	       -useSites 1.0	 proportion of sites to use to calculate correlation of residuals&lt;br /&gt;
	       -useInds filename     path to tab delimited file with first column containing all individuals ID and second column with 1 to include individual in analysis and 0 otherwise (default all individuals are included)&lt;br /&gt;
	       -misTol 0.05 	 tolerance for considering site as missing when using genotype likelihoods. Use same value as used in NGSadmix to keep compatibility when using genotype likelihoods (-beagle)&lt;br /&gt;
	       -minMaf 0.05 	 minimum minor allele frequency to keep site. Use same value as used in NGSadmix to keep compatibility when using genotype likelihoods (-beagle)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Input File==&lt;br /&gt;
&lt;br /&gt;
===Plink===&lt;br /&gt;
Genotype data files in binary PLINK format (.bed .fam .bim).&lt;br /&gt;
===Beagle genotype likelhoods===&lt;br /&gt;
The input file contains genotype likelihoods in a .beagle file format [http://faculty.washington.edu/browning/beagle/beagle.html].&lt;br /&gt;
and can be compressed with gzip.&lt;br /&gt;
==== BAM files  ====&lt;br /&gt;
If you have BAM files you can use [[ANGSD]] to produce genotype likelihoods in .beagle format. Please &lt;br /&gt;
see [http://www.popgen.dk/angsd/index.php/Beagle_input Creation of Beagle files with ANGSD]&lt;br /&gt;
&lt;br /&gt;
==== VCF files ====&lt;br /&gt;
If you already have made a VCF file that contains genotype likehood information then  it should be possible to convert .vcf files with genotype likelihoods to .beagle file via vcftools [https://vcftools.github.io/man_latest.html] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vcftools --vcf input.vcf --out test --BEAGLE-GL --chr 1,2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Chromosome has to be specified.&lt;br /&gt;
&lt;br /&gt;
You can also use bcftools' [https://samtools.github.io/bcftools/bcftools.html] 'query' option for generating a .beagle file from a .vcf file.&lt;br /&gt;
&lt;br /&gt;
==Output Files==&lt;br /&gt;
The analysis performed by evalAdmix produces 1 file, containing a tab delimited N times N symmetric correlation matrix, where column i in line j contains the correlation of residuals between individual i and j, and the diagonal values (self-correlation) are set to NA:&lt;br /&gt;
&lt;br /&gt;
NA      0.008609        -0.006919       0.002731        0.020224&amp;lt;br /&amp;gt;&lt;br /&gt;
0.008609        NA      0.000033        0.004968        -0.008470&amp;lt;br /&amp;gt;&lt;br /&gt;
-0.006919       0.000033        NA      0.006982        0.005664&amp;lt;br /&amp;gt;&lt;br /&gt;
0.002731        0.004968        0.006982        NA      0.000521&amp;lt;br /&amp;gt;&lt;br /&gt;
0.020224        -0.008470       0.005664        0.000521        NA&lt;br /&gt;
&lt;br /&gt;
==Run command example==&lt;br /&gt;
&lt;br /&gt;
=== Genotype data ===&lt;br /&gt;
Download the input file containing genotype in binary plink format&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.bed&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.bim&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.fam&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run ADMIXTURE [http://software.genetics.ucla.edu/admixture/] to obtain admixture proprotions&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;admixture admixTjeck2.bed 3&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run evalAdmix&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix -plink admixTjeck2 -fname admixTjeck2.3.P -qname admixTjeck2.3.Q -P 20 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Plot results in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# read population labels and estimated admixture proportions&lt;br /&gt;
pop&amp;lt;-read.table(&amp;quot;admixTjeck2.fam&amp;quot;)&lt;br /&gt;
q&amp;lt;-read.table(&amp;quot;admixTjeck2.3.Q&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# order according to population and plot the ADMIXTURE reults&lt;br /&gt;
ord&amp;lt;-order(pop[,2])&lt;br /&gt;
barplot(t(q)[,ord],col=2:10,space=0,border=NA,xlab=&amp;quot;Individuals&amp;quot;,ylab=&amp;quot;Demo2 Admixture proportions for K=3&amp;quot;)&lt;br /&gt;
text(tapply(1:nrow(pop),pop[ord,2],mean),-0.05,unique(pop[ord,2]),xpd=T)&lt;br /&gt;
abline(v=cumsum(sapply(unique(pop[ord,2]),function(x){sum(pop[ord,2]==x)})),col=1,lwd=1.2)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
r&amp;lt;-as.matrix(read.table(&amp;quot;output.corres.txt&amp;quot;))&lt;br /&gt;
&lt;br /&gt;
# Plot correlation of residuals&lt;br /&gt;
source(&amp;quot;NicePlotCorRes.R&amp;quot;)&lt;br /&gt;
plotCorRes(cor_mat = r, pop = as.vector(pop[,2]), title=&amp;quot;Evaluation of 1000G admixture proportions with K=3&amp;quot;, max_z=0.1, min_z=-0.1)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Low depth sequencing data ===&lt;br /&gt;
Download the input file containing genotype likelihoods in beagle format&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget popgen.dk/software/download/NGSadmix/data/Demo2input.gz&lt;br /&gt;
wget popgen.dk/software/download/NGSadmix/data/Demo2pop.info&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Execute [[NgsAdmix |NGSadmix]] to obtain admixture proportions&lt;br /&gt;
&amp;lt;pre&amp;gt;./NGSadmix -likes Demo2input.gz -K 3 -P 20 -o myoutfiles -minMaf 0.05&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
::Input file = Demo2input.gz&lt;br /&gt;
::Ancestral Populations K=3&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
::Output prefix = myoutfiles (-o myoutfiles) &lt;br /&gt;
::SNPs with MAF &amp;gt; 5%  (-minMaf 0.05)&lt;br /&gt;
&lt;br /&gt;
Run evalAdmix&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix -beagle Demo2input.gz -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 20 &amp;lt;/pre&amp;gt;&lt;br /&gt;
::Input file = input.gz&lt;br /&gt;
::Ancestral Populations frequency file myoutfiles.fopt.gz&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
&lt;br /&gt;
Plot results in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# read population labels and estimated admixture proportions&lt;br /&gt;
pop&amp;lt;-read.table(&amp;quot;Demo2pop.info&amp;quot;,as.is=T)&lt;br /&gt;
q&amp;lt;-read.table(&amp;quot;myoutfiles.qopt&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# order according to population and plot the NGSadmix reults&lt;br /&gt;
ord&amp;lt;-order(pop[,1])&lt;br /&gt;
barplot(t(q)[,ord],col=2:10,space=0,border=NA,xlab=&amp;quot;Individuals&amp;quot;,ylab=&amp;quot;Demo2 Admixture proportions for K=3&amp;quot;)&lt;br /&gt;
text(tapply(1:nrow(pop),pop[ord,1],mean),-0.05,unique(pop[ord,1]),xpd=T)&lt;br /&gt;
abline(v=cumsum(sapply(unique(pop[ord,1]),function(x){sum(pop[ord,1]==x)})),col=1,lwd=1.2)&lt;br /&gt;
&lt;br /&gt;
r&amp;lt;-read.table(&amp;quot;output.corres.txt&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Plot correlation of residuals&lt;br /&gt;
source(&amp;quot;NicePlotCorRes.R&amp;quot;)&lt;br /&gt;
plotCorRes(cor_mat = r, pop = as.vector(pop[,1]), title=&amp;quot;Evaluation of 1000G admixture proportions with K=3&amp;quot;, max_z=0.1, min_z=-0.1)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Citation==&lt;br /&gt;
&lt;br /&gt;
evalAdmix has a preprint&lt;br /&gt;
&lt;br /&gt;
[https://doi.org/10.1101/708883 Evaluation of Model Fit of Inferred Admixture Proportions]&lt;/div&gt;</summary>
		<author><name>Genis</name></author>
	</entry>
	<entry>
		<id>https://www.popgen.dk/software/index.php?title=EvalAdmix&amp;diff=1216</id>
		<title>EvalAdmix</title>
		<link rel="alternate" type="text/html" href="https://www.popgen.dk/software/index.php?title=EvalAdmix&amp;diff=1216"/>
		<updated>2019-07-21T11:46:48Z</updated>

		<summary type="html">&lt;p&gt;Genis: /* Download and Installation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;evalAdmix allows to evaluate the results of an admixture analysis. It takes as input the genotype data (either called genotypes in plink files or genotype likelihoods beagle files) used in the admixture analysis and the frequency&lt;br /&gt;
and admixture propotions (P and Q files) generated.&lt;br /&gt;
&lt;br /&gt;
The output is a pairwise correlation of residuals matrix between individuals The correlation will be 0 in case of a good fit of the data to the admixture model. When something is wrong, individuals from the same population will be positively correlated; and individuals from different populationts but that share one or more ancestral populations as admixture sources will have a negative correlation. Positive correlation between a pair of individuals might also be due to relatedness.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:evalAdmix.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Download and Installation==&lt;br /&gt;
&lt;br /&gt;
evalAdmix can be installed from [https://github.com/GenisGE/evalAdmix github] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; git clone https://github.com/GenisGE/evalAdmix.git&lt;br /&gt;
cd evalAdmix&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Quick start==&lt;br /&gt;
:&amp;lt;code&amp;gt; ./evalAdmix -beagle inputBeagleFile.gz  -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 10  &amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt; ./evalAdmix -plink inputPlinkPrefix  -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 10  &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''-beagle''' beagle file of genotype likelihoods&lt;br /&gt;
* '''-plink''' binary plink file prefix with genotype data&lt;br /&gt;
* '''-fname''' file with ancestral frequencies&lt;br /&gt;
* '''-qname''' file with admixture proportions&lt;br /&gt;
* '''-o''' prefix of output file names&lt;br /&gt;
* '''-P''' Number of threads used&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix  &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Arguments:&lt;br /&gt;
	Required:&lt;br /&gt;
		-plink path to binary plink file (excluding the .bed)&lt;br /&gt;
		or&lt;br /&gt;
	      	-beagle path to beagle file containing genotype likelihoods (alternative to -plink)&lt;br /&gt;
		&lt;br /&gt;
		-fname path to ancestral population frequencies file&lt;br /&gt;
	       	-qname path to admixture proportions file&lt;br /&gt;
		&lt;br /&gt;
	Optional:       &lt;br /&gt;
	&lt;br /&gt;
	       -o name of the output file&lt;br /&gt;
	       &lt;br /&gt;
	 Setup (optional):&lt;br /&gt;
	 &lt;br /&gt;
	       -P 1 number of threads&lt;br /&gt;
	       -autosomeMax 23	 autosome ends with this chromsome&lt;br /&gt;
	       -nIts 5	 number of iterations to do for frequency correction; if set to 0 calculates correlation without correction (fast but biased)&lt;br /&gt;
	       -useSites 1.0	 proportion of sites to use to calculate correlation of residuals&lt;br /&gt;
	       -useInds filename     path to tab delimited file with first column containing all individuals ID and second column with 1 to include individual in analysis and 0 otherwise (default all individuals are included)&lt;br /&gt;
	       -misTol 0.05 	 tolerance for considering site as missing when using genotype likelihoods. Use same value as used in NGSadmix to keep compatibility when using genotype likelihoods (-beagle)&lt;br /&gt;
	       -minMaf 0.05 	 minimum minor allele frequency to keep site. Use same value as used in NGSadmix to keep compatibility when using genotype likelihoods (-beagle)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Input File==&lt;br /&gt;
&lt;br /&gt;
===Plink===&lt;br /&gt;
Genotype data files in binary PLINK format (.bed .fam .bim).&lt;br /&gt;
===Beagle genotype likelhoods===&lt;br /&gt;
The input file contains genotype likelihoods in a .beagle file format [http://faculty.washington.edu/browning/beagle/beagle.html].&lt;br /&gt;
and can be compressed with gzip.&lt;br /&gt;
==== BAM files  ====&lt;br /&gt;
If you have BAM files you can use [[ANGSD]] to produce genotype likelihoods in .beagle format. Please &lt;br /&gt;
see [http://www.popgen.dk/angsd/index.php/Beagle_input Creation of Beagle files with ANGSD]&lt;br /&gt;
&lt;br /&gt;
==== VCF files ====&lt;br /&gt;
If you already have made a VCF file that contains genotype likehood information then  it should be possible to convert .vcf files with genotype likelihoods to .beagle file via vcftools [https://vcftools.github.io/man_latest.html] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vcftools --vcf input.vcf --out test --BEAGLE-GL --chr 1,2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Chromosome has to be specified.&lt;br /&gt;
&lt;br /&gt;
You can also use bcftools' [https://samtools.github.io/bcftools/bcftools.html] 'query' option for generating a .beagle file from a .vcf file.&lt;br /&gt;
&lt;br /&gt;
==Output Files==&lt;br /&gt;
The analysis performed by evalAdmix produces 1 file, containing a tab delimited N times N symmetric correlation matrix, where column i in line j contains the correlation of residuals between individual i and j, and the diagonal values (self-correlation) are set to NA:&lt;br /&gt;
&lt;br /&gt;
NA      0.008609        -0.006919       0.002731        0.020224&amp;lt;br /&amp;gt;&lt;br /&gt;
0.008609        NA      0.000033        0.004968        -0.008470&amp;lt;br /&amp;gt;&lt;br /&gt;
-0.006919       0.000033        NA      0.006982        0.005664&amp;lt;br /&amp;gt;&lt;br /&gt;
0.002731        0.004968        0.006982        NA      0.000521&amp;lt;br /&amp;gt;&lt;br /&gt;
0.020224        -0.008470       0.005664        0.000521        NA&lt;br /&gt;
&lt;br /&gt;
==Run command example==&lt;br /&gt;
&lt;br /&gt;
=== Genotype data ===&lt;br /&gt;
Download the input file containing genotype in binary plink format&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.bed&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.bim&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.fam&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run ADMIXTURE [http://software.genetics.ucla.edu/admixture/] to obtain admixture proprotions&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;admixture admixTjeck2.bed 3&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run evalAdmix&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix -plink admixTjeck2 -fname admixTjeck2.3.P -qname admixTjeck2.3.Q -P 20 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Plot results in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# read population labels and estimated admixture proportions&lt;br /&gt;
pop&amp;lt;-read.table(&amp;quot;admixTjeck2.fam&amp;quot;)&lt;br /&gt;
q&amp;lt;-read.table(&amp;quot;admixTjeck2.3.Q&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# order according to population and plot the ADMIXTURE reults&lt;br /&gt;
ord&amp;lt;-order(pop[,2])&lt;br /&gt;
barplot(t(q)[,ord],col=2:10,space=0,border=NA,xlab=&amp;quot;Individuals&amp;quot;,ylab=&amp;quot;Demo2 Admixture proportions for K=3&amp;quot;)&lt;br /&gt;
text(tapply(1:nrow(pop),pop[ord,2],mean),-0.05,unique(pop[ord,2]),xpd=T)&lt;br /&gt;
abline(v=cumsum(sapply(unique(pop[ord,2]),function(x){sum(pop[ord,2]==x)})),col=1,lwd=1.2)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
r&amp;lt;-as.matrix(read.table(&amp;quot;output.corres.txt&amp;quot;))&lt;br /&gt;
&lt;br /&gt;
# Plot correlation of residuals&lt;br /&gt;
source(&amp;quot;NicePlotCorRes.R&amp;quot;)&lt;br /&gt;
plotCorRes(cor_mat = r, pop = as.vector(pop[,2]), title=&amp;quot;Evaluation of 1000G admixture proportions with K=3&amp;quot;, max_z=0.1, min_z=-0.1)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Low depth sequencing data ===&lt;br /&gt;
Download the input file containing genotype likelihoods in beagle format&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget popgen.dk/software/download/NGSadmix/data/Demo2input.gz&lt;br /&gt;
wget popgen.dk/software/download/NGSadmix/data/Demo2pop.info&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Execute [[NgsAdmix |NGSadmix]] to obtain admixture proportions&lt;br /&gt;
&amp;lt;pre&amp;gt;./NGSadmix -likes Demo2input.gz -K 3 -P 20 -o myoutfiles -minMaf 0.05&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
::Input file = Demo2input.gz&lt;br /&gt;
::Ancestral Populations K=3&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
::Output prefix = myoutfiles (-o myoutfiles) &lt;br /&gt;
::SNPs with MAF &amp;gt; 5%  (-minMaf 0.05)&lt;br /&gt;
&lt;br /&gt;
Run evalAdmix&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix -beagle Demo2input.gz -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 20 &amp;lt;/pre&amp;gt;&lt;br /&gt;
::Input file = input.gz&lt;br /&gt;
::Ancestral Populations frequency file myoutfiles.fopt.gz&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
&lt;br /&gt;
Plot results in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# read population labels and estimated admixture proportions&lt;br /&gt;
pop&amp;lt;-read.table(&amp;quot;Demo2pop.info&amp;quot;,as.is=T)&lt;br /&gt;
q&amp;lt;-read.table(&amp;quot;myoutfiles.qopt&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# order according to population and plot the NGSadmix reults&lt;br /&gt;
ord&amp;lt;-order(pop[,1])&lt;br /&gt;
barplot(t(q)[,ord],col=2:10,space=0,border=NA,xlab=&amp;quot;Individuals&amp;quot;,ylab=&amp;quot;Demo2 Admixture proportions for K=3&amp;quot;)&lt;br /&gt;
text(tapply(1:nrow(pop),pop[ord,1],mean),-0.05,unique(pop[ord,1]),xpd=T)&lt;br /&gt;
abline(v=cumsum(sapply(unique(pop[ord,1]),function(x){sum(pop[ord,1]==x)})),col=1,lwd=1.2)&lt;br /&gt;
&lt;br /&gt;
r&amp;lt;-read.table(&amp;quot;output.corres.txt&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Plot correlation of residuals&lt;br /&gt;
source(&amp;quot;NicePlotCorRes.R&amp;quot;)&lt;br /&gt;
plotCorRes(cor_mat = r, pop = as.vector(pop[,1]), title=&amp;quot;Evaluation of 1000G admixture proportions with K=3&amp;quot;, max_z=0.1, min_z=-0.1)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Citation==&lt;br /&gt;
&lt;br /&gt;
evalAdmix has a preprint&lt;br /&gt;
&lt;br /&gt;
[https://doi.org/10.1101/708883 Evaluation of Model Fit of Inferred Admixture Proportions]&lt;/div&gt;</summary>
		<author><name>Genis</name></author>
	</entry>
	<entry>
		<id>https://www.popgen.dk/software/index.php?title=EvalAdmix&amp;diff=1215</id>
		<title>EvalAdmix</title>
		<link rel="alternate" type="text/html" href="https://www.popgen.dk/software/index.php?title=EvalAdmix&amp;diff=1215"/>
		<updated>2019-07-21T11:45:58Z</updated>

		<summary type="html">&lt;p&gt;Genis: /* Run command example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;evalAdmix allows to evaluate the results of an admixture analysis. It takes as input the genotype data (either called genotypes in plink files or genotype likelihoods beagle files) used in the admixture analysis and the frequency&lt;br /&gt;
and admixture propotions (P and Q files) generated.&lt;br /&gt;
&lt;br /&gt;
The output is a pairwise correlation of residuals matrix between individuals The correlation will be 0 in case of a good fit of the data to the admixture model. When something is wrong, individuals from the same population will be positively correlated; and individuals from different populationts but that share one or more ancestral populations as admixture sources will have a negative correlation. Positive correlation between a pair of individuals might also be due to relatedness.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:evalAdmix.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Download and Installation==&lt;br /&gt;
&lt;br /&gt;
evalAdmix can be installed from [https://github.com/GenisGE/evalAdmix github] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
git clone https://github.com/GenisGE/evalAdmix.git&lt;br /&gt;
cd evalAdmix&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Quick start==&lt;br /&gt;
:&amp;lt;code&amp;gt; ./evalAdmix -beagle inputBeagleFile.gz  -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 10  &amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt; ./evalAdmix -plink inputPlinkPrefix  -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 10  &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''-beagle''' beagle file of genotype likelihoods&lt;br /&gt;
* '''-plink''' binary plink file prefix with genotype data&lt;br /&gt;
* '''-fname''' file with ancestral frequencies&lt;br /&gt;
* '''-qname''' file with admixture proportions&lt;br /&gt;
* '''-o''' prefix of output file names&lt;br /&gt;
* '''-P''' Number of threads used&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix  &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Arguments:&lt;br /&gt;
	Required:&lt;br /&gt;
		-plink path to binary plink file (excluding the .bed)&lt;br /&gt;
		or&lt;br /&gt;
	      	-beagle path to beagle file containing genotype likelihoods (alternative to -plink)&lt;br /&gt;
		&lt;br /&gt;
		-fname path to ancestral population frequencies file&lt;br /&gt;
	       	-qname path to admixture proportions file&lt;br /&gt;
		&lt;br /&gt;
	Optional:       &lt;br /&gt;
	&lt;br /&gt;
	       -o name of the output file&lt;br /&gt;
	       &lt;br /&gt;
	 Setup (optional):&lt;br /&gt;
	 &lt;br /&gt;
	       -P 1 number of threads&lt;br /&gt;
	       -autosomeMax 23	 autosome ends with this chromsome&lt;br /&gt;
	       -nIts 5	 number of iterations to do for frequency correction; if set to 0 calculates correlation without correction (fast but biased)&lt;br /&gt;
	       -useSites 1.0	 proportion of sites to use to calculate correlation of residuals&lt;br /&gt;
	       -useInds filename     path to tab delimited file with first column containing all individuals ID and second column with 1 to include individual in analysis and 0 otherwise (default all individuals are included)&lt;br /&gt;
	       -misTol 0.05 	 tolerance for considering site as missing when using genotype likelihoods. Use same value as used in NGSadmix to keep compatibility when using genotype likelihoods (-beagle)&lt;br /&gt;
	       -minMaf 0.05 	 minimum minor allele frequency to keep site. Use same value as used in NGSadmix to keep compatibility when using genotype likelihoods (-beagle)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Input File==&lt;br /&gt;
&lt;br /&gt;
===Plink===&lt;br /&gt;
Genotype data files in binary PLINK format (.bed .fam .bim).&lt;br /&gt;
===Beagle genotype likelhoods===&lt;br /&gt;
The input file contains genotype likelihoods in a .beagle file format [http://faculty.washington.edu/browning/beagle/beagle.html].&lt;br /&gt;
and can be compressed with gzip.&lt;br /&gt;
==== BAM files  ====&lt;br /&gt;
If you have BAM files you can use [[ANGSD]] to produce genotype likelihoods in .beagle format. Please &lt;br /&gt;
see [http://www.popgen.dk/angsd/index.php/Beagle_input Creation of Beagle files with ANGSD]&lt;br /&gt;
&lt;br /&gt;
==== VCF files ====&lt;br /&gt;
If you already have made a VCF file that contains genotype likehood information then  it should be possible to convert .vcf files with genotype likelihoods to .beagle file via vcftools [https://vcftools.github.io/man_latest.html] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vcftools --vcf input.vcf --out test --BEAGLE-GL --chr 1,2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Chromosome has to be specified.&lt;br /&gt;
&lt;br /&gt;
You can also use bcftools' [https://samtools.github.io/bcftools/bcftools.html] 'query' option for generating a .beagle file from a .vcf file.&lt;br /&gt;
&lt;br /&gt;
==Output Files==&lt;br /&gt;
The analysis performed by evalAdmix produces 1 file, containing a tab delimited N times N symmetric correlation matrix, where column i in line j contains the correlation of residuals between individual i and j, and the diagonal values (self-correlation) are set to NA:&lt;br /&gt;
&lt;br /&gt;
NA      0.008609        -0.006919       0.002731        0.020224&amp;lt;br /&amp;gt;&lt;br /&gt;
0.008609        NA      0.000033        0.004968        -0.008470&amp;lt;br /&amp;gt;&lt;br /&gt;
-0.006919       0.000033        NA      0.006982        0.005664&amp;lt;br /&amp;gt;&lt;br /&gt;
0.002731        0.004968        0.006982        NA      0.000521&amp;lt;br /&amp;gt;&lt;br /&gt;
0.020224        -0.008470       0.005664        0.000521        NA&lt;br /&gt;
&lt;br /&gt;
==Run command example==&lt;br /&gt;
&lt;br /&gt;
=== Genotype data ===&lt;br /&gt;
Download the input file containing genotype in binary plink format&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.bed&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.bim&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.fam&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run ADMIXTURE [http://software.genetics.ucla.edu/admixture/] to obtain admixture proprotions&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;admixture admixTjeck2.bed 3&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run evalAdmix&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix -plink admixTjeck2 -fname admixTjeck2.3.P -qname admixTjeck2.3.Q -P 20 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Plot results in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# read population labels and estimated admixture proportions&lt;br /&gt;
pop&amp;lt;-read.table(&amp;quot;admixTjeck2.fam&amp;quot;)&lt;br /&gt;
q&amp;lt;-read.table(&amp;quot;admixTjeck2.3.Q&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# order according to population and plot the ADMIXTURE reults&lt;br /&gt;
ord&amp;lt;-order(pop[,2])&lt;br /&gt;
barplot(t(q)[,ord],col=2:10,space=0,border=NA,xlab=&amp;quot;Individuals&amp;quot;,ylab=&amp;quot;Demo2 Admixture proportions for K=3&amp;quot;)&lt;br /&gt;
text(tapply(1:nrow(pop),pop[ord,2],mean),-0.05,unique(pop[ord,2]),xpd=T)&lt;br /&gt;
abline(v=cumsum(sapply(unique(pop[ord,2]),function(x){sum(pop[ord,2]==x)})),col=1,lwd=1.2)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
r&amp;lt;-as.matrix(read.table(&amp;quot;output.corres.txt&amp;quot;))&lt;br /&gt;
&lt;br /&gt;
# Plot correlation of residuals&lt;br /&gt;
source(&amp;quot;NicePlotCorRes.R&amp;quot;)&lt;br /&gt;
plotCorRes(cor_mat = r, pop = as.vector(pop[,2]), title=&amp;quot;Evaluation of 1000G admixture proportions with K=3&amp;quot;, max_z=0.1, min_z=-0.1)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Low depth sequencing data ===&lt;br /&gt;
Download the input file containing genotype likelihoods in beagle format&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget popgen.dk/software/download/NGSadmix/data/Demo2input.gz&lt;br /&gt;
wget popgen.dk/software/download/NGSadmix/data/Demo2pop.info&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Execute [[NgsAdmix |NGSadmix]] to obtain admixture proportions&lt;br /&gt;
&amp;lt;pre&amp;gt;./NGSadmix -likes Demo2input.gz -K 3 -P 20 -o myoutfiles -minMaf 0.05&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
::Input file = Demo2input.gz&lt;br /&gt;
::Ancestral Populations K=3&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
::Output prefix = myoutfiles (-o myoutfiles) &lt;br /&gt;
::SNPs with MAF &amp;gt; 5%  (-minMaf 0.05)&lt;br /&gt;
&lt;br /&gt;
Run evalAdmix&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix -beagle Demo2input.gz -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 20 &amp;lt;/pre&amp;gt;&lt;br /&gt;
::Input file = input.gz&lt;br /&gt;
::Ancestral Populations frequency file myoutfiles.fopt.gz&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
&lt;br /&gt;
Plot results in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# read population labels and estimated admixture proportions&lt;br /&gt;
pop&amp;lt;-read.table(&amp;quot;Demo2pop.info&amp;quot;,as.is=T)&lt;br /&gt;
q&amp;lt;-read.table(&amp;quot;myoutfiles.qopt&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# order according to population and plot the NGSadmix reults&lt;br /&gt;
ord&amp;lt;-order(pop[,1])&lt;br /&gt;
barplot(t(q)[,ord],col=2:10,space=0,border=NA,xlab=&amp;quot;Individuals&amp;quot;,ylab=&amp;quot;Demo2 Admixture proportions for K=3&amp;quot;)&lt;br /&gt;
text(tapply(1:nrow(pop),pop[ord,1],mean),-0.05,unique(pop[ord,1]),xpd=T)&lt;br /&gt;
abline(v=cumsum(sapply(unique(pop[ord,1]),function(x){sum(pop[ord,1]==x)})),col=1,lwd=1.2)&lt;br /&gt;
&lt;br /&gt;
r&amp;lt;-read.table(&amp;quot;output.corres.txt&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Plot correlation of residuals&lt;br /&gt;
source(&amp;quot;NicePlotCorRes.R&amp;quot;)&lt;br /&gt;
plotCorRes(cor_mat = r, pop = as.vector(pop[,1]), title=&amp;quot;Evaluation of 1000G admixture proportions with K=3&amp;quot;, max_z=0.1, min_z=-0.1)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Citation==&lt;br /&gt;
&lt;br /&gt;
evalAdmix has a preprint&lt;br /&gt;
&lt;br /&gt;
[https://doi.org/10.1101/708883 Evaluation of Model Fit of Inferred Admixture Proportions]&lt;/div&gt;</summary>
		<author><name>Genis</name></author>
	</entry>
	<entry>
		<id>https://www.popgen.dk/software/index.php?title=EvalAdmix&amp;diff=1214</id>
		<title>EvalAdmix</title>
		<link rel="alternate" type="text/html" href="https://www.popgen.dk/software/index.php?title=EvalAdmix&amp;diff=1214"/>
		<updated>2019-07-21T11:43:24Z</updated>

		<summary type="html">&lt;p&gt;Genis: /* Parameters */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;evalAdmix allows to evaluate the results of an admixture analysis. It takes as input the genotype data (either called genotypes in plink files or genotype likelihoods beagle files) used in the admixture analysis and the frequency&lt;br /&gt;
and admixture propotions (P and Q files) generated.&lt;br /&gt;
&lt;br /&gt;
The output is a pairwise correlation of residuals matrix between individuals The correlation will be 0 in case of a good fit of the data to the admixture model. When something is wrong, individuals from the same population will be positively correlated; and individuals from different populationts but that share one or more ancestral populations as admixture sources will have a negative correlation. Positive correlation between a pair of individuals might also be due to relatedness.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:evalAdmix.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Download and Installation==&lt;br /&gt;
&lt;br /&gt;
evalAdmix can be installed from [https://github.com/GenisGE/evalAdmix github] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
git clone https://github.com/GenisGE/evalAdmix.git&lt;br /&gt;
cd evalAdmix&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Quick start==&lt;br /&gt;
:&amp;lt;code&amp;gt; ./evalAdmix -beagle inputBeagleFile.gz  -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 10  &amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt; ./evalAdmix -plink inputPlinkPrefix  -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 10  &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''-beagle''' beagle file of genotype likelihoods&lt;br /&gt;
* '''-plink''' binary plink file prefix with genotype data&lt;br /&gt;
* '''-fname''' file with ancestral frequencies&lt;br /&gt;
* '''-qname''' file with admixture proportions&lt;br /&gt;
* '''-o''' prefix of output file names&lt;br /&gt;
* '''-P''' Number of threads used&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix  &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Arguments:&lt;br /&gt;
	Required:&lt;br /&gt;
		-plink path to binary plink file (excluding the .bed)&lt;br /&gt;
		or&lt;br /&gt;
	      	-beagle path to beagle file containing genotype likelihoods (alternative to -plink)&lt;br /&gt;
		&lt;br /&gt;
		-fname path to ancestral population frequencies file&lt;br /&gt;
	       	-qname path to admixture proportions file&lt;br /&gt;
		&lt;br /&gt;
	Optional:       &lt;br /&gt;
	&lt;br /&gt;
	       -o name of the output file&lt;br /&gt;
	       &lt;br /&gt;
	 Setup (optional):&lt;br /&gt;
	 &lt;br /&gt;
	       -P 1 number of threads&lt;br /&gt;
	       -autosomeMax 23	 autosome ends with this chromsome&lt;br /&gt;
	       -nIts 5	 number of iterations to do for frequency correction; if set to 0 calculates correlation without correction (fast but biased)&lt;br /&gt;
	       -useSites 1.0	 proportion of sites to use to calculate correlation of residuals&lt;br /&gt;
	       -useInds filename     path to tab delimited file with first column containing all individuals ID and second column with 1 to include individual in analysis and 0 otherwise (default all individuals are included)&lt;br /&gt;
	       -misTol 0.05 	 tolerance for considering site as missing when using genotype likelihoods. Use same value as used in NGSadmix to keep compatibility when using genotype likelihoods (-beagle)&lt;br /&gt;
	       -minMaf 0.05 	 minimum minor allele frequency to keep site. Use same value as used in NGSadmix to keep compatibility when using genotype likelihoods (-beagle)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Input File==&lt;br /&gt;
&lt;br /&gt;
===Plink===&lt;br /&gt;
Genotype data files in binary PLINK format (.bed .fam .bim).&lt;br /&gt;
===Beagle genotype likelhoods===&lt;br /&gt;
The input file contains genotype likelihoods in a .beagle file format [http://faculty.washington.edu/browning/beagle/beagle.html].&lt;br /&gt;
and can be compressed with gzip.&lt;br /&gt;
==== BAM files  ====&lt;br /&gt;
If you have BAM files you can use [[ANGSD]] to produce genotype likelihoods in .beagle format. Please &lt;br /&gt;
see [http://www.popgen.dk/angsd/index.php/Beagle_input Creation of Beagle files with ANGSD]&lt;br /&gt;
&lt;br /&gt;
==== VCF files ====&lt;br /&gt;
If you already have made a VCF file that contains genotype likehood information then  it should be possible to convert .vcf files with genotype likelihoods to .beagle file via vcftools [https://vcftools.github.io/man_latest.html] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vcftools --vcf input.vcf --out test --BEAGLE-GL --chr 1,2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Chromosome has to be specified.&lt;br /&gt;
&lt;br /&gt;
You can also use bcftools' [https://samtools.github.io/bcftools/bcftools.html] 'query' option for generating a .beagle file from a .vcf file.&lt;br /&gt;
&lt;br /&gt;
==Output Files==&lt;br /&gt;
The analysis performed by evalAdmix produces 1 file, containing a tab delimited N times N symmetric correlation matrix, where column i in line j contains the correlation of residuals between individual i and j, and the diagonal values (self-correlation) are set to NA:&lt;br /&gt;
&lt;br /&gt;
NA      0.008609        -0.006919       0.002731        0.020224&amp;lt;br /&amp;gt;&lt;br /&gt;
0.008609        NA      0.000033        0.004968        -0.008470&amp;lt;br /&amp;gt;&lt;br /&gt;
-0.006919       0.000033        NA      0.006982        0.005664&amp;lt;br /&amp;gt;&lt;br /&gt;
0.002731        0.004968        0.006982        NA      0.000521&amp;lt;br /&amp;gt;&lt;br /&gt;
0.020224        -0.008470       0.005664        0.000521        NA&lt;br /&gt;
&lt;br /&gt;
==Run command example==&lt;br /&gt;
&lt;br /&gt;
=== Genotype data ===&lt;br /&gt;
Download the input file containing genotype in binary plink format&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.bed&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.bim&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.fam&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run ADMIXTURE[http://software.genetics.ucla.edu/admixture/] to obtain admixture proprotions&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;admixture admixTjeck2.bed 3&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run evalAdmix&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix -plink admixTjeck2 -fname admixTjeck2.3.P -qname admixTjeck2.3.Q -P 20 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Plot results in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# read population labels and estimated admixture proportions&lt;br /&gt;
pop&amp;lt;-read.table(&amp;quot;admixTjeck2.fam&amp;quot;)&lt;br /&gt;
q&amp;lt;-read.table(&amp;quot;admixTjeck2.3.Q&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# order according to population and plot the ADMIXTURE reults&lt;br /&gt;
ord&amp;lt;-order(pop[,2])&lt;br /&gt;
barplot(t(q)[,ord],col=2:10,space=0,border=NA,xlab=&amp;quot;Individuals&amp;quot;,ylab=&amp;quot;Demo2 Admixture proportions for K=3&amp;quot;)&lt;br /&gt;
text(tapply(1:nrow(pop),pop[ord,2],mean),-0.05,unique(pop[ord,2]),xpd=T)&lt;br /&gt;
abline(v=cumsum(sapply(unique(pop[ord,2]),function(x){sum(pop[ord,2]==x)})),col=1,lwd=1.2)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
r&amp;lt;-as.matrix(read.table(&amp;quot;output.corres.txt&amp;quot;))&lt;br /&gt;
&lt;br /&gt;
source(&amp;quot;NicePlotCorRes.R&amp;quot;)&lt;br /&gt;
# Plot correlation of residuals&lt;br /&gt;
plotCorRes(cor_mat = r, pop = as.vector(pop[,2]), title=&amp;quot;Evaluation of 1000G admixture proportions with K=3&amp;quot;, max_z=0.1, min_z=-0.1)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Low depth sequencing data ===&lt;br /&gt;
Download the input file containing genotype likelihoods in beagle format&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget popgen.dk/software/download/NGSadmix/data/Demo2input.gz&lt;br /&gt;
wget popgen.dk/software/download/NGSadmix/data/Demo2pop.info&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Execute [[NgsAdmix |NGSadmix]] to obtain admixture proportions&lt;br /&gt;
&amp;lt;pre&amp;gt;./NGSadmix -likes Demo2input.gz -K 3 -P 20 -o myoutfiles -minMaf 0.05&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
::Input file = Demo2input.gz&lt;br /&gt;
::Ancestral Populations K=3&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
::Output prefix = myoutfiles (-o myoutfiles) &lt;br /&gt;
::SNPs with MAF &amp;gt; 5%  (-minMaf 0.05)&lt;br /&gt;
&lt;br /&gt;
Run evalAdmix&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix -beagle Demo2input.gz -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 20 &amp;lt;/pre&amp;gt;&lt;br /&gt;
::Input file = input.gz&lt;br /&gt;
::Ancestral Populations frequency file myoutfiles.fopt.gz&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
&lt;br /&gt;
Plot results in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# read population labels and estimated admixture proportions&lt;br /&gt;
pop&amp;lt;-read.table(&amp;quot;Demo2pop.info&amp;quot;,as.is=T)&lt;br /&gt;
q&amp;lt;-read.table(&amp;quot;myoutfiles.qopt&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# order according to population and plot the NGSadmix reults&lt;br /&gt;
ord&amp;lt;-order(pop[,1])&lt;br /&gt;
barplot(t(q)[,ord],col=2:10,space=0,border=NA,xlab=&amp;quot;Individuals&amp;quot;,ylab=&amp;quot;Demo2 Admixture proportions for K=3&amp;quot;)&lt;br /&gt;
text(tapply(1:nrow(pop),pop[ord,1],mean),-0.05,unique(pop[ord,1]),xpd=T)&lt;br /&gt;
abline(v=cumsum(sapply(unique(pop[ord,1]),function(x){sum(pop[ord,1]==x)})),col=1,lwd=1.2)&lt;br /&gt;
&lt;br /&gt;
r&amp;lt;-read.table(&amp;quot;output.corres.txt&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
source(&amp;quot;NicePlotCorRes.R&amp;quot;)&lt;br /&gt;
# Plot correlation of residuals&lt;br /&gt;
plotCorRes(cor_mat = r, pop = as.vector(pop[,1]), title=&amp;quot;Evaluation of 1000G admixture proportions with K=3&amp;quot;, max_z=0.1, min_z=-0.1)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Citation==&lt;br /&gt;
&lt;br /&gt;
evalAdmix has a preprint&lt;br /&gt;
&lt;br /&gt;
[https://doi.org/10.1101/708883 Evaluation of Model Fit of Inferred Admixture Proportions]&lt;/div&gt;</summary>
		<author><name>Genis</name></author>
	</entry>
	<entry>
		<id>https://www.popgen.dk/software/index.php?title=EvalAdmix&amp;diff=1213</id>
		<title>EvalAdmix</title>
		<link rel="alternate" type="text/html" href="https://www.popgen.dk/software/index.php?title=EvalAdmix&amp;diff=1213"/>
		<updated>2019-07-21T11:41:01Z</updated>

		<summary type="html">&lt;p&gt;Genis: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;evalAdmix allows to evaluate the results of an admixture analysis. It takes as input the genotype data (either called genotypes in plink files or genotype likelihoods beagle files) used in the admixture analysis and the frequency&lt;br /&gt;
and admixture propotions (P and Q files) generated.&lt;br /&gt;
&lt;br /&gt;
The output is a pairwise correlation of residuals matrix between individuals The correlation will be 0 in case of a good fit of the data to the admixture model. When something is wrong, individuals from the same population will be positively correlated; and individuals from different populationts but that share one or more ancestral populations as admixture sources will have a negative correlation. Positive correlation between a pair of individuals might also be due to relatedness.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:evalAdmix.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Download and Installation==&lt;br /&gt;
&lt;br /&gt;
evalAdmix can be installed from [https://github.com/GenisGE/evalAdmix github] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
git clone https://github.com/GenisGE/evalAdmix.git&lt;br /&gt;
cd evalAdmix&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Quick start==&lt;br /&gt;
:&amp;lt;code&amp;gt; ./evalAdmix -beagle inputBeagleFile.gz  -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 10  &amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt; ./evalAdmix -plink inputPlinkPrefix  -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 10  &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''-beagle''' beagle file of genotype likelihoods&lt;br /&gt;
* '''-plink''' binary plink file prefix with genotype data&lt;br /&gt;
* '''-fname''' file with ancestral frequencies&lt;br /&gt;
* '''-qname''' file with admixture proportions&lt;br /&gt;
* '''-o''' prefix of output file names&lt;br /&gt;
* '''-P''' Number of threads used&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix  &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Arguments:&lt;br /&gt;
	-plink path to binary plink file (excluding the .bed)&lt;br /&gt;
	-beagle path to beagle file containing genotype likelihoods (alternative to -plink)&lt;br /&gt;
	-fname path to ancestral population frequencies file&lt;br /&gt;
	-qname path to admixture proportions file&lt;br /&gt;
	-o name of the output file&lt;br /&gt;
Setup:&lt;br /&gt;
	-P 1 number of threads&lt;br /&gt;
	-autosomeMax 23	 autosome ends with this chromsome&lt;br /&gt;
	-nIts 5	 number of iterations to do for frequency correction; if set to 0 calculates correlation without correction (fast but biased)&lt;br /&gt;
	-useSites 1.0	 proportion of sites to use to calculate correlation of residuals&lt;br /&gt;
	-misTol 0.05 	 tolerance for considering site as missing when using genotype likelihoods. Use same value as used in NGSadmix to keep compatibility when using genotype likelihoods (-beagle)&lt;br /&gt;
	-minMaf 0.05 	 minimum minor allele frequency to keep site. Use same value as used in NGSadmix to keep compatibility when using genotype likelihoods (-beagle)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Input File==&lt;br /&gt;
&lt;br /&gt;
===Plink===&lt;br /&gt;
Genotype data files in binary PLINK format (.bed .fam .bim).&lt;br /&gt;
===Beagle genotype likelhoods===&lt;br /&gt;
The input file contains genotype likelihoods in a .beagle file format [http://faculty.washington.edu/browning/beagle/beagle.html].&lt;br /&gt;
and can be compressed with gzip.&lt;br /&gt;
==== BAM files  ====&lt;br /&gt;
If you have BAM files you can use [[ANGSD]] to produce genotype likelihoods in .beagle format. Please &lt;br /&gt;
see [http://www.popgen.dk/angsd/index.php/Beagle_input Creation of Beagle files with ANGSD]&lt;br /&gt;
&lt;br /&gt;
==== VCF files ====&lt;br /&gt;
If you already have made a VCF file that contains genotype likehood information then  it should be possible to convert .vcf files with genotype likelihoods to .beagle file via vcftools [https://vcftools.github.io/man_latest.html] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vcftools --vcf input.vcf --out test --BEAGLE-GL --chr 1,2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Chromosome has to be specified.&lt;br /&gt;
&lt;br /&gt;
You can also use bcftools' [https://samtools.github.io/bcftools/bcftools.html] 'query' option for generating a .beagle file from a .vcf file.&lt;br /&gt;
&lt;br /&gt;
==Output Files==&lt;br /&gt;
The analysis performed by evalAdmix produces 1 file, containing a tab delimited N times N symmetric correlation matrix, where column i in line j contains the correlation of residuals between individual i and j, and the diagonal values (self-correlation) are set to NA:&lt;br /&gt;
&lt;br /&gt;
NA      0.008609        -0.006919       0.002731        0.020224&amp;lt;br /&amp;gt;&lt;br /&gt;
0.008609        NA      0.000033        0.004968        -0.008470&amp;lt;br /&amp;gt;&lt;br /&gt;
-0.006919       0.000033        NA      0.006982        0.005664&amp;lt;br /&amp;gt;&lt;br /&gt;
0.002731        0.004968        0.006982        NA      0.000521&amp;lt;br /&amp;gt;&lt;br /&gt;
0.020224        -0.008470       0.005664        0.000521        NA&lt;br /&gt;
&lt;br /&gt;
==Run command example==&lt;br /&gt;
&lt;br /&gt;
=== Genotype data ===&lt;br /&gt;
Download the input file containing genotype in binary plink format&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.bed&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.bim&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.fam&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run ADMIXTURE[http://software.genetics.ucla.edu/admixture/] to obtain admixture proprotions&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;admixture admixTjeck2.bed 3&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run evalAdmix&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix -plink admixTjeck2 -fname admixTjeck2.3.P -qname admixTjeck2.3.Q -P 20 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Plot results in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# read population labels and estimated admixture proportions&lt;br /&gt;
pop&amp;lt;-read.table(&amp;quot;admixTjeck2.fam&amp;quot;)&lt;br /&gt;
q&amp;lt;-read.table(&amp;quot;admixTjeck2.3.Q&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# order according to population and plot the ADMIXTURE reults&lt;br /&gt;
ord&amp;lt;-order(pop[,2])&lt;br /&gt;
barplot(t(q)[,ord],col=2:10,space=0,border=NA,xlab=&amp;quot;Individuals&amp;quot;,ylab=&amp;quot;Demo2 Admixture proportions for K=3&amp;quot;)&lt;br /&gt;
text(tapply(1:nrow(pop),pop[ord,2],mean),-0.05,unique(pop[ord,2]),xpd=T)&lt;br /&gt;
abline(v=cumsum(sapply(unique(pop[ord,2]),function(x){sum(pop[ord,2]==x)})),col=1,lwd=1.2)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
r&amp;lt;-as.matrix(read.table(&amp;quot;output.corres.txt&amp;quot;))&lt;br /&gt;
&lt;br /&gt;
source(&amp;quot;NicePlotCorRes.R&amp;quot;)&lt;br /&gt;
# Plot correlation of residuals&lt;br /&gt;
plotCorRes(cor_mat = r, pop = as.vector(pop[,2]), title=&amp;quot;Evaluation of 1000G admixture proportions with K=3&amp;quot;, max_z=0.1, min_z=-0.1)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Low depth sequencing data ===&lt;br /&gt;
Download the input file containing genotype likelihoods in beagle format&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget popgen.dk/software/download/NGSadmix/data/Demo2input.gz&lt;br /&gt;
wget popgen.dk/software/download/NGSadmix/data/Demo2pop.info&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Execute [[NgsAdmix |NGSadmix]] to obtain admixture proportions&lt;br /&gt;
&amp;lt;pre&amp;gt;./NGSadmix -likes Demo2input.gz -K 3 -P 20 -o myoutfiles -minMaf 0.05&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
::Input file = Demo2input.gz&lt;br /&gt;
::Ancestral Populations K=3&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
::Output prefix = myoutfiles (-o myoutfiles) &lt;br /&gt;
::SNPs with MAF &amp;gt; 5%  (-minMaf 0.05)&lt;br /&gt;
&lt;br /&gt;
Run evalAdmix&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix -beagle Demo2input.gz -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 20 &amp;lt;/pre&amp;gt;&lt;br /&gt;
::Input file = input.gz&lt;br /&gt;
::Ancestral Populations frequency file myoutfiles.fopt.gz&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
&lt;br /&gt;
Plot results in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# read population labels and estimated admixture proportions&lt;br /&gt;
pop&amp;lt;-read.table(&amp;quot;Demo2pop.info&amp;quot;,as.is=T)&lt;br /&gt;
q&amp;lt;-read.table(&amp;quot;myoutfiles.qopt&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# order according to population and plot the NGSadmix reults&lt;br /&gt;
ord&amp;lt;-order(pop[,1])&lt;br /&gt;
barplot(t(q)[,ord],col=2:10,space=0,border=NA,xlab=&amp;quot;Individuals&amp;quot;,ylab=&amp;quot;Demo2 Admixture proportions for K=3&amp;quot;)&lt;br /&gt;
text(tapply(1:nrow(pop),pop[ord,1],mean),-0.05,unique(pop[ord,1]),xpd=T)&lt;br /&gt;
abline(v=cumsum(sapply(unique(pop[ord,1]),function(x){sum(pop[ord,1]==x)})),col=1,lwd=1.2)&lt;br /&gt;
&lt;br /&gt;
r&amp;lt;-read.table(&amp;quot;output.corres.txt&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
source(&amp;quot;NicePlotCorRes.R&amp;quot;)&lt;br /&gt;
# Plot correlation of residuals&lt;br /&gt;
plotCorRes(cor_mat = r, pop = as.vector(pop[,1]), title=&amp;quot;Evaluation of 1000G admixture proportions with K=3&amp;quot;, max_z=0.1, min_z=-0.1)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Citation==&lt;br /&gt;
&lt;br /&gt;
evalAdmix has a preprint&lt;br /&gt;
&lt;br /&gt;
[https://doi.org/10.1101/708883 Evaluation of Model Fit of Inferred Admixture Proportions]&lt;/div&gt;</summary>
		<author><name>Genis</name></author>
	</entry>
	<entry>
		<id>https://www.popgen.dk/software/index.php?title=EvalAdmix&amp;diff=1212</id>
		<title>EvalAdmix</title>
		<link rel="alternate" type="text/html" href="https://www.popgen.dk/software/index.php?title=EvalAdmix&amp;diff=1212"/>
		<updated>2019-07-21T11:38:51Z</updated>

		<summary type="html">&lt;p&gt;Genis: /* Run command example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;evalAdmix allows to evaluate the results of an admixture analysis. It takes as input the genotype data (either called genotypes in plink files or genotype likelihoods beagle files) used in the admixture analysis and the frequency&lt;br /&gt;
and admixture propotions (P and Q files) generated.&lt;br /&gt;
&lt;br /&gt;
The output is a pairwise correlation of residuals matrix between individuals The correlation will be 0 in case of a good fit of the data to the admixture model. When something is wrong, individuals from the same population will be positively correlated; and individuals from different populationts but that share one or more ancestral populations as admixture sources will have a negative correlation. Positive correlation between a pair of individuals might also be due to relatedness.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:evalAdmix.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Download and Installation==&lt;br /&gt;
&lt;br /&gt;
evalAdmix can be installed from [https://github.com/GenisGE/evalAdmix github] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
git clone https://github.com/GenisGE/evalAdmix.git&lt;br /&gt;
cd evalAdmix&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Quick start==&lt;br /&gt;
:&amp;lt;code&amp;gt; ./evalAdmix -beagle inputBeagleFile.gz  -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 10  &amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt; ./evalAdmix -plink inputPlinkPrefix  -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 10  &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''-beagle''' beagle file of genotype likelihoods&lt;br /&gt;
* '''-plink''' binary plink file prefix with genotype data&lt;br /&gt;
* '''-fname''' file with ancestral frequencies&lt;br /&gt;
* '''-qname''' file with admixture proportions&lt;br /&gt;
* '''-o''' prefix of output file names&lt;br /&gt;
* '''-P''' Number of threads used&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix  &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Arguments:&lt;br /&gt;
	-plink path to binary plink file (excluding the .bed)&lt;br /&gt;
	-beagle path to beagle file containing genotype likelihoods (alternative to -plink)&lt;br /&gt;
	-fname path to ancestral population frequencies file&lt;br /&gt;
	-qname path to admixture proportions file&lt;br /&gt;
	-o name of the output file&lt;br /&gt;
Setup:&lt;br /&gt;
	-P 1 number of threads&lt;br /&gt;
	-autosomeMax 23	 autosome ends with this chromsome&lt;br /&gt;
	-nIts 5	 number of iterations to do for frequency correction; if set to 0 calculates correlation without correction (fast but biased)&lt;br /&gt;
	-useSites 1.0	 proportion of sites to use to calculate correlation of residuals&lt;br /&gt;
	-misTol 0.05 	 tolerance for considering site as missing when using genotype likelihoods. Use same value as used in NGSadmix to keep compatibility when using genotype likelihoods (-beagle)&lt;br /&gt;
	-minMaf 0.05 	 minimum minor allele frequency to keep site. Use same value as used in NGSadmix to keep compatibility when using genotype likelihoods (-beagle)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Input File==&lt;br /&gt;
&lt;br /&gt;
===Plink===&lt;br /&gt;
Genotype data files in binary PLINK format (.bed .fam .bim).&lt;br /&gt;
===Beagle genotype likelhoods===&lt;br /&gt;
The input file contains genotype likelihoods in a .beagle file format [http://faculty.washington.edu/browning/beagle/beagle.html].&lt;br /&gt;
and can be compressed with gzip.&lt;br /&gt;
==== BAM files  ====&lt;br /&gt;
If you have BAM files you can use [[ANGSD]] to produce genotype likelihoods in .beagle format. Please &lt;br /&gt;
see [http://www.popgen.dk/angsd/index.php/Beagle_input Creation of Beagle files with ANGSD]&lt;br /&gt;
&lt;br /&gt;
==== VCF files ====&lt;br /&gt;
If you already have made a VCF file that contains genotype likehood information then  it should be possible to convert .vcf files with genotype likelihoods to .beagle file via vcftools [https://vcftools.github.io/man_latest.html] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vcftools --vcf input.vcf --out test --BEAGLE-GL --chr 1,2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Chromosome has to be specified.&lt;br /&gt;
&lt;br /&gt;
You can also use bcftools' [https://samtools.github.io/bcftools/bcftools.html] 'query' option for generating a .beagle file from a .vcf file.&lt;br /&gt;
&lt;br /&gt;
==Output Files==&lt;br /&gt;
The analysis performed by evalAdmix produces 1 file, containing a tab delimited N times N symmetric correlation matrix, where column i in line j contains the correlation of residuals between individual i and j, and the diagonal values (self-correlation) are set to NA:&lt;br /&gt;
&lt;br /&gt;
NA      0.008609        -0.006919       0.002731        0.020224&amp;lt;br /&amp;gt;&lt;br /&gt;
0.008609        NA      0.000033        0.004968        -0.008470&amp;lt;br /&amp;gt;&lt;br /&gt;
-0.006919       0.000033        NA      0.006982        0.005664&amp;lt;br /&amp;gt;&lt;br /&gt;
0.002731        0.004968        0.006982        NA      0.000521&amp;lt;br /&amp;gt;&lt;br /&gt;
0.020224        -0.008470       0.005664        0.000521        NA&lt;br /&gt;
&lt;br /&gt;
==Run command example==&lt;br /&gt;
&lt;br /&gt;
=== Genotype data ===&lt;br /&gt;
Download the input file containing genotype in binary plink format&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.bed&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.bim&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.fam&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run ADMIXTURE to obtain admixture proprotions&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;admixture admixTjeck2.bed 3&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run evalAdmix&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix -plink admixTjeck2 -fname admixTjeck2.3.P -qname admixTjeck2.3.Q -P 20 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Plot results in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# read population labels and estimated admixture proportions&lt;br /&gt;
pop&amp;lt;-read.table(&amp;quot;admixTjeck2.fam&amp;quot;)&lt;br /&gt;
q&amp;lt;-read.table(&amp;quot;admixTjeck2.3.Q&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# order according to population and plot the ADMIXTURE reults&lt;br /&gt;
ord&amp;lt;-order(pop[,2])&lt;br /&gt;
barplot(t(q)[,ord],col=2:10,space=0,border=NA,xlab=&amp;quot;Individuals&amp;quot;,ylab=&amp;quot;Demo2 Admixture proportions for K=3&amp;quot;)&lt;br /&gt;
text(tapply(1:nrow(pop),pop[ord,2],mean),-0.05,unique(pop[ord,2]),xpd=T)&lt;br /&gt;
abline(v=cumsum(sapply(unique(pop[ord,2]),function(x){sum(pop[ord,2]==x)})),col=1,lwd=1.2)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
r&amp;lt;-as.matrix(read.table(&amp;quot;output.corres.txt&amp;quot;))&lt;br /&gt;
&lt;br /&gt;
source(&amp;quot;NicePlotCorRes.R&amp;quot;)&lt;br /&gt;
# Plot correlation of residuals&lt;br /&gt;
plotCorRes(cor_mat = r, pop = as.vector(pop[,2]), title=&amp;quot;Evaluation of 1000G admixture proportions with K=3&amp;quot;, max_z=0.1, min_z=-0.1)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Low depth sequencing data ===&lt;br /&gt;
Download the input file containing genotype likelihoods in beagle format&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget popgen.dk/software/download/NGSadmix/data/Demo2input.gz&lt;br /&gt;
wget popgen.dk/software/download/NGSadmix/data/Demo2pop.info&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Execute [[NgsAdmix |NGSadmix]] to obtain admixture proportions&lt;br /&gt;
&amp;lt;pre&amp;gt;./NGSadmix -likes Demo2input.gz -K 3 -P 20 -o myoutfiles -minMaf 0.05&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
::Input file = Demo2input.gz&lt;br /&gt;
::Ancestral Populations K=3&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
::Output prefix = myoutfiles (-o myoutfiles) &lt;br /&gt;
::SNPs with MAF &amp;gt; 5%  (-minMaf 0.05)&lt;br /&gt;
&lt;br /&gt;
Run evalAdmix&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix -beagle Demo2input.gz -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 20 &amp;lt;/pre&amp;gt;&lt;br /&gt;
::Input file = input.gz&lt;br /&gt;
::Ancestral Populations frequency file myoutfiles.fopt.gz&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
&lt;br /&gt;
Plot results in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# read population labels and estimated admixture proportions&lt;br /&gt;
pop&amp;lt;-read.table(&amp;quot;Demo2pop.info&amp;quot;,as.is=T)&lt;br /&gt;
q&amp;lt;-read.table(&amp;quot;myoutfiles.qopt&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# order according to population and plot the NGSadmix reults&lt;br /&gt;
ord&amp;lt;-order(pop[,1])&lt;br /&gt;
barplot(t(q)[,ord],col=2:10,space=0,border=NA,xlab=&amp;quot;Individuals&amp;quot;,ylab=&amp;quot;Demo2 Admixture proportions for K=3&amp;quot;)&lt;br /&gt;
text(tapply(1:nrow(pop),pop[ord,1],mean),-0.05,unique(pop[ord,1]),xpd=T)&lt;br /&gt;
abline(v=cumsum(sapply(unique(pop[ord,1]),function(x){sum(pop[ord,1]==x)})),col=1,lwd=1.2)&lt;br /&gt;
&lt;br /&gt;
r&amp;lt;-read.table(&amp;quot;output.corres.txt&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
source(&amp;quot;NicePlotCorRes.R&amp;quot;)&lt;br /&gt;
# Plot correlation of residuals&lt;br /&gt;
plotCorRes(cor_mat = r, pop = as.vector(pop[,1]), title=&amp;quot;Evaluation of 1000G admixture proportions with K=3&amp;quot;, max_z=0.1, min_z=-0.1)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Citation==&lt;br /&gt;
&lt;br /&gt;
evalAdmix has a preprint&lt;br /&gt;
&lt;br /&gt;
[https://doi.org/10.1101/708883 Evaluation of Model Fit of Inferred Admixture Proportions]&lt;/div&gt;</summary>
		<author><name>Genis</name></author>
	</entry>
	<entry>
		<id>https://www.popgen.dk/software/index.php?title=EvalAdmix&amp;diff=1211</id>
		<title>EvalAdmix</title>
		<link rel="alternate" type="text/html" href="https://www.popgen.dk/software/index.php?title=EvalAdmix&amp;diff=1211"/>
		<updated>2019-07-21T11:35:35Z</updated>

		<summary type="html">&lt;p&gt;Genis: /* Citation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;evalAdmix allows to evaluate the results of an admixture analysis. It takes as input the genotype data (either called genotypes in plink files or genotype likelihoods beagle files) used in the admixture analysis and the frequency&lt;br /&gt;
and admixture propotions (P and Q files) generated.&lt;br /&gt;
&lt;br /&gt;
The output is a pairwise correlation of residuals matrix between individuals The correlation will be 0 in case of a good fit of the data to the admixture model. When something is wrong, individuals from the same population will be positively correlated; and individuals from different populationts but that share one or more ancestral populations as admixture sources will have a negative correlation. Positive correlation between a pair of individuals might also be due to relatedness.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:evalAdmix.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Download and Installation==&lt;br /&gt;
&lt;br /&gt;
evalAdmix can be installed from [https://github.com/GenisGE/evalAdmix github] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
git clone https://github.com/GenisGE/evalAdmix.git&lt;br /&gt;
cd evalAdmix&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Quick start==&lt;br /&gt;
:&amp;lt;code&amp;gt; ./evalAdmix -beagle inputBeagleFile.gz  -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 10  &amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt; ./evalAdmix -plink inputPlinkPrefix  -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 10  &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''-beagle''' beagle file of genotype likelihoods&lt;br /&gt;
* '''-plink''' binary plink file prefix with genotype data&lt;br /&gt;
* '''-fname''' file with ancestral frequencies&lt;br /&gt;
* '''-qname''' file with admixture proportions&lt;br /&gt;
* '''-o''' prefix of output file names&lt;br /&gt;
* '''-P''' Number of threads used&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix  &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Arguments:&lt;br /&gt;
	-plink path to binary plink file (excluding the .bed)&lt;br /&gt;
	-beagle path to beagle file containing genotype likelihoods (alternative to -plink)&lt;br /&gt;
	-fname path to ancestral population frequencies file&lt;br /&gt;
	-qname path to admixture proportions file&lt;br /&gt;
	-o name of the output file&lt;br /&gt;
Setup:&lt;br /&gt;
	-P 1 number of threads&lt;br /&gt;
	-autosomeMax 23	 autosome ends with this chromsome&lt;br /&gt;
	-nIts 5	 number of iterations to do for frequency correction; if set to 0 calculates correlation without correction (fast but biased)&lt;br /&gt;
	-useSites 1.0	 proportion of sites to use to calculate correlation of residuals&lt;br /&gt;
	-misTol 0.05 	 tolerance for considering site as missing when using genotype likelihoods. Use same value as used in NGSadmix to keep compatibility when using genotype likelihoods (-beagle)&lt;br /&gt;
	-minMaf 0.05 	 minimum minor allele frequency to keep site. Use same value as used in NGSadmix to keep compatibility when using genotype likelihoods (-beagle)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Input File==&lt;br /&gt;
&lt;br /&gt;
===Plink===&lt;br /&gt;
Genotype data files in binary PLINK format (.bed .fam .bim).&lt;br /&gt;
===Beagle genotype likelhoods===&lt;br /&gt;
The input file contains genotype likelihoods in a .beagle file format [http://faculty.washington.edu/browning/beagle/beagle.html].&lt;br /&gt;
and can be compressed with gzip.&lt;br /&gt;
==== BAM files  ====&lt;br /&gt;
If you have BAM files you can use [[ANGSD]] to produce genotype likelihoods in .beagle format. Please &lt;br /&gt;
see [http://www.popgen.dk/angsd/index.php/Beagle_input Creation of Beagle files with ANGSD]&lt;br /&gt;
&lt;br /&gt;
==== VCF files ====&lt;br /&gt;
If you already have made a VCF file that contains genotype likehood information then  it should be possible to convert .vcf files with genotype likelihoods to .beagle file via vcftools [https://vcftools.github.io/man_latest.html] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vcftools --vcf input.vcf --out test --BEAGLE-GL --chr 1,2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Chromosome has to be specified.&lt;br /&gt;
&lt;br /&gt;
You can also use bcftools' [https://samtools.github.io/bcftools/bcftools.html] 'query' option for generating a .beagle file from a .vcf file.&lt;br /&gt;
&lt;br /&gt;
==Output Files==&lt;br /&gt;
The analysis performed by evalAdmix produces 1 file, containing a tab delimited N times N symmetric correlation matrix, where column i in line j contains the correlation of residuals between individual i and j, and the diagonal values (self-correlation) are set to NA:&lt;br /&gt;
&lt;br /&gt;
NA      0.008609        -0.006919       0.002731        0.020224&amp;lt;br /&amp;gt;&lt;br /&gt;
0.008609        NA      0.000033        0.004968        -0.008470&amp;lt;br /&amp;gt;&lt;br /&gt;
-0.006919       0.000033        NA      0.006982        0.005664&amp;lt;br /&amp;gt;&lt;br /&gt;
0.002731        0.004968        0.006982        NA      0.000521&amp;lt;br /&amp;gt;&lt;br /&gt;
0.020224        -0.008470       0.005664        0.000521        NA&lt;br /&gt;
&lt;br /&gt;
==Run command example==&lt;br /&gt;
&lt;br /&gt;
=== Genotype data ===&lt;br /&gt;
Download the input file containing genotype in binary plink format&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.bed&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.bim&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.fam&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run ADMIXTURE to obtain admixture proprotions&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;admixture admixTjeck2.bed 3&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run evalAdmix&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix -plink admixTjeck2 -fname admixTjeck2.3.P -qname admixTjeck2.3.Q -P 20 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Plot results in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# read population labels and estimated admixture proportions&lt;br /&gt;
pop&amp;lt;-read.table(&amp;quot;admixTjeck2.fam&amp;quot;)&lt;br /&gt;
q&amp;lt;-read.table(&amp;quot;admixTjeck2.3.Q&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# order according to population and plot the ADMIXTURE reults&lt;br /&gt;
ord&amp;lt;-order(pop[,2])&lt;br /&gt;
barplot(t(q)[,ord],col=2:10,space=0,border=NA,xlab=&amp;quot;Individuals&amp;quot;,ylab=&amp;quot;Demo2 Admixture proportions for K=3&amp;quot;)&lt;br /&gt;
text(tapply(1:nrow(pop),pop[ord,2],mean),-0.05,unique(pop[ord,2]),xpd=T)&lt;br /&gt;
abline(v=cumsum(sapply(unique(pop[ord,2]),function(x){sum(pop[ord,2]==x)})),col=1,lwd=1.2)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
r&amp;lt;-read.table(&amp;quot;output.corres.txt&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Plot correlation of residuals&lt;br /&gt;
mypalette &amp;lt;- colorRampPalette(colors = c(&amp;quot;blue&amp;quot;, &amp;quot;green&amp;quot;, &amp;quot;red&amp;quot;), space=&amp;quot;Lab&amp;quot;)(10)    &lt;br /&gt;
mylegend &amp;lt;- as.raster(mypalette, ncol=1)[10:1,]&lt;br /&gt;
&lt;br /&gt;
layout(matrix(1:2,ncol=2), width = c(4,1),height = c(1,1))&lt;br /&gt;
par(mar=c(5,4,4,0))&lt;br /&gt;
image(as.matrix(r)[ord,ord], col=mypalette, &lt;br /&gt;
      yaxt=&amp;quot;n&amp;quot;,xaxt=&amp;quot;n&amp;quot;, zlim=c(-0.25,0.25),useRaster=T,&lt;br /&gt;
      main=&amp;quot;Correlation of residuals&amp;quot;, &lt;br /&gt;
      oldstyle=T,cex.main=1)&lt;br /&gt;
text(tapply(1:nrow(pop),pop[ord,2],mean)/length(pop[ord,2]),-0.1,unique(pop[ord,2]),xpd=T)&lt;br /&gt;
text(-0.1,tapply(1:nrow(pop),pop[ord,2],mean)/length(pop[ord,2]),unique(pop[ord,2]),xpd=T)&lt;br /&gt;
abline(v=cumsum(sapply(unique(pop[ord,2]),function(x){sum(pop[ord,2]==x)}))/length(pop[ord,2]),col=1,lwd=1.2)&lt;br /&gt;
abline(h=cumsum(sapply(unique(pop[ord,2]),function(x){sum(pop[ord,2]==x)}))/length(pop[ord,2]),col=1,lwd=1.2)&lt;br /&gt;
par(mar=c(5,0.5,4,2))&lt;br /&gt;
plot(c(0,1),c(0,1),type = 'n', axes = F,xlab = '', ylab = '', main = '')&lt;br /&gt;
rasterImage(mylegend, 0, 0.25, 0.4,0.75)&lt;br /&gt;
text(x=0.8, y = c(0.25,0.5, 0.75), labels = c(-0.25, 0, 0.25),cex=0.8)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
=== Low depth sequencing data ===&lt;br /&gt;
Download the input file containing genotype likelihoods in beagle format&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget popgen.dk/software/download/NGSadmix/data/Demo2input.gz&lt;br /&gt;
wget popgen.dk/software/download/NGSadmix/data/Demo2pop.info&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Execute [[NgsAdmix |NGSadmix]] to obtain admixture proportions&lt;br /&gt;
&amp;lt;pre&amp;gt;./NGSadmix -likes Demo2input.gz -K 3 -P 20 -o myoutfiles -minMaf 0.05&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
::Input file = Demo2input.gz&lt;br /&gt;
::Ancestral Populations K=3&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
::Output prefix = myoutfiles (-o myoutfiles) &lt;br /&gt;
::SNPs with MAF &amp;gt; 5%  (-minMaf 0.05)&lt;br /&gt;
&lt;br /&gt;
Run evalAdmix&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix -beagle Demo2input.gz -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 20 &amp;lt;/pre&amp;gt;&lt;br /&gt;
::Input file = input.gz&lt;br /&gt;
::Ancestral Populations frequency file myoutfiles.fopt.gz&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
&lt;br /&gt;
Plot results in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# read population labels and estimated admixture proportions&lt;br /&gt;
pop&amp;lt;-read.table(&amp;quot;Demo2pop.info&amp;quot;,as.is=T)&lt;br /&gt;
q&amp;lt;-read.table(&amp;quot;myoutfiles.qopt&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# order according to population and plot the NGSadmix reults&lt;br /&gt;
ord&amp;lt;-order(pop[,1])&lt;br /&gt;
barplot(t(q)[,ord],col=2:10,space=0,border=NA,xlab=&amp;quot;Individuals&amp;quot;,ylab=&amp;quot;Demo2 Admixture proportions for K=3&amp;quot;)&lt;br /&gt;
text(tapply(1:nrow(pop),pop[ord,1],mean),-0.05,unique(pop[ord,1]),xpd=T)&lt;br /&gt;
abline(v=cumsum(sapply(unique(pop[ord,1]),function(x){sum(pop[ord,1]==x)})),col=1,lwd=1.2)&lt;br /&gt;
&lt;br /&gt;
r&amp;lt;-read.table(&amp;quot;output.corres.txt&amp;quot;)&lt;br /&gt;
image(as.matrix(r))&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Citation==&lt;br /&gt;
&lt;br /&gt;
evalAdmix has a preprint&lt;br /&gt;
&lt;br /&gt;
[https://doi.org/10.1101/708883 Evaluation of Model Fit of Inferred Admixture Proportions]&lt;/div&gt;</summary>
		<author><name>Genis</name></author>
	</entry>
	<entry>
		<id>https://www.popgen.dk/software/index.php?title=EvalAdmix&amp;diff=1210</id>
		<title>EvalAdmix</title>
		<link rel="alternate" type="text/html" href="https://www.popgen.dk/software/index.php?title=EvalAdmix&amp;diff=1210"/>
		<updated>2019-07-20T16:31:47Z</updated>

		<summary type="html">&lt;p&gt;Genis: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;evalAdmix allows to evaluate the results of an admixture analysis. It takes as input the genotype data (either called genotypes in plink files or genotype likelihoods beagle files) used in the admixture analysis and the frequency&lt;br /&gt;
and admixture propotions (P and Q files) generated.&lt;br /&gt;
&lt;br /&gt;
The output is a pairwise correlation of residuals matrix between individuals The correlation will be 0 in case of a good fit of the data to the admixture model. When something is wrong, individuals from the same population will be positively correlated; and individuals from different populationts but that share one or more ancestral populations as admixture sources will have a negative correlation. Positive correlation between a pair of individuals might also be due to relatedness.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:evalAdmix.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Download and Installation==&lt;br /&gt;
&lt;br /&gt;
evalAdmix can be installed from [https://github.com/GenisGE/evalAdmix github] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
git clone https://github.com/GenisGE/evalAdmix.git&lt;br /&gt;
cd evalAdmix&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Quick start==&lt;br /&gt;
:&amp;lt;code&amp;gt; ./evalAdmix -beagle inputBeagleFile.gz  -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 10  &amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt; ./evalAdmix -plink inputPlinkPrefix  -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 10  &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''-beagle''' beagle file of genotype likelihoods&lt;br /&gt;
* '''-plink''' binary plink file prefix with genotype data&lt;br /&gt;
* '''-fname''' file with ancestral frequencies&lt;br /&gt;
* '''-qname''' file with admixture proportions&lt;br /&gt;
* '''-o''' prefix of output file names&lt;br /&gt;
* '''-P''' Number of threads used&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix  &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Arguments:&lt;br /&gt;
	-plink path to binary plink file (excluding the .bed)&lt;br /&gt;
	-beagle path to beagle file containing genotype likelihoods (alternative to -plink)&lt;br /&gt;
	-fname path to ancestral population frequencies file&lt;br /&gt;
	-qname path to admixture proportions file&lt;br /&gt;
	-o name of the output file&lt;br /&gt;
Setup:&lt;br /&gt;
	-P 1 number of threads&lt;br /&gt;
	-autosomeMax 23	 autosome ends with this chromsome&lt;br /&gt;
	-nIts 5	 number of iterations to do for frequency correction; if set to 0 calculates correlation without correction (fast but biased)&lt;br /&gt;
	-useSites 1.0	 proportion of sites to use to calculate correlation of residuals&lt;br /&gt;
	-misTol 0.05 	 tolerance for considering site as missing when using genotype likelihoods. Use same value as used in NGSadmix to keep compatibility when using genotype likelihoods (-beagle)&lt;br /&gt;
	-minMaf 0.05 	 minimum minor allele frequency to keep site. Use same value as used in NGSadmix to keep compatibility when using genotype likelihoods (-beagle)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Input File==&lt;br /&gt;
&lt;br /&gt;
===Plink===&lt;br /&gt;
Genotype data files in binary PLINK format (.bed .fam .bim).&lt;br /&gt;
===Beagle genotype likelhoods===&lt;br /&gt;
The input file contains genotype likelihoods in a .beagle file format [http://faculty.washington.edu/browning/beagle/beagle.html].&lt;br /&gt;
and can be compressed with gzip.&lt;br /&gt;
==== BAM files  ====&lt;br /&gt;
If you have BAM files you can use [[ANGSD]] to produce genotype likelihoods in .beagle format. Please &lt;br /&gt;
see [http://www.popgen.dk/angsd/index.php/Beagle_input Creation of Beagle files with ANGSD]&lt;br /&gt;
&lt;br /&gt;
==== VCF files ====&lt;br /&gt;
If you already have made a VCF file that contains genotype likehood information then  it should be possible to convert .vcf files with genotype likelihoods to .beagle file via vcftools [https://vcftools.github.io/man_latest.html] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vcftools --vcf input.vcf --out test --BEAGLE-GL --chr 1,2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Chromosome has to be specified.&lt;br /&gt;
&lt;br /&gt;
You can also use bcftools' [https://samtools.github.io/bcftools/bcftools.html] 'query' option for generating a .beagle file from a .vcf file.&lt;br /&gt;
&lt;br /&gt;
==Output Files==&lt;br /&gt;
The analysis performed by evalAdmix produces 1 file, containing a tab delimited N times N symmetric correlation matrix, where column i in line j contains the correlation of residuals between individual i and j, and the diagonal values (self-correlation) are set to NA:&lt;br /&gt;
&lt;br /&gt;
NA      0.008609        -0.006919       0.002731        0.020224&amp;lt;br /&amp;gt;&lt;br /&gt;
0.008609        NA      0.000033        0.004968        -0.008470&amp;lt;br /&amp;gt;&lt;br /&gt;
-0.006919       0.000033        NA      0.006982        0.005664&amp;lt;br /&amp;gt;&lt;br /&gt;
0.002731        0.004968        0.006982        NA      0.000521&amp;lt;br /&amp;gt;&lt;br /&gt;
0.020224        -0.008470       0.005664        0.000521        NA&lt;br /&gt;
&lt;br /&gt;
==Run command example==&lt;br /&gt;
&lt;br /&gt;
=== Genotype data ===&lt;br /&gt;
Download the input file containing genotype in binary plink format&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.bed&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.bim&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.fam&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run ADMIXTURE to obtain admixture proprotions&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;admixture admixTjeck2.bed 3&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run evalAdmix&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix -plink admixTjeck2 -fname admixTjeck2.3.P -qname admixTjeck2.3.Q -P 20 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Plot results in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# read population labels and estimated admixture proportions&lt;br /&gt;
pop&amp;lt;-read.table(&amp;quot;admixTjeck2.fam&amp;quot;)&lt;br /&gt;
q&amp;lt;-read.table(&amp;quot;admixTjeck2.3.Q&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# order according to population and plot the ADMIXTURE reults&lt;br /&gt;
ord&amp;lt;-order(pop[,2])&lt;br /&gt;
barplot(t(q)[,ord],col=2:10,space=0,border=NA,xlab=&amp;quot;Individuals&amp;quot;,ylab=&amp;quot;Demo2 Admixture proportions for K=3&amp;quot;)&lt;br /&gt;
text(tapply(1:nrow(pop),pop[ord,2],mean),-0.05,unique(pop[ord,2]),xpd=T)&lt;br /&gt;
abline(v=cumsum(sapply(unique(pop[ord,2]),function(x){sum(pop[ord,2]==x)})),col=1,lwd=1.2)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
r&amp;lt;-read.table(&amp;quot;output.corres.txt&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Plot correlation of residuals&lt;br /&gt;
mypalette &amp;lt;- colorRampPalette(colors = c(&amp;quot;blue&amp;quot;, &amp;quot;green&amp;quot;, &amp;quot;red&amp;quot;), space=&amp;quot;Lab&amp;quot;)(10)    &lt;br /&gt;
mylegend &amp;lt;- as.raster(mypalette, ncol=1)[10:1,]&lt;br /&gt;
&lt;br /&gt;
layout(matrix(1:2,ncol=2), width = c(4,1),height = c(1,1))&lt;br /&gt;
par(mar=c(5,4,4,0))&lt;br /&gt;
image(as.matrix(r)[ord,ord], col=mypalette, &lt;br /&gt;
      yaxt=&amp;quot;n&amp;quot;,xaxt=&amp;quot;n&amp;quot;, zlim=c(-0.25,0.25),useRaster=T,&lt;br /&gt;
      main=&amp;quot;Correlation of residuals&amp;quot;, &lt;br /&gt;
      oldstyle=T,cex.main=1)&lt;br /&gt;
text(tapply(1:nrow(pop),pop[ord,2],mean)/length(pop[ord,2]),-0.1,unique(pop[ord,2]),xpd=T)&lt;br /&gt;
text(-0.1,tapply(1:nrow(pop),pop[ord,2],mean)/length(pop[ord,2]),unique(pop[ord,2]),xpd=T)&lt;br /&gt;
abline(v=cumsum(sapply(unique(pop[ord,2]),function(x){sum(pop[ord,2]==x)}))/length(pop[ord,2]),col=1,lwd=1.2)&lt;br /&gt;
abline(h=cumsum(sapply(unique(pop[ord,2]),function(x){sum(pop[ord,2]==x)}))/length(pop[ord,2]),col=1,lwd=1.2)&lt;br /&gt;
par(mar=c(5,0.5,4,2))&lt;br /&gt;
plot(c(0,1),c(0,1),type = 'n', axes = F,xlab = '', ylab = '', main = '')&lt;br /&gt;
rasterImage(mylegend, 0, 0.25, 0.4,0.75)&lt;br /&gt;
text(x=0.8, y = c(0.25,0.5, 0.75), labels = c(-0.25, 0, 0.25),cex=0.8)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
=== Low depth sequencing data ===&lt;br /&gt;
Download the input file containing genotype likelihoods in beagle format&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget popgen.dk/software/download/NGSadmix/data/Demo2input.gz&lt;br /&gt;
wget popgen.dk/software/download/NGSadmix/data/Demo2pop.info&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Execute [[NgsAdmix |NGSadmix]] to obtain admixture proportions&lt;br /&gt;
&amp;lt;pre&amp;gt;./NGSadmix -likes Demo2input.gz -K 3 -P 20 -o myoutfiles -minMaf 0.05&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
::Input file = Demo2input.gz&lt;br /&gt;
::Ancestral Populations K=3&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
::Output prefix = myoutfiles (-o myoutfiles) &lt;br /&gt;
::SNPs with MAF &amp;gt; 5%  (-minMaf 0.05)&lt;br /&gt;
&lt;br /&gt;
Run evalAdmix&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix -beagle Demo2input.gz -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 20 &amp;lt;/pre&amp;gt;&lt;br /&gt;
::Input file = input.gz&lt;br /&gt;
::Ancestral Populations frequency file myoutfiles.fopt.gz&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
&lt;br /&gt;
Plot results in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# read population labels and estimated admixture proportions&lt;br /&gt;
pop&amp;lt;-read.table(&amp;quot;Demo2pop.info&amp;quot;,as.is=T)&lt;br /&gt;
q&amp;lt;-read.table(&amp;quot;myoutfiles.qopt&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# order according to population and plot the NGSadmix reults&lt;br /&gt;
ord&amp;lt;-order(pop[,1])&lt;br /&gt;
barplot(t(q)[,ord],col=2:10,space=0,border=NA,xlab=&amp;quot;Individuals&amp;quot;,ylab=&amp;quot;Demo2 Admixture proportions for K=3&amp;quot;)&lt;br /&gt;
text(tapply(1:nrow(pop),pop[ord,1],mean),-0.05,unique(pop[ord,1]),xpd=T)&lt;br /&gt;
abline(v=cumsum(sapply(unique(pop[ord,1]),function(x){sum(pop[ord,1]==x)})),col=1,lwd=1.2)&lt;br /&gt;
&lt;br /&gt;
r&amp;lt;-read.table(&amp;quot;output.corres.txt&amp;quot;)&lt;br /&gt;
image(as.matrix(r))&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Citation==&lt;br /&gt;
&lt;br /&gt;
evalAdmix has a pre-print&lt;br /&gt;
&lt;br /&gt;
[https://doi.org/10.1101/708883 Evaluation of Model Fit of Inferred Admixture Proportions]&lt;/div&gt;</summary>
		<author><name>Genis</name></author>
	</entry>
	<entry>
		<id>https://www.popgen.dk/software/index.php?title=EvalAdmix&amp;diff=1209</id>
		<title>EvalAdmix</title>
		<link rel="alternate" type="text/html" href="https://www.popgen.dk/software/index.php?title=EvalAdmix&amp;diff=1209"/>
		<updated>2019-07-20T16:29:45Z</updated>

		<summary type="html">&lt;p&gt;Genis: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;evalAdmix allows to evaluate the results of an admixture analysis. It takes as input the genotype data (either called genotypes in plink files or genotype likelihoods beagle files) used in the admixture analysis and the frequency&lt;br /&gt;
and admixture propotions (P and Q files) generated.&lt;br /&gt;
&lt;br /&gt;
The output is a pairwise correlation of residuals matrix between individuals The correlation will be 0 in case of a good fit of the data to the admixture model. When something is wrong, individuals from the same population will be positively correlated; and individuals from different populationts but that share one or more ancestral populations as admixture sources will have a negative correlation. Positive correlation between a pair of individuals might also be due to relatedness.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:evalAdmix.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Download and Installation==&lt;br /&gt;
&lt;br /&gt;
evalAdmix can be installed from [https://github.com/GenisGE/evalAdmix github] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
git clone https://github.com/GenisGE/evalAdmix.git&lt;br /&gt;
cd evalAdmix&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Quick start==&lt;br /&gt;
:&amp;lt;code&amp;gt; ./evalAdmix -beagle inputBeagleFile.gz  -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 10  &amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt; ./evalAdmix -plink inputPlinkPrefix  -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 10  &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''-beagle''' beagle file of genotype likelihoods&lt;br /&gt;
* '''-plink''' binary plink file prefix with genotype data&lt;br /&gt;
* '''-fname''' file with ancestral frequencies&lt;br /&gt;
* '''-qname''' file with admixture proportions&lt;br /&gt;
* '''-o''' prefix of output file names&lt;br /&gt;
* '''-P''' Number of threads used&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix  &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Arguments:&lt;br /&gt;
	-plink path to binary plink file (excluding the .bed)&lt;br /&gt;
	-beagle path to beagle file containing genotype likelihoods (alternative to -plink)&lt;br /&gt;
	-fname path to ancestral population frequencies file&lt;br /&gt;
	-qname path to admixture proportions file&lt;br /&gt;
	-o name of the output file&lt;br /&gt;
Setup:&lt;br /&gt;
	-P 1 number of threads&lt;br /&gt;
	-autosomeMax 23	 autosome ends with this chromsome&lt;br /&gt;
	-nIts 5	 number of iterations to do for frequency correction; if set to 0 calculates correlation without correction (fast but biased)&lt;br /&gt;
	-useSites 1.0	 proportion of sites to use to calculate correlation of residuals&lt;br /&gt;
	-misTol 0.05 	 tolerance for considering site as missing when using genotype likelihoods. Use same value as used in NGSadmix to keep compatibility when using genotype likelihoods (-beagle)&lt;br /&gt;
	-minMaf 0.05 	 minimum minor allele frequency to keep site. Use same value as used in NGSadmix to keep compatibility when using genotype likelihoods (-beagle)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Input File==&lt;br /&gt;
&lt;br /&gt;
===Plink===&lt;br /&gt;
Genotype data files in binary PLINK format (.bed .fam .bim).&lt;br /&gt;
===Beagle genotype likelhoods===&lt;br /&gt;
The input file contains genotype likelihoods in a .beagle file format [http://faculty.washington.edu/browning/beagle/beagle.html].&lt;br /&gt;
and can be compressed with gzip.&lt;br /&gt;
==== BAM files  ====&lt;br /&gt;
If you have BAM files you can use [[ANGSD]] to produce genotype likelihoods in .beagle format. Please &lt;br /&gt;
see [http://www.popgen.dk/angsd/index.php/Beagle_input Creation of Beagle files with ANGSD]&lt;br /&gt;
&lt;br /&gt;
==== VCF files ====&lt;br /&gt;
If you already have made a VCF file that contains genotype likehood information then  it should be possible to convert .vcf files with genotype likelihoods to .beagle file via vcftools [https://vcftools.github.io/man_latest.html] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vcftools --vcf input.vcf --out test --BEAGLE-GL --chr 1,2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Chromosome has to be specified.&lt;br /&gt;
&lt;br /&gt;
You can also use bcftools' [https://samtools.github.io/bcftools/bcftools.html] 'query' option for generating a .beagle file from a .vcf file.&lt;br /&gt;
&lt;br /&gt;
==Output Files==&lt;br /&gt;
The analysis performed by evalAdmix produces 1 file, containing a tab delimited N times N symmetric correlation matrix, where column i in line j contains the correlation of residuals between individual i and j, and the diagonal values (self-correlation) are set to NA:&lt;br /&gt;
&lt;br /&gt;
NA      0.008609        -0.006919       0.002731        0.020224&amp;lt;br /&amp;gt;&lt;br /&gt;
0.008609        NA      0.000033        0.004968        -0.008470&amp;lt;br /&amp;gt;&lt;br /&gt;
-0.006919       0.000033        NA      0.006982        0.005664&amp;lt;br /&amp;gt;&lt;br /&gt;
0.002731        0.004968        0.006982        NA      0.000521&amp;lt;br /&amp;gt;&lt;br /&gt;
0.020224        -0.008470       0.005664        0.000521        NA&lt;br /&gt;
&lt;br /&gt;
==Run command example==&lt;br /&gt;
&lt;br /&gt;
=== Genotype data ===&lt;br /&gt;
Download the input file containing genotype in binary plink format&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.bed&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.bim&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.fam&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run ADMIXTURE to obtain admixture proprotions&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;admixture admixTjeck2.bed 3&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run evalAdmix&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix -plink admixTjeck2 -fname admixTjeck2.3.P -qname admixTjeck2.3.Q -P 20 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Plot results in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# read population labels and estimated admixture proportions&lt;br /&gt;
pop&amp;lt;-read.table(&amp;quot;admixTjeck2.fam&amp;quot;)&lt;br /&gt;
q&amp;lt;-read.table(&amp;quot;admixTjeck2.3.Q&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# order according to population and plot the ADMIXTURE reults&lt;br /&gt;
ord&amp;lt;-order(pop[,2])&lt;br /&gt;
barplot(t(q)[,ord],col=2:10,space=0,border=NA,xlab=&amp;quot;Individuals&amp;quot;,ylab=&amp;quot;Demo2 Admixture proportions for K=3&amp;quot;)&lt;br /&gt;
text(tapply(1:nrow(pop),pop[ord,2],mean),-0.05,unique(pop[ord,2]),xpd=T)&lt;br /&gt;
abline(v=cumsum(sapply(unique(pop[ord,2]),function(x){sum(pop[ord,2]==x)})),col=1,lwd=1.2)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
r&amp;lt;-read.table(&amp;quot;output.corres.txt&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Plot correlation of residuals&lt;br /&gt;
mypalette &amp;lt;- colorRampPalette(colors = c(&amp;quot;blue&amp;quot;, &amp;quot;green&amp;quot;, &amp;quot;red&amp;quot;), space=&amp;quot;Lab&amp;quot;)(10)    &lt;br /&gt;
mylegend &amp;lt;- as.raster(mypalette, ncol=1)[10:1,]&lt;br /&gt;
&lt;br /&gt;
layout(matrix(1:2,ncol=2), width = c(4,1),height = c(1,1))&lt;br /&gt;
par(mar=c(5,4,4,0))&lt;br /&gt;
image(as.matrix(r)[ord,ord], col=mypalette, &lt;br /&gt;
      yaxt=&amp;quot;n&amp;quot;,xaxt=&amp;quot;n&amp;quot;, zlim=c(-0.25,0.25),useRaster=T,&lt;br /&gt;
      main=&amp;quot;Correlation of residuals&amp;quot;, &lt;br /&gt;
      oldstyle=T,cex.main=1)&lt;br /&gt;
text(tapply(1:nrow(pop),pop[ord,2],mean)/length(pop[ord,2]),-0.1,unique(pop[ord,2]),xpd=T)&lt;br /&gt;
text(-0.1,tapply(1:nrow(pop),pop[ord,2],mean)/length(pop[ord,2]),unique(pop[ord,2]),xpd=T)&lt;br /&gt;
abline(v=cumsum(sapply(unique(pop[ord,2]),function(x){sum(pop[ord,2]==x)}))/length(pop[ord,2]),col=1,lwd=1.2)&lt;br /&gt;
abline(h=cumsum(sapply(unique(pop[ord,2]),function(x){sum(pop[ord,2]==x)}))/length(pop[ord,2]),col=1,lwd=1.2)&lt;br /&gt;
par(mar=c(5,0.5,4,2))&lt;br /&gt;
plot(c(0,1),c(0,1),type = 'n', axes = F,xlab = '', ylab = '', main = '')&lt;br /&gt;
rasterImage(mylegend, 0, 0.25, 0.4,0.75)&lt;br /&gt;
text(x=0.8, y = c(0.25,0.5, 0.75), labels = c(-0.25, 0, 0.25),cex=0.8)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
=== Low depth sequencing data ===&lt;br /&gt;
Download the input file containing genotype likelihoods in beagle format&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget popgen.dk/software/download/NGSadmix/data/Demo2input.gz&lt;br /&gt;
wget popgen.dk/software/download/NGSadmix/data/Demo2pop.info&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Execute [[NgsAdmix |NGSadmix]] to obtain admixture proportions&lt;br /&gt;
&amp;lt;pre&amp;gt;./NGSadmix -likes Demo2input.gz -K 3 -P 20 -o myoutfiles -minMaf 0.05&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
::Input file = Demo2input.gz&lt;br /&gt;
::Ancestral Populations K=3&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
::Output prefix = myoutfiles (-o myoutfiles) &lt;br /&gt;
::SNPs with MAF &amp;gt; 5%  (-minMaf 0.05)&lt;br /&gt;
&lt;br /&gt;
Run evalAdmix&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix -beagle Demo2input.gz -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 20 &amp;lt;/pre&amp;gt;&lt;br /&gt;
::Input file = input.gz&lt;br /&gt;
::Ancestral Populations frequency file myoutfiles.fopt.gz&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
&lt;br /&gt;
Plot results in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# read population labels and estimated admixture proportions&lt;br /&gt;
pop&amp;lt;-read.table(&amp;quot;Demo2pop.info&amp;quot;,as.is=T)&lt;br /&gt;
q&amp;lt;-read.table(&amp;quot;myoutfiles.qopt&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# order according to population and plot the NGSadmix reults&lt;br /&gt;
ord&amp;lt;-order(pop[,1])&lt;br /&gt;
barplot(t(q)[,ord],col=2:10,space=0,border=NA,xlab=&amp;quot;Individuals&amp;quot;,ylab=&amp;quot;Demo2 Admixture proportions for K=3&amp;quot;)&lt;br /&gt;
text(tapply(1:nrow(pop),pop[ord,1],mean),-0.05,unique(pop[ord,1]),xpd=T)&lt;br /&gt;
abline(v=cumsum(sapply(unique(pop[ord,1]),function(x){sum(pop[ord,1]==x)})),col=1,lwd=1.2)&lt;br /&gt;
&lt;br /&gt;
r&amp;lt;-read.table(&amp;quot;output.corres.txt&amp;quot;)&lt;br /&gt;
image(as.matrix(r))&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Citation==&lt;br /&gt;
&lt;br /&gt;
evalAdmix has a pre-print&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Garcia-Erill G, Albrechtsen A; &lt;br /&gt;
Evaluation of Model Fit of Inferred Admixture Proportions,&lt;br /&gt;
(July 19, 2019), [https://doi.org/10.1101/708883 bioRxiv]&lt;/div&gt;</summary>
		<author><name>Genis</name></author>
	</entry>
	<entry>
		<id>https://www.popgen.dk/software/index.php?title=Template:Cite_bioRxiv&amp;diff=1208</id>
		<title>Template:Cite bioRxiv</title>
		<link rel="alternate" type="text/html" href="https://www.popgen.dk/software/index.php?title=Template:Cite_bioRxiv&amp;diff=1208"/>
		<updated>2019-07-20T16:25:13Z</updated>

		<summary type="html">&lt;p&gt;Genis: Created page with &amp;quot;{{cite bioRxiv |last1=Garcia-Erill|first1=G |last2=Albrechtsen|first2=A |date=July 19, 2019|title=Evaluation of Model Fit of Inferred Admixture Proportions|biorxiv=https://doi...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{cite bioRxiv |last1=Garcia-Erill|first1=G |last2=Albrechtsen|first2=A |date=July 19, 2019|title=Evaluation of Model Fit of Inferred Admixture Proportions|biorxiv=https://doi.org/10.1101/708883 }}&lt;/div&gt;</summary>
		<author><name>Genis</name></author>
	</entry>
	<entry>
		<id>https://www.popgen.dk/software/index.php?title=EvalAdmix&amp;diff=1207</id>
		<title>EvalAdmix</title>
		<link rel="alternate" type="text/html" href="https://www.popgen.dk/software/index.php?title=EvalAdmix&amp;diff=1207"/>
		<updated>2019-07-20T16:25:06Z</updated>

		<summary type="html">&lt;p&gt;Genis: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;evalAdmix allows to evaluate the results of an admixture analysis. It takes as input the genotype data (either called genotypes in plink files or genotype likelihoods beagle files) used in the admixture analysis and the frequency&lt;br /&gt;
and admixture propotions (P and Q files) generated.&lt;br /&gt;
&lt;br /&gt;
The output is a pairwise correlation of residuals matrix between individuals The correlation will be 0 in case of a good fit of the data to the admixture model. When something is wrong, individuals from the same population will be positively correlated; and individuals from different populationts but that share one or more ancestral populations as admixture sources will have a negative correlation. Positive correlation between a pair of individuals might also be due to relatedness.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:evalAdmix.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Download and Installation==&lt;br /&gt;
&lt;br /&gt;
evalAdmix can be installed from [https://github.com/GenisGE/evalAdmix github] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
git clone https://github.com/GenisGE/evalAdmix.git&lt;br /&gt;
cd evalAdmix&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Quick start==&lt;br /&gt;
:&amp;lt;code&amp;gt; ./evalAdmix -beagle inputBeagleFile.gz  -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 10  &amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt; ./evalAdmix -plink inputPlinkPrefix  -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 10  &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''-beagle''' beagle file of genotype likelihoods&lt;br /&gt;
* '''-plink''' binary plink file prefix with genotype data&lt;br /&gt;
* '''-fname''' file with ancestral frequencies&lt;br /&gt;
* '''-qname''' file with admixture proportions&lt;br /&gt;
* '''-o''' prefix of output file names&lt;br /&gt;
* '''-P''' Number of threads used&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix  &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Arguments:&lt;br /&gt;
	-plink path to binary plink file (excluding the .bed)&lt;br /&gt;
	-beagle path to beagle file containing genotype likelihoods (alternative to -plink)&lt;br /&gt;
	-fname path to ancestral population frequencies file&lt;br /&gt;
	-qname path to admixture proportions file&lt;br /&gt;
	-o name of the output file&lt;br /&gt;
Setup:&lt;br /&gt;
	-P 1 number of threads&lt;br /&gt;
	-autosomeMax 23	 autosome ends with this chromsome&lt;br /&gt;
	-nIts 5	 number of iterations to do for frequency correction; if set to 0 calculates correlation without correction (fast but biased)&lt;br /&gt;
	-useSites 1.0	 proportion of sites to use to calculate correlation of residuals&lt;br /&gt;
	-misTol 0.05 	 tolerance for considering site as missing when using genotype likelihoods. Use same value as used in NGSadmix to keep compatibility when using genotype likelihoods (-beagle)&lt;br /&gt;
	-minMaf 0.05 	 minimum minor allele frequency to keep site. Use same value as used in NGSadmix to keep compatibility when using genotype likelihoods (-beagle)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Input File==&lt;br /&gt;
&lt;br /&gt;
===Plink===&lt;br /&gt;
Genotype data files in binary PLINK format (.bed .fam .bim).&lt;br /&gt;
===Beagle genotype likelhoods===&lt;br /&gt;
The input file contains genotype likelihoods in a .beagle file format [http://faculty.washington.edu/browning/beagle/beagle.html].&lt;br /&gt;
and can be compressed with gzip.&lt;br /&gt;
==== BAM files  ====&lt;br /&gt;
If you have BAM files you can use [[ANGSD]] to produce genotype likelihoods in .beagle format. Please &lt;br /&gt;
see [http://www.popgen.dk/angsd/index.php/Beagle_input Creation of Beagle files with ANGSD]&lt;br /&gt;
&lt;br /&gt;
==== VCF files ====&lt;br /&gt;
If you already have made a VCF file that contains genotype likehood information then  it should be possible to convert .vcf files with genotype likelihoods to .beagle file via vcftools [https://vcftools.github.io/man_latest.html] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vcftools --vcf input.vcf --out test --BEAGLE-GL --chr 1,2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Chromosome has to be specified.&lt;br /&gt;
&lt;br /&gt;
You can also use bcftools' [https://samtools.github.io/bcftools/bcftools.html] 'query' option for generating a .beagle file from a .vcf file.&lt;br /&gt;
&lt;br /&gt;
==Output Files==&lt;br /&gt;
The analysis performed by evalAdmix produces 1 file, containing a tab delimited N times N symmetric correlation matrix, where column i in line j contains the correlation of residuals between individual i and j, and the diagonal values (self-correlation) are set to NA:&lt;br /&gt;
&lt;br /&gt;
NA      0.008609        -0.006919       0.002731        0.020224&amp;lt;br /&amp;gt;&lt;br /&gt;
0.008609        NA      0.000033        0.004968        -0.008470&amp;lt;br /&amp;gt;&lt;br /&gt;
-0.006919       0.000033        NA      0.006982        0.005664&amp;lt;br /&amp;gt;&lt;br /&gt;
0.002731        0.004968        0.006982        NA      0.000521&amp;lt;br /&amp;gt;&lt;br /&gt;
0.020224        -0.008470       0.005664        0.000521        NA&lt;br /&gt;
&lt;br /&gt;
==Run command example==&lt;br /&gt;
&lt;br /&gt;
=== Genotype data ===&lt;br /&gt;
Download the input file containing genotype in binary plink format&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.bed&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.bim&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.fam&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run ADMIXTURE to obtain admixture proprotions&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;admixture admixTjeck2.bed 3&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run evalAdmix&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix -plink admixTjeck2 -fname admixTjeck2.3.P -qname admixTjeck2.3.Q -P 20 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Plot results in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# read population labels and estimated admixture proportions&lt;br /&gt;
pop&amp;lt;-read.table(&amp;quot;admixTjeck2.fam&amp;quot;)&lt;br /&gt;
q&amp;lt;-read.table(&amp;quot;admixTjeck2.3.Q&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# order according to population and plot the ADMIXTURE reults&lt;br /&gt;
ord&amp;lt;-order(pop[,2])&lt;br /&gt;
barplot(t(q)[,ord],col=2:10,space=0,border=NA,xlab=&amp;quot;Individuals&amp;quot;,ylab=&amp;quot;Demo2 Admixture proportions for K=3&amp;quot;)&lt;br /&gt;
text(tapply(1:nrow(pop),pop[ord,2],mean),-0.05,unique(pop[ord,2]),xpd=T)&lt;br /&gt;
abline(v=cumsum(sapply(unique(pop[ord,2]),function(x){sum(pop[ord,2]==x)})),col=1,lwd=1.2)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
r&amp;lt;-read.table(&amp;quot;output.corres.txt&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Plot correlation of residuals&lt;br /&gt;
mypalette &amp;lt;- colorRampPalette(colors = c(&amp;quot;blue&amp;quot;, &amp;quot;green&amp;quot;, &amp;quot;red&amp;quot;), space=&amp;quot;Lab&amp;quot;)(10)    &lt;br /&gt;
mylegend &amp;lt;- as.raster(mypalette, ncol=1)[10:1,]&lt;br /&gt;
&lt;br /&gt;
layout(matrix(1:2,ncol=2), width = c(4,1),height = c(1,1))&lt;br /&gt;
par(mar=c(5,4,4,0))&lt;br /&gt;
image(as.matrix(r)[ord,ord], col=mypalette, &lt;br /&gt;
      yaxt=&amp;quot;n&amp;quot;,xaxt=&amp;quot;n&amp;quot;, zlim=c(-0.25,0.25),useRaster=T,&lt;br /&gt;
      main=&amp;quot;Correlation of residuals&amp;quot;, &lt;br /&gt;
      oldstyle=T,cex.main=1)&lt;br /&gt;
text(tapply(1:nrow(pop),pop[ord,2],mean)/length(pop[ord,2]),-0.1,unique(pop[ord,2]),xpd=T)&lt;br /&gt;
text(-0.1,tapply(1:nrow(pop),pop[ord,2],mean)/length(pop[ord,2]),unique(pop[ord,2]),xpd=T)&lt;br /&gt;
abline(v=cumsum(sapply(unique(pop[ord,2]),function(x){sum(pop[ord,2]==x)}))/length(pop[ord,2]),col=1,lwd=1.2)&lt;br /&gt;
abline(h=cumsum(sapply(unique(pop[ord,2]),function(x){sum(pop[ord,2]==x)}))/length(pop[ord,2]),col=1,lwd=1.2)&lt;br /&gt;
par(mar=c(5,0.5,4,2))&lt;br /&gt;
plot(c(0,1),c(0,1),type = 'n', axes = F,xlab = '', ylab = '', main = '')&lt;br /&gt;
rasterImage(mylegend, 0, 0.25, 0.4,0.75)&lt;br /&gt;
text(x=0.8, y = c(0.25,0.5, 0.75), labels = c(-0.25, 0, 0.25),cex=0.8)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
=== Low depth sequencing data ===&lt;br /&gt;
Download the input file containing genotype likelihoods in beagle format&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget popgen.dk/software/download/NGSadmix/data/Demo2input.gz&lt;br /&gt;
wget popgen.dk/software/download/NGSadmix/data/Demo2pop.info&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Execute [[NgsAdmix |NGSadmix]] to obtain admixture proportions&lt;br /&gt;
&amp;lt;pre&amp;gt;./NGSadmix -likes Demo2input.gz -K 3 -P 20 -o myoutfiles -minMaf 0.05&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
::Input file = Demo2input.gz&lt;br /&gt;
::Ancestral Populations K=3&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
::Output prefix = myoutfiles (-o myoutfiles) &lt;br /&gt;
::SNPs with MAF &amp;gt; 5%  (-minMaf 0.05)&lt;br /&gt;
&lt;br /&gt;
Run evalAdmix&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix -beagle Demo2input.gz -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 20 &amp;lt;/pre&amp;gt;&lt;br /&gt;
::Input file = input.gz&lt;br /&gt;
::Ancestral Populations frequency file myoutfiles.fopt.gz&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
&lt;br /&gt;
Plot results in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# read population labels and estimated admixture proportions&lt;br /&gt;
pop&amp;lt;-read.table(&amp;quot;Demo2pop.info&amp;quot;,as.is=T)&lt;br /&gt;
q&amp;lt;-read.table(&amp;quot;myoutfiles.qopt&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# order according to population and plot the NGSadmix reults&lt;br /&gt;
ord&amp;lt;-order(pop[,1])&lt;br /&gt;
barplot(t(q)[,ord],col=2:10,space=0,border=NA,xlab=&amp;quot;Individuals&amp;quot;,ylab=&amp;quot;Demo2 Admixture proportions for K=3&amp;quot;)&lt;br /&gt;
text(tapply(1:nrow(pop),pop[ord,1],mean),-0.05,unique(pop[ord,1]),xpd=T)&lt;br /&gt;
abline(v=cumsum(sapply(unique(pop[ord,1]),function(x){sum(pop[ord,1]==x)})),col=1,lwd=1.2)&lt;br /&gt;
&lt;br /&gt;
r&amp;lt;-read.table(&amp;quot;output.corres.txt&amp;quot;)&lt;br /&gt;
image(as.matrix(r))&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Citation==&lt;br /&gt;
&lt;br /&gt;
The program has a pre-print:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{cite bioRxiv |last1=Garcia-Erill|first1=G |last2=Albrechtsen|first2=A |date=July 19, 2019|title=Evaluation of Model Fit of Inferred Admixture Proportions|biorxiv=https://doi.org/10.1101/708883 }}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Genís Garcia-Erill, Anders Albrechtsen; &lt;br /&gt;
Evaluation of Model Fit of Inferred Admixture Proportions,&lt;br /&gt;
bioRxiv, (July 19, 2019), https://doi.org/10.1101/708883&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Genis</name></author>
	</entry>
	<entry>
		<id>https://www.popgen.dk/software/index.php?title=EvalAdmix&amp;diff=1206</id>
		<title>EvalAdmix</title>
		<link rel="alternate" type="text/html" href="https://www.popgen.dk/software/index.php?title=EvalAdmix&amp;diff=1206"/>
		<updated>2019-07-20T16:20:19Z</updated>

		<summary type="html">&lt;p&gt;Genis: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;evalAdmix allows to evaluate the results of an admixture analysis. It takes as input the genotype data (either called genotypes in plink files or genotype likelihoods beagle files) used in the admixture analysis and the frequency&lt;br /&gt;
and admixture propotions (P and Q files) generated.&lt;br /&gt;
&lt;br /&gt;
The output is a pairwise correlation of residuals matrix between individuals The correlation will be 0 in case of a good fit of the data to the admixture model. When something is wrong, individuals from the same population will be positively correlated; and individuals from different populationts but that share one or more ancestral populations as admixture sources will have a negative correlation. Positive correlation between a pair of individuals might also be due to relatedness.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:evalAdmix.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Download and Installation==&lt;br /&gt;
&lt;br /&gt;
evalAdmix can be installed from [https://github.com/GenisGE/evalAdmix github] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
git clone https://github.com/GenisGE/evalAdmix.git&lt;br /&gt;
cd evalAdmix&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Quick start==&lt;br /&gt;
:&amp;lt;code&amp;gt; ./evalAdmix -beagle inputBeagleFile.gz  -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 10  &amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt; ./evalAdmix -plink inputPlinkPrefix  -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 10  &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''-beagle''' beagle file of genotype likelihoods&lt;br /&gt;
* '''-plink''' binary plink file prefix with genotype data&lt;br /&gt;
* '''-fname''' file with ancestral frequencies&lt;br /&gt;
* '''-qname''' file with admixture proportions&lt;br /&gt;
* '''-o''' prefix of output file names&lt;br /&gt;
* '''-P''' Number of threads used&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix  &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Arguments:&lt;br /&gt;
	-plink path to binary plink file (excluding the .bed)&lt;br /&gt;
	-beagle path to beagle file containing genotype likelihoods (alternative to -plink)&lt;br /&gt;
	-fname path to ancestral population frequencies file&lt;br /&gt;
	-qname path to admixture proportions file&lt;br /&gt;
	-o name of the output file&lt;br /&gt;
Setup:&lt;br /&gt;
	-P 1 number of threads&lt;br /&gt;
	-autosomeMax 23	 autosome ends with this chromsome&lt;br /&gt;
	-nIts 5	 number of iterations to do for frequency correction; if set to 0 calculates correlation without correction (fast but biased)&lt;br /&gt;
	-useSites 1.0	 proportion of sites to use to calculate correlation of residuals&lt;br /&gt;
	-misTol 0.05 	 tolerance for considering site as missing when using genotype likelihoods. Use same value as used in NGSadmix to keep compatibility when using genotype likelihoods (-beagle)&lt;br /&gt;
	-minMaf 0.05 	 minimum minor allele frequency to keep site. Use same value as used in NGSadmix to keep compatibility when using genotype likelihoods (-beagle)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Input File==&lt;br /&gt;
&lt;br /&gt;
===Plink===&lt;br /&gt;
Genotype data files in binary PLINK format (.bed .fam .bim).&lt;br /&gt;
===Beagle genotype likelhoods===&lt;br /&gt;
The input file contains genotype likelihoods in a .beagle file format [http://faculty.washington.edu/browning/beagle/beagle.html].&lt;br /&gt;
and can be compressed with gzip.&lt;br /&gt;
==== BAM files  ====&lt;br /&gt;
If you have BAM files you can use [[ANGSD]] to produce genotype likelihoods in .beagle format. Please &lt;br /&gt;
see [http://www.popgen.dk/angsd/index.php/Beagle_input Creation of Beagle files with ANGSD]&lt;br /&gt;
&lt;br /&gt;
==== VCF files ====&lt;br /&gt;
If you already have made a VCF file that contains genotype likehood information then  it should be possible to convert .vcf files with genotype likelihoods to .beagle file via vcftools [https://vcftools.github.io/man_latest.html] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vcftools --vcf input.vcf --out test --BEAGLE-GL --chr 1,2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Chromosome has to be specified.&lt;br /&gt;
&lt;br /&gt;
You can also use bcftools' [https://samtools.github.io/bcftools/bcftools.html] 'query' option for generating a .beagle file from a .vcf file.&lt;br /&gt;
&lt;br /&gt;
==Output Files==&lt;br /&gt;
The analysis performed by evalAdmix produces 1 file, containing a tab delimited N times N symmetric correlation matrix, where column i in line j contains the correlation of residuals between individual i and j, and the diagonal values (self-correlation) are set to NA:&lt;br /&gt;
&lt;br /&gt;
NA      0.008609        -0.006919       0.002731        0.020224&amp;lt;br /&amp;gt;&lt;br /&gt;
0.008609        NA      0.000033        0.004968        -0.008470&amp;lt;br /&amp;gt;&lt;br /&gt;
-0.006919       0.000033        NA      0.006982        0.005664&amp;lt;br /&amp;gt;&lt;br /&gt;
0.002731        0.004968        0.006982        NA      0.000521&amp;lt;br /&amp;gt;&lt;br /&gt;
0.020224        -0.008470       0.005664        0.000521        NA&lt;br /&gt;
&lt;br /&gt;
==Run command example==&lt;br /&gt;
&lt;br /&gt;
=== Genotype data ===&lt;br /&gt;
Download the input file containing genotype in binary plink format&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.bed&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.bim&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.fam&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run ADMIXTURE to obtain admixture proprotions&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;admixture admixTjeck2.bed 3&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run evalAdmix&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix -plink admixTjeck2 -fname admixTjeck2.3.P -qname admixTjeck2.3.Q -P 20 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Plot results in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# read population labels and estimated admixture proportions&lt;br /&gt;
pop&amp;lt;-read.table(&amp;quot;admixTjeck2.fam&amp;quot;)&lt;br /&gt;
q&amp;lt;-read.table(&amp;quot;admixTjeck2.3.Q&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# order according to population and plot the ADMIXTURE reults&lt;br /&gt;
ord&amp;lt;-order(pop[,2])&lt;br /&gt;
barplot(t(q)[,ord],col=2:10,space=0,border=NA,xlab=&amp;quot;Individuals&amp;quot;,ylab=&amp;quot;Demo2 Admixture proportions for K=3&amp;quot;)&lt;br /&gt;
text(tapply(1:nrow(pop),pop[ord,2],mean),-0.05,unique(pop[ord,2]),xpd=T)&lt;br /&gt;
abline(v=cumsum(sapply(unique(pop[ord,2]),function(x){sum(pop[ord,2]==x)})),col=1,lwd=1.2)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
r&amp;lt;-read.table(&amp;quot;output.corres.txt&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Plot correlation of residuals&lt;br /&gt;
mypalette &amp;lt;- colorRampPalette(colors = c(&amp;quot;blue&amp;quot;, &amp;quot;green&amp;quot;, &amp;quot;red&amp;quot;), space=&amp;quot;Lab&amp;quot;)(10)    &lt;br /&gt;
mylegend &amp;lt;- as.raster(mypalette, ncol=1)[10:1,]&lt;br /&gt;
&lt;br /&gt;
layout(matrix(1:2,ncol=2), width = c(4,1),height = c(1,1))&lt;br /&gt;
par(mar=c(5,4,4,0))&lt;br /&gt;
image(as.matrix(r)[ord,ord], col=mypalette, &lt;br /&gt;
      yaxt=&amp;quot;n&amp;quot;,xaxt=&amp;quot;n&amp;quot;, zlim=c(-0.25,0.25),useRaster=T,&lt;br /&gt;
      main=&amp;quot;Correlation of residuals&amp;quot;, &lt;br /&gt;
      oldstyle=T,cex.main=1)&lt;br /&gt;
text(tapply(1:nrow(pop),pop[ord,2],mean)/length(pop[ord,2]),-0.1,unique(pop[ord,2]),xpd=T)&lt;br /&gt;
text(-0.1,tapply(1:nrow(pop),pop[ord,2],mean)/length(pop[ord,2]),unique(pop[ord,2]),xpd=T)&lt;br /&gt;
abline(v=cumsum(sapply(unique(pop[ord,2]),function(x){sum(pop[ord,2]==x)}))/length(pop[ord,2]),col=1,lwd=1.2)&lt;br /&gt;
abline(h=cumsum(sapply(unique(pop[ord,2]),function(x){sum(pop[ord,2]==x)}))/length(pop[ord,2]),col=1,lwd=1.2)&lt;br /&gt;
par(mar=c(5,0.5,4,2))&lt;br /&gt;
plot(c(0,1),c(0,1),type = 'n', axes = F,xlab = '', ylab = '', main = '')&lt;br /&gt;
rasterImage(mylegend, 0, 0.25, 0.4,0.75)&lt;br /&gt;
text(x=0.8, y = c(0.25,0.5, 0.75), labels = c(-0.25, 0, 0.25),cex=0.8)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
=== Low depth sequencing data ===&lt;br /&gt;
Download the input file containing genotype likelihoods in beagle format&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget popgen.dk/software/download/NGSadmix/data/Demo2input.gz&lt;br /&gt;
wget popgen.dk/software/download/NGSadmix/data/Demo2pop.info&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Execute [[NgsAdmix |NGSadmix]] to obtain admixture proportions&lt;br /&gt;
&amp;lt;pre&amp;gt;./NGSadmix -likes Demo2input.gz -K 3 -P 20 -o myoutfiles -minMaf 0.05&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
::Input file = Demo2input.gz&lt;br /&gt;
::Ancestral Populations K=3&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
::Output prefix = myoutfiles (-o myoutfiles) &lt;br /&gt;
::SNPs with MAF &amp;gt; 5%  (-minMaf 0.05)&lt;br /&gt;
&lt;br /&gt;
Run evalAdmix&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix -beagle Demo2input.gz -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 20 &amp;lt;/pre&amp;gt;&lt;br /&gt;
::Input file = input.gz&lt;br /&gt;
::Ancestral Populations frequency file myoutfiles.fopt.gz&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
&lt;br /&gt;
Plot results in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# read population labels and estimated admixture proportions&lt;br /&gt;
pop&amp;lt;-read.table(&amp;quot;Demo2pop.info&amp;quot;,as.is=T)&lt;br /&gt;
q&amp;lt;-read.table(&amp;quot;myoutfiles.qopt&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# order according to population and plot the NGSadmix reults&lt;br /&gt;
ord&amp;lt;-order(pop[,1])&lt;br /&gt;
barplot(t(q)[,ord],col=2:10,space=0,border=NA,xlab=&amp;quot;Individuals&amp;quot;,ylab=&amp;quot;Demo2 Admixture proportions for K=3&amp;quot;)&lt;br /&gt;
text(tapply(1:nrow(pop),pop[ord,1],mean),-0.05,unique(pop[ord,1]),xpd=T)&lt;br /&gt;
abline(v=cumsum(sapply(unique(pop[ord,1]),function(x){sum(pop[ord,1]==x)})),col=1,lwd=1.2)&lt;br /&gt;
&lt;br /&gt;
r&amp;lt;-read.table(&amp;quot;output.corres.txt&amp;quot;)&lt;br /&gt;
image(as.matrix(r))&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Citation==&lt;br /&gt;
&lt;br /&gt;
The program has a pre-print:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{cite bioRxiv |last1=Garcia-Erill|first1=G |last1=Albrechtsen|first1=A |date=July 19, 2019|title=Evaluation of Model Fit of Inferred Admixture Proportions|biorxiv=https://doi.org/10.1101/708883 }}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Genís Garcia-Erill, Anders Albrechtsen; &lt;br /&gt;
Evaluation of Model Fit of Inferred Admixture Proportions,&lt;br /&gt;
bioRxiv, (July 19, 2019), https://doi.org/10.1101/708883&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Genis</name></author>
	</entry>
	<entry>
		<id>https://www.popgen.dk/software/index.php?title=File:EvalAdmix.png&amp;diff=1205</id>
		<title>File:EvalAdmix.png</title>
		<link rel="alternate" type="text/html" href="https://www.popgen.dk/software/index.php?title=File:EvalAdmix.png&amp;diff=1205"/>
		<updated>2019-07-20T16:10:51Z</updated>

		<summary type="html">&lt;p&gt;Genis: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Genis</name></author>
	</entry>
	<entry>
		<id>https://www.popgen.dk/software/index.php?title=EvalAdmix&amp;diff=1204</id>
		<title>EvalAdmix</title>
		<link rel="alternate" type="text/html" href="https://www.popgen.dk/software/index.php?title=EvalAdmix&amp;diff=1204"/>
		<updated>2019-07-20T16:08:30Z</updated>

		<summary type="html">&lt;p&gt;Genis: /* Output Files */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;evalAdmix allows to evaluate the results of an admixture analysis. It takes as input the genotype data (either called genotypes in plink files or genotype likelihoods beagle files) used in the admixture analysis and the frequency&lt;br /&gt;
and admixture propotions (P and Q files) generated.&lt;br /&gt;
&lt;br /&gt;
The output is a pairwise correlation of residuals matrix between individuals The correlation will be 0 in case of a good fit of the data to the admixture model. When something is wrong, individuals from the same population will be positively correlated; and individuals from different populationts but that share one or more ancestral populations as admixture sources will have a negative correlation. Positive correlation between a pair of individuals might also be due to relatedness.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:evalAdmix.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Download and Installation==&lt;br /&gt;
&lt;br /&gt;
evalAdmix can be installed from [https://github.com/GenisGE/evalAdmix github] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
git clone https://github.com/GenisGE/evalAdmix.git&lt;br /&gt;
cd evalAdmix&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Quick start==&lt;br /&gt;
:&amp;lt;code&amp;gt; ./evalAdmix -beagle inputBeagleFile.gz  -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 10  &amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt; ./evalAdmix -plink inputPlinkPrefix  -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 10  &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''-beagle''' beagle file of genotype likelihoods&lt;br /&gt;
* '''-plink''' binary plink file prefix with genotype data&lt;br /&gt;
* '''-fname''' file with ancestral frequencies&lt;br /&gt;
* '''-qname''' file with admixture proportions&lt;br /&gt;
* '''-o''' prefix of output file names&lt;br /&gt;
* '''-P''' Number of threads used&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix  &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Arguments:&lt;br /&gt;
	-plink path to binary plink file (excluding the .bed)&lt;br /&gt;
	-beagle path to beagle file containing genotype likelihoods (alternative to -plink)&lt;br /&gt;
	-fname path to ancestral population frequencies file&lt;br /&gt;
	-qname path to admixture proportions file&lt;br /&gt;
	-o name of the output file&lt;br /&gt;
Setup:&lt;br /&gt;
	-P 1 number of threads&lt;br /&gt;
	-autosomeMax 23	 autosome ends with this chromsome&lt;br /&gt;
	-nIts 5	 number of iterations to do for frequency correction; if set to 0 calculates correlation without correction (fast but biased)&lt;br /&gt;
	-useSites 1.0	 proportion of sites to use to calculate correlation of residuals&lt;br /&gt;
	-misTol 0.05 	 tolerance for considering site as missing when using genotype likelihoods. Use same value as used in NGSadmix to keep compatibility when using genotype likelihoods (-beagle)&lt;br /&gt;
	-minMaf 0.05 	 minimum minor allele frequency to keep site. Use same value as used in NGSadmix to keep compatibility when using genotype likelihoods (-beagle)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Input File==&lt;br /&gt;
&lt;br /&gt;
===Plink===&lt;br /&gt;
Genotype data files in binary PLINK format (.bed .fam .bim).&lt;br /&gt;
===Beagle genotype likelhoods===&lt;br /&gt;
The input file contains genotype likelihoods in a .beagle file format [http://faculty.washington.edu/browning/beagle/beagle.html].&lt;br /&gt;
and can be compressed with gzip.&lt;br /&gt;
==== BAM files  ====&lt;br /&gt;
If you have BAM files you can use [[ANGSD]] to produce genotype likelihoods in .beagle format. Please &lt;br /&gt;
see [http://www.popgen.dk/angsd/index.php/Beagle_input Creation of Beagle files with ANGSD]&lt;br /&gt;
&lt;br /&gt;
==== VCF files ====&lt;br /&gt;
If you already have made a VCF file that contains genotype likehood information then  it should be possible to convert .vcf files with genotype likelihoods to .beagle file via vcftools [https://vcftools.github.io/man_latest.html] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vcftools --vcf input.vcf --out test --BEAGLE-GL --chr 1,2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Chromosome has to be specified.&lt;br /&gt;
&lt;br /&gt;
You can also use bcftools' [https://samtools.github.io/bcftools/bcftools.html] 'query' option for generating a .beagle file from a .vcf file.&lt;br /&gt;
&lt;br /&gt;
==Output Files==&lt;br /&gt;
The analysis performed by evalAdmix produces 1 file, containing a tab delimited N times N symmetric correlation matrix, where column i in line j contains the correlation of residuals between individual i and j, and the diagonal values (self-correlation) are set to NA:&lt;br /&gt;
&lt;br /&gt;
NA      0.008609        -0.006919       0.002731        0.020224&amp;lt;br /&amp;gt;&lt;br /&gt;
0.008609        NA      0.000033        0.004968        -0.008470&amp;lt;br /&amp;gt;&lt;br /&gt;
-0.006919       0.000033        NA      0.006982        0.005664&amp;lt;br /&amp;gt;&lt;br /&gt;
0.002731        0.004968        0.006982        NA      0.000521&amp;lt;br /&amp;gt;&lt;br /&gt;
0.020224        -0.008470       0.005664        0.000521        NA&lt;br /&gt;
&lt;br /&gt;
==Run command example==&lt;br /&gt;
&lt;br /&gt;
=== Genotype data ===&lt;br /&gt;
Download the input file containing genotype in binary plink format&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.bed&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.bim&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.fam&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run ADMIXTURE to obtain admixture proprotions&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;admixture admixTjeck2.bed 3&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run evalAdmix&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix -plink admixTjeck2 -fname admixTjeck2.3.P -qname admixTjeck2.3.Q -P 20 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Plot results in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# read population labels and estimated admixture proportions&lt;br /&gt;
pop&amp;lt;-read.table(&amp;quot;admixTjeck2.fam&amp;quot;)&lt;br /&gt;
q&amp;lt;-read.table(&amp;quot;admixTjeck2.3.Q&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# order according to population and plot the ADMIXTURE reults&lt;br /&gt;
ord&amp;lt;-order(pop[,2])&lt;br /&gt;
barplot(t(q)[,ord],col=2:10,space=0,border=NA,xlab=&amp;quot;Individuals&amp;quot;,ylab=&amp;quot;Demo2 Admixture proportions for K=3&amp;quot;)&lt;br /&gt;
text(tapply(1:nrow(pop),pop[ord,2],mean),-0.05,unique(pop[ord,2]),xpd=T)&lt;br /&gt;
abline(v=cumsum(sapply(unique(pop[ord,2]),function(x){sum(pop[ord,2]==x)})),col=1,lwd=1.2)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
r&amp;lt;-read.table(&amp;quot;output.corres.txt&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Plot correlation of residuals&lt;br /&gt;
mypalette &amp;lt;- colorRampPalette(colors = c(&amp;quot;blue&amp;quot;, &amp;quot;green&amp;quot;, &amp;quot;red&amp;quot;), space=&amp;quot;Lab&amp;quot;)(10)    &lt;br /&gt;
mylegend &amp;lt;- as.raster(mypalette, ncol=1)[10:1,]&lt;br /&gt;
&lt;br /&gt;
layout(matrix(1:2,ncol=2), width = c(4,1),height = c(1,1))&lt;br /&gt;
par(mar=c(5,4,4,0))&lt;br /&gt;
image(as.matrix(r)[ord,ord], col=mypalette, &lt;br /&gt;
      yaxt=&amp;quot;n&amp;quot;,xaxt=&amp;quot;n&amp;quot;, zlim=c(-0.25,0.25),useRaster=T,&lt;br /&gt;
      main=&amp;quot;Correlation of residuals&amp;quot;, &lt;br /&gt;
      oldstyle=T,cex.main=1)&lt;br /&gt;
text(tapply(1:nrow(pop),pop[ord,2],mean)/length(pop[ord,2]),-0.1,unique(pop[ord,2]),xpd=T)&lt;br /&gt;
text(-0.1,tapply(1:nrow(pop),pop[ord,2],mean)/length(pop[ord,2]),unique(pop[ord,2]),xpd=T)&lt;br /&gt;
abline(v=cumsum(sapply(unique(pop[ord,2]),function(x){sum(pop[ord,2]==x)}))/length(pop[ord,2]),col=1,lwd=1.2)&lt;br /&gt;
abline(h=cumsum(sapply(unique(pop[ord,2]),function(x){sum(pop[ord,2]==x)}))/length(pop[ord,2]),col=1,lwd=1.2)&lt;br /&gt;
par(mar=c(5,0.5,4,2))&lt;br /&gt;
plot(c(0,1),c(0,1),type = 'n', axes = F,xlab = '', ylab = '', main = '')&lt;br /&gt;
rasterImage(mylegend, 0, 0.25, 0.4,0.75)&lt;br /&gt;
text(x=0.8, y = c(0.25,0.5, 0.75), labels = c(-0.25, 0, 0.25),cex=0.8)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
=== Low depth sequencing data ===&lt;br /&gt;
Download the input file containing genotype likelihoods in beagle format&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget popgen.dk/software/download/NGSadmix/data/Demo2input.gz&lt;br /&gt;
wget popgen.dk/software/download/NGSadmix/data/Demo2pop.info&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Execute [[NgsAdmix |NGSadmix]] to obtain admixture proportions&lt;br /&gt;
&amp;lt;pre&amp;gt;./NGSadmix -likes Demo2input.gz -K 3 -P 20 -o myoutfiles -minMaf 0.05&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
::Input file = Demo2input.gz&lt;br /&gt;
::Ancestral Populations K=3&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
::Output prefix = myoutfiles (-o myoutfiles) &lt;br /&gt;
::SNPs with MAF &amp;gt; 5%  (-minMaf 0.05)&lt;br /&gt;
&lt;br /&gt;
Run evalAdmix&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix -beagle Demo2input.gz -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 20 &amp;lt;/pre&amp;gt;&lt;br /&gt;
::Input file = input.gz&lt;br /&gt;
::Ancestral Populations frequency file myoutfiles.fopt.gz&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
&lt;br /&gt;
Plot results in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# read population labels and estimated admixture proportions&lt;br /&gt;
pop&amp;lt;-read.table(&amp;quot;Demo2pop.info&amp;quot;,as.is=T)&lt;br /&gt;
q&amp;lt;-read.table(&amp;quot;myoutfiles.qopt&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# order according to population and plot the NGSadmix reults&lt;br /&gt;
ord&amp;lt;-order(pop[,1])&lt;br /&gt;
barplot(t(q)[,ord],col=2:10,space=0,border=NA,xlab=&amp;quot;Individuals&amp;quot;,ylab=&amp;quot;Demo2 Admixture proportions for K=3&amp;quot;)&lt;br /&gt;
text(tapply(1:nrow(pop),pop[ord,1],mean),-0.05,unique(pop[ord,1]),xpd=T)&lt;br /&gt;
abline(v=cumsum(sapply(unique(pop[ord,1]),function(x){sum(pop[ord,1]==x)})),col=1,lwd=1.2)&lt;br /&gt;
&lt;br /&gt;
r&amp;lt;-read.table(&amp;quot;output.corres.txt&amp;quot;)&lt;br /&gt;
image(as.matrix(r))&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Citation==&lt;/div&gt;</summary>
		<author><name>Genis</name></author>
	</entry>
	<entry>
		<id>https://www.popgen.dk/software/index.php?title=EvalAdmix&amp;diff=1203</id>
		<title>EvalAdmix</title>
		<link rel="alternate" type="text/html" href="https://www.popgen.dk/software/index.php?title=EvalAdmix&amp;diff=1203"/>
		<updated>2019-07-19T13:35:04Z</updated>

		<summary type="html">&lt;p&gt;Genis: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;evalAdmix allows to evaluate the results of an admixture analysis. It takes as input the genotype data (either called genotypes in plink files or genotype likelihoods beagle files) used in the admixture analysis and the frequency&lt;br /&gt;
and admixture propotions (P and Q files) generated.&lt;br /&gt;
&lt;br /&gt;
The output is a pairwise correlation of residuals matrix between individuals The correlation will be 0 in case of a good fit of the data to the admixture model. When something is wrong, individuals from the same population will be positively correlated; and individuals from different populationts but that share one or more ancestral populations as admixture sources will have a negative correlation. Positive correlation between a pair of individuals might also be due to relatedness.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:evalAdmix.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Download and Installation==&lt;br /&gt;
&lt;br /&gt;
evalAdmix can be installed from [https://github.com/GenisGE/evalAdmix github] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
git clone https://github.com/GenisGE/evalAdmix.git&lt;br /&gt;
cd evalAdmix&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Quick start==&lt;br /&gt;
:&amp;lt;code&amp;gt; ./evalAdmix -beagle inputBeagleFile.gz  -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 10  &amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt; ./evalAdmix -plink inputPlinkPrefix  -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 10  &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''-beagle''' beagle file of genotype likelihoods&lt;br /&gt;
* '''-plink''' binary plink file prefix with genotype data&lt;br /&gt;
* '''-fname''' file with ancestral frequencies&lt;br /&gt;
* '''-qname''' file with admixture proportions&lt;br /&gt;
* '''-o''' prefix of output file names&lt;br /&gt;
* '''-P''' Number of threads used&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix  &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Arguments:&lt;br /&gt;
	-plink path to binary plink file (excluding the .bed)&lt;br /&gt;
	-beagle path to beagle file containing genotype likelihoods (alternative to -plink)&lt;br /&gt;
	-fname path to ancestral population frequencies file&lt;br /&gt;
	-qname path to admixture proportions file&lt;br /&gt;
	-o name of the output file&lt;br /&gt;
Setup:&lt;br /&gt;
	-P 1 number of threads&lt;br /&gt;
	-autosomeMax 23	 autosome ends with this chromsome&lt;br /&gt;
	-nIts 5	 number of iterations to do for frequency correction; if set to 0 calculates correlation without correction (fast but biased)&lt;br /&gt;
	-useSites 1.0	 proportion of sites to use to calculate correlation of residuals&lt;br /&gt;
	-misTol 0.05 	 tolerance for considering site as missing when using genotype likelihoods. Use same value as used in NGSadmix to keep compatibility when using genotype likelihoods (-beagle)&lt;br /&gt;
	-minMaf 0.05 	 minimum minor allele frequency to keep site. Use same value as used in NGSadmix to keep compatibility when using genotype likelihoods (-beagle)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Input File==&lt;br /&gt;
&lt;br /&gt;
===Plink===&lt;br /&gt;
Genotype data files in binary PLINK format (.bed .fam .bim).&lt;br /&gt;
===Beagle genotype likelhoods===&lt;br /&gt;
The input file contains genotype likelihoods in a .beagle file format [http://faculty.washington.edu/browning/beagle/beagle.html].&lt;br /&gt;
and can be compressed with gzip.&lt;br /&gt;
==== BAM files  ====&lt;br /&gt;
If you have BAM files you can use [[ANGSD]] to produce genotype likelihoods in .beagle format. Please &lt;br /&gt;
see [http://www.popgen.dk/angsd/index.php/Beagle_input Creation of Beagle files with ANGSD]&lt;br /&gt;
&lt;br /&gt;
==== VCF files ====&lt;br /&gt;
If you already have made a VCF file that contains genotype likehood information then  it should be possible to convert .vcf files with genotype likelihoods to .beagle file via vcftools [https://vcftools.github.io/man_latest.html] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vcftools --vcf input.vcf --out test --BEAGLE-GL --chr 1,2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Chromosome has to be specified.&lt;br /&gt;
&lt;br /&gt;
You can also use bcftools' [https://samtools.github.io/bcftools/bcftools.html] 'query' option for generating a .beagle file from a .vcf file.&lt;br /&gt;
&lt;br /&gt;
==Output Files==&lt;br /&gt;
The analysis performed by evalAdmix produces 1 correlation  file:&lt;br /&gt;
&lt;br /&gt;
==Run command example==&lt;br /&gt;
&lt;br /&gt;
=== Genotype data ===&lt;br /&gt;
Download the input file containing genotype in binary plink format&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.bed&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.bim&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.fam&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run ADMIXTURE to obtain admixture proprotions&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;admixture admixTjeck2.bed 3&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run evalAdmix&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix -plink admixTjeck2 -fname admixTjeck2.3.P -qname admixTjeck2.3.Q -P 20 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Plot results in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# read population labels and estimated admixture proportions&lt;br /&gt;
pop&amp;lt;-read.table(&amp;quot;admixTjeck2.fam&amp;quot;)&lt;br /&gt;
q&amp;lt;-read.table(&amp;quot;admixTjeck2.3.Q&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# order according to population and plot the ADMIXTURE reults&lt;br /&gt;
ord&amp;lt;-order(pop[,2])&lt;br /&gt;
barplot(t(q)[,ord],col=2:10,space=0,border=NA,xlab=&amp;quot;Individuals&amp;quot;,ylab=&amp;quot;Demo2 Admixture proportions for K=3&amp;quot;)&lt;br /&gt;
text(tapply(1:nrow(pop),pop[ord,2],mean),-0.05,unique(pop[ord,2]),xpd=T)&lt;br /&gt;
abline(v=cumsum(sapply(unique(pop[ord,2]),function(x){sum(pop[ord,2]==x)})),col=1,lwd=1.2)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
r&amp;lt;-read.table(&amp;quot;output.corres.txt&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Plot correlation of residuals&lt;br /&gt;
mypalette &amp;lt;- colorRampPalette(colors = c(&amp;quot;blue&amp;quot;, &amp;quot;green&amp;quot;, &amp;quot;red&amp;quot;), space=&amp;quot;Lab&amp;quot;)(10)    &lt;br /&gt;
mylegend &amp;lt;- as.raster(mypalette, ncol=1)[10:1,]&lt;br /&gt;
&lt;br /&gt;
layout(matrix(1:2,ncol=2), width = c(4,1),height = c(1,1))&lt;br /&gt;
par(mar=c(5,4,4,0))&lt;br /&gt;
image(as.matrix(r)[ord,ord], col=mypalette, &lt;br /&gt;
      yaxt=&amp;quot;n&amp;quot;,xaxt=&amp;quot;n&amp;quot;, zlim=c(-0.25,0.25),useRaster=T,&lt;br /&gt;
      main=&amp;quot;Correlation of residuals&amp;quot;, &lt;br /&gt;
      oldstyle=T,cex.main=1)&lt;br /&gt;
text(tapply(1:nrow(pop),pop[ord,2],mean)/length(pop[ord,2]),-0.1,unique(pop[ord,2]),xpd=T)&lt;br /&gt;
text(-0.1,tapply(1:nrow(pop),pop[ord,2],mean)/length(pop[ord,2]),unique(pop[ord,2]),xpd=T)&lt;br /&gt;
abline(v=cumsum(sapply(unique(pop[ord,2]),function(x){sum(pop[ord,2]==x)}))/length(pop[ord,2]),col=1,lwd=1.2)&lt;br /&gt;
abline(h=cumsum(sapply(unique(pop[ord,2]),function(x){sum(pop[ord,2]==x)}))/length(pop[ord,2]),col=1,lwd=1.2)&lt;br /&gt;
par(mar=c(5,0.5,4,2))&lt;br /&gt;
plot(c(0,1),c(0,1),type = 'n', axes = F,xlab = '', ylab = '', main = '')&lt;br /&gt;
rasterImage(mylegend, 0, 0.25, 0.4,0.75)&lt;br /&gt;
text(x=0.8, y = c(0.25,0.5, 0.75), labels = c(-0.25, 0, 0.25),cex=0.8)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
=== Low depth sequencing data ===&lt;br /&gt;
Download the input file containing genotype likelihoods in beagle format&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget popgen.dk/software/download/NGSadmix/data/Demo2input.gz&lt;br /&gt;
wget popgen.dk/software/download/NGSadmix/data/Demo2pop.info&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Execute [[NgsAdmix |NGSadmix]] to obtain admixture proportions&lt;br /&gt;
&amp;lt;pre&amp;gt;./NGSadmix -likes Demo2input.gz -K 3 -P 20 -o myoutfiles -minMaf 0.05&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
::Input file = Demo2input.gz&lt;br /&gt;
::Ancestral Populations K=3&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
::Output prefix = myoutfiles (-o myoutfiles) &lt;br /&gt;
::SNPs with MAF &amp;gt; 5%  (-minMaf 0.05)&lt;br /&gt;
&lt;br /&gt;
Run evalAdmix&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix -beagle Demo2input.gz -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 20 &amp;lt;/pre&amp;gt;&lt;br /&gt;
::Input file = input.gz&lt;br /&gt;
::Ancestral Populations frequency file myoutfiles.fopt.gz&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
&lt;br /&gt;
Plot results in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# read population labels and estimated admixture proportions&lt;br /&gt;
pop&amp;lt;-read.table(&amp;quot;Demo2pop.info&amp;quot;,as.is=T)&lt;br /&gt;
q&amp;lt;-read.table(&amp;quot;myoutfiles.qopt&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# order according to population and plot the NGSadmix reults&lt;br /&gt;
ord&amp;lt;-order(pop[,1])&lt;br /&gt;
barplot(t(q)[,ord],col=2:10,space=0,border=NA,xlab=&amp;quot;Individuals&amp;quot;,ylab=&amp;quot;Demo2 Admixture proportions for K=3&amp;quot;)&lt;br /&gt;
text(tapply(1:nrow(pop),pop[ord,1],mean),-0.05,unique(pop[ord,1]),xpd=T)&lt;br /&gt;
abline(v=cumsum(sapply(unique(pop[ord,1]),function(x){sum(pop[ord,1]==x)})),col=1,lwd=1.2)&lt;br /&gt;
&lt;br /&gt;
r&amp;lt;-read.table(&amp;quot;output.corres.txt&amp;quot;)&lt;br /&gt;
image(as.matrix(r))&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Citation==&lt;/div&gt;</summary>
		<author><name>Genis</name></author>
	</entry>
	<entry>
		<id>https://www.popgen.dk/software/index.php?title=EvalAdmix&amp;diff=1202</id>
		<title>EvalAdmix</title>
		<link rel="alternate" type="text/html" href="https://www.popgen.dk/software/index.php?title=EvalAdmix&amp;diff=1202"/>
		<updated>2019-07-19T13:08:04Z</updated>

		<summary type="html">&lt;p&gt;Genis: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;evalAdmix allows to evaluate the results of an admixture analysis. It takes as input the genotype data (either called genotypes in plink files or genotype likelihoods beagle files) used in the admixture analysis and the frequency&lt;br /&gt;
and admixture propotions (P and Q files) generated.&lt;br /&gt;
&lt;br /&gt;
The output is a pairwise correlation of residuals matrix between individuals The correlation will be 0 in case of a good fit of the data to the admixture model. When something is wrong, individuals from the same population will be positively correlated; and individuals from different populationts but that share one or more ancestral populations as admixture sources will have a negative correlation. Positive correlation between a pair of individuals might also be due to relatedness.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:evalAdmix.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Download and Installation==&lt;br /&gt;
&lt;br /&gt;
evalAdmix can be installed from [https://github.com/GenisGE/evalAdmix github] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
git clone https://github.com/GenisGE/evalAdmix.git&lt;br /&gt;
cd evalAdmix&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Quick start==&lt;br /&gt;
:&amp;lt;code&amp;gt; ./evalAdmix -beagle inputBeagleFile.gz  -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 10  &amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt; ./evalAdmix -plink inputPlinkPrefix  -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 10  &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''-beagle''' beagle file of genotype likelihoods&lt;br /&gt;
* '''-plink''' binary plink file prefix with genotype data&lt;br /&gt;
* '''-fname''' file with ancestral frequencies&lt;br /&gt;
* '''-qname''' file with admixture proportions&lt;br /&gt;
* '''-o''' prefix of output file names&lt;br /&gt;
* '''-P''' Number of threads used&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix  &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Arguments:&lt;br /&gt;
	-plink path to binary plink file (excluding the .bed)&lt;br /&gt;
	-beagle path to beagle file containing genotype likelihoods (alternative to -plink)&lt;br /&gt;
	-fname path to ancestral population frequencies file&lt;br /&gt;
	-qname path to admixture proportions file&lt;br /&gt;
	-o name of the output file&lt;br /&gt;
Setup:&lt;br /&gt;
	-P 1 number of threads&lt;br /&gt;
	-autosomeMax 23	 autosome ends with this chromsome&lt;br /&gt;
	-nIts 5	 number of iterations to do for frequency correction; if set to 0 calculates correlation without correction (fast but biased)&lt;br /&gt;
	-useSites 1.0	 proportion of sites to use to calculate correlation of residuals&lt;br /&gt;
	-misTol 0.05 	 tolerance for considering site as missing when using genotype likelihoods. Use same value as used in NGSadmix to keep compatibility when using genotype likelihoods (-beagle)&lt;br /&gt;
	-minMaf 0.05 	 minimum minor allele frequency to keep site. Use same value as used in NGSadmix to keep compatibility when using genotype likelihoods (-beagle)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Input File==&lt;br /&gt;
&lt;br /&gt;
===Plink===&lt;br /&gt;
Genotype data files in binary PLINK format (.bed .fam .bim).&lt;br /&gt;
===Beagle genotype likelhoods===&lt;br /&gt;
The input file contains genotype likelihoods in a .beagle file format [http://faculty.washington.edu/browning/beagle/beagle.html].&lt;br /&gt;
and can be compressed with gzip.&lt;br /&gt;
==== BAM files  ====&lt;br /&gt;
If you have BAM files you can use [[ANGSD]] to produce genotype likelihoods in .beagle format. Please &lt;br /&gt;
see [http://www.popgen.dk/angsd/index.php/Beagle_input Creation of Beagle files with ANGSD]&lt;br /&gt;
&lt;br /&gt;
==== VCF files ====&lt;br /&gt;
If you already have made a VCF file that contains genotype likehood information then  it should be possible to convert .vcf files with genotype likelihoods to .beagle file via vcftools [https://vcftools.github.io/man_latest.html] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vcftools --vcf input.vcf --out test --BEAGLE-GL --chr 1,2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Chromosome has to be specified.&lt;br /&gt;
&lt;br /&gt;
You can also use bcftools' [https://samtools.github.io/bcftools/bcftools.html] 'query' option for generating a .beagle file from a .vcf file.&lt;br /&gt;
&lt;br /&gt;
==Output Files==&lt;br /&gt;
The analysis performed by evalAdmix produces 1 correlation  file:&lt;br /&gt;
&lt;br /&gt;
==Run command example==&lt;br /&gt;
&lt;br /&gt;
=== Genotype data ===&lt;br /&gt;
Download the input file containing genotype in binary plink format&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.bed&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.bim&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.fam&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run ADMIXTURE to obtain admixture proprotions&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;admixture admixTjeck2.bed 3&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run evalAdmix&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix -plink admixTjeck2 -fname admixTjeck2.3.P -qname admixTjeck2.3.Q -P 20 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Low depth sequencing data ===&lt;br /&gt;
Download the input file containing genotype likelihoods in beagle format&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget popgen.dk/software/download/NGSadmix/data/Demo2input.gz&lt;br /&gt;
wget popgen.dk/software/download/NGSadmix/data/Demo2pop.info&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Execute [[NgsAdmix |NGSadmix]] to obtain admixture proportions&lt;br /&gt;
&amp;lt;pre&amp;gt;./NGSadmix -likes Demo2input.gz -K 3 -P 20 -o myoutfiles -minMaf 0.05&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
::Input file = Demo2input.gz&lt;br /&gt;
::Ancestral Populations K=3&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
::Output prefix = myoutfiles (-o myoutfiles) &lt;br /&gt;
::SNPs with MAF &amp;gt; 5%  (-minMaf 0.05)&lt;br /&gt;
&lt;br /&gt;
Run evalAdmix&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix -beagle Demo2input.gz -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 20 &amp;lt;/pre&amp;gt;&lt;br /&gt;
::Input file = input.gz&lt;br /&gt;
::Ancestral Populations frequency file myoutfiles.fopt.gz&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
&lt;br /&gt;
Plot results in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# read population labels and estimated admixture proportions&lt;br /&gt;
pop&amp;lt;-read.table(&amp;quot;Demo2pop.info&amp;quot;,as.is=T)&lt;br /&gt;
q&amp;lt;-read.table(&amp;quot;myoutfiles.qopt&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# order according to population and plot the NGSadmix reults&lt;br /&gt;
ord&amp;lt;-order(pop[,1])&lt;br /&gt;
barplot(t(q)[,ord],col=2:10,space=0,border=NA,xlab=&amp;quot;Individuals&amp;quot;,ylab=&amp;quot;Demo2 Admixture proportions for K=3&amp;quot;)&lt;br /&gt;
text(tapply(1:nrow(pop),pop[ord,1],mean),-0.05,unique(pop[ord,1]),xpd=T)&lt;br /&gt;
abline(v=cumsum(sapply(unique(pop[ord,1]),function(x){sum(pop[ord,1]==x)})),col=1,lwd=1.2)&lt;br /&gt;
&lt;br /&gt;
r&amp;lt;-read.table(&amp;quot;output.corres.txt&amp;quot;)&lt;br /&gt;
image(as.matrix(r))&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Citation==&lt;/div&gt;</summary>
		<author><name>Genis</name></author>
	</entry>
	<entry>
		<id>https://www.popgen.dk/software/index.php?title=EvalAdmix&amp;diff=1201</id>
		<title>EvalAdmix</title>
		<link rel="alternate" type="text/html" href="https://www.popgen.dk/software/index.php?title=EvalAdmix&amp;diff=1201"/>
		<updated>2019-07-19T13:06:45Z</updated>

		<summary type="html">&lt;p&gt;Genis: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;evalAdmix allows to evaluate the results of an admixture analysis. It takes as input the genotype data (either called genotypes in plink files or genotype likelihoods beagle files) used in the admixture analysis and the frequency&lt;br /&gt;
and admixture propotions (P and Q files) generated.&lt;br /&gt;
&lt;br /&gt;
The output is a pairwise correlation of residuals matrix between individuals The correlation will be 0 in case of a good fit of the data to the admixture model. When something is wrong, individuals from the same population will be positively correlated; and individuals from different populationts but that share one or more ancestral populations as admixture sources will have a negative correlation. Positive correlation between a pair of individuals might also be due to relatedness.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:evalAdmix.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Download and Installation==&lt;br /&gt;
&lt;br /&gt;
evalAdmix can be installed from [https://github.com/GenisGE/evalAdmix github] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
git clone https://github.com/GenisGE/evalAdmix.git&lt;br /&gt;
cd evalAdmix&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Quick start==&lt;br /&gt;
:&amp;lt;code&amp;gt; ./evalAdmix -beagle inputBeagleFile.gz  -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 10  &amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt; ./evalAdmix -plink inputPlinkPrefix  -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 10  &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''-beagle''' beagle file of genotype likelihoods&lt;br /&gt;
* '''-plink''' binary plink file prefix with genotype data&lt;br /&gt;
* '''-fname''' file with ancestral frequencies&lt;br /&gt;
* '''-qname''' file with admixture proportions&lt;br /&gt;
* '''-o''' prefix of output file names&lt;br /&gt;
* '''-P''' Number of threads used&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix  &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Arguments:&lt;br /&gt;
	-plink path to binary plink file (excluding the .bed)&lt;br /&gt;
	-beagle path to beagle file containing genotype likelihoods (alternative to -plink)&lt;br /&gt;
	-fname path to ancestral population frequencies file&lt;br /&gt;
	-qname path to admixture proportions file&lt;br /&gt;
	-o name of the output file&lt;br /&gt;
Setup:&lt;br /&gt;
	-P 1 number of threads&lt;br /&gt;
	-autosomeMax 23	 autosome ends with this chromsome&lt;br /&gt;
	-nIts 5	 number of iterations to do for frequency correction; if set to 0 calculates correlation without correction (fast but biased)&lt;br /&gt;
	-useSites 1.0	 proportion of sites to use to calculate correlation of residuals&lt;br /&gt;
	-misTol 0.05 	 tolerance for considering site as missing when using genotype likelihoods. Use same value as used in NGSadmix to keep compatibility when using genotype likelihoods (-beagle)&lt;br /&gt;
	-minMaf 0.05 	 minimum minor allele frequency to keep site. Use same value as used in NGSadmix to keep compatibility when using genotype likelihoods (-beagle)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Input File==&lt;br /&gt;
&lt;br /&gt;
===Plink===&lt;br /&gt;
Genotype data files in binary PLINK format (.bed .fam .bim).&lt;br /&gt;
===Beagle genotype likelhoods===&lt;br /&gt;
The input file contains genotype likelihoods in a .beagle file format [http://faculty.washington.edu/browning/beagle/beagle.html].&lt;br /&gt;
and can be compressed with gzip.&lt;br /&gt;
==== BAM files  ====&lt;br /&gt;
If you have BAM files you can use [[ANGSD]] to produce genotype likelihoods in .beagle format. Please &lt;br /&gt;
see [http://www.popgen.dk/angsd/index.php/Beagle_input Creation of Beagle files with ANGSD]&lt;br /&gt;
&lt;br /&gt;
==== VCF files ====&lt;br /&gt;
If you already have made a VCF file that contains genotype likehood information then  it should be possible to convert .vcf files with genotype likelihoods to .beagle file via vcftools [https://vcftools.github.io/man_latest.html] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vcftools --vcf input.vcf --out test --BEAGLE-GL --chr 1,2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Chromosome has to be specified.&lt;br /&gt;
&lt;br /&gt;
You can also use bcftools' [https://samtools.github.io/bcftools/bcftools.html] 'query' option for generating a .beagle file from a .vcf file.&lt;br /&gt;
&lt;br /&gt;
==Output Files==&lt;br /&gt;
The analysis performed by evalAdmix produces 1 correlation  file:&lt;br /&gt;
&lt;br /&gt;
==Run command example==&lt;br /&gt;
&lt;br /&gt;
=== low depth sequencing data ===&lt;br /&gt;
Download the input file containing genotype in binary plink format&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.bed&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.bim&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.fam&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run ADMIXTURE to obtain admixture proprotions&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;admixture admixTjeck2.bed 3&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run evalAdmix&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix -plink admixTjeck2 -fname admixTjeck2.3.P -qname admixTjeck2.3.Q -P 20 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== low depth sequencing data ===&lt;br /&gt;
Download the input file containing genotype likelihoods in beagle format&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget popgen.dk/software/download/NGSadmix/data/Demo2input.gz&lt;br /&gt;
wget popgen.dk/software/download/NGSadmix/data/Demo2pop.info&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Execute [[NgsAdmix |NGSadmix]] to obtain admixture proportions&lt;br /&gt;
&amp;lt;pre&amp;gt;./NGSadmix -likes Demo2input.gz -K 3 -P 20 -o myoutfiles -minMaf 0.05&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
::Input file = Demo2input.gz&lt;br /&gt;
::Ancestral Populations K=3&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
::Output prefix = myoutfiles (-o myoutfiles) &lt;br /&gt;
::SNPs with MAF &amp;gt; 5%  (-minMaf 0.05)&lt;br /&gt;
&lt;br /&gt;
Run evalAdmix&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix -beagle Demo2input.gz -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 20 &amp;lt;/pre&amp;gt;&lt;br /&gt;
::Input file = input.gz&lt;br /&gt;
::Ancestral Populations frequency file myoutfiles.fopt.gz&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
&lt;br /&gt;
Plot results in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# read population labels and estimated admixture proportions&lt;br /&gt;
pop&amp;lt;-read.table(&amp;quot;Demo2pop.info&amp;quot;,as.is=T)&lt;br /&gt;
q&amp;lt;-read.table(&amp;quot;myoutfiles.qopt&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# order according to population and plot the NGSadmix reults&lt;br /&gt;
ord&amp;lt;-order(pop[,1])&lt;br /&gt;
barplot(t(q)[,ord],col=2:10,space=0,border=NA,xlab=&amp;quot;Individuals&amp;quot;,ylab=&amp;quot;Demo2 Admixture proportions for K=3&amp;quot;)&lt;br /&gt;
text(tapply(1:nrow(pop),pop[ord,1],mean),-0.05,unique(pop[ord,1]),xpd=T)&lt;br /&gt;
abline(v=cumsum(sapply(unique(pop[ord,1]),function(x){sum(pop[ord,1]==x)})),col=1,lwd=1.2)&lt;br /&gt;
&lt;br /&gt;
r&amp;lt;-read.table(&amp;quot;output.corres.txt&amp;quot;)&lt;br /&gt;
image(as.matrix(r))&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Citation==&lt;/div&gt;</summary>
		<author><name>Genis</name></author>
	</entry>
	<entry>
		<id>https://www.popgen.dk/software/index.php?title=EvalAdmix&amp;diff=1200</id>
		<title>EvalAdmix</title>
		<link rel="alternate" type="text/html" href="https://www.popgen.dk/software/index.php?title=EvalAdmix&amp;diff=1200"/>
		<updated>2019-07-19T13:04:58Z</updated>

		<summary type="html">&lt;p&gt;Genis: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;evalAdmix allows to evaluate the results of an admixture analysis. It takes as input the genotype data (either called genotypes in plink files or genotype likelihoods beagle files) used in the admixture analysis and the frequency&lt;br /&gt;
and admixture propotions (P and Q files) generated.&lt;br /&gt;
&lt;br /&gt;
The output is a pairwise correlation of residuals matrix between individuals The correlation will be 0 in case of a good fit of the data to the admixture model. When something is wrong, individuals from the same population will be positively correlated; and individuals from different populationts but that share one or more ancestral populations as admixture sources will have a negative correlation. Positive correlation between a pair of individuals might also be due to relatedness.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:evalAdmix.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Download and Installation==&lt;br /&gt;
&lt;br /&gt;
evalAdmix can be installed from [https://github.com/GenisGE/evalAdmix github] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
git clone https://github.com/GenisGE/evalAdmix.git&lt;br /&gt;
cd evalAdmix&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Quick start==&lt;br /&gt;
:&amp;lt;code&amp;gt; ./evalAdmix -beagle inputBeagleFile.gz  -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 10  &amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt; ./evalAdmix -plink inputPlinkPrefix  -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 10  &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''-bealge''' beagle file of genotype likelihoods&lt;br /&gt;
* '''-fname''' number of clusters&lt;br /&gt;
* '''-o''' prefix of output file names&lt;br /&gt;
* '''-P''' Number of threads used&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix  &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Arguments:&lt;br /&gt;
	-plink path to binary plink file (excluding the .bed)&lt;br /&gt;
	-beagle path to beagle file containing genotype likelihoods (alternative to -plink)&lt;br /&gt;
	-fname path to ancestral population frequencies file&lt;br /&gt;
	-qname path to admixture proportions file&lt;br /&gt;
	-o name of the output file&lt;br /&gt;
Setup:&lt;br /&gt;
	-P 1 number of threads&lt;br /&gt;
	-autosomeMax 23	 autosome ends with this chromsome&lt;br /&gt;
	-nIts 5	 number of iterations to do for frequency correction; if set to 0 calculates correlation without correction (fast but biased)&lt;br /&gt;
	-useSites 1.0	 proportion of sites to use to calculate correlation of residuals&lt;br /&gt;
	-misTol 0.05 	 tolerance for considering site as missing when using genotype likelihoods. Use same value as used in NGSadmix to keep compatibility when using genotype likelihoods (-beagle)&lt;br /&gt;
	-minMaf 0.05 	 minimum minor allele frequency to keep site. Use same value as used in NGSadmix to keep compatibility when using genotype likelihoods (-beagle)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Input File==&lt;br /&gt;
&lt;br /&gt;
===Plink===&lt;br /&gt;
Genotype data files in binary PLINK format (.bed .fam .bim).&lt;br /&gt;
===Beagle genotype likelhoods===&lt;br /&gt;
The input file contains genotype likelihoods in a .beagle file format [http://faculty.washington.edu/browning/beagle/beagle.html].&lt;br /&gt;
and can be compressed with gzip.&lt;br /&gt;
==== BAM files  ====&lt;br /&gt;
If you have BAM files you can use [[ANGSD]] to produce genotype likelihoods in .beagle format. Please &lt;br /&gt;
see [http://www.popgen.dk/angsd/index.php/Beagle_input Creation of Beagle files with ANGSD]&lt;br /&gt;
&lt;br /&gt;
==== VCF files ====&lt;br /&gt;
If you already have made a VCF file that contains genotype likehood information then  it should be possible to convert .vcf files with genotype likelihoods to .beagle file via vcftools [https://vcftools.github.io/man_latest.html] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vcftools --vcf input.vcf --out test --BEAGLE-GL --chr 1,2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Chromosome has to be specified.&lt;br /&gt;
&lt;br /&gt;
You can also use bcftools' [https://samtools.github.io/bcftools/bcftools.html] 'query' option for generating a .beagle file from a .vcf file.&lt;br /&gt;
&lt;br /&gt;
==Output Files==&lt;br /&gt;
The analysis performed by evalAdmix produces 1 correlation  file:&lt;br /&gt;
&lt;br /&gt;
==Run command example==&lt;br /&gt;
&lt;br /&gt;
=== low depth sequencing data ===&lt;br /&gt;
Download the input file containing genotype in binary plink format&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.bed&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.bim&lt;br /&gt;
wget http://pontus.popgen.dk/albrecht/open/admixTjeck/plink/admixTjeck2.fam&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run ADMIXTURE to obtain admixture proprotions&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;admixture admixTjeck2.bed 3&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run evalAdmix&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix -plink admixTjeck2 -fname admixTjeck2.3.P -qname admixTjeck2.3.Q -P 20 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== low depth sequencing data ===&lt;br /&gt;
Download the input file containing genotype likelihoods in beagle format&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget popgen.dk/software/download/NGSadmix/data/Demo2input.gz&lt;br /&gt;
wget popgen.dk/software/download/NGSadmix/data/Demo2pop.info&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Execute [[NgsAdmix |NGSadmix]] to obtain admixture proportions&lt;br /&gt;
&amp;lt;pre&amp;gt;./NGSadmix -likes Demo2input.gz -K 3 -P 20 -o myoutfiles -minMaf 0.05&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
::Input file = Demo2input.gz&lt;br /&gt;
::Ancestral Populations K=3&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
::Output prefix = myoutfiles (-o myoutfiles) &lt;br /&gt;
::SNPs with MAF &amp;gt; 5%  (-minMaf 0.05)&lt;br /&gt;
&lt;br /&gt;
Run evalAdmix&lt;br /&gt;
&amp;lt;pre&amp;gt;./evalAdmix -beagle Demo2input.gz -fname myoutfiles.fopt.gz -qname myoutfiles.qopt -P 20 &amp;lt;/pre&amp;gt;&lt;br /&gt;
::Input file = input.gz&lt;br /&gt;
::Ancestral Populations frequency file myoutfiles.fopt.gz&lt;br /&gt;
::Computer cores = 20 (-P 20). &lt;br /&gt;
&lt;br /&gt;
Plot results in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# read population labels and estimated admixture proportions&lt;br /&gt;
pop&amp;lt;-read.table(&amp;quot;Demo2pop.info&amp;quot;,as.is=T)&lt;br /&gt;
q&amp;lt;-read.table(&amp;quot;myoutfiles.qopt&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# order according to population and plot the NGSadmix reults&lt;br /&gt;
ord&amp;lt;-order(pop[,1])&lt;br /&gt;
barplot(t(q)[,ord],col=2:10,space=0,border=NA,xlab=&amp;quot;Individuals&amp;quot;,ylab=&amp;quot;Demo2 Admixture proportions for K=3&amp;quot;)&lt;br /&gt;
text(tapply(1:nrow(pop),pop[ord,1],mean),-0.05,unique(pop[ord,1]),xpd=T)&lt;br /&gt;
abline(v=cumsum(sapply(unique(pop[ord,1]),function(x){sum(pop[ord,1]==x)})),col=1,lwd=1.2)&lt;br /&gt;
&lt;br /&gt;
r&amp;lt;-read.table(&amp;quot;output.corres.txt&amp;quot;)&lt;br /&gt;
image(as.matrix(r))&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Citation==&lt;/div&gt;</summary>
		<author><name>Genis</name></author>
	</entry>
</feed>