[Bioperl-l] How to show branch length value in tree
Shachi Gahoi
shachigahoimbi at gmail.com
Fri Aug 5 05:40:11 UTC 2011
Instead of both node id and accession, Can I replace node id with accession?
On Thu, Aug 4, 2011 at 4:52 PM, Roy Chaudhuri <roy.chaudhuri at gmail.com>wrote:
> Hi Shachi,
>
> Please keep replies on the mailing list, that way others can follow the
> discussion.
>
> As I mentioned, it is not possible to draw njplot-style trees with labelled
> branches using Bio::Tree::Draw::Cladogram, it currently only labels nodes
> (you could perhaps add branch labels as a feature request on Redmine).
>
> The code I gave overwrites the existing "leaf" node ids (the accessions)
> with branch lengths, if you want to also keep the existing labels you could
> try something like:
>
>
> for my $node ($t1->get_nodes) {
> if ($node->is_Leaf) {
> $node->id($node->branch_**length.' '.$node->id);
> } else {
>
> $node->id($node->branch_**length)
> }
> }
>
> Cheers,
> Roy.
>
>
> On 04/08/2011 05:36, Shachi Gahoi wrote:
>
>> Thank You so much. Now branch length is coming in tree.
>>
>> But I want Accesssion number in place of node id.
>>
>> I attached snapshot of tree as I want. Please tell me how can I do this.
>>
>>
>>
>>
>> On Wed, Aug 3, 2011 at 7:31 PM, Roy Chaudhuri <roy.chaudhuri at gmail.com
>> <mailto:roy.chaudhuri at gmail.**com <roy.chaudhuri at gmail.com>>> wrote:
>>
>> Sorry, the code had a typo, it should be:
>>
>>
>> my $obj1 = Bio::Tree::Draw::Cladogram->__**new(-bootstrap => 1,
>> -tree => $t1,
>> -compact => 0);
>> for my $node ($t1->get_nodes) {
>>
>> $node->id($node->branch___**length) if defined
>> $node->branch_length;
>> }
>> $obj1->print(-file => "$dir/$stem.eps")
>>
>> On 03/08/2011 14:58, Roy Chaudhuri wrote:
>>
>> Hi Shachi,
>>
>> I don't think you can draw labels on branches using
>> Bio::Tree::Draw::Cladogram. However, it will draw node labels,
>> so you
>> could copy the branch lengths over to the node ids:
>>
>> my $obj1 = Bio::Tree::Draw::Cladogram->__**new(-bootstrap => 1,
>> -tree => $t1,
>> -compact => 0);
>> for my $node ($tree->get_nodes) {
>> $node->id($node->branch___**length) if defined
>> $node->branch_length;
>> }
>> $obj1->print(-file => "$dir/$stem.eps")
>>
>> Incidentally, in your script you write the tree out to a file,
>> then read
>> it back in using TreeIO. This is unnecessary, you can use $tree
>> directly
>> as input to Bio::Tree::Draw::Cladogram.
>>
>> Alternatively, you could write out a newick file and use
>> non-Bioperl
>> software such as njplot or MEGA to draw your tree with labelled
>> branch
>> lengths.
>>
>> Cheers,
>> Roy.
>>
>> On 03/08/2011 07:00, Shachi Gahoi wrote:
>>
>> Dear All
>>
>> I am using Bio::Tree modules for constructing and drawing
>> tree. *I am unable
>> to show branch length value in tree.
>> *
>> Please tell me How can I do this, if anybody knows.
>>
>> Here is my script which i am using...and i also attached
>> generated tree.
>>
>> Thanks in advance
>>
>> ##############################**__############################
>> **##__##########################**####__######
>>
>> use Bio::AlignIO;
>> use Bio::Align::ProteinStatistics;
>> use Bio::Tree::DistanceFactory;
>> use Bio::TreeIO;
>> use Bio::Tree::Draw::Cladogram;
>>
>> # for a dna alignment
>> # can also use ProteinStatistics
>>
>> my $alnio = Bio::AlignIO->new(-file => 'ADP.aln',
>> -format=>'clustalw');
>>
>> my $dfactory = Bio::Tree::DistanceFactory->__**new(-method =>
>> 'UPGMA');
>>
>> my $stats = Bio::Align::ProteinStatistics-**__>new;
>>
>> my $treeout = Bio::TreeIO->new(-format => 'newick', -file
>> =>'>ADP1.dnd');
>>
>> while( my $aln = $alnio->next_aln )
>> {
>> my $mat = $stats->distance(-method => 'Kimura', -align
>> => $aln);
>>
>> my $tree = $dfactory->make_tree($mat);
>> $treeout->write_tree($tree);
>> }
>>
>> my $dir = shift || '.';
>>
>> opendir(DIR, $dir) || die $!;
>> for my $file ( readdir(DIR) )
>> {
>> next unless $file =~ /(\S+)\.dnd$/;
>> my $stem = $1;
>> my $treeio = Bio::TreeIO->new('-format' => 'newick',
>> '-file' => "$dir/$file");
>>
>> if( my $t1 = $treeio->next_tree )
>> {
>> my $obj1 =
>> Bio::Tree::Draw::Cladogram->__**new(-bootstrap => 1,
>> -tree
>> => $t1,
>>
>> -compact => 0);
>> $obj1->print(-file => "$dir/$stem.eps");
>> }
>> }
>>
>> ##############################**__############################
>> **##__##########################**####__##############
>>
>>
>>
>>
>> ______________________________**___________________
>> Bioperl-l mailing list
>> Bioperl-l at lists.open-bio.org
>> <mailto:Bioperl-l at lists.open-**bio.org<Bioperl-l at lists.open-bio.org>
>> >
>>
>> http://lists.open-bio.org/__**mailman/listinfo/bioperl-l<http://lists.open-bio.org/__mailman/listinfo/bioperl-l>
>> <http://lists.open-bio.org/**mailman/listinfo/bioperl-l<http://lists.open-bio.org/mailman/listinfo/bioperl-l>
>> >
>>
>>
>>
>>
>>
>>
>> --
>> Regards,
>> Shachi
>>
>
>
--
Regards,
Shachi
More information about the Bioperl-l
mailing list