[BioPython] Cladograms

Peter Cock p.j.a.cock at googlemail.com
Fri Nov 28 11:29:44 UTC 2008


On Thu, Nov 27, 2008 at 3:17 PM, Renato Alves <rjalves at igc.gulbenkian.pt> wrote:
> Hi everyone,
>
> I've been searching the web for python modules to do cladograms but the only
> relevant stuff I found was relative to dendograms and hierarchical
> clustering which will give the representation I need.

Hi Renato,

> My goal is something that resembles a heatmap[1] but where the trees will be
> cladograms[2] instead of the result of clustering steps.

In my heatmap example you cited (using R), you can in principle supply
the tree to be used (instead of it defaulting to doing a hierarchical
clustering).  If you like the images from the R heatmap function, I
would suggest you look at loading phylogenetic trees into R and
passing them to the heatmap function.  I have not tried this myself.

> I know that probably I won't find modules doing exactly what I want, which
> is why I'm searching for tools to do each step separately and try to glue
> them somehow.

I can understand the idea here, but in practice the "glueing" the
images together may not be trivial.  You'll have to make sure that
they are drawn using vector image formats (allowing you to scale the
images to match), or if using bitmaps you'll need to be able to
specify things pixel perfect.   You will also need to hope that the
tree is drawn with equal vertical spacing between leaves, otherwise it
won't match the grid of the heatmap.  That said, there a lot of tree
drawing packages out there, and this could work.

> For the heatmap I have something already that will probably do
> the job, but for the cladograms I couldn't find any decent module.
> Do you happen to know any dark alley in BioPython or any other external
> module that would allow me to do the cladogram?

You could in principle use python and a package like reportlab to draw
both the tree and the heatmap - but you'd end up writing a lot of your
own code.  For example, I have used python and reportlab to draw
colourful PDF trees with aligned columns of data, e.g. Supplementary
figures 1 and 2 from: http://dx.doi.org/10.1099/mic.0.2007/013672-0

The script that drew these trees is actually rather complicated
(partly due to showing two sets of bootstrap values).  If I recall
correctly, it also used Thomas Mailund's Newick Tree module to parse
the tree files, and not Biopython.  See
http://www.daimi.au.dk/~mailund/newick.html

Next time I need to draw a customised tree, I'll try to look at
writing something more general purpose to go in Biopython under
Bio.Graphics (using Bio.Nexus to load tree files).

For now, I would suggest you explore the R heatmap function and its
arguments (and perhaps call this via python if you need to - it would
be simpler just to use R directly).

Peter



More information about the Biopython mailing list