SOAPy_st.pp.make_network
- SOAPy_st.pp.make_network(adata: AnnData, sample_key: str | None = None, sample: str | int | list | None = None, cluster_key: str = 'clusters', method: Literal['radius', 'knn', 'regular', 'neighbor'] = 'knn', cutoff: float | int = 6, max_quantile: float | int = 98, exclude: str | dict | None = None, scale: str | float = 'hires', spatial_in_obsm: str = 'spatial', inplace: bool = True) AnnData
A function to create a network based on spatial information. We offer four different ways to build a network: KNN network, range radiation network, regular network
and First-order neighbor network
‘exclude’ is a parameter to exclude categories that cannot form an edge, you can set ‘same’ and ‘different’ to specifies the same/different clusters may not be connected.If you want to define a custom class of points that can’t be connected as edges, pass it as a dictionary.
Parameters
- adataanndata.AnnData
An AnnData object containing spatial omics data and spatial information.
- sample_keystr, optional
Batch’s key in adata.obs.
- sampleUnion[str, int, list], optional
The sample number for which the network needs to be built.
- cluster_keystr, optional
The column label of clusters in adata.obs.
- methodstr, optional
the method to make network, select in ‘Radius’ and ‘KNN’.
- cutoffUnion[float, int], optional
In KNN network and regular network, cutoff means number of neighbors to use. In range radiation network, cutoff means range of parameter space to use
- max_quantileUnion[float, int], optional
In Neighbor network, Order the distance of all sides, and more than max_quantile% of the sides will be removed
- excludeUnion[str, float], optional
Excluding categories that cannot form an edge.
- scaleUnion[str, float], optional
Scale used in subsequent analyses. If it’s Visium data it can also be HE image labels (hires or lower). Most of the time you don’t need to change this.
- spatial_in_obsmstr, optional
Keyword of coordinate information in obsm.
- inplacebool, optional
Whether to change the original adata.
Returns
uns['SOAPy']SOAPy generated parameters
uns['SOAPy']['indices']adjacency matrix of network
uns['SOAPy']['distance']distance matrix of network
uns['SOAPy']['edges']edges of network