Coder Social home page Coder Social logo

Comments (2)

jeetsukumaran avatar jeetsukumaran commented on August 16, 2024

I will look into this in detail tomorrow, but at first glance I rather
suspect that the problem might be that you are reading in the tree as
unrooted. Try adding a "[&R]" to your tree string and see if it works?
It still might a bug on the library-side, even if it works with the
above work-around, depending on what might be reasonably expected in
this case ...

On 9/8/16 9:35 PM, geronimp wrote:

Hi there,

I'm encountering a bit of a problem where I'm trying to reroot a tree
that is trifurcated at the root so that the new root is on the longest
edge descending from the current root. I've outlined the problem with
the following code:

example tree

|import dendropy tree_string =
'(1111319:0.0267,(1111717:0.01494,1111294:0.02598)1.000:0.02879,(1111874:0.03322,1111783:0.01707)0.772:0.01236);'
tree = dendropy.Tree.get(data=tree_string, schema="newick") |

The tree is trifurcated

|print tree.as_ascii_plot(plot_metric='length')
/------------------------------ 1111319 | | /----------------- 1111717
+--------------------------------+ | ------------------------------
1111294 | | /-------------------------------------- 1111874
-------------+ ------------------- 1111783 |

I want to reroot the tree on the longest edge descending from the root
(i.e. the middle one). So I find that edge, and attempt to reroot it on
that edge

|children = {x.length:x for x in tree.seed_node.child_edges()}
longest_edge_length = max(children.keys()) longest_edge =
children[longest_edge_length] tree.reroot_at_edge(longest_edge,
length1=(longest_edge_length/2), length2=(longest_edge_length/2)) |

But the tree is still trifurcated

|print tree.as_ascii_plot(plot_metric='length') /-----------------
1111717 /--------------------------------+ |
------------------------------ 1111294 |
+------------------------------ 1111319 | |
/-------------------------------------- 1111874 -------------+
------------------- 1111783 |

Strangely enough, when I try it again on the just-rerooted tree it works

|print tree.as_ascii_plot(plot_metric='length')
tree.reroot_at_edge(longest_edge, length1=(longest_edge_length/2),
length2=(longest_edge_length/2)) /--------------- 1111717
/--------------+ | --------------------------- 1111294 + |
/--------------------------- 1111319 --------------+ |
/----------------------------------- 1111874 ------------+
----------------- 1111783 |

The following description of the reroot_at_edge function lead me to
believe that it would create a node on the edge you specify, and reroot
the tree on that node, with the distances on either side of the node
being specified with the 'length' parameters:

Takes an internal edge, |edge|, adds a new node to it, and then roots
the tree on the new node.

I'm not totally sure if this is a bug or just my misunderstanding of how
to use the reroot_at_edge function. Do you have any idea why it would
not be working on the first try? How would I be able to achieve what I
need on the first go?

I'm using version 4.1.0 of dendropy

Thanks so much for any help you can provide.

Joel


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#69, or mute the
thread
https://github.com/notifications/unsubscribe-auth/AABmR4ixhdBLbGcZpJeu4CsrUZF1QNzRks5qoLfWgaJpZM4J4nX5.


Jeet Sukumaran

[email protected]

Blog/Personal Pages:
http://jeetworks.org/
GitHub Repositories:
http://github.com/jeetsukumaran
Photographs (as stream):
http://www.flickr.com/photos/jeetsukumaran/
Photographs (by galleries):

http://www.flickr.com/photos/jeetsukumaran/sets/

from dendropy.

geronimp avatar geronimp commented on August 16, 2024

You're right, seems I wasn't checking whether the tree was rooted.
Thanks for the quick reply!

from dendropy.

Related Issues (20)

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.