# Calculating the likelihood for an ultrametric tree (example)

In this example we will calculate the likelihood where is a single site, is a rooted tree topology, and is the node heights for the tree topology. Since we are using node heights instead of branch lengths, and if we make the node heights at the tips all zeros, the tree is necessarily ultrametric. The site pattern, topology and branch lengths correspond to the following tree:

The node heights are given in some unit of time before present. As long as the substitution rate is constant across the tree (i.e. we are assuming a strict molecular clock), there are three unique branch lengths in expected substitutions per site. In this example we assume a constant rate .

The branch lengths of humans and chimps in substitutions per site are both 0.1, the branch length of the ancestor of humans and chimps (HC) is 0.2, and the branch length of gorillas is 0.3. We will calculate the likelihood under the Jukes–Cantor model, so we only have to calculate the probability of the state being the same by the end of a branch (e.g. A to A), and the probability of the state being something else (e.g. A to C), given the state at the beginning and the branch length.

For the human and chimp branches, these will be (to four decimal places):

For the HC branch, these will be:

For the gorilla branch, these will be:

For the tip nodes, the partial likelihoods are 1 for the observed states, and 0 otherwise:

For each internal node we have to consider the left and right children separately. We will start off by calculating the partial likelihood of state A of the HC internal node. Beginning with the left child (humans), the probability of the child state being A is the probability of the end state being the same (as calculated above), multiplied by the partial likelihood of the child state. This is . For child states C, G and T, the probabilities will be , so the probability for the left child branch integrating over all child states is .

The right child (chimpanzees) has the same branch length and partial
likelihoods, so its probability will also be , and the partial
likelihood of state A for the HC node will be . We use the product because we want to calculate the probability of
the left **and** right subtree states.

For state C in the HC node, the probability along the left branch for child state A will be . The probability for state C will be , and for states G and T will be . So the probability for the left branch integrating over child states will be . Again the right branch will be the same, so the partial likelihood of state C will be

Because of the equal base frequencies and equal rates assumption in Jukes–Cantor, the partial likelihoods of G and T will be the same as for C.

Now for state A at the root, the probability along the left branch for child state A will be the probability of the state remaining the same given a branch length of 0.2, multiplied by the partial likelihood of state A for the HC node, or . For child states C, G and T it will be , which is the probability of the state being different at the end given a branch length of 0.2 multiplied by the partial likelihoods. So the probability along the left branch for state A at the root integrating over the left child states will be .

For the right child (gorillas) only state C has a non-zero partial likelihood, so we should multiply the above by the probability of a different state given the branch length 0.3 to get the partial likelihood of state A at the root, which will be .

For state C at the root, the probability of child state A along the left (HC) branch will be , the probability of child state C will be , and the probabilities of child states G or T will be . So integrating over the child states for the left branch, the probability will be . Again because of the symmetry in Jukes–Cantor, the probability along the left branch will be the same for root states G and T.

However for state C at the root, the probability along the right
(gorilla) branch will be the probability of the *same* state at the end given a
branch length of 0.3, but for states G and T the probabilities will be
for a *different* state. So for state C at the root the partial likelihood
will be , but for states G and T their partial
likelihoods will be .

Each partial likelihood for a node is conditioned on the state at that node , but to calculate the likelihood at a node we need to integrate over the probabilities for each state at that node. Following the chain rule, we can convert the conditional likelihoods to joint probabilities by multipling the partials by the base (stationary) frequencies. For Jukes–Cantor the base frequencies are all equal and hence given there are 4 nucleotide states.

So we can calculate the likelihood for the entire tree by summing the root partial likelihoods and dividing by 4. For this tree and site, the likelihood .