text: user2063: I'm curious how a PCA for population structure is built from an alignment/BAM or SAM file. How do programs like angsd and ngsCovar actually build a PCA? What exactly makes things come out as different and how can this be determined? If I have 3 alignments that look like this:
  
  Locus1:
  >Indiv1
  ACGT
  >Indiv2
  ACGC
  >Indiv3
  ACGA
  
  
  Locus2:
  >Indiv1
  GACT
  >Indiv2
  GACA
  >Indiv3
  GAGT
  
  
  Locus3:
  >Indiv1
  GGTC
  >Indiv2
  GGCT
  >Indiv3
  GCTA
  
  
  (These example alignments leave out quality scores for simplicity, assume that each has high quality across the board.)
  What algorithm or system would be used to graph them on a PCA? How many dimensions would that PCA have? Is it possible to model this by hand so that I can understand what's going on/how it is built?
  
  user77: In general, the process works as such:
  
  Variants are found at a number of loci in each sample (missing loci are often imputed).
  Each sample is scored at each locus, often according to the number of copies of the reference allele that it has (so, 0-2).
  The resulting matrix is used for PCA.
  
  
original_text: 2063: <p>I'm curious how a PCA for population structure is built from an alignment/BAM or SAM file. How do programs like <a href="http://www.popgen.dk/angsd/index.php/ANGSD" rel="nofollow noreferrer">angsd</a> and <a href="https://github.com/mfumagalli/ngsPopGen" rel="nofollow noreferrer">ngsCovar</a> actually build a PCA? What exactly makes things come out as different and how can this be determined? If I have 3 alignments that look like this:</p>
  
  <hr>
  
  <p>Locus1:</p>
  
  <pre><code>&gt;Indiv1
  ACGT
  &gt;Indiv2
  ACGC
  &gt;Indiv3
  ACGA
  </code></pre>
  
  <hr>
  
  <p>Locus2:</p>
  
  <pre><code>&gt;Indiv1
  GACT
  &gt;Indiv2
  GACA
  &gt;Indiv3
  GAGT
  </code></pre>
  
  <hr>
  
  <p>Locus3:</p>
  
  <pre><code>&gt;Indiv1
  GGTC
  &gt;Indiv2
  GGCT
  &gt;Indiv3
  GCTA
  </code></pre>
  
  <hr>
  
  <p>(These example alignments leave out quality scores for simplicity, assume that each has high quality across the board.)</p>
  
  <p>What algorithm or system would be used to graph them on a PCA? How many dimensions would that PCA have? Is it possible to model this by hand so that I can understand what's going on/how it is built?</p>
   77: <p>In general, the process works as such:</p>
  
  <ol>
  <li>Variants are found at a number of loci in each sample (missing loci are often imputed).</li>
  <li>Each sample is scored at each locus, often according to the number of copies of the reference allele that it has (so, 0-2).</li>
  <li>The resulting matrix is used for PCA.</li>
  </ol>
  