mantispy.pp.outliers

Contents

mantispy.pp.outliers#

mantispy.pp.outliers(adata, method='ecod', contamination=0.01, score_cutoff=None, key='selected', by=None, seed=0, key_added='qc_outlier', copy=False)[source]#

Flag outlying cells.

Every method produces a score where higher means more outlying, and the same thresholding applies to all of them, so contamination is the flagged fraction whichever method is used.

Parameters:
  • adata (AnnData) – Object to flag.

  • method (str (default: 'ecod')) – "ecod" is parameter-free and interpretable per feature, "isolation_forest" catches outliers defined by feature interactions, and "mad" takes the largest robust z-score across features, which is easy to explain but sees each feature alone.

  • contamination (float (default: 0.01)) – Fraction of cells to flag. Ignored when score_cutoff is given.

  • score_cutoff (float | None (default: None)) – Threshold the score absolutely instead of by quantile. With method="mad" the score is a robust z-score, so score_cutoff=5 gives the usual rule.

  • key (str | None (default: 'selected')) – Restrict to features flagged by this boolean var column, usually "selected". Falls back to every feature when the column is absent.

  • by (str | None (default: None)) – Threshold within each group of this obs column, e.g. per plate, rather than globally.

  • seed (int (default: 0)) – Seed for isolation_forest.

  • key_added (str (default: 'qc_outlier')) – Prefix for the outputs: obs[key_added] and obs[key_added + "_score"].

  • copy (bool (default: False)) – Return a modified copy instead of mutating in place.

Return type:

AnnData | None

Returns:

None, or the modified copy.