Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I finally got this working. The basic premise is that you're going to use the <code>labels/nodelist</code> to build your <code>node_sizes</code>. This way they correlate properly. I'm sure I'm missing some important options to make the tree look 100% but it appears the node sizes are showing up properly.</p> <pre><code>#basically a stripped down rewrite of Phylo.draw_graphviz import networkx, pylab from Bio import Phylo #taken from draw_graphviz def get_label_mapping(G, selection): for node in G.nodes(): if (selection is None) or (node in selection): try: label = str(node) if label not in (None, node.__class__.__name__): yield (node, label) except (LookupError, AttributeError, ValueError): pass kwargs={} tree = Phylo.read('tree.dnd', 'newick') G = Phylo.to_networkx(tree) Gi = networkx.convert_node_labels_to_integers(G, discard_old_labels=False) node_sizes = [] labels = dict(get_label_mapping(G, None)) kwargs['nodelist'] = labels.keys() #create our node sizes based on our labels because the labels are used for the node_list #this way they should be correct for label in labels.keys(): if str(label) != "Clade": num = label.name.split('-') #the times 50 is just a guess on what would look best size = int(num[-1]) * 50 node_sizes.append(size) kwargs['node_size'] = node_sizes posi = networkx.pygraphviz_layout(Gi, 'neato', args='') posn = dict((n, posi[Gi.node_labels[n]]) for n in G) networkx.draw(G, posn, labels=labels, node_color='#c0deff', **kwargs) pylab.show() </code></pre> <p>Resulting Tree <img src="https://i.stack.imgur.com/0j3VJ.png" alt="alt text"></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload