agormp / phylotreelib Goto Github PK
View Code? Open in Web Editor NEWLibrary for analyzing and manipulating phylogenetic trees
License: GNU General Public License v3.0
Library for analyzing and manipulating phylogenetic trees
License: GNU General Public License v3.0
Hi,
thanks for the work and the lib. I have a problem with the spr (subtree pruning and regrafting) function, which I would like to use to create randomly different topologies of a strictly bifurcating tree.
If I take as the source node a leaf and not an internal node this leads to internal nodes being non-bifurcating (just one additional internal node between the original internal node and the leaf) and this can lead in newick representation even to unmatching opening and closing parentheses. Is it not possible to prune leaves or is there a workaround how I can remove these introduced non-bifurcating internal nodes?
Also, I find it quite difficult/verbose to define all conditions to filter possible regrafting nodes after I picked (randomly) a pruning node from the tree (which doesn't lead to an Error due to being a (remote - also internal) child of the same node or a parent or root or the other children of the parent node...). Is there maybe a function (planned) which makes this easier and gives potential options to do random spr moves on a tree?
Thanks a lot in advance and again thanks for your work with this library!
Elias
P.S.: I wrote for this some helper functions like a recursive "_get_all_remote_children()" function to get all remote child nodes, not just remote child leaves or an "_is_rotation_variant()" to check for rotation variants of two trees (or is this already solved by comparing the (sorted) newick representations?) - if these are ideas for future additions to the lib and you are interested, I'm happy to share.
Hey again,
I detected a bug in the treedist() function, which returns 0.0 (i.e. no difference) between two trees with different topologies such as these (ete3 normalised robinson-foulds dist for comparison):
import phylotreelib as pt
import ete3
a = pt.Tree.from_string('(A,(B,(C,D)));')
b = pt.Tree.from_string('((A,B),(C,D));')
a.treedist(b)
>0.0
tree1 = ete3.Tree('(A,(B,(C,D)));')
tree2 = ete3.Tree('((A,B),(C,D));')
tree1.compare(tree2)['norm_rf']
>0.5
Is this known?
Using version 1.5.5. MWE
import phylotreelib as pt
tree = pt.Tree.from_string("(Gorilla:3, (Human:2, (Chimpanzee:1, Bonobo:1):1):1);")
tree.numberprune(2, return_leaves=True)
Observed error:
>>> tree.numberprune(2, return_leaves=True)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.9/site-packages/phylotreelib.py", line 2192, in numberprune
clusters = self.cluster_n(nclust=nkeep)[0] # list containing sets of leafnames
File "/usr/local/lib/python3.9/site-packages/phylotreelib.py", line 1825, in cluster_n
kid_dict[kid].parent_height = pheight
AttributeError: 'Branchstruct' object has no attribute 'parent_height'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.