scvi.dataloaders.AnnTorchDataset#
- class scvi.dataloaders.AnnTorchDataset(adata_manager, getitem_tensors=None)[source]#
Extension of torch dataset to get tensors from anndata.
Attributes table#
Returns the keys of the mappings in scvi data registry. |
Methods table#
|
|
Sets data attribute. |
|
Sets up the __getitem__ function used by Pytorch. |
Attributes#
registered_keys
Methods#
get_data
setup_data_attr
- AnnTorchDataset.setup_data_attr()[source]#
Sets data attribute.
Reduces number of times anndata needs to be accessed
setup_getitem
- AnnTorchDataset.setup_getitem()[source]#
Sets up the __getitem__ function used by Pytorch.
By default, getitem will return every single item registered in the scvi data registry and will attempt to infer the correct type. np.float32 for continuous values, otherwise np.int64.
If you want to specify which specific tensors to return you can pass in a List of keys from the scvi data registry. If you want to speficy specific tensors to return as well as their associated types, then you can pass in a dictionary with their type.
Paramaters#
- getitem_tensors:
Either a list of keys in the scvi data registry to return when getitem is called or a dictionary mapping keys to numpy types.
Examples
>>> sd = AnnTorchDataset(adata_manager, getitem_tensors =['X', 'batch'])
# following will only return the X and batch both by default as np.float32 >>> sd.setup_getitem()
# This will return X as an integer and batch as np.float32 >>> sd.setup_getitem(getitem_tensors = {‘X’:np.int64, ‘batch’:np.float32])