2
$\begingroup$

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?

$\endgroup$
1
  • 1
    $\begingroup$ Can you update your post to somewhere mention that this is related to population structure? There are other uses of PCA using BAM files that use completely unrelated methods (e.g., deepTools). $\endgroup$
    – Devon Ryan
    Dec 16, 2017 at 20:05

1 Answer 1

4
$\begingroup$

In general, the process works as such:

  1. Variants are found at a number of loci in each sample (missing loci are often imputed).
  2. Each sample is scored at each locus, often according to the number of copies of the reference allele that it has (so, 0-2).
  3. The resulting matrix is used for PCA.
$\endgroup$
4
  • $\begingroup$ @terdon "...according to the number of copies of the reference allele that it has (so, 0-2)." So the PCA is related to heterozygosity? $\endgroup$
    – 5r9n
    Dec 17, 2017 at 19:10
  • $\begingroup$ You said each locus was scored often based on number of copies- what else could it be scored on? $\endgroup$
    – 5r9n
    Dec 17, 2017 at 19:13
  • $\begingroup$ So you build a matrix (often) based on allele copy (0, 1, or 2) then make a covariance matrix and do associated eigendecomposition stuff to generate a PCA? $\endgroup$
    – 5r9n
    Dec 17, 2017 at 20:24
  • $\begingroup$ One could consider making a numeric score for the genotype, such that each non-reference genotype got a different value (instead of them being all lumped into 0/1). I've not seen someone try that, so I don't know whether it's useful. Usually PCA is done via SVD these days, but really however you want to do it should lead to similarish results. $\endgroup$
    – Devon Ryan
    Dec 17, 2017 at 20:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.