text: user73: This is a question from /u/beneficii9 on reddit. The original post can be found here.
  
  Through the Personal Genome Project, I have had my whole genome sequenced by Veritas, and have it in the form of a single VCF file for the whole genome and one BAS file for each chromosome. The reference genome associated with the VCF file is hg19. It has been helpful in health data; for example, I discovered I'm homozygous for the non-functional variant CYP-2D6 gene (rs3892097), which can render several common medications useless, and helps explain why some medicines didn't really work for me. My doctor has found this information very helpful.
  Unfortunately, I can't find any way of looking at admixture or ancestry. I've tried setting everything up using a combination of VCFTools, Plink1.9, and ADMIXTURE, but I can't get it to work. I think for ADMIXTURE you have to have a bunch of genomes sorted by geographical origin to compare your genome against, but I'm not sure how to do that, and what's online isn't very clear to me. So scratch that one off.
  I've tried converting the file to 23andme format (and at this /u/psychosomaticism has been very helpful). I did that (though it seems there were problems because of the way the VCF file was set up). But the websites that take the data want you to point them to your 23andme account, and that doesn't really work if you only have the file. 23andme doesn't provide for people who had their whole genomes sequenced. They want you to give them a saliva sample like everyone else.
  So, what can I do?
  
  
  user472: Related: ethnicity check either from bam or vcf files
  The missing piece of your puzzle is an ancestry-labeled reference dataset.  1000 Genomes phase 3 usually works well enough here, and it now has variant callsets for both GRCh37 and GRCh38.
  
  user84: Adding another answer that, while much more involved, offers flexibility, walks through minimal steps, and provides visualizations.
  I created a Dash app and repository that explores this type of analysis using published ancestry informative SNPs and 1000 Genomes Project Data. 
  
  Identify published ancestry informative SNPs (AISNPs).
  
  
  Kidd et al.
  Kosoy et al.
  
  Download 1000 Genomes Project genotype bcf data.
  Limit genotype data from (2) to AISNPs loci from (1).
  One-hot encode the genotypes.
  Perform dimensionality reduction (PCA, t-SNE, or UMAP)
  Plot components. 
  
  The original post seemed to want to project their genome against a reference sample. The plot_walkthrough.ipynb in the tgviz repo shows how this can be achieved.
  Output from the notebook on my own data:
  
  
  user73: Ancestry testing is a tricky subject. I spent a good chunk of my PhD project on questions similar to this, and haven't really found a good answer for how to detect unmodelled ancestry.
  The general idea of how I tried to approach ancestry determination was to create a model set containing well-defined groups of individuals with a known, specific ancestral background. A query individual (or individuals) were then added to this group, and an ancestry-estimating program was run (specifically Structure) to work out what proportion of the unknown individual was attributable to each of the known groups. I would expect that most genetic ancestry tests follow a similar approach to this, although perhaps with a little bit less care about the definition of the model population groups.
  Problems arise when individuals are incorrectly assigned to a particular group, when groups are present in the model set that represent a larger proportion of individuals than most other groups, when groups are closely-related to other groups, and when an ancestral history is present in a test individual that doesn't match any of the model groups. And all that assumes that the marker set used for ancestry determination is perfect: no bias towards any particular group, and no systematic genotyping error.
  This doesn't mean that ancestry testing won't work, but it's a good idea to take the results with a large grain of salt. There's a good example of a media personality in New Zealand who was told that she had a very high probability of being 100% Māori, despite having a good knowledge of her own family history that indicated one European ancestor a few generations back on both sides of her family.
  
  user601: A suggestion from the UK Biobank QC methods white paper:
  
  Create a set of SNPs common to your VCF and the 1000 genomes phase 3 call set.
  Perform PCA of the 1000 genomes samples using eigenstrat smartpca. You might have to convert to binary plink format.
  Project your genotypes onto this pre-computed PCA space and visualize using ggplot to see which cluster you fall in.
  
  
  user84: A modified implementation of Vivek's answer.
  peddy is a Python package that samples an input .vcf at ~25000 sites and projects onto a principal component space built on 2504 thousand genome samples. The author has extensive documentation of the tool's features and a link to the preprint. 
  I downloaded the .vcf and .vcf.tbi for the NA12878 sample from Genome in a Bottle's ftp here. Then, created a custom .ped file, NA12878.ped, with the contents:
  NA12878 HG001   0       0       2       0
  At the command line:
  $ peddy --plot --prefix myvcf HG001_GRCh37_GIAB_highconf_CG-IllFB-IllGATKHC-Ion-10X-SOLID_CHROM1-X_v.3.3.2_highconf_PGandRTGphasetransfer.vcf.gz NA12878.ped
  
  The output files all have the prefix myvcf., here's myvcf.pca_check.png
  
  
