scvi.data.AnnTorchDataset#

class scvi.data.AnnTorchDataset(adata_manager, getitem_tensors=None, load_sparse_tensor=False)[source]#

Extension of Dataset for AnnData objects.

Parameters:
adata_manager AnnDataManager

AnnDataManager object with a registered AnnData object.

getitem_tensors list | dict[str, type] | None (default: None)

Specifies the keys in the data registry (adata_manager.data_registry) to return in __getitem__. One of the following:

  • dict: Keys correspond to keys in the data registry and values correspond to the desired dtype of the returned data.

  • list: Elements correspond to keys in the data registry. Continuous data will be returned as float32 and discrete data will be returned as int64.

  • None: All registered data will be returned. Continuous data will be returned as float32 and discrete data will be returned as int64.

load_sparse_tensor bool (default: False)

EXPERIMENTAL If True, loads data with sparse CSR or CSC layout as a Tensor with the same layout. Can lead to speedups in data transfers to GPUs, depending on the sparsity of the data.

Attributes table#

data

Dictionary of data tensors.

keys_and_dtypes

Keys and corresponding dtype of data to fetch in __getitem__.

registered_keys

Keys in the data registry.

Methods table#

Attributes#

AnnTorchDataset.data#

Dictionary of data tensors.

First time this is accessed, data is fetched from the underlying AnnData object. Subsequent accesses will return the cached dictionary.

AnnTorchDataset.keys_and_dtypes#

Keys and corresponding dtype of data to fetch in __getitem__.

AnnTorchDataset.registered_keys#

Keys in the data registry.

Methods#