Read-based phasing: minimum error correction (MEC)

Each read comes from one of the two haplotypes of a diploid sample and shows the reference (R) or alternate (A) allele at the heterozygous SNPs it covers. The page phases the SNPs by minimising the number of read bases that disagree with the two haplotypes. It does this by alternating between choosing the best phase for every read given the SNP phases, and the best phase for every SNP given the read phases. Random restarts help it escape local optima. Keys: → step, ← back, f run all, r reset, s random reset (new initial SNP phases).

1 Reads

2 Model and algorithm

δi ∈ {1, −1} is the phase of SNP i: 1 if haplotype 1 carries the reference allele, −1 if it carries the alternate. σk ∈ {1, −1} is the phase of read k: 1 if it comes from haplotype 1, −1 from haplotype 2. Coding R as 1 and A as −1, read k should show δiσk at SNP i, and each disagreement is an error: qki(δiσk) = 0 if the read base bki = δiσk, and 1 otherwise.

MEC: find δ and σ that minimise Σk Σi∈Ik qki(δiσk), where Ik is the set of SNPs on read k. The problem is NP-hard, but the read phases are easy given the SNP phases, and vice versa:

  1. Randomly assign SNP phase
  2. Infer optimal read phase
  3. If flipping the phases of some SNPs improves, flip them and go to step 2
  4. Go to step 1 for enough iterations (to avoid local optima)

3 Reads, read phases and SNP phases

base carried by haplotype 1 under the current SNP phases base carried by haplotype 2 label colour = phase (1 / −1) bold: an error (cell colour ≠ read colour) SNPs flipped in this step

4 Restarts