mantispy.pp.calculate_qc_metrics

mantispy.pp.calculate_qc_metrics#

mantispy.pp.calculate_qc_metrics(adata, image_shape=None, border_margin=10, max_nan_fraction=0.5, copy=False)#

Compute per-cell and per-feature QC metrics.

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

  • image_shape (tuple[int, int] | None (default: None)) – (height, width) of a field of view. Without it, and without Metadata_Center_X/_Y in obs, the border flag stays False.

  • border_margin (int (default: 10)) – Distance from the image edge, in pixels, inside which a cell is a border cell.

  • max_nan_fraction (float (default: 0.5)) – Largest fraction of missing features a cell may have and still pass. Partial NaN is routine in CellProfiler output (Zernike and RadialDistribution features are undefined for small objects), so requiring no missing values would fail almost every cell.

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

Return type:

AnnData | None

Returns:

None, or the modified copy. Writes the obs columns qc_n_nan_features, qc_nan_fraction, qc_is_border, qc_area_outlier and qc_pass, and the var columns qc_n_nan, qc_variance and qc_n_unique.

Raises:

KeyError – If var has no feature column, which qc_area_outlier needs to find the area features, and which the schema requires.