[BUG] GET http://localhost:5005/api/v0.2/colors: 404 (NOT FOUND)
alexlenail opened this issue · 10 comments
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
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
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!
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..
Oh that's interesting -- they're all hex rgbA...
Hey Alex - am I correct in understanding that you have resolved your own issue?
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]])
Got it - thanks, for the explanation Alex - following up on this internally!
ps which version of scanpy did you generate your dataset with?
scanpy==1.9.1, python 3.9.13, macOS 12.5.1
perfect, thanks!