API#

Preprocessing#

pp.setup_data(sc_adata, st_adata[, ...])

Prepare aligned single-cell and spatial datasets for cellpin.

pp.load_sc_example(*[, cache_dir, ...])

Load the single-cell example dataset used by cellpin tutorials.

pp.load_sp_example(*[, cache_dir, ...])

Load the spatial example dataset used by cellpin tutorials.

Tools#

tl.label_transfer(model, sc_adata, ...[, ...])

Transfer cell type labels from scRNA to spatial data via kNN in cellpin latent space.

Plotting#

pl.losses(log_path[, keys, smooth, figsize, ...])

Plot validation loss curves from a Lightning CSVLogger metrics.csv.

Models#

models.CellPin(sc_dataset[, config, checkpoint])

CellPin: hybrid two-view VAE for single-cell and spatial transcriptomics.

Model methods#

CellPin.fit(dataset[, pretrain_epochs, ...])

Train CellPin: Stage 1 (pretrain) followed by Stage 2 (distillation).

CellPin.pretrain_model(dataset[, ...])

Stage-1 pretraining (full-gene view only, ELBO).

CellPin.train_model(dataset[, ...])

Stage-2 main training (both views, full ELBO + invariance + SNN).

CellPin.impute(dataloader[, obs_adata, ...])

Impute with MC averaging and optional count-space normalisation.

CellPin.get_cell_embedding(dataloader[, ...])

Encode cells to the latent space via the panel encoder.

Dataset#

dataset.scAnnDataset(adata[, layer, ...])

scRNA-seq AnnData dataset wrapper.

dataset.stAnnDataset(adata, panel_genes[, ...])

Spatial AnnData dataset aligned to a panel gene list.