[Bioperl-l] Bioperl help needed!
Jason Stajich
jason.stajich at duke.edu
Tue Nov 2 13:02:48 EST 2004
Well I'm only going to help if you try some of this out on your own
first and post what you've tried.
$tree->get_lca(-nodes => \@nodes) will find the least common ancestor
($node) = $tree->find_node($name) will find a particular node based on
its name
So
- Make a list of node names in Tree A which into a clade with 70%
support (based on the code I posted before).
- Then find these nodes in Tree B (find_node method).
- Find their LCA (get_lca method).
- Then walk back down from the LCA (an internal node) and get all the
tips (get_all_Descendents + the grep code posted below).
- Check if there are any other taxa in the clade thus violating your
requirement of identical clades.
Post your code that does parts of what you want and we can help point.
Please post to the list so other people can learn from it too.
-jason
On Nov 2, 2004, at 12:43 PM, Zara Ghazoui wrote:
> Thanks for yur reply.
>
> Are you just checking to see if they are present in tree B or have the
> same relationships (in the same clade). You can use methods like
> get_lca (see TreeFunctionsI) to get the least common ancestor of a set
> of nodes and see if
>
> I do need to check that the nodes are present in TreeB and have the
> SAME relationship (in the same clade).
>
> Many thanks,
>
> Zara
>
>
> Jason Stajich wrote:
>
>>
>> On Nov 2, 2004, at 11:18 AM, Zara Ghazoui wrote:
>>
>>> What I would like to be able to do is the following:
>>>
>>> I need to iterate through all the nodes of tree A (with bootstrap
>>> value >70) to see if each node, with its descedents (subtree) are
>>> present in tree B.
>>>
>> Are you just checking to see if they are present in tree B or have
>> the same relationships (in the same clade). You can use methods
>> like get_lca (see TreeFunctionsI) to get the least common ancestor of
>> a set of nodes and see if
>>
>> The $node->ancestor method lets you walk UP the tree to get ancestors
>> (each node only has 1 ancestor) or $node->get_all_Descendents to get
>> all descendents below a node, or just $node->each_Descendent to get
>> just the Nodes in the level below.
>>
>> Here is one way to start, but not really sure of the behavior you
>> want.
>>
>> # assuming you have stored the bootstrap value as an internal ID for
>> the node
>> # like this where the A-B clade has 75% support
>> # ((A:0.100,B:0.200)75:0.150,C:0.300);
>>
>> # get all the nodes, grep out for those which are NOT tips and have
>> bootstrap support >= 70
>> for my $node ( grep { ! $_->is_Leaf() && $_->id >= 70 }
>> $treeA->get_Nodes ) {
>> # note that this will touch the same nodes more than once
>> my $all_present = 1;
>> # grab all the tips from this clade
>> for my $descendent ( grep { $_->is_Leaf} $node->get_all_Descendents
>> ) {
>> my $name = $descdendent->id;
>> unless( grep { $_->is_Leaf && $_->id eq $name } $treeB->get_Nodes
>> ) {
>> $all_present = 0;
>> warn("Cannot find node $name in treeB\n");
>> }
>> # do something whether or not we found all the child tips of
>> $node in treeB
>> # based on $all_present variable.
>> }
>>
>>
>>> Hope this clarifies my first question!
>>>
>>> Zara
>>>
>>> _______________________________________________
>>> Bioperl-l mailing list
>>> Bioperl-l at portal.open-bio.org
>>> http://portal.open-bio.org/mailman/listinfo/bioperl-l
>>>
>>>
>> --
>> Jason Stajich
>> jason.stajich at duke.edu
>> http://www.duke.edu/~jes12/
>>
>
>
>
--
Jason Stajich
jason.stajich at duke.edu
http://www.duke.edu/~jes12/
More information about the Bioperl-l
mailing list