scvi.dataloaders.AnnTorchDataset.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.

getitem_tensors:

Either a list of keys in the scvi data registry to return when getitem is called or

Examples

>>> sd = AnnTorchDataset(adata)

# following will only return the X and batch_indices both by defualt as np.float32 >>> sd.setup_getitem(getitem_tensors = [‘X,’batch_indices’])

# This will return X as an integer and batch_indices as np.float32 >>> sd.setup_getitem(getitem_tensors = {‘X’:np.int64, ‘batch_indices’:np.float32])