symphonypy.tl.per_cluster_confidence
- symphonypy.tl.per_cluster_confidence(adata_query: AnnData, adata_ref: AnnData, cluster_key: str, u: float = 2, lamb: float = 0, transferred_primary_basis: str = 'X_pca_reference', obs: str | None = 'symphony_per_cluster_dist', uns: str | None = 'symphony_per_cluster_dist')
Calculates the Mahalanobis distance from user-defined query clusters to their nearest reference centroid after initial projection into reference PCA space. All query cells in a cluster get the same score. Higher distance indicates less confidence. Due to the instability of estimating covariance with small numbers of cells, we do not assign a score to clusters smaller than u * d, where d is the dimensionality of the embedding and u is specified.
- Parameters:
adata_query (AnnData) – query adata object mapped to
adata_refwith Symphonyadata_ref (AnnData) – reference adata object (with Harmony object in
adata_ref.uns)cluster_key (str) – which keys from
adata_query.obsto use as a cluster label (if list, adata_query will be grouped by them)u (float, optional) – at least u * d cells are to be assigned to a cluster, where d is a dimensionality of representation, defaults to 2
lamb (float, optional) – ridge regression like coef for covariance matrix inversion numerical stability, defaults to 0
transferred_primary_basis (str, optional) –
adata_query.obsm[transferred_primary_basis]should contain pre-Symphony reference PC query representation, defaults to “X_pca_reference”obs (str | None, optional) – If not None, resulted dists would be written to
adata_query.obs[obs]for each cell (just the same value for each cluster), defaults to “symphony_per_cluster_dist”uns (str | None, optional) – If not None, resulted dists would be written to
adata_query.uns[uns]for each cluster, defaults to “symphony_per_cluster_dist”