sctk.cellwise_qc

sctk.cellwise_qc(adata, metrics=None, cell_qc_key='cell_passed_qc', uns_qc_key='scautoqc_ranges', **kwargs)

Filter cells in an AnnData object based on quality control metrics. The object is modified in-place.

This function filters cells in an AnnData object based on quality control metrics. The metrics used for filtering can be specified using the metrics argument. By default, the function uses a set of default metrics, but these can be overridden by passing a list/tuple of metric names or a dictionary of metric names and their corresponding parameters.

Parameters:
  • adata – AnnData object to filter cells from.

  • metrics – Optional data frame specifying the parameters for each metric. If not provided, the function uses a set of default metrics stored in sctk.default_metric_params_df. For defaults and an explanation, please refer to the scAutoQC demo notebook.

  • cell_qc_key – Obs column in the object to store the per-cell QC calls in.

  • uns_qc_key – Uns key to store the determined QC ranges used in filtering.

  • **kwargs – Additional keyword arguments to pass to the fit_gaussian() function.

Returns:

None.

Raises:

ValueError – If metrics is not a list/tuple of metric names or a dictionary of metric names and their corresponding parameters.

Examples

>>> import scanpy as sc
>>> import sctk
>>> adata = sc.datasets.pbmc3k()
>>> sctk.calculate_qc(adata)
>>> sctk.cellwise_qc(adata)