Question: Visualize / Highlight Specific Nodes In A Taxonomy Tree
gravatar for Khader Shameer
6.8 years ago by
Manhattan, NY
Khader Shameer17k wrote:

I have a set of species and a score derived from set of proteins associated with each species in the given format. I would like to know what will be the best visualization option to map these species to a tree of life. The idea is to visualize how these proteins are distribute on the tree of life.

Is there any webserver / software package which can perform such type of visualization. Google is only giving me tools for the visualization of phylogeny tree. Here am not looking at a phylogeny tree, these sequences are not homologs. What I am looking is a way to highlight these nodes in a given phylogeny tree using the taxonomy ids. If possible to give a grading color schema to show the significant species.

Taxid Score
9606 75
9823 2
9844 1
9913 27
99287 1

Thanks in advance

taxonomy visualization tree • 3.8k views
ADD COMMENTlink modified 3.8 years ago by umer.zeeshan.ijaz1.7k • written 6.8 years ago by Khader Shameer17k
gravatar for jhc
6.8 years ago by
jhc2.5k wrote:

If you need more control over your tree images, you can program how the tree is rendered using ETE (Python language)

A very very simple example that associates node features with node size and color would look like this:

from ete2 import Tree, faces
import colorsys
import random

def hls2hex(h, l, s):
    ''' Converts from HLS to RGB '''
    return '#%02x%02x%02x' %tuple(map(lambda x: int(x*255), 
                                      colorsys.hls_to_rgb(h, l, s)))
def get_color(h=None, s=0.5, l=0.5):
    ''' Returns a RGB color code with the specific Hue, Saturation and
    lightness. Otherwise, it returns a random color'''
    if not h:
        h = random.random()
    return hls2hex(h, l, s)

def my_layout(node):
    """ This function set the rules that control how nodes are drawn"""
    value =, None)
    if value is not None:

        # generate a gradient on color lightness for 0.3 to 0.8. A
        # assume value is in the (0,1) range.
        gradient = 0.3 + (float(value)/100)/2

        # Set node size and color based on the dictionary of user
        # values
        color = get_color(h=0.9, l=gradient)
        node.img_style["size"] = 20 + value
        node.img_style["fgcolor"] = color
        node.img_style["line_type"] = 1

        # Text labels can also be added to the image
        faces.add_face_to_node(faces.TextFace(" (%s) ", \
                                   node=node, column=0, aligned=True)

        faces.add_face_to_node(faces.TextFace("value: %s" %value), \
                                   node=node, column=1, aligned=True)
        node.img_style["size"] = 0

# Loads the example tree
t = Tree("(((9606,9844),99287),(9823,9913));")

# Loads the example values associated to leaf nodes
tax2size = {
    "9606": 100, "9823": 80,  "9844": 60,  "9913": 40,  "99287": 20  }
t.render("gradient.png", my_layout)

alt text fullsize

ADD COMMENTlink written 6.8 years ago by jhc2.5k

That's neat. Thanks jhc !

ADD REPLYlink written 6.8 years ago by Khader Shameer17k

Cool module. and nice color choice.

ADD REPLYlink written 6.3 years ago by brentp22k

jhc,great idea. I would like to do something similar only start with the Tree-of-Life and assign abunce values. However I can't seem to open the NCBI Taxonomy trees ( with ETE2. I would love to copy your general method but using the entire taxonomical dataset.

ADD REPLYlink written 5.7 years ago by Zach Powers340
gravatar for Lars Juhl Jensen
6.8 years ago by
Copenhagen, Denmark
Lars Juhl Jensen11k wrote:

I would use iTOL for that. I am not sure if it can do a color gradient, but it has several different ways of visualizing data onto a phylogenetic tree.

ADD COMMENTlink written 6.8 years ago by Lars Juhl Jensen11k

Yes, iTOL has gradients, see: under "Uploading trees and data"

ADD REPLYlink written 6.8 years ago by Michael Kuhn4.9k

Thanks a lot Lars.

ADD REPLYlink written 6.8 years ago by Khader Shameer17k

Thanks a lot Lars, Michael !

ADD REPLYlink written 6.8 years ago by Khader Shameer17k
gravatar for Lo Sauer
6.3 years ago by
Lo Sauer160
Lo Sauer160 wrote:

If you happen to be tackling metagenomic data (I am not sure), MEGAN will be of much help, in the task of actually sorting out the phylogenetic relationships, even of unknown taxa.

Similar plots as posted by jhc can be created directly in the software.


In a preprocessing step, the set of DNA sequences is compared against databases of known sequences using BLAST or another comparison tool. MEGAN is then used to compute and explore the taxonomical content of the data set, employing the NCBI taxonomy to summarize and order the results. A simple lowest common ancestor algorithm assigns reads to taxa such that the taxonomical level of the assigned taxon reflects the level of conservation of the sequenceconservation of the sequence conservation of the sequence

ADD COMMENTlink written 6.3 years ago by Lo Sauer160
gravatar for umer.zeeshan.ijaz
3.8 years ago by
Glasgow, UK
umer.zeeshan.ijaz1.7k wrote:

If you can convert those taxids to scientific names of species and use a comma-separated table, then you can use my PHYLOmap to visualise phylogenetic tree (which links up with ITOL).

Format the data as table.csv given on page 2.

Best Wishes,





ADD COMMENTlink written 3.8 years ago by umer.zeeshan.ijaz1.7k
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 811 users visited in the last hour