Skip to content

Plotting colormap not compatible with scanpy #41

Description

@casblaauw

Report

Following #8 , tf-mindi saves the colormap to adata.uns[f'{your_variable}_colors'], in an attempt to align with scanpy. I think saving the colormap makes a ton of sense, except that sadly scanpy for a mysterious reason has decided to only save the list of colors, and regenerate the associated keys with pd.Categorical(adata.obs['your_variable']).categories every time, just assuming that they still match.

Trying to use the scanpy plotting function now throws a warning and overwrites your colors:

> sc.pl.tsne(adata, color='cluster_dbd')
WARNING: The following color value found in adata.uns['cluster_dbd_colors'] is not valid: 'C2H2 ZF'. Default colors will be used instead.

I can have a look at fixing this in ensure_colors (maintaining compatibility with existing adatas containing the dict colormap, of course), but it'll have to be in a few weeks. For now, sc.pl.tsne(adata, color='cluster_dbd', palette=adata.uns['cluster_dbd_colors']) should work.

Versions

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions