You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I got some code working with a base tree. It simply takes some user input and generates a dictionary of name to colour and colours the nodes based on that. The working one is like so:
#colour_map is defined above, but it's a simple dict of search parameter to colour. like {'cat' : pink}. The quotes are an artefact of how the Newick file is generated.
def NewNodeStyle(colour: str) -> NodeStyle:
ns = NodeStyle()
ns['shape'] = "sphere"
ns['size'] = 10
ns['fgcolor'] = colour
return ns
for term, colour in colour_map.items():
nodes = t.search_nodes(name=term)
for node in nodes:
colour_nodes(colour, node)
node.set_style(NewNodeStyle(colour))
Then I render it. Works fine, if I say 'Cat' and I want it to be "pink" (or "Pink") I get all species called 'Cat' labelled as a pink sphere.
However, if I make a PhyloTree instead, I cannot recolour nodes. The same exact code but with PhyloTree instead does nothing. I even wrote something to trace the node back up to the root and give each node this style but no good.
Mapping species to node works fine of course, as does searching by the species derived from the name (which is species + NCBI accession). If I print the 'node' here it prints the node. It just will not recolour or change the style of the nodes I want. Is the issue between keyboard and screen or is this a quirk with PhyloTree? From the docs I understand it extends the Tree base so it SHOULD work the same and appears to from the doc.
I ran it with a dummy file generated to be small and easy like the doc but that also didn't work.
Some notes: Jupyter Lab in a Conda environment on Windows. Version is latest Conda version so 3.1.3. Many apologies if this is my error, the docs are excellent but I've been at this for about six hours so I figured it was time to submit an issue.
The text was updated successfully, but these errors were encountered:
Hi,
I got some code working with a base tree. It simply takes some user input and generates a dictionary of name to colour and colours the nodes based on that. The working one is like so:
Then I render it. Works fine, if I say 'Cat' and I want it to be "pink" (or "Pink") I get all species called 'Cat' labelled as a pink sphere.
However, if I make a PhyloTree instead, I cannot recolour nodes. The same exact code but with PhyloTree instead does nothing. I even wrote something to trace the node back up to the root and give each node this style but no good.
Mapping species to node works fine of course, as does searching by the species derived from the name (which is species + NCBI accession). If I print the 'node' here it prints the node. It just will not recolour or change the style of the nodes I want. Is the issue between keyboard and screen or is this a quirk with PhyloTree? From the docs I understand it extends the Tree base so it SHOULD work the same and appears to from the doc.
I ran it with a dummy file generated to be small and easy like the doc but that also didn't work.
Some notes: Jupyter Lab in a Conda environment on Windows. Version is latest Conda version so 3.1.3. Many apologies if this is my error, the docs are excellent but I've been at this for about six hours so I figured it was time to submit an issue.
The text was updated successfully, but these errors were encountered: