Filtering cells by expression of specific gene

Hi there,

I have a mixed population of cells, some expressing GFP and some not. I want to filter my adata object to contain ONLY the cells expressing GFP - I’ve tried the following but have not been successful:

adata2 = adata[adata[: , 'GFP'].X > 0.5, :] 

I get the following error:
IndexError: Unknown indexer <910x1 sparse matrix of type ‘<class ‘numpy.bool_’>’
with 148 stored elements in Compressed Sparse Row format> of type <class ‘anndata._core.views.SparseCSRView’>

Any help would be greatly appreciated :slight_smile:

Did you try this:

adata[(adata[:,‘GFP’].X>0).flatten(), : ]