Session Ready
Exercise

Markov Models for Allele Frequencies

In the lecture, you saw that the leading eigenvalue of the Markov matrix \(M\), whose R output is:

      [,1]  [,2]  [,3]  [,4]
[1,] 0.980 0.005 0.005 0.010
[2,] 0.005 0.980 0.010 0.005
[3,] 0.005 0.010 0.980 0.005
[4,] 0.010 0.005 0.005 0.980

produced an eigenvector modeling a situation where the alleles are represented equally (each with probability 0.25).

In this exercise, we use a for-loop to iterate the process of mutation from an initial allele distribution of:

[1] 1 0 0 0

and show that this is indeed what happens - that the eigenvector yields the right information in lieu of the for-loop.

For more on Markov Processes, see this link.

Instructions
100 XP
  • Print x, the allele distribution after the 1000 mutations.
  • Find and scale the first eigenvector of M (which is loaded for you) so that it sums to 1. Assign to v1.
  • Print v1, the scaled first eigenvector of M and compare with x.