moscot.utils.tagged_array.TaggedArray.from_adata#

classmethod TaggedArray.from_adata(adata, dist_key, attr, tag=Tag.POINT_CLOUD, key=None, cost='sq_euclidean', backend='ott', **kwargs)[source]#

Create tagged array from AnnData.

Warning

Sparse arrays will be always densified.

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

  • dist_key (Union[Any, Tuple[Any, Any]]) – Key which determines into which source/target subset adata belongs.

  • attr (Literal['X', 'obsp', 'obsm', 'layers', 'uns']) – Attribute of AnnData used when extracting/computing the cost.

  • tag (Tag) – Tag used to interpret the extracted data.

  • key (Optional[str]) – Key in the attr of AnnData used when extracting/computing the cost.

  • cost (Union[str, Literal['barcode_distance', 'leaf_distance', 'custom'], Literal['euclidean', 'sq_euclidean', 'cosine', 'pnorm_p', 'sq_pnorm', 'elastic_l1', 'elastic_l2', 'elastic_stvs', 'elastic_sqk_overlap', 'geodesic']]) –

    Cost function to apply to the extracted array, depending on tag:

    • if tag = 'point_cloud', it is extracted from the backend.

    • if tag = 'graph' the cost has to be 'geodesic'.

    • if tag = 'cost' or tag = 'kernel', and cost = 'custom', the extracted array is already assumed to be a cost/kernel matrix. Otherwise, BaseCost is used to compute the cost matrix.

  • backend (Literal['ott']) – Which backend to use, see get_available_backends().

  • kwargs (Any) – Keyword arguments for the BaseCost or any backend-specific cost.

Return type:

TaggedArray

Returns:

: The tagged array.