cellcharter.tl.purity

Contents

cellcharter.tl.purity#

cellcharter.tl.purity(adata, cluster_key='component', library_key='sample', out_key='purity', exterior=False, copy=False)#

Compute the purity of the topological boundaries of sets of cells.

It computes the purity of each cluster as the ratio between the number of cells of the cluster that are within the boundary and the total number of cells within the boundary.

Parameters:
  • adata (AnnData) – Annotated data object.

  • cluster_key (str (default: 'component')) – Key in anndata.AnnData.obs where the cluster labels are stored.

  • library_key (str (default: 'sample')) – Key in anndata.AnnData.obs where the sample labels are stored.

  • out_key (str (default: 'purity')) – Key in anndata.AnnData.obs where the metric values are stored if copy = False.

  • exterior (bool (default: False)) – If True, the computation of the purity ignores the polygon’s internal holes.

  • copy (bool (default: False)) – If True, return the result, otherwise save it to the adata object.

Return type:

None | dict[int, float]

Returns:

If copy = True, returns a dict with the cluster labels as keys and the purity as values.

Otherwise, modifies the adata with the following key: