Presentation is loading. Please wait.

Presentation is loading. Please wait.

Markov Chain Monte Carlo Hadas Barkay Anat Hashavit.

Similar presentations


Presentation on theme: "Markov Chain Monte Carlo Hadas Barkay Anat Hashavit."— Presentation transcript:

1 Markov Chain Monte Carlo Hadas Barkay Anat Hashavit

2 Motivation Motivation Models built to represent diverse types of genetic data tend to have a complex structure. Computation on these structures are often intractable. We see this, for instance, in pedigree analysis. Stochastic simulation techniques are good ways to obtain approximation. Markov Chain Monte Carlo methods have proven to be quite useful for such simulations.

3 Markov chain Markov chains are random processes X 1,X 2,…,having a discrete 1-dimensional index set (1,2,3…) domain D of m states {s1,…,sm} from which it takes it’s values Satisfying the markov property: The distribution of x t+1 given all the previous states x t x t-1 … depends only on the immediately preceding state x t X1X1 X2X3Xi-1XiXi+1S1S1 S2S2 S3S3 S i-1 SiSi S i+1

4 A markov chain also consists of 1.An m dimensional initial distribution vector 2.An m×m transition probabilities transition matrix P= (A ij ) s.t P(i,j)=Pr[x t+1 =s i |x t =s j ] X1X1 X2X3Xi-1XiXi+1S1S1 S2S2 S3S3 S i-1 SiSi S i+1

5 The multiplications shown in the previous slide are equivalent to multiplying M by itself. We conclude that P 2 ik = Pr(x t+2 =s k |x t =s i ) more generally P n ik = Pr(x t+n =s k |x t =s i ) Notice that the transition probability between X t and X t+2 are also derived in the following way:

6 Stationary distribution A distribution P = ( p 1,…, p m) is stationary if P P = P When P is unique for a transition matrix P, the rows of all coinside with P. in other words, the long-run probability of being in state j is P j, regardless of the initial state.

7 The gambler example a gambler wins 1 dollar with probability losses 1 dollar with probability 1-p the gambler plays 5 rounds. The transition matrix of that markov chain is:

8 there is no unique stationary distribution for this example any distribution p for which p 1 + p 6 =1 will satisfy p P= p. For example:

9 For p=0.5 we can see that The long run frequency of being in a given state depends on the initial state

10 Some properties of Markov chains A Markov chain is aperiodic if the chances of getting from state to state are not periodic in the number of states needed. States i,j communicate if state j is reachable from state i, i.e there exists a finite number n s.t p n (i,j)>0. A Markov chain is said to be irreducible if all its states communicate. A Markov chain is said to be ergodic if it is irreducible and aperiodic. An ergodic Markov chain always has a unique stationary distribution

11 MCMC - Monte Carlo Markov Chain Examples : 1.Boltzman distribution 1.Boltzman distribution: where is the canonical Partitioning function, which is sometimes incalculable. Goal: Calculating an Expectatoin Value When the probabilities  i are given up to an unknown normalization factor Z.

12 Prob(data|  2 ) = P(x 11,x 12,x 13,x 21,x 22,x 23 ) = Probability of data (sum over all states of all hidden variables) Prob(data|  2 ) = P(x 11,x 12,x 13,x 21,x 22,x 23 ) =  l11m, l11f … s23f [P(l 11m ) P(l 11f ) P(x 11 | l 11m, l 11f, ) … P(s 13m ) P(s 13f ) P(s 23m | s 13m,  2 ) P(s 23m | s 13m,  2 ) ] 2. Constructing the likelihood function …

13 Method: Simulate don’t go over all space. Calculate an estimator to the expectation value. We want to calculate the expectation value MCMC tells us how to carry out the sampling to create a good (unbiased, low variance) estimator. Instead, we calculate an estimator to the expectation value, by sampling from the space.

14 MCMC: create an ergodic (=irreducible, aperiodic) Markov Chain and simulate from it. We need to define an ergodic transition matrix for which  is a unique stationary distibution. If P satisfies detailed balance, i.e. for all, then  is stationary for P:

15 Metropolis (1953) suggested a simulating algorithm, in which one defines P indirectly via a symmetric transition matrix Q in the following way: If you are in state i, propose a state j with probability Move from i to j with probability. Hastings (1970) generalized for a non-symmetric Q : This assures detailed balance of P :

16 Metropolis – Hastings Algorithm: Start with any state. Step t: current state is. Propose state j with probablity. compute Accept state j if. else, draw uniformly from [0,1] a random number c. If, accept state j else, stay in state i.

