Open jnmark opened 2 years ago
Hi @jnmark before I embark on trying to figure this out, have you tried palette = {'0': '#1f77b4', '1': '#ff7f0e'...}
passing your cluster names as a string such as '0'
and '1'
? Thank you.
Hi @ajitjohnson thanks for catching my rookie error. That worked perfectly, yes! :) While we are on the topic of enhancement, could I also ask how the cluster order is decided in the legend? It doesn't seem to be sequential.
@jnmark I think it is the default matplotlib order (Is it likely alphabetical ordering or numeric ordering. like 0,1,10,...,19, 2, 20, ...).
If you want a specific ordering I would try to re-categorize and sort your column.
anticipated_order = ['A', 'C', 'B', .....]
adata.obs['column_that_is_colored'] = adata.obs['column_that_is_colored'].astype('category')
adata.obs['column_that_is_colored'] = adata.obs['column_that_is_colored'].cat.reorder_categories(anticipated_order )
adata.obs = adata.obs.sort_values('column_that_is_colored')
Hi, first of all, great package! Have been using the animate function pretty extensively. :)
I had a question about adjusting colors in
sm.hl.animate
- I would like to use the cluster colors stored inadata.uns['cluster_colors']
for the UMAP and spatial plot. I tried a few things - creating a colormap from the numerical values of the color array and specifying this with thecmap
argument, zipping the colors into a dictionary and providing it in thepalette
argument, and then directly mapping the categories to colors in the function itself using palette = {0: '#1f77b4', 1: '#ff7f0e'...}, but none of these options seem to change the colors. It would be very helpful to have the colors retained in the animation since the rest of my analysis is color coded according to the cluster colors inadata.uns
. Thanks for the help!