'keep' function?

8 views
Skip to first unread message

Erik Hanschen

unread,
Jun 7, 2016, 7:50:41 PM6/7/16
to bio-phylo
Hi all,

I'm having trouble with the 'keep' function- I'm hoping to reduce my tree to only four taxa, so I used the code below. Is there a problem with my code?

Thanks a lot!
Erik


#!/usr/bin/env perl

use strict;
use warnings;
use Bio::Phylo::IO qw(parse unparse);

my $tree = Bio::Phylo::IO->parse( '-handle' => \*DATA, 
                                  '-format' => 'newick',
                                  '-keep'   => ['64','20','52','47'])->first;

print $tree->to_newick, "\n";

__DATA__
(64,(32,((20,18),((33,47),52))));


Rutger Vos

unread,
Jun 8, 2016, 5:59:12 AM6/8/16
to bio-phylo
Hi Erik,

there isn't a problem with your code, there is a problem with our implementation, which doesn't meet your expectations :-)

The -keep argument does something not very spectacular: it simply parses out tip labels from the newick string before attempting to interpet the tree, and it only does this for "cherries" whose members are next to one another in the tree string. For example, if your tree has:

[...](A,B,([...]

Then (and only then) is it possible to remove A or B in this way. If there is more complex pruning then you are better off first interpreting the full tree and then use $tree->keep_tips([qw(64 20 52 47)]).

Hope this helps,

Rutger

--
You received this message because you are subscribed to the Google Groups "bio-phylo" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bio-phylo+...@googlegroups.com.
To post to this group, send email to bio-...@googlegroups.com.
Visit this group at https://groups.google.com/group/bio-phylo.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages