You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here is the code I run. The baltic.py was obtained from the evogytis.
import imp
bt = imp.load_source('baltic', 'E:/Bio/Jupyter/baltic/baltic.py')
from glob import glob
from collections import defaultdict
import re
import numpy as np
import pandas as pd
from matplotlib import pyplot as plt
import matplotlib as mpl
import pickle
%matplotlib inline
import random
from pprint import pprint
treefiles = glob('E:/Bio/Jupyter/siv-cst/RAxML_bestTree*')
treefiles.sort(key=lambda x: int(x.split('_')[-2]))
def make_bt_tree(treefile):
t = bt.tree()
bt.make_tree(open(treefile, 'r').readlines()[0].strip(), t)
t.treeStats() ## initial traversal, checks for stats
t.sortBranches() ## traverses tree, sorts branches, draws tree
return t
trees = { i:make_bt_tree(treefile) for i,treefile in enumerate(treefiles)}
After this step, I got the same results as yours.
Tree height: 4.249024
Tree length: 27.026251
Numbers of objects in tree: 124 (61 nodes and 63 leaves)
...................
However, when I move to the next step I met this error. I didn't modify any code of this cell.
def euclidean((x1,y1),(x2,y2)):
return ((float(x2)-float(x1))**2+(float(y1)-float(y2))**2)**0.5
def sum_tip_distances(tree1,tree2):
tree1_tips = { k.numName: k for k in tree1.Objects if k.branchType=='leaf' }
tree2_tips = { k.numName: k for k in tree2.Objects if k.branchType=='leaf' }
shared_tips = set(tree1_tips.keys()).intersection(set(tree2_tips.keys()))
total_dist = 0.0
for t in shared_tips:
total_dist += euclidean( (tree1_tips[t].x, tree1_tips[t].y), (tree2_tips[t].x, tree2_tips[t].y) )
return total_dist
def untangle(tree1, tree2):
current_distance = sum_tip_distances(tree1, tree2)
for n in sorted(tree2.nodes,key=lambda x: -x.height):
if n.parent=='Root':
continue
n.rotate()
tree2.drawTree()
new_distance = sum_tip_distances(tree1, tree2)
if new_distance <= current_distance:
current_distance = new_distance
continue
else:
n.rotate()
tree2.drawTree()
for i in range(1,len(trees)):
untangle(trees[i-1], trees[i])
Could you please help me figure it out?
Thanks
The text was updated successfully, but these errors were encountered:
Hi, there
I am trying to repeat the figure generated by F1-recombination.ipynb and generate my tangle tree by baltic. I met an error which indicates
Here is the code I run. The baltic.py was obtained from the evogytis.
After this step, I got the same results as yours.
However, when I move to the next step I met this error. I didn't modify any code of this cell.
Could you please help me figure it out?
Thanks
The text was updated successfully, but these errors were encountered: