scvi.dataloaders.AnnbatchDataModule#

class scvi.dataloaders.AnnbatchDataModule(dataset, batch_size=None, batch_key=None, label_key=None, sample_key=None, unlabeled_category='Unknown', model_name='SCVI', train_size=1.0, categorical_covariate_keys=None, continuous_covariate_keys=None, var_names=None, layer=None, chunk_size=256, preload_nchunks=32, preload_to_gpu=True, shuffle=False, class_sampler_key=None, class_weights=None)[source]#

Bases: LightningDataModule

LightningDataModule for annbatch.Loader with full scvi-tools integration.

Parameters:
dataset annbatch.Loader

The Loader configured with a DatasetCollection.

batch_size int, optional (default: None)

Not used directly — the Loader already handles batching internally.

batch_key str | None (default: None)

Column name in obs to use as batch identity.

label_key str | None (default: None)

Column name in obs to use as labels.

sample_key str | None (default: None)

Column name in obs to use as sample identity.

unlabeled_category str | None (default: 'Unknown')

Value used for unlabeled cells. Default is "Unknown".

model_name str (default: 'SCVI')

The scvi-tools model name. Default is "SCVI".

train_size float (default: 1.0)

Fraction of data to use for training. Default is 1.0.

categorical_covariate_keys list[str] | None (default: None)

Column names in obs to use as categorical covariates.

continuous_covariate_keys list[str] | None (default: None)

Column names in obs to use as continuous covariates.

Attributes table#

Methods table#

inference_dataloader()

Dataloader for inference with on_before_batch_transfer applied.

on_before_batch_transfer(batch, dataloader_idx)

Convert an annbatch Loader batch to the dictionary required by scvi-tools.

set_batch_size([batch_size])

Update the annbatch sampler batch size used for train and validation.

set_split([train_size, validation_size, ...])

Configure disjoint train/validation ranges over the same annbatch collection.

train_dataloader()

Create the train data loader.

val_dataloader()

Create the validation data loader.

Attributes#

AnnbatchDataModule.batch_labels#
AnnbatchDataModule.extra_categorical_covs#
AnnbatchDataModule.extra_continuous_covs#
AnnbatchDataModule.labels_mapping#
AnnbatchDataModule.n_batch#
AnnbatchDataModule.n_labels#
AnnbatchDataModule.n_obs#
AnnbatchDataModule.n_obs_per_sample#
AnnbatchDataModule.n_samples#
AnnbatchDataModule.n_vars#
AnnbatchDataModule.registry#
AnnbatchDataModule.samples_mapping#
AnnbatchDataModule.train_size#

Fraction of data to use for training.

AnnbatchDataModule.unlabeled_category#

String assigned to unlabeled cells.

Methods#

AnnbatchDataModule.inference_dataloader()[source]#

Dataloader for inference with on_before_batch_transfer applied.

AnnbatchDataModule.on_before_batch_transfer(batch, dataloader_idx)[source]#

Convert an annbatch Loader batch to the dictionary required by scvi-tools.

Follows the same encoding pattern as TileDBDataModule and MappedCollectionDataModule.

AnnbatchDataModule.set_batch_size(batch_size=None)[source]#

Update the annbatch sampler batch size used for train and validation.

Return type:

None

AnnbatchDataModule.set_split(train_size=None, validation_size=None, shuffle_set_split=True, batch_size=None)[source]#

Configure disjoint train/validation ranges over the same annbatch collection.

AnnbatchDataModule.train_dataloader()[source]#

Create the train data loader.

AnnbatchDataModule.val_dataloader()[source]#

Create the validation data loader.