You could use ETE to control how different nodes in a tree are drawn.
Load a tree and create your own layout function to control how
different nodes should be shown. That's the general idea (see
example) and is up to you how different nodes are branches should
be drawn. They problem may come with huge trees. I have tested
the example with a random 5000 tips tree, and ETE will be able to
generate the SVG in few seconds, however you will need quite a
lot memory and CPU to handle a vector-graphics document like the
one generated.
The ETE GUI will also open the image, but performance could be very
bad depending on your system. PNG on the other hand cannot be
used to store such a big image, so you will need to scale it to
something smaller.
In summary, ETE will help you to draw your trees in a programmatic
way, but consider also the possibility of collapsing nodes, or
split your tree into smaller partitions if you plan to spend some
time inspecting very large topologies. ETE can also help you with
that, since you can generate independent tree pictures for
different clusters within the same tree, search and traverse node at your convenience, etc.
Also, here you have a little recipe about how to run a clustering
analysis using hcluster and convert the result into an ETE tree.
http://stackoverflow.com/questions/9364609/converting-ndarray-generated-by-hcluster-into-a-newick-string-for-use-with-ete2/17657426#17657426
Hope it helps
example:
from ete2 import Tree, TreeStyle, random_color
import random
def my_layout(node):
if node.is_leaf():
node.img_style["size"] = random.randint(4, 30)
node.img_style["shape"] = "sphere"
node.img_style["fgcolor"] = random_color()
else:
node.img_style["size"] = 0
t = Tree()
t.populate(10)
t.dist = 0
ts = TreeStyle()
ts.mode = "c" # circular
ts.show_leaf_name = True
ts.layout_fn = my_layout
t.show(tree_style=ts)
# For very large trees, avoid t.show and use SVG rendering
# t.populate(5000)
# t.render("mytree.svg", tree_style=ts)
# PNG will require fixing image dimensions
# t.render("mytree.svg", tree_style=ts, w=15000, units="px")
Yes, I use python. ETE looks like a lot what I want. So, for each branch, ETE can generate the size for all children branches?