spared.graph_operations.get_graphs_one_slide
- spared.graph_operations.get_graphs_one_slide(adata: AnnData, n_hops: int, layer: str, hex_geometry: bool) Tuple[dict, int][source]
Get neighbor graphs for a single slide. This function receives an AnnData object with a single slide and for each node computes the graph in an n_hops radius in a pytorch geometric format. The AnnData object must have both embeddings and predictions in the adata.obsm attribute.
It returns a dictionary where the patch names are the keys and a pytorch geometric graph for each one as values. NOTE: The first node of every graph is the center.
- Parameters:
adata (ad.AnnData) – The AnnData object with the slide data.
n_hops (int) – The number of hops to compute the graph.
layer (str) – The layer of the graph to predict. Will be added as y to the graph.
hex_geometry (bool) – Whether the slide has hexagonal geometry or not.
- Returns:
Tuple(dict,int) dict: A dictionary where the patch names are the keys and pytorch geometric graph for each one as values. The first node of every graph is the center. int: Max column or row difference between the center and the neighbors. Used for positional encoding.