Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PhyloNodes styles not working like TreeNodes #693

Open
mwodring opened this issue Jul 25, 2023 · 0 comments
Open

PhyloNodes styles not working like TreeNodes #693

mwodring opened this issue Jul 25, 2023 · 0 comments

Comments

@mwodring
Copy link

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:

#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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant