scvi.external.contrastivevi.ContrastiveDataSplitter#

class scvi.external.contrastivevi.ContrastiveDataSplitter(adata_manager, background_indices, target_indices, train_size=None, validation_size=None, shuffle_set_split=True, load_sparse_tensor=False, pin_memory=False, external_indexing=None, **kwargs)[source]#

Bases: DataSplitter

Creates ContrastiveDataLoader for training, validation, and test set.

If train_size + validation_set < 1 then test_set is non-empty.

Parameters:
  • adata_manager (AnnDataManager) – AnnDataManager object that has been created via setup_anndata.

  • background_indices (Indices for background samples in adata.)

  • target_indices (Indices for target samples in adata.)

  • train_size (float | None (default: None)) – float, or None (default is 0.9)

  • validation_size (float | None (default: None)) – float, or None (default is None)

  • shuffle_set_split (bool (default: True)) – Whether to shuffle indices before splitting. If False, the val, train, and test set are split in the sequential order of the data according to validation_size and train_size percentages.

  • load_sparse_tensor (bool (default: False)) – If True, loads sparse CSR or CSC arrays in the input dataset as sparse Tensor with the same layout. Can lead to significant speedups in transferring data to GPUs, depending on the sparsity of the data. Passed into AnnDataLoader.

  • pin_memory (bool (default: False)) – Whether to copy tensors into device-pinned memory before returning them. Passed into AnnDataLoader.

  • external_indexing (list[array, array, array] | None (default: None)) – A list of data split indices in the order of training, validation, and test sets. Validation and test set are not required and can be left empty. Note that per group (train,valid,test) it will cover both the background and target indices

  • **kwargs – Keyword args for data loader. Data loader class is AnnDataLoader.

Attributes table#

Methods table#

setup([stage])

Split background and target indices into train/val/test sets.

test_dataloader()

Create a test data loader.

train_dataloader()

Create a train data loader.

val_dataloader()

Create validation data loader.

Attributes#

Methods#

ContrastiveDataSplitter.setup(stage=None)[source]#

Split background and target indices into train/val/test sets.

ContrastiveDataSplitter.test_dataloader()[source]#

Create a test data loader.

Return type:

ContrastiveDataLoader

ContrastiveDataSplitter.train_dataloader()[source]#

Create a train data loader.

Return type:

ContrastiveDataLoader

ContrastiveDataSplitter.val_dataloader()[source]#

Create validation data loader.

Return type:

ContrastiveDataLoader