# Computing a consensus chronogram from MT trees

## Reading all 100 trees computed by Gergely from replicates of 1% of the transfer-based constraints.

``````

In [1]:

import sys
from ete3 import Tree, TreeStyle, NodeStyle
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import math

fileT = "100.trees"
try:
f=open(fileT, 'r')
except IOError:
print ("Unknown file: " + fileT)
sys.exit()

allTrees = list()
for l in f:
allTrees.append( Tree( l.strip() ) )

``````

Node ids are consistent across all trees.

## Getting node Heights.

``````

In [17]:

#File where I store useful functions
exec (open("/Users/boussau/Programs/PythonCode/functions.py").read ())

id2Heights=list()
for t in allTrees:
node2Height,id2Height = getNodeHeights( t )
id2Heights.append(id2Height)

``````

Now we have the node heights.

## Outputting the consensus chronogram, with confidence intervals.

``````

In [18]:

print(len(id2Heights))
# Creating a uniform weight vector
weights = [1] * len(id2Heights)
outputsWeightedChronogram (allTrees[0].copy(), id2Heights, "consensus100MT", weights)

``````
``````

96

``````
``````

In [ ]:

``````