planarian_lineages
planarian_lineages copied to clipboard
Rank genes on custom cluster labels
Hi,
I applied scanpy on 1.3 millions neurons, [https://github.com/theislab/scanpy_usage/blob/master/170522_visualizing_one_million_cells/cluster.py], but i have different cluster labels (not predicted by louvain in scanpy). So i want to use my custom labels to plot umap and rank genes, but i got error.
adata.obs['louvain'] = Y_pred
where Y_pred
are my custom labels,
sc.tl.rank_genes_groups(adata, 'louvain')
I run this command and got following error,
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/khalid/.local/lib/python3.7/site-packages/scanpy/tools/_rank_genes_groups.py", line 128, in rank_genes_groups
adata, groups_order, groupby)
File "/home/khalid/.local/lib/python3.7/site-packages/scanpy/utils.py", line 724, in select_groups
groups_order = adata.obs[key].cat.categories
File "/home/khalid/anaconda3/lib/python3.7/site-packages/pandas/core/generic.py", line 5175, in __getattr__
return object.__getattribute__(self, name)
File "/home/khalid/anaconda3/lib/python3.7/site-packages/pandas/core/accessor.py", line 175, in __get__
accessor_obj = self._accessor(obj)
File "/home/khalid/anaconda3/lib/python3.7/site-packages/pandas/core/arrays/categorical.py", line 2593, in __init__
self._validate(data)
File "/home/khalid/anaconda3/lib/python3.7/site-packages/pandas/core/arrays/categorical.py", line 2603, in _validate
"Can only use .cat accessor with a " "'category' dtype"
AttributeError: Can only use .cat accessor with a 'category' dtype