athena.graph_builder.graphBuilder module¶
Reference¶
-
build_graph
(so, spl, builder_type='knn', mask_key='cellmasks', key_added=None, config=None, inplace=True, coordinate_keys=('x', 'y'))[source]¶ Build graph representation for a sample. A graph is constructed based on the provided segmentation masks for the sample. For the knn and radius graph representation the centroid of each mask is used. For the contact graph representation the segmentation masks are dilation is performed. The segmentation masks that overlap after dilation are considered to be in physical contact and connected in the contact graph.
- Parameters
so – SpatialOmics object
spl (
str
) – sample name in so.spl.indexbuilder_type – graph type to construct {knn, radius, contact}
mask_key – key in so.masks[spl] to use as segmentation masks from which the observation coordinates are extracted, if None coordinate_keys from obs attribute are used
key_added – key added in so.G[spl][key_add] to store the graph.
config – dict containing a dict ‘builder_params’ that specifies the graph construction parameters
inplace – whether to return a new SpatialOmics instance
coordinate_keys – column names of the x and y coordinates of a observation
- Returns
None or SpatialOmics if inplace = False