rapids_singlecell.pp.filter_genes#

rapids_singlecell.pp.filter_genes(data, *, min_counts=None, min_cells=None, max_counts=None, max_cells=None, out=False, copy=False, verbose=True, inplace=True)[source]#

Filter genes based on number of cells or counts.

Keep genes that have at least min_counts counts or are expressed in at least min_cells cells or have at most max_counts counts or are expressed in at most max_cells cells.

Only provide one of the optional parameters min_counts, min_cells, max_counts, max_cells per call.

Parameters:
data AnnData | ndarray | csc_matrix | csr_matrix | 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 | str | bool (default: False)

Where to write the counts per gene, e.g. A.var['n_cells']. If True, return the mask and counts instead of subsetting data and writing them. If False, they are written to .var['n_counts'] or .var['n_cells'], depending on what was thresholded.

copy bool (default: False)

Whether to subset and return a copy of data instead of modifying it.

verbose bool (default: True)

Print number of discarded genes

Return type:

AnnData | tuple[ndarray, ndarray] | None

Returns:

With out=True or array input, returns the following arrays, else subsets and annotates the data matrix

gene_subset

Boolean index mask that does filtering. True means that the gene is kept. False means the gene is removed.

number_per_gene

Depending on what was thresholded (counts or cells), the array stores n_counts or n_cells per gene.