Comments (2)
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.
You're right, seems I wasn't checking whether the tree was rooted.
Thanks for the quick reply!
from dendropy.
Related Issues (20)
- `Tree.mrca` has side effect of changing rooting state HOT 6
- `shuffle_taxa` raises `DeprecationWarning`
- Keep supporting Python2.7? HOT 3
- Some examples in `/docs/source/examples` are broken
- Add developer documentation
- Track PyPi URL change for project homepage
- Chore: Fix `ResourceWarning`s from tests
- Chore: fix `distutils` deprecation warning HOT 1
- `paup_estimate_tree_nj` example experiences intermittent failure HOT 1
- Provide public interface for `_convert_node_to_root_polytomy` HOT 1
- quote_underscores argument unrecognized HOT 1
- Documentation Deployment
- Create smoke tests
- Multithreaded option fails with no error message - leaf labels issue? HOT 2
- Error runnig picrust due to cannot import name '_convert_node_to_root_polytomy' HOT 2
- Website dendropy.org is down HOT 5
- treesim.birth_death_tree() raises division by zero error when used to extend an existing tree HOT 4
- Final Steps for Version 5 Release
- JOSS Paper?
- Support values written as quoted node labels since >4.6.1 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dendropy.