Question: Displaying attributes on Tree nodes ETE
gravatar for moranr
4.5 years ago by
moranr270 wrote:



I am trying to display attributes of a tree.  The tree has been loaded in newick format with  attributes (annotated in the newick file) e.g.:

"Genes" , "Identical", "Duplicated" etc. 


When I try to make an image of the tree with these attributes I get an error.  I am able to print the attributes and tree as ascii. 


t=Tree('sampleGeneTree.tree', format=1)

ts = TreeStyle()
ts.show_leaf_name = True

def my_layout(node):
    #dont include root
    if not node.is_leaf() and node.up:
        #add attributes 
        node.add_face(TextFace(, column=1, position="branch-right")
        node.add_face(AttrFace(node.Genes, text_prefix="/"), column=2, position="branch-top")

ts.layout_fn = my_layout

This gives this error :

AttributeError: 'TreeNode' object has no attribute '10'

10 is the value of the node.Genes. 

What am I doing wrong here ? 



ete phylogenetics python • 1.8k views
ADD COMMENTlink modified 4.5 years ago by jhc2.8k • written 4.5 years ago by moranr270
gravatar for jhc
4.5 years ago by
jhc2.8k wrote:

AttrFace receives the name of an attribute as the first argument. Use TextFace for static values

node.add_face(AttrFace("Genes", text_prefix="/"), column=2, position="branch-top")
ADD COMMENTlink modified 6 months ago by RamRS27k • written 4.5 years ago by jhc2.8k

Ah, thank you.

ADD REPLYlink written 4.5 years ago by moranr270
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: 943 users visited in the last hour