Special note: Use the tree, observed states at the leaves, branch lengths and the JC69, calculate the posterior probability of [A,G,C,T] at node 15. Build on the code already provided. # Use this character state vector indicating # the nucleotide at leaf nodes 1-8 site1=["A","C","C","C","G","C","C","A"] # Use this tree structure tree4 = { 15: ['N',{"node": 14, "branch": 0.02}, {"node": 8, "branch": 1.1}], 14: ['N',{"node": 13, "branch": 0.11}, {"node": 7, "branch": 1.2}], 13: ['N',{"node": 12, "branch": 0.12}, {"node": 6, "branch": 0.8}], 12: ['N',{"node": 11, "branch": 0.64}, {"node": 9, "branch": 0.11}], 11: ['N',{"node": 3, "branch": 0.26}, {"node": 10, "branch": 0.24}], 10: ['N',{"node": 4, "branch": 0.02}, {"node": 5, "branch": 0.08}], 9: ['N',{"node": 1, "branch": 0.4}, {"node": 2, "branch": 0.6}] } for i in range(1, 9): tree4[i] = ['L'] # JC69 model to generate Q matrix def JC69(): Q = np.full((4,4),0.25) np.fill_diagonal(Q,-.75) Q = Q/0.75 return Q # Initialize rate matrix Q = JC69() # Answer
This is the 3rd time I am asking this question on this platform. Previous answers were wrong or incomplete.
Please, do not give me the same old wrong answers. Write a workable code to solve this problem and I will upvote
Special note: Use the tree, observed states at the leaves, branch lengths and the JC69,
calculate the posterior probability of [A,G,C,T] at node 15. Build on the code already provided.
# Use this character state vector indicating
# the nucleotide at leaf nodes 1-8
site1=["A","C","C","C","G","C","C","A"]
# Use this tree structure
tree4 = {
15: ['N',{"node": 14, "branch": 0.02}, {"node": 8, "branch": 1.1}],
14: ['N',{"node": 13, "branch": 0.11}, {"node": 7, "branch": 1.2}],
13: ['N',{"node": 12, "branch": 0.12}, {"node": 6, "branch": 0.8}],
12: ['N',{"node": 11, "branch": 0.64}, {"node": 9, "branch": 0.11}],
11: ['N',{"node": 3, "branch": 0.26}, {"node": 10, "branch": 0.24}],
10: ['N',{"node": 4, "branch": 0.02}, {"node": 5, "branch": 0.08}],
9: ['N',{"node": 1, "branch": 0.4}, {"node": 2, "branch": 0.6}]
}
for i in range(1, 9):
tree4[i] = ['L']
# JC69 model to generate Q matrix
def JC69():
Q = np.full((4,4),0.25)
np.fill_diagonal(Q,-.75)
Q = Q/0.75
return Q
# Initialize rate matrix
Q = JC69()
# Answer
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images