How to quantify cell type using scanpy?

Is there a way to find counts per cell type and the its percentage?
I tried to run sc.pl.count_occurrence(adata, add_percentage=True, count_variable='cell_type') but says scanpy doesn’t have the attribute.

Scanpy does not have that function. But I think what you’re looking for is more like:

adata.obs["cell_type"].value_counts()
# or, for frequencies
adata.obs["cell_type"].value_counts(normalize=True)
1 Like

That worked like a charm. Thank you!

1 Like