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) – Not used directly — the Loader already handles batching internally.

  • batch_key (str, optional) – Column name in obs to use as batch identity.

  • label_key (str, optional) – Column name in obs to use as labels.

  • sample_key (str, optional) – Column name in obs to use as sample identity.

  • unlabeled_category (str, optional) – Value used for unlabeled cells. Default is "Unknown".

  • model_name (str, optional) – The scvi-tools model name. Default is "SCVI".

  • train_size (float, optional) – Fraction of data to use for training. Default is 1.0.

  • categorical_covariate_keys (list of str, optional) – Column names in obs to use as categorical covariates.

  • continuous_covariate_keys (list of str, optional) – 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[source]#
AnnbatchDataModule.extra_categorical_covs[source]#
AnnbatchDataModule.extra_continuous_covs[source]#
AnnbatchDataModule.labels_mapping[source]#
AnnbatchDataModule.n_batch[source]#
AnnbatchDataModule.n_labels[source]#
AnnbatchDataModule.n_obs[source]#
AnnbatchDataModule.n_obs_per_sample[source]#
AnnbatchDataModule.n_samples[source]#
AnnbatchDataModule.n_vars[source]#
AnnbatchDataModule.registry[source]#
AnnbatchDataModule.samples_mapping[source]#
AnnbatchDataModule.train_size[source]#

Fraction of data to use for training.

AnnbatchDataModule.unlabeled_category[source]#

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.