Question: 2. Write a method to simulate sequences down a simulated tree according to the Jukes-Cantor substitution model. Your method should take a tree with n

 2. Write a method to simulate sequences down a simulated tree

2. Write a method to simulate sequences down a simulated tree according to the Jukes-Cantor substitution model. Your method should take a tree with n leaves, sequence length L, and a mutation rate ?. It should return either a matrix of sequences corresponding to nodes in the tree or the tree with sequences stored at the nodes. Your method should generate a uniform random sequence of length L at the root node and recursively mutate it down the branches of the tree, using the node heights to calculate branch length. Pseudocode methods for random sequence generation and mutation down a lineage are provided at the end of this problem.

randseq(L) for (i in 1 to L) 
 seq[i] = choice([A,C,G,T], [0.25,0.25,0.25,0.25]) return seq 

The mutate method below allows mutations from a base to itself. The uncorrected mutation rate (? rather than 3?) can therefore be used.

4

mutate(X,t,mu) L= X.length() \\ the number of mutations is Poisson with total rate L*mu*t numMutation = randpoiss(L*mu*t) \\ for each mutation, choose a site to mutate and mutate it for (i in 1 to numMutation) 
 \\ choose a site site = ceiling(random()*L) \\ mutate that site X[site] = choice([A,C,G,T], [0.25,0.25,0.25,0.25]) 

return X

2. Write a method to simulate sequences down a simulated tree according to the Jukes-Cantor substitution model. Your method should take a tree with n leaves, sequence length L, and a mutation rate ?. It should return either a matrix of sequences corresponding to nodes in the tree or the tree with sequences stored at the nodes. Your method should generate a uniform random sequence of length L at the root node and recursively mutate it down the branches of the tree, using the node heights to calculate branch length. Pseudocode methods for random sequence generation and mutation down a lineage are provided at the end of this problem 2. Write a method to simulate sequences down a simulated tree according to the Jukes-Cantor substitution model. Your method should take a tree with n leaves, sequence length L, and a mutation rate ?. It should return either a matrix of sequences corresponding to nodes in the tree or the tree with sequences stored at the nodes. Your method should generate a uniform random sequence of length L at the root node and recursively mutate it down the branches of the tree, using the node heights to calculate branch length. Pseudocode methods for random sequence generation and mutation down a lineage are provided at the end of this

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!