netmap.downstream.clustering.unify_group_labelling

netmap.downstream.clustering.unify_group_labelling(adata, grn_adata, col_adata, col_grn_adata, return_mapping=True)[source]

Match overclustered GRN labels to a reference clustering using argmax assignment.

Each GRN cluster is mapped to the reference cluster that contains the majority of its cells (argmax of the contingency matrix column). Unlike the Hungarian algorithm, this allows many-to-one mappings, making it suitable when grn_adata has more clusters than adata.

Parameters:
  • adata (anndata.AnnData) – Reference AnnData with ground-truth cluster labels.

  • grn_adata (anndata.AnnData) – GRN AnnData whose clusters will be remapped.

  • col_adata (str) – Column in adata.obs with reference cluster labels.

  • col_grn_adata (str) – Column in grn_adata.obs with GRN cluster labels.

  • return_mapping (bool) – If True also return the mapping dict. Defaults to True.

Returns:

Fraction of correctly matched cells. If

return_mapping=True, returns (score, reverse_mapping).

Return type:

float or tuple