Subsetting cells based on gene expression


I would like to select and subset a certain fraction of my cells based on the expression of a certain marker/set of marker genes. I would appreciate any information as to how to achieve that best.

Many thanks.

anndata_subset = anndata[anndata[: , ‘GENE’].X > 0.5, :]

1 Like

But if i try this with multiple genes like
anndata_subset = anndata[anndata[: , [‘GENE1’,‘GENE2’]].X > 0.5, :]
This will not work as there is co expression in some cells which will lead to duplicate values
ValueError: Buffer has wrong number of dimensions (expected 1, got 0)

any suggestions there??