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

[BUG] GET http://localhost:5005/api/v0.2/colors: 404 (NOT FOUND) #2598

Open
alexlenail opened this issue Dec 30, 2022 · 10 comments
Open

[BUG] GET http://localhost:5005/api/v0.2/colors: 404 (NOT FOUND) #2598

alexlenail opened this issue Dec 30, 2022 · 10 comments
Labels

Comments

@alexlenail
Copy link

Describe the bug
Just installed cellxgene, and tried to load a dataset of mine, got this error and fails to load.

Version (please complete the following information):

  • Desktop or hosted?: pip installed on local machine
  • Browser (if hosted) [e.g. chrome, safari]: chrome
  • Version [e.g. 0.13.0]: cellxgene-1.1.1
@alexlenail alexlenail added the bug label Dec 30, 2022
@alexlenail
Copy link
Author

 cellxgene launch https://github.com/chanzuckerberg/cellxgene/raw/main/example-dataset/pbmc3k.h5ad

does work though. Could it have to do with this warning?

[cellxgene] Warning: Var annotation 'index' has 32507 categories, this may be cumbersome or slow to display. We recommend setting the --max-category-items option to 500, this will hide categorical annotations with more than 500 categories in the UI

@alexlenail
Copy link
Author

A little more digging:

DEBUG:server.app.app:Unknown color format type!
Traceback (most recent call last):
  File "/Users/alex/miniconda3/envs/py39/lib/python3.9/site-packages/server/common/colors.py", line 187, in convert_color_to_hex_format
    raise ColorFormatException("Unknown color format type!")
server.common.errors.ColorFormatException: Unknown color format type!

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/alex/miniconda3/envs/py39/lib/python3.9/site-packages/server/common/rest.py", line 243, in colors_get
    return make_response(jsonify(data_adaptor.get_colors()), HTTPStatus.OK)
  File "/Users/alex/miniconda3/envs/py39/lib/python3.9/site-packages/server/data_anndata/anndata_adaptor.py", line 334, in get_colors
    return convert_anndata_category_colors_to_cxg_category_colors(self.data)
  File "/Users/alex/miniconda3/envs/py39/lib/python3.9/site-packages/server/common/colors.py", line 231, in convert_anndata_category_colors_to_cxg_category_colors
    zip(data.obs[category_name].cat.categories, [convert_color_to_hex_format(c) for c in data.uns[uns_key]])
  File "/Users/alex/miniconda3/envs/py39/lib/python3.9/site-packages/server/common/colors.py", line 231, in <listcomp>
    zip(data.obs[category_name].cat.categories, [convert_color_to_hex_format(c) for c in data.uns[uns_key]])
  File "/Users/alex/miniconda3/envs/py39/lib/python3.9/site-packages/server/common/colors.py", line 189, in convert_color_to_hex_format
    raise ColorFormatException(e)
server.common.errors.ColorFormatException: Unknown color format type!

@alexlenail
Copy link
Author

Removing all my colors from .uns seems to have solved it. My colors were in the format:

'majority_voting_colors': ['#b9342cff', '#873c46ff', '#996068ff', ...

They display properly when I make UMAPs in scanpy..

@alexlenail
Copy link
Author

alexlenail commented Dec 30, 2022

Oh that's interesting -- they're all hex rgbA...

@MaximilianLombardo
Copy link

Hey Alex - am I correct in understanding that you have resolved your own issue?

@alexlenail
Copy link
Author

alexlenail commented Jan 10, 2023

yes, but I think there's still an issue with cellxgene, when it loads adatas written by modern versions of scanpy.

When I set the palette in a scanpy UMAP, it will save the palette under .uns. It saves it in a hex format with RGBA, so something like #aabbccff rather than a traditions 6-digit hex color code. This causes the error message above.

Since scanpy will be doing this for many users, perhaps cellxgene should be able to handle these 8-digit hex colors (and parse them as RGBA?

In the meantime, here's my workaround (call this function right before writing your h5ad to read into cellxgene):

def rgba_hex_colors_to_rgb(adata):
    for key in adata.uns.keys():
        if key.endswith('colors'):
            adata.uns[key] = np.array([(c if len(c)<=7 else c[:-2]) for c in adata.uns[key]])

@MaximilianLombardo
Copy link

Got it - thanks, for the explanation Alex - following up on this internally!

@MaximilianLombardo
Copy link

ps which version of scanpy did you generate your dataset with?

@alexlenail
Copy link
Author

scanpy==1.9.1, python 3.9.13, macOS 12.5.1

@MaximilianLombardo
Copy link

perfect, thanks!

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

No branches or pull requests

2 participants