I am trying to re-cluster a subset of cells from my dataset.
sc.tl.leiden(adata_clean, restrict_to = ('pheno_leiden', ['1']), resolution = 1, neighbors_key= "neighbors_30", key_added = "leiden_test")
gives ValueError: ‘1’ is not a valid category for ‘pheno_leiden’.
adata_clean.obs['pheno_leiden'].value_counts()
gives
How is 1 not a valid category? I don’t understand
Are the values of pheno_leiden
integers? E.g. (adata_clean.obs["pheno_leiden"] == 1).any()
?
They are expected to be categorical strings, but this error would occur if they were integers.
Lockhaa
3
Yes, this is the problem. I guess I don’t understand why they are integers.
The code I’m running to generate pheno_leiden is
sc.external.tl.phenograph(adata_T, clustering_algo='leiden', k=30, jaccard=True,
primary_metric='euclidean', resolution_parameter=1, seed=seed)
Restrict_to doesn’t work with integers so do I need to convert pheno_leiden to categorical strings in order to run it?
I guess I don’t understand why they are integers.
Sometimes (or often) this is what clustering algorithms return.
Restrict_to doesn’t work with integers so do I need to convert pheno_leiden to categorical strings in order to run it?
Yup.
We can probably make scanpy throw a more helpful error here in the future, since that was fairly opaque.