rapids_singlecell.pp.calculate_qc_metrics#

rapids_singlecell.pp.calculate_qc_metrics(adata, *, expr_type='counts', var_type='genes', qc_vars=None, log1p=True, use=None, out=True (settings.preset='scanpy-v1' – changes in 2.0), layer=None)[source]#

Calculate basic quality-control metrics [MCLW17].

Calculates number of genes per cell (n_genes) and number of counts per cell (n_counts). Loosely based on calculate_qc_metrics from scanpy [WAT18]. Updates obs and var with columns with qc data.

Parameters:
adata AnnData

AnnData object

expr_type str (default: 'counts')

Name of kind of values in X.

var_type str (default: 'genes')

The kind of thing the variables are.

qc_vars str | list (default: None)

Keys for boolean columns of var which identify variables you could want to control for (e.g. Mito). Create these boolean columns before calculating QC metrics.

log1p bool (default: True)

Set to False to skip computing log1p transformed annotations.

use LayerAcc | str | None (default: None)

Which matrix to use for expression values, e.g. A.X or A.layers['counts']. Strings are resolved by anndata.acc.AdAcc.resolve(), e.g. 'layers.counts'.

out MultiAcc | str | QcMetricsOut | bool | Default (default: True (settings.preset='scanpy-v1' – changes in 2.0))

Where to write the metrics. If False, they are written as columns of .obs and .var (see below). An accessor like A.obsm['qc'] writes the metrics tables as whole DataFrames to .obsm['qc'] and .varm['qc'] instead. A mapping (QcMetricsOut) writes only the tables it names, e.g. {'obs': A.obsm['qc']}. If True, they are returned as a QcMetricsResult. Defaults to True if rapids_singlecell.settings.preset is ScanpyV1, else False.

Return type:

QcMetricsResult | None

Returns:

A QcMetricsResult if out=True, else None.

With out=False, adds the following columns in obs :
total_{var_type}_by_{expr_type}

E.g. ‘total_genes_by_counts’. Number of genes with positive counts in a cell.

total_{expr_type}

E.g. ‘total_counts’. Total number of counts for a cell.

for qc_var in qc_vars
total_{expr_type}_{qc_var}

number of counts per qc_var (e.g total counts mitochondrial genes)

pct_{expr_type}_{qc_var}

Proportion of counts of qc_var (percent of counts mitochondrial genes)

adds the following columns in var :
total_{expr_type}

E.g. ‘total_counts’. Sum of counts for a gene.

n_genes_by_{expr_type}

E.g. ‘n_cells_by_counts’. Number of cells this expression is measured in.

mean_{expr_type}

E.g. “mean_counts”. Mean expression over all cells.

pct_dropout_by_{expr_type}

E.g. ‘pct_dropout_by_counts’. Percentage of cells this feature does not appear in.