original_text: 73: <p><em>This is a question from <a href="https://www.reddit.com/user/beneficii9" rel="noreferrer">/u/beneficii9</a> on reddit. The original post can be found <a href="https://www.reddit.com/r/bioinformatics/comments/6f040g/how_do_you_do_admixture_testing_with_a_whole/" rel="noreferrer">here</a>.</em></p>
  <blockquote>
  <p>Through the Personal Genome Project, I have had my whole genome sequenced by Veritas, and have it in the form of a single VCF file for the whole genome and one BAS file for each chromosome. The reference genome associated with the VCF file is hg19. It has been helpful in health data; for example, I discovered I'm homozygous for the non-functional variant CYP-2D6 gene (<a href="https://www.ncbi.nlm.nih.gov/projects/SNP/snp_ref.cgi?rs=3892097" rel="noreferrer">rs3892097</a>), which can render several common medications useless, and helps explain why some medicines didn't really work for me. My doctor has found this information very helpful.</p>
  <p>Unfortunately, I can't find any way of looking at admixture or ancestry. I've tried setting everything up using a combination of VCFTools, Plink1.9, and ADMIXTURE, but I can't get it to work. I think for ADMIXTURE you have to have a bunch of genomes sorted by geographical origin to compare your genome against, but I'm not sure how to do that, and what's online isn't very clear to me. So scratch that one off.</p>
  <p>I've tried converting the file to 23andme format (and at this <a href="https://www.reddit.com/u/psychosomaticism" rel="noreferrer">/u/psychosomaticism</a> has been very helpful). I did that (though it seems there were problems because of the way the VCF file was set up). But the websites that take the data want you to point them to your 23andme account, and that doesn't really work if you only have the file. 23andme doesn't provide for people who had their whole genomes sequenced. They want you to give them a saliva sample like everyone else.</p>
  <p>So, what can I do?</p>
  </blockquote>
   472: <p>Related: <a href="https://bioinformatics.stackexchange.com/questions/3259/ethnicity-check-either-from-bam-or-vcf-files/3300#3300">ethnicity check either from bam or vcf files</a></p>
  
  <p>The missing piece of your puzzle is an ancestry-labeled reference dataset.  1000 Genomes phase 3 usually works well enough here, and it now has variant callsets for both GRCh37 and GRCh38.</p>
   84: <p>Adding another answer that, while much more involved, offers flexibility, walks through minimal steps, and provides visualizations.<br>
  I created a <a href="http://tgviz.herokuapp.com/" rel="nofollow noreferrer">Dash app</a> and <a href="https://github.com/arvkevi/tgviz" rel="nofollow noreferrer">repository</a> that explores this type of analysis using published ancestry informative SNPs and 1000 Genomes Project Data. </p>
  
  <ol>
  <li>Identify published ancestry informative SNPs (AISNPs).
  
  <ul>
  <li><a href="https://www.ncbi.nlm.nih.gov/pubmed?db=pubmed&amp;cmd=Retrieve&amp;dopt=citation&amp;list_uids=24508742" rel="nofollow noreferrer">Kidd et al.</a></li>
  <li><a href="https://www.ncbi.nlm.nih.gov/pubmed?cmd=Retrieve&amp;dopt=citation&amp;list_uids=18683858" rel="nofollow noreferrer">Kosoy et al.</a></li>
  </ul></li>
  <li>Download 1000 Genomes Project genotype <a href="http://tgviz.herokuapp.com/ftp.1000genomes.ebi.ac.uk/vol1/ftp/release/20130502/supporting/bcf_files/" rel="nofollow noreferrer">bcf data</a>.</li>
  <li>Limit genotype data from (2) to AISNPs loci from (1).</li>
  <li>One-hot encode the genotypes.</li>
  <li>Perform dimensionality reduction (PCA, t-SNE, or UMAP)</li>
  <li>Plot components. </li>
  </ol>
  
  <p>The original post seemed to want to project their genome against a reference sample. The <a href="https://github.com/arvkevi/tgviz/blob/master/notebooks/plot_walkthrough.ipynb" rel="nofollow noreferrer">plot_walkthrough.ipynb</a> in the <code>tgviz</code> repo shows how this can be achieved.<br>
  Output from the notebook on my own data:</p>
  
  <p><a href="https://i.stack.imgur.com/wo2JH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wo2JH.png" alt="enter image description here"></a></p>
   73: <p>Ancestry testing is a tricky subject. I spent a good chunk of <a href="http://researcharchive.vuw.ac.nz/handle/10063/1987" rel="nofollow noreferrer">my PhD project</a> on questions similar to this, and haven't really found a good answer for how to detect unmodelled ancestry.</p>
  
  <p>The general idea of how I tried to approach ancestry determination was to create a model set containing well-defined groups of individuals with a known, specific ancestral background. A query individual (or individuals) were then added to this group, and an ancestry-estimating program was run (specifically <a href="http://web.stanford.edu/group/pritchardlab/structure.html" rel="nofollow noreferrer">Structure</a>) to work out what proportion of the unknown individual was attributable to each of the known groups. I would expect that most genetic ancestry tests follow a similar approach to this, although perhaps with a little bit less care about the definition of the model population groups.</p>
  
  <p>Problems arise when individuals are incorrectly assigned to a particular group, when groups are present in the model set that represent a larger proportion of individuals than most other groups, when groups are closely-related to other groups, and when an ancestral history is present in a test individual that doesn't match any of the model groups. And all that assumes that the marker set used for ancestry determination is perfect: no bias towards any particular group, and no systematic genotyping error.</p>
  
  <p>This doesn't mean that ancestry testing won't work, but it's a good idea to take the results with a large grain of salt. There's a <a href="https://www.theguardian.com/world/2017/apr/13/a-dna-test-showed-im-100-maori-many-thought-there-were-none-of-us-left" rel="nofollow noreferrer">good example</a> of a media personality in New Zealand who was told that she had a very high probability of being 100% Māori, despite having a good knowledge of her own family history that indicated one European ancestor a few generations back on both sides of her family.</p>
   601: <p>A suggestion from the UK Biobank QC methods white paper:</p>
  
  <ol>
  <li>Create a set of SNPs common to your VCF and the 1000 genomes phase 3 call set.</li>
  <li>Perform PCA of the 1000 genomes samples using eigenstrat smartpca. You might have to convert to binary plink format.</li>
  <li>Project your genotypes onto this pre-computed PCA space and visualize using ggplot to see which cluster you fall in.</li>
  </ol>
   84: <p>A modified implementation of Vivek's answer.</p>
  
  <p><a href="https://github.com/brentp/peddy" rel="noreferrer">peddy</a> is a Python package that samples an input <code>.vcf</code> at ~25000 sites and projects onto a principal component space built on 2504 thousand genome samples. The author has extensive documentation of the tool's features and a link to the preprint. </p>
  
  <p>I downloaded the <code>.vcf</code> and <code>.vcf.tbi</code> for the NA12878 sample from Genome in a Bottle's <a href="ftp://ftp-trace.ncbi.nlm.nih.gov/giab/ftp/release/NA12878_HG001/NISTv3.3.2/GRCh37/" rel="noreferrer">ftp here</a>. Then, created a custom <code>.ped</code> file, <code>NA12878.ped</code>, with the contents:</p>
  
  <p><code>NA12878 HG001   0       0       2       0</code></p>
  
  <p>At the command line:</p>
  
  <p><code>$ peddy --plot --prefix myvcf HG001_GRCh37_GIAB_highconf_CG-IllFB-IllGATKHC-Ion-10X-SOLID_CHROM1-X_v.3.3.2_highconf_PGandRTGphasetransfer.vcf.gz NA12878.ped
  </code></p>
  
  <p>The output files all have the prefix <code>myvcf.</code>, here's <code>myvcf.pca_check.png</code>
  <a href="https://i.stack.imgur.com/FmHmB.png" rel="noreferrer"><img src="https://i.stack.imgur.com/FmHmB.png" alt="myvcf.pca_check.png"></a></p>
  