17 Simulated Annealing Goal: Find the most probable state of a Markov Chain. Use the Metropolis Algorithm with a different acceptance probability: Where  is the temperature. Cool gradually, i.e., allow the chain to run m times with an initial temperature, then set a new temperature and allow the chain to run again. Repeat n times, until.

18 Simulated Annealing (Kirkpatrick,1983) Goal: Find the global minimum of a multi -dimensional surface, when all states have an equal probability. Use another variation of the Metropolis Algorithm. Suppose you are in state i. Draw a new state j, and accept using the acceptance probabilty: Where T is the temperature. Cool gradually.

19 Parameters to play with: n (number of loops) m (number of iterations in each loop) T 0 (initial temperature, shouldn’t be too high or too low)  T (cooling speed, shouldn’t be too fast) k (“Boltzman constant” – scaling parameter) C (first step scaling parameter) (initial state) q ij (how to draw the next step)

20 MCMC Example: Descent Graph Corresponds to a specific inheritance vector. Vertices: the individuals’ genes (2 genes for each individual in the pedigree). Edges: represent the gene flow specified by the inheritance vector. A child’s gene is connected by an edge to the parent’s gene from which it flowed. (Taken from tutorial 6)

21 12 1211 a/b 21 13 22 14 a/b 2324 b/d a/c 3456 1278 (a,b) (a,c)(b,d)(a,b) Descent Graph Assume that the descent graph vertices below represent the pedigree on the left. (Taken from tutorial 6)

22 3456 1278 (a,b) (a,c)(b,d)(a,b) Descent Graph 1. Assume that paternally inherited genes are on the left. 2. Assume that non-founders are placed in increasing order. 3.A ‘1’ (‘0’) is used to denote a paternally (maternally) originated gene.  The gene flow above corresponds to the inheritance vector: v = ( 1,1; 0,0; 1,1; 1,1; 1,1; 0,0 ) (Taken from tutorial 6)

23 Creating a Markov Chain of descent graphs: A Markov Chain state is a (legal) descent graph. We need to define transition rules from one state to another. We will show 4 possible transition rules : T 0, T 1, T 2a, T 2b.

24 Transition rule T 0 : Choose parent, child.

25 Transition rule T 0 : Choose parent, child. Swap paternal arc to maternal arc (or vice versa) Small change in the graph slow mixing

26 Transition rule T 1 : Choose person i.

27 Transition rule T 1 : Choose person i. Perform a T 0 transition from i to each one of his/her children.

28 Transition rule T 2a : Choose a couple i.j with common children.

29 Transition rule T 2a : Choose a couple i.j with common children. Exchange the subtree rooted at the maternal node of i with the subtree rooted at the maternal node of j. exchange also the paternally rooted subtrees.

30 Transition rule T 2b : Choose a couple i.j with common children.

31 Transition rule T 2b : Choose a couple i.j with common children. Exchange the subtree rooted at the maternal node of i with the subtree rooted at the paternal node of j, and vice versa.

32 Problem : 1/1 2/2 Two legal graphs of inheritance. No way to move from a to b using allowed transitions (the states don’t communicate). a 1/1 2/2 1/2 3/3 1/2 b 3/3

33 Solution: allow passage through illegal graphs (tunneling) 1/1 2/2 1/2 3/3 1/1 2/2 1/1 2/2 1/2 3/3 1/2 b 3/3

34 Applying tunneling in MCMC: In order to move from state i to state j (one step of the chain), (1) Select a transition (+person+locus) and perform it. (2) Toss a coin. If it says “head”, stop. If it says “tail”, goto (1). (3) If the proposed state j is legal, accept it with the Metropolis probability This assures that the Markov Chain is irreducible.

35 One use of descent graphs MCMC is the calculation of the location score for location d, given marker evidence M and trait phenotypes T : The difficult term to calculate is the conditional probability. Assuming linkage equilibrium we can write,where is a descent graph. MCMC: the stationary distribution of the chain is the conditional distribution. If a sequence of legal descent graphs is generated by running the chain, then for n large enough the estimate is:. The term can be calculated quickly, using MENDEL.

36 The Gibbs sampler Special case of the Metropolis - Hastings algorithm for Cartesian product state spaces Suppose that each sample point i=(i 1,i 2,i 3..i m ) has m components, for instance, a pedigree of m individuals The Gibbs sampler updates one component of i at a time. If the component is chosen randomly and resampled conditional on the components, then the acceptance probability is 1.

