scvi.data.AnnTorchDataset#

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

Extension of torch dataset to get tensors from AnnData.

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

  • getitem_tensors (Union[List[str], Dict[str, type], 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.

Examples

>>> sd = AnnTorchDataset(adata_manager, ['X', 'batch'])
>>> sd[[0, 1, 2]] # Return the X and batch data both as np.float32
>>> sd = AnnTorchDataset(adata_manager, {'X':np.int64, 'batch':np.float32]})
>>> sd[[0, 1, 2]] # Return the X as np.int64 and batch as np.float32

Attributes table#

registered_keys

Returns the keys of the mappings in scvi data registry.

Methods table#

get_data(scvi_data_key)

Get the tensor associated with a key.

Attributes#

AnnTorchDataset.registered_keys[source]#

Returns the keys of the mappings in scvi data registry.

Methods#

AnnTorchDataset.get_data(scvi_data_key)[source]#

Get the tensor associated with a key.