basilkhuder/Seurat-to-RNA-Velocity

Failed to incorprate colors with "color = sample_one.uns['Cluster_colors']"

Flyingcattle opened this issue · 4 comments

Thanks very much for the helpful tutorial, I succeeded in incorporating UMAP coordinates, but failed with Cluster color. My AnnData object looks like:
AnnData object with n_obs × n_vars = 6667 × 1496
obs: 'orig.ident', 'nCount_spliced', 'nFeature_spliced', 'nCount_unspliced', 'nFeature_unspliced', 'nCount_ambiguous', 'nFeature_ambiguous', 'nCount_RNA', 'nFeature_RNA', 'nCount_SCT', 'nFeature_SCT', 'SCT_snn_res.0.8', 'seurat_clusters', 'initial_size_unspliced', 'initial_size_spliced', 'initial_size', 'n_counts', 'velocity_self_transition'
var: 'features', 'ambiguous_features', 'spliced_features', 'unspliced_features', 'velocity_gamma', 'velocity_r2', 'velocity_genes'
uns: 'pca', 'neighbors', 'velocity_settings', 'velocity_graph', 'velocity_graph_neg', 'seurat_clusters_colors'
obsm: 'X_umap', 'X_pca', 'velocity_umap'
varm: 'PCs'
layers: 'ambiguous', 'spliced', 'unspliced', 'Ms', 'Mu', 'velocity', 'variance_velocity'

When I use "scv.pl.velocity_embedding_stream(adata, basis="umap", color=adata.uns['seurat_clusters_colors'])";
image

I got a series of UMAP plots colored with seurat_clusters_colors, but not the expected seurat_clusters_colors for each cell cluster.
I am new to python, and I do appreciate any helpful suggestions.

Hi there!

Can you show me what the contents "seurat_clusters_colors" look like?

@basilkhuder
Thank you for your quick response, Yes, my "seurat_clusters_colors" look like:
In[ ]: adata.uns["seurat_clusters_colors"]
Out [ ]: ['#023fa5',
'#7d87b9',
'#bec1d4',
'#d6bcc0',
'#bb7784',
'#8e063b',
'#4a6fe3',
'#8595e1',
'#b5bbe3',
'#e6afb9',
'#e07b91',
'#d33f6a',
'#11c638',
'#8dd593',
'#c6dec7',
'#ead3c6',
'#f0b98d',
'#ef9708',
'#0fcfc0']

I also tried to use the following 2 methods but also failed:
First:
In[ ]: ident_colours = ["#C987BB","#9400D3", "#5BBC5E", "#9851A1", "#83BA40",
"#8C6DAF", "#ADFF2F", "#5767AE", "#E68824",
"#6495ED", "#D5AC3C", "#7859A3", "#228B22",
"#C84F9E", "#4DC1B4", "#EE82EE", "#40E0D0","#40E0D0","#40E0D0"]
adata.uns['my_color']=ident_colours
scv.pl.velocity_embedding_stream(adata, basis="umap", color = adata.uns["my_color"])

Finally, I got a similar result above.

Second:
I incorporated cell colors for each cell and store them in "adata.uns['mycolor']", it looks like:

In[ ]: type(sample_one.uns['mycolor'])
Out[ ]: list
In[ ]: type(sample_one.uns['mycolor'][1])
Out[ ]:str
In[ ]: sample_one.uns['mycolor']
Out[ ]:["['#D5AC3C']",
"['#83BA40']",
"['#D5AC3C']",
"['#E68824']",
"['#5767AE']",
"['#9851A1']",
"['#83BA40']",
"['#5767AE']",
"['#5BBC5E']",
...
and then used
scv.pl.velocity_embedding_stream(sample_one, basis="umap", color=sample_one.uns['mycolor'])
An error then occured with:
" ValueError: Image size of 3325536x288 pixels is too large. It must be less than 2^16 in each direction. "

Managed to fix this issue, it's a scanpy version error, fixed when scanpy was updated to the newest version.

Managed to fix this issue, it's a scanpy version error, fixed when scanpy was updated to the newest version.

Thank you for the updating! Glad you found a fix.