Question: Write a pseudo-code algorithm for the above model using the following classes 1. Write a method that simulates trees according to the Kingman coalescent model

Write a pseudo-code algorithm for the above model using the following classes



1. Write a method that simulates trees according to the Kingman coalescent model (described below) which takes as input the number of leaves, n, and the effective population size, Ne. Use the provided Python classes to represent a tree (available on Canvas) The Kingman coalescent model is a lineage death process backwards in time that provides a simple algorithm for simulating a gene tree of n chromosomes from a larger population of Ne chromosomes. From each leaf, start a lineage going back in time. Each pair of lineages coalesces at rate 1/Ne. When there are k lineages, the total rate of coalescence in the tree is ()/Ne. Thus, we can generate a coalescent tree with n leaves as follows: Set k n, t 0 Make n leaf nodes with time t 0 and labeled from 1 to n. This is the set of available nodes While k > 1, iterate: Generate a time t N Exp ( ( )/Ne). Set t = t + tk. Make a new node, m, with height t and choose two distinct nodes, i and j, uniformly at random from the set of available nodes. Make i and j the child nodes of m Add m to the set of available nodes and remove i and j from this set Set k -k-1 To check the correctness of your implementation, simulate 1000 trees and check that the mean height of the trees (that is, the time of the root node) agrees with the theoretical mean of 2Ne(1 - 1. Write a method that simulates trees according to the Kingman coalescent model (described below) which takes as input the number of leaves, n, and the effective population size, Ne. Use the provided Python classes to represent a tree (available on Canvas) The Kingman coalescent model is a lineage death process backwards in time that provides a simple algorithm for simulating a gene tree of n chromosomes from a larger population of Ne chromosomes. From each leaf, start a lineage going back in time. Each pair of lineages coalesces at rate 1/Ne. When there are k lineages, the total rate of coalescence in the tree is ()/Ne. Thus, we can generate a coalescent tree with n leaves as follows: Set k n, t 0 Make n leaf nodes with time t 0 and labeled from 1 to n. This is the set of available nodes While k > 1, iterate: Generate a time t N Exp ( ( )/Ne). Set t = t + tk. Make a new node, m, with height t and choose two distinct nodes, i and j, uniformly at random from the set of available nodes. Make i and j the child nodes of m Add m to the set of available nodes and remove i and j from this set Set k -k-1 To check the correctness of your implementation, simulate 1000 trees and check that the mean height of the trees (that is, the time of the root node) agrees with the theoretical mean of 2Ne(1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
