[Bioperl-l] How to show branch length value in tree

Smithies, Russell Russell.Smithies at agresearch.co.nz
Sun Aug 7 21:45:19 UTC 2011


The constructor for Bio::Tree::Draw::Cladogram lets you specify the font and size, did you try setting it there?

 Title   : new
 Usage   : my $obj = Bio::Tree::Draw::Cladogram->new();
 Function: Builds a new Bio::Tree::Draw::Cladogram object 
 Returns : Bio::Tree::Draw::Cladogram
 Args    : -tree => Bio::Tree::Tree object
           -second => Bio::Tree::Tree object (optional)
           -font => font name [string] (optional) <<<<-------------
           -size => font size [integer] (optional) <<<<-------------
           -top => top margin [integer] (optional)
           -bottom => bottom margin [integer] (optional)
           -left => left margin [integer] (optional)
           -right => right margin [integer] (optional)
           -tip => extra tip space [integer] (optional)
           -column => extra space between cladograms [integer] (optional)
           -compact => ignore branch lengths [boolean] (optional)
           -ratio => horizontal to vertical ratio [integer] (optional)
           -colors => use colors to color edges [boolean] (optional)
           -bootstrap => draw bootstrap or internal ids [boolean]



--Russell



> -----Original Message-----
> From: bioperl-l-bounces at lists.open-bio.org [mailto:bioperl-l-
> bounces at lists.open-bio.org] On Behalf Of Shachi Gahoi
> Sent: Saturday, 6 August 2011 4:26 p.m.
> To: Roy Chaudhuri
> Cc: bioperl-l List
> Subject: Re: [Bioperl-l] How to show branch length value in tree
> 
> Thank you so much.
> 
> Please tell me one more thing, *can I reduce branch length font?
> *
> On Fri, Aug 5, 2011 at 4:24 PM, Roy Chaudhuri
> <roy.chaudhuri at gmail.com>wrote:
> 
> > In that case then you only want to add branch lengths to non-leaf
> nodes, so
> > it would be:
> >
> >
> > for my $node ($t1->get_nodes) {
> >  $node->id($node->branch_**length) unless $node->is_Leaf
> >
> > }
> >
> >
> > On 05/08/2011 06:40, Shachi Gahoi wrote:
> >
> >>
> >> 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
> >> <mailto:roy.chaudhuri at gmail.**com <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>
> >> >
> >>        <mailto: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>>
> >>        <mailto:Bioperl-l at lists.open-_**_bio.org<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>
> >> >
> >>        <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
> >>
> >
> >
> 
> 
> --
> Regards,
> Shachi
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/bioperl-l
=======================================================================
Attention: The information contained in this message and/or attachments
from AgResearch Limited is intended only for the persons or entities
to which it is addressed and may contain confidential and/or privileged
material. Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by persons or
entities other than the intended recipients is prohibited by AgResearch
Limited. If you have received this message in error, please notify the
sender immediately.
=======================================================================




More information about the Bioperl-l mailing list