spared.dataloaders.get_pretrain_dataloaders

spared.dataloaders.get_pretrain_dataloaders(adata: AnnData, layer: str = 'c_d_log1p', batch_size: int = 128, shuffle: bool = True, use_cuda: bool = False) Tuple[AnnLoader, AnnLoader, AnnLoader][source]

Get dataloaders for pretraining an image encoder. This function returns the dataloaders for training an image encoder. This means training a purely vision-based model on only the patches to predict the gene expression of the patches.

Dataloaders are returned as a tuple, if there is no test set for the dataset, then the test dataloader is None.

Parameters:
  • adata (ad.AnnData) – The AnnData object that will be processed.

  • layer (str, optional) – The layer to use for the pre-training. The adata.X will be set to that of ‘layer’. Defaults to ‘deltas’.

  • batch_size (int, optional) – The batch size of the loaders. Defaults to 128.

  • shuffle (bool, optional) – Whether to shuffle the data in the loaders. Defaults to True.

  • use_cuda (bool, optional) – True for using cuda in the loader. Defaults to False.

Returns:

The train, validation and test dataloaders. If there is no test set, the test dataloader is None.

Return type:

Tuple[AnnLoader, AnnLoader, AnnLoader]