scvi.dataloaders.AnnDataLoader#

class scvi.dataloaders.AnnDataLoader(adata_manager, shuffle=False, indices=None, batch_size=128, sampler=None, data_and_attributes=None, drop_last=False, iter_ndarray=False, **data_loader_kwargs)[source]#

DataLoader for loading tensors from AnnData objects.

Parameters:
  • adata_manager (AnnDataManager) – AnnDataManager object with a registered AnnData object.

  • shuffle (bool (default: False)) – Whether the data should be shuffled

  • indices (Union[Sequence[int], Sequence[bool], None] (default: None)) – The indices of the observations in the adata to load

  • batch_size (int (default: 128)) – minibatch size to load each iteration

  • sampler (Optional[Sampler] (default: None)) – Defines the strategy to draw samples from the dataset. Can be any Iterable with __len__ implemented. If specified, shuffle must not be specified. By default, we use a custom sampler that is designed to get a minibatch of data with one call to __getitem__.

  • data_and_attributes (Union[List[str], Dict[str, dtype], None] (default: None)) – Dictionary with keys representing keys in data registry (adata_manager.data_registry) and value equal to desired numpy loading type (later made into torch tensor) or list of such keys. A list can be used to subset to certain keys in the event that more tensors than needed have been registered. If None, defaults to all registered data.

  • iter_ndarray (bool (default: False)) – Whether to iterate over numpy arrays instead of torch tensors

  • data_loader_kwargs – Keyword arguments for DataLoader

Attributes table#

multiprocessing_context

Methods table#

check_worker_number_rationality()

Attributes#

AnnDataLoader.multiprocessing_context[source]#
AnnDataLoader.dataset: Dataset[T_co]#
AnnDataLoader.batch_size: Optional[int]#
AnnDataLoader.num_workers: int#
AnnDataLoader.pin_memory: bool#
AnnDataLoader.drop_last: bool#
AnnDataLoader.timeout: float#
AnnDataLoader.sampler: Union[Sampler, Iterable]#
AnnDataLoader.pin_memory_device: str#
AnnDataLoader.prefetch_factor: Optional[int]#

Methods#

AnnDataLoader.check_worker_number_rationality()[source]#