cellflow.preprocessing.transfer_labels

cellflow.preprocessing.transfer_labels(query_adata, ref_adata, label_key, wknn_key='wknn', copy=False)[source]

Transfer labels from the reference to the query dataset.

Parameters:
  • query_adata (AnnData) – An AnnData object with the query data

  • ref_adata (AnnData) – An AnnData object with the reference data

  • label_key (str) – Key in obs of ref_adata containing the labels

  • wknn_key (str) – Key in uns of ref_adata containing the weighted k-nearest neighbors graph

  • copy (bool) – Return a copy of query_adata instead of updating it in place

Return type:

AnnData | None

Returns:

: If copy is True, returns a new AnnData object with the transferred labels stored in obs. Otherwise, updates adata in place.

Sets the following fields:

  • .obs[f"{label_key}_transfer"]: Transferred labels

  • .obs[f"{label_key}_transfer_score"]: Confidence scores for the transferred labels