[Bioperl-l] Bio::Tree::Tree -- rerooting & bootstrap problem
Jason Stajich
jason at bioperl.org
Sat May 12 22:12:56 UTC 2007
On May 10, 2007, at 9:13 AM, Bank Beszteri wrote:
> Dear Bioperl folks,
>
> I´m trying to use Bio::Tree::Tree for manipulating phylogenetic trees,
> but in some things it did not behave as I expected it to, so I had to
> look inside a bit.
> In particular, I had problems with mixed up bootstrap values after
> re-rooting. After looking into the Bio::Tree::Tree data structures, it
> seems that
>
> a) bootstrap values are stored as attributes of nodes of the tree
> [to my
> understanding, they should rather be attributes of branches but
> Bio::Tree::Tree apparently tries to simplify away branches]; each node
> stores the bootstrap value belonging to the branch that connects it to
> its ancestor node (I´m reading in trees from Newick strings, and
> bootstrap values arrive in the id fields of internal branches)
Please feel free to suggest an alternative implementation if you
don't agree with the object model. It has worked quite well in our
hands so I'd be all ears for someone wanting to get in an do some
more work on it.
We have answered the question as to why bootstrap values are internal
ids many times on this list and I believe on the wiki -- the parser
can't tell the difference between a node id and a bootstrap value
because nexus uses the same slot for both. if you know you have
bootstrap values in the internal node it is trivial to process your
tree and copy the values over.
for my $node ( grep { ! $_->is_Leaf } $tree->get_all_nodes ) {
$node->bootstrap($node->id);
$node->id('');
}
I just added this as a method to TreeFunctionI so that it can be
easily called now to help satisfy everyone who hopes that the toolkit
can guess whether the internal nodes are bootstraps or identifiers.
>
> b) when re-rooting a tree, bootstrap values stay with the same node
> where they were before. Because the node that used to be the
> ancestor of
> a particular node in the original tree might have become its
> descendant
> after re-rooting, the bootstrap values are being mixed up.
>
> Can you confirm my conclusion? Whether yes or no, have you got an easy
> workaround or alternative solution to re-rooting trees (without having
> to touch the reroot method) or any other hints that could be useful
> for
> me to deal with this issue?
>
I think you are right, but I am not clear what should be value for
the internal node attached to the root now.
Note that is always helpful to provide example code illustrating your
problem. Here is an example which I think illustrates your problem.
use Bio::TreeIO;
my $in = Bio::TreeIO->new(-format => 'newick',
-fh => \*DATA);
my $out = Bio::TreeIO->new(-format => 'newick');
while( my $t = $in->next_tree ){
my ($a) = $t->find_node(-id =>"A");
$out->write_tree($t);
$t->reroot($a);
$out->write_tree($t);
}
__DATA__
(((A:5,B:5)90:2,C:4)25:3,D:10);
> Cheers,
>
> Bank
>
>
>
> --
> Dr. Bánk Beszteri
> Alfred Wegener Institute for Polar and Marine Research
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/bioperl-l
--
Jason Stajich
jason at bioperl.org
http://jason.open-bio.org/
More information about the Bioperl-l
mailing list