cellpin.tl.label_transfer#
- cellpin.tl.label_transfer(model, sc_adata, cell_type_col, sp_adata, conf_threshold=0.0, k=15, test_size=0.2, random_state=42, table_key='table')#
Transfer cell type labels from scRNA to spatial data via kNN in cellpin latent space.
If
X_cellpinis absent from either adata,impute()is run automatically with default settings and the embedding is stored back into the adata.- Args:
model: Trained
CellPininstance. sc_adata: Single-cell AnnData with ground-truth cell type labels. cell_type_col: Column insc_adata.obscontaining the cell type labels. sp_adata: Spatial AnnData (or SpatialData) to annotate. Modified in-place:sp_adata.obs["cellpin_annotation"]andsp_adata.obs["cellpin_annotation_certainty"]are written.- conf_threshold: Min max-class probability to assign a label (default 0.0 =
annotate all). Cells below this threshold receive the label
"Unknown".
k: Number of nearest neighbours (default 15). test_size: Fraction of scRNA cells held out for evaluation (default 0.2). random_state: Random seed for the train/test split (default 42). table_key: Table key when
sp_adatais aSpatialDataobject.- Returns:
Tuple of
(test_accuracy, sp_adata).