37 The Gibbs sampler Proof: Let i c be the uniformly chosen component Denote the remaining components by i -c If j is a neighbor of i reachable by changing only component i c then j -c =i -c. The proposal probability is p i q ij =p j q ji and satisfies p i q ij =p j q ji The ratio appearing in the acceptance probability is

38 Example: MCMC with ordered genotypes Suppose we want to generate a pedigree for which we know only the unordered genotype of 4 individuals in the last generation. We make the following simplifying assumptions: The population is in HW equilibrium The three loci are in linkage equilibrium There is no crossover interference between the three loci

39 One option is to first simulate the founders genotype according to population frequencies, then “drop” genes along the tree according to Mendel’s law and the recombination fractions 12 1211 21 13 22 14 2,4 1,2 2,4 1,2 2,2 2324 3,4 1,2 1,3 1,2 1,3

40 One realization of an ordered genotype consisting with the data we have is the following pedigree : One realization of an ordered genotype consisting with the data we have is the following pedigree : 12 1211 21 13 22 14 2|4 1|2 2|4 1|2 2 |2 2324 4|3 1|2 1|3 2 | 1 1|3 2|1 1|2 1|3 1|4 3|1 2|1 1|3 1|2 4|2 2|3 2 |4 2|1 3|1 1|3 3|2 3|3

41 Computing the probability of a certain realization of this pedigree is easy but even for this small tree the proposal we saw is just one of ((4 3 ) 2 ) 4 x(2 3 ) 12 =2 84 options. It is obvious we need a better method.

42 The Gibbs sampler updates the genotype of one individual at one locus at a time. The Gibbs sampler updates the genotype of one individual at one locus at a time. This is easy given all other data due to the local nature of the dependency. This is easy given all other data due to the local nature of the dependency. We need to compute * Pr[x im (l), x ip (l)|x im (-l), x ip (-l), x -i,y] Where x im (l), x ip (l) are the maternal and paternal alleles of locus l of individual i, x im (-l), x ip (-l) are the paternal and maternal alleles of all other loci of individual i, y is the phenotype data, and x -i denotes the data of all other individuals in the pedigree. The Gibbs sampler

43 This calculation involves only the phenotype of i and the genotypes of his parents and children under the no crossover assumption the genotype of on locus across a chromosome depends only on it’s adjacent loci We get the following expression to calculate *

44 Lets return to the pedigree we showed earlier. Assume that the ordered genotype is the current state, and we want to update individual 13 at locus number 2.pedigree There are 3 genotypes consistent with the genotype configuration of other individuals in the pedigree 1|1,2|1, 1|3 We need to calculate the probability of each one of these states according to the equation shown in the last slide

45 We first compute the paternal and maternal transmission probabilities for each allele in these three genotypes. Then we need the transmission probabilities from individual 13 to his kids. Once the three have been computed,they are normalized by dividing each one by the total sum. The genotype is sampled according to that distribution.

46 Problems : Updating is done a single genotype at a time. For a large pedigree this is a very slow process The Gibbs sampler may also be reducible, i.e. some legal states will never be reached. For example: A|B A|C A|A B|C A|C A|B A|A C|B by Gibbs

47 One solution to this problem is allowing illegal states in the chain which will later be discarded. Another is to identify the irreducible components called islands and to define metropolis states allowing to jump from one island to another. However the whole process of finding the islands and setting up proposal for the metropolis jumps is not fully automated the work involved for each different pedigree prevents the widespread use of this method.

48 Other MCMC that use the Gibbs Sampler The L-sampler (Heath, 1997) A Whole Locus Gibbs sampler combining Monte Carlo simulation with single-locus peeling

49 The M-sampler (Thompson and Heath, 1999; Thompson, 2000a) A whole-meiosis Gibbs sampler which jointly updates an entire meiosis from the full conditional distribution Other MCMC that use the Gibbs Sampler

50 References K. Lange, Mathematical and Statistical Methods for Genetic Analysis, chapter 9, Springer (1997). A. Bureau, T.P. Speed, Course stat 260: Statistics in Genetics, week 7. A.W. George, E. Thompson, Discovering Disease Genes: Multipoint Linkage Analysis via a New Markov Chain Monte Carlo Approach, Statistical Science, Vol. 18, No.4 (2003) Lecture notes. Tutorial notes.

51 The End!!


Download ppt "Markov Chain Monte Carlo Hadas Barkay Anat Hashavit."

Similar presentations


Ads by Google