Merging clusters

I clustered at high resolution and defined 15 leiden clusters. Now I want to create a new .obs column with a more general labeling that combines the previous clusters into less names. When I try to remap with something like:

new_cluster_names = [ ‘list of new names’ ]

adata.obs[‘new_clusters’] = anndata.obs[‘old_clusters’].cat.rename_categories(new_cluster_names)

I get an ValueError: Categorical categories must be unique.

I don’t want them to be unique I want to combine them into one please help!!

took forever but i got it to work using pandas.series.map function

You might want to try decreasing the resolution parameter in sc.tl.leiden (or louvain if you use that). That will decrease the number of clusters it splits into in a way that might be more legitimate than manually mapping.