scanpy.api.pp.downsample_counts

scanpy.api.pp.downsample_counts(adata, target_counts=20000, random_state=0, replace=True, copy=False)

Downsample counts so that each cell has no more than target_counts.

Cells with fewer counts than target_counts are unaffected by this. This has been implemented by M. D. Luecken.

Parameters:
adata : AnnData

Annotated data matrix.

target_counts : int (default: 20,000)

Target number of counts for downsampling. Cells with more counts than ‘target_counts’ will be downsampled to have ‘target_counts’ counts.

random_state : int or None, optional (default: 0)

Random seed to change subsampling.

replace : bool, optional (default: True)

Whether to sample the counts with replacement.

copy : bool, optional (default: False)

If an AnnData is passed, determines whether a copy is returned.

Returns:

Depending on copy returns or updates an adata with downsampled .X.

Return type:

AnnData, None