[Bioperl-l] Fitch methode
Jason Stajich
jason.stajich at gmail.com
Thu Oct 11 05:24:29 UTC 2012
It assumes that you have assigned trait values to all nodes in the tree, the key is assigned when you do an add_trait on a tree.
You can see how to add traits and some sample data if you look in the t/Tree/Statistics.t code and you'll see the assignment of the $key
my $key = $tree->add_trait(test_input_file('traits.tab'));
>From the documentation:
Tree‐Trait statistics
The following methods produce descriptors of trait distribution among
leaf nodes within the trees. They require that a trait has been set for
each leaf node. The tag methods of Bio::Tree::Node are used to store
them as key/value pairs. In this way, one tree can store more than one
trait.
Trees have method add_traits() to set trait values from a file. See the
add_trait() method in Bio::Tree::TreeFunctionsI.
fitch
Example : fitch($tree, $key, $node);
Description: Calculates Parsimony Score (PS) and internal trait
values using the Fitch 1971 parsimony algorithm for
the subtree a defined by the (internal) node.
Node defaults to the root.
Returns : true on success
Exceptions : leaf nodes have to have the trait defined
Args : 1. Bio::Tree::TreeI object
2. trait name string
3. Bio::Tree::NodeI object within the tree, optional
Runs first fitch_up that calculates parsimony scores and then
fitch_down that should resolve most of the trait/character state
ambiguities.
Fitch, W.M., 1971. Toward defining the course of evolution: minimal
change for a specific tree topology. Syst. Zool. 20, 406−416.
You can access calculated parsimony values using:
$score = $node−>−>get_tag_values('ps_score');
and the trait value with:
$traitvalue = $node−>−>get_tag_values('ps_trait'); # only the first
@traitvalues = $node−>−>get_tag_values('ps_trait');
Note that there can be more that one trait value, especially for the
root node.
Documentation rendered in Pdoc:
http://docs.bioperl.org/bioperl-live/Bio/Tree/Statistics.html#POD3
Here is the documentation for add_traits from the
add_trait
Title : add_trait
Usage : my $key = $tree−>add_trait($trait_file, 3);
Function: Add traits to the leaf nodes of a Bio::Tree:Tree from a file.
The trait file is a tab−delimited text file and needs to have a
header line giving names to traits. The first column contains the
leaf node ids. Subsequent columns contain different trait value sets.
Single or double quotes are removed from the trait values. Traits
are added to leaf nodes as a tag named $key using the add_tag_value()
method. This means that you can retrieve the trait values using the
get_tag_values() method (see the documentation for Bio::Tree::Node).
Returns : Trait name (a scalar) on success, undef on failure (for example, if
the column index requested was too large).
Args : * Name of trait file (scalar string).
* Index of trait file column (scalar int). Note that numbering starts
at 0. Default: 1 (second column).
* Ignore missing values. Typically, if a leaf node has no value in
the trait file, an exception is thrown. If you set this option to
1, then no trait will be given to the node (no exception thrown).
also see the documentation rendered in Pdoc:
http://docs.bioperl.org/bioperl-live/Bio/Tree/TreeFunctionsI.html#POD19
On Oct 9, 2012, at 1:15 PM, Alexandre Miranda <amiranda65 at gmail.com> wrote:
> Hello,
>
> I desperately try to implement the methode Fitch from the library
> Bio:Tree:Statistics.
>
> But I cannot understand what kind of parameter I should used for the $key
> value : fitch($tree, $key, $node);
>
> Can you please send me a sample of code using that methode ?
>
> thanks for your quick reply.
>
> Best Regards,
>
> Alexandre
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/bioperl-l
Jason Stajich
jason.stajich at gmail.com
jason at bioperl.org
More information about the Bioperl-l
mailing list