scanpy.pp.filter_genes#
- scanpy.pp.filter_genes(data, *, min_counts=None, min_cells=None, max_counts=None, max_cells=None, out=False, copy=False, inplace=True)[source]#
Filter genes based on number of cells or counts.
Keep genes that have at least
min_countscounts or are expressed in at leastmin_cellscells or have at mostmax_countscounts or are expressed in at mostmax_cellscells.Only provide one of the optional parameters
min_counts,min_cells,max_counts,max_cellsper call.Array type support# Array type
supported
… experimentally in dask
Array✅
✅
✅
✅
- Parameters:
- data
AnnData|csr_array|csc_array|csr_matrix|csc_matrix|ndarray|Array An annotated data matrix of shape
n_obs×n_vars. Rows correspond to cells and columns to genes.- min_counts
int|None(default:None) Minimum number of counts required for a gene to pass filtering.
- min_cells
int|None(default:None) Minimum number of cells expressed required for a gene to pass filtering.
- max_counts
int|None(default:None) Maximum number of counts required for a gene to pass filtering.
- max_cells
int|None(default:None) Maximum number of cells expressed required for a gene to pass filtering.
- out
AdRef[Idx2D|int,AnnData] |str|bool(default:False) Where to write the counts per gene (see below), e.g.
A.var['n_cells']. IfTrue, return the mask and counts instead of subsettingdataand writing them. IfFalse, they are written to.var['n_counts']or.var['n_cells'], depending on what was thresholded.- copy
bool(default:False) Return a filtered copy instead of subsetting
datain place.- inplace
bool(default:True) Deprecated since version 1.13.0: Use
out=Trueinstead ofinplace=False.Perform computation inplace or return result.
- data
- Return type:
- Returns:
Depending on
out, returns the following arrays or directly subsets and annotates the data matrix- gene_subset
Boolean index mask that does filtering.
Truemeans that the gene is kept.Falsemeans the gene is removed.- number_per_gene
Depending on what was thresholded (
countsorcells), the array storesn_countsorn_cellsper gene.