spared.dataloaders.get_graph_dataloaders
- spared.dataloaders.get_graph_dataloaders(adata: AnnData, dataset_path: str = '', layer: str = 'c_t_log1p', n_hops: int = 2, backbone: str = 'densenet', model_path: str = 'None', batch_size: int = 128, shuffle: bool = True, hex_geometry: bool = True, patch_size: int = 224) Tuple[DataLoader, DataLoader, DataLoader][source]
Get dataloaders for the graphs of a dataset. This function performs all the pipeline to get graphs dataloaders for a dataset. It does the following steps:
Computes embeddings and predictions for the patches using the specified backbone and model.
Computes the graph dictionaries for the dataset using the embeddings and predictions.
Saves the graphs in the dataset_path folder.
Returns the train, validation and test dataloaders for the graphs.
The function also checks if the graphs are already saved in the dataset_path folder. If they are, it loads them instead of recomputing them. In case the dataset has no test set, the test dataloader is set to None.
- Parameters:
adata (ad.AnnData) – The AnnData object to process.
dataset_path (str, optional) – The path to the dataset (where the graphs will be stored). Defaults to ‘’.
layer (str, optional) – Layer to predict. Defaults to ‘c_t_log1p’.
n_hops (int, optional) – Number of hops to compute the graph. Defaults to 2.
backbone (str, optional) – Backbone model to use. Defaults to ‘densenet’.
model_path (str, optional) – Path to the model to use. Defaults to “None”.
batch_size (int, optional) – Batch size of the dataloaders. Defaults to 128.
shuffle (bool, optional) – Whether to shuffle the data in the dataloaders. Defaults to True.
hex_geometry (bool, optional) – Whether the graph is hexagonal or not. Defaults to True.
patch_size (int, optional) – Size of the patches. Defaults to 224.
- Returns:
_description_
- Return type:
Tuple[geo_DataLoader, geo_DataLoader, geo_DataLoader]