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 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 thisStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started