Code Monkey home page Code Monkey logo

phylotreelib's People

Contributors

agormp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

qvecell

phylotreelib's Issues

spr() from bifurcating tree leads to non-bifurcating tree

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.

bug in treedist() function

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?

Tree.numberprune does not seem to work

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'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.