mantispy.tl.similarity

Contents

mantispy.tl.similarity#

mantispy.tl.similarity(adata, metric='cosine', use_rep=None, key_added='similarity', copy=False)#

Store pairwise profile similarity in obsp[key_added].

Parameters:
  • adata (AnnData) – Profiles to compare.

  • metric (str (default: 'cosine')) – Similarity between profiles, one of METRICS.

  • use_rep (str | None (default: None)) – Compare obsm[use_rep] instead of X.

  • key_added (str (default: 'similarity')) – obsp key written.

  • 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 dense float32 similarity matrix of similarity_matrix to obsp[key_added].

Notes

The result is dense and quadratic in the number of profiles, so this expects well- or perturbation-level profiles rather than single cells.