Esempio n. 1
0
def visualizeTree(sTreePath, pathToSfamilies, bootValue, width, height):
    # Random tree
    stree = Tree()
    stree = readTreeFromFile(sTreePath)
   
    snodesStatDic={}
    snodesStatDic= getFamiliesStatisticsForEachNode(pathToSfamilies, bootValue)
    #print snodesStatDic
    # Some random features in all nodes
    for n in stree.traverse():
        if n.name in snodesStatDic.keys():
            total= reduce(lambda x,y: x+y, snodesStatDic[n.name])
            #norm= [(x*100)/total for x in snodesStatDic[n.name]]
            norm= [x for x in snodesStatDic[n.name]]
            n.add_features(pie_data=norm)
    # Create an empty TreeStyle
    ts = TreeStyle()

    # Set our custom layout function
    ts.layout_fn=layout

    # Draw a tree 
    ts.mode = "r"
    
    #ts.force_topology= False
    ts.complete_branch_lines_when_necessary= True
    # We will add node names manually
    ts.show_leaf_name = False
    # Show branch data
    #ts.show_branch_length = True
    #ts.show_branch_support = True
    

    return stree, ts