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 inanndata.AnnData.obs
where the cluster labels are stored.library_key (
str
(default:'sample'
)) – Key inanndata.AnnData.obs
where the sample labels are stored.out_key (
str
(default:'purity'
)) – Key inanndata.AnnData.obs
where the metric values are stored ifcopy = False
.exterior (
bool
(default:False
)) – IfTrue
, the computation of the purity ignores the polygon’s internal holes.copy (
bool
(default:False
)) – IfTrue
, return the result, otherwise save it to theadata
object.
- Return type:
- Returns:
If
copy = True
, returns adict
with the cluster labels as keys and the purity as values.- Otherwise, modifies the
adata
with the following key: anndata.AnnData.uns
['shape_{{cluster_key}}']['{{out_key}}']
- - the above mentioneddict
.
- Otherwise, modifies the