<jupyter_start><jupyter_text>Construct Phylogenetic Tree<jupyter_code>!! raxmlHPC -p 100 -# 3 -m GTRGAMMA -s host_coi_nogaps.fasta -n host_coi_nogaps.tree -T 2
!! ls *.tree<jupyter_output><empty_output><jupyter_text>Compute pairwise patristic distances in the phylogenetic tree<jupyter_code>from dendropy import Tree
from dendropy.calculate.treemeasure import PatristicDistanceMatrix
coi_tree = Tree.get(file=open('RAxML_bestTree.host_coi_nogaps.tree', 'r'),
                    schema='newick')


coi_pds = PatristicDistanceMatrix(coi_tree)
coi_pds.sum_of_distances()
taxon1 = coi_tree.leaf_nodes()[0].taxon
taxon2 = coi_tree.leaf_nodes()[1].taxon
taxon2 = coi_tree.leaf_nodes()[1].taxon.__str__()
taxon2.replace("'","")
coi_pds.__call__(taxon1, taxon2)
patristic_distances = nx.Graph()
pds = []
for taxon1, taxon2 in product(coi_tree.leaf_nodes(), coi_tree.leaf_nodes()):
    taxon1 = taxon1.taxon
    taxon2 = taxon2.taxon
    
    pd = coi_pds.__call__(taxon1, taxon2)
    t1 = taxon1.__str__().replace("'","").split('.')[0]
    t2 = taxon2.__str__().replace("'","").split('.')[0]
    patristic_distances.add_edge(t1, t2, pd=pd)
    pds.append(pd)
plt.hist(pds)
max(pds)
min(pds)
nx.write_gpickle(patristic_distances, 'supp_data/patristic_distances.pkl')
patristic_distances.edge['Mallard']<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14652567975830816, 'fraction_numerical': 0.022658610271903322, 'mean_word_length': 5.901041666666667, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 1}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '81253', 'license': 'MIT', 'n_tokens_mistral': 566, 'n_tokens_neox': 549, 'n_words': 77, 'path': 'Data Preprocessing - Host COI distance.ipynb', 'repo_name': 'ericmjl/influenza-global-reassortment', 'size': '1324'}