spacenet.utils.add_node_labels#

spacenet.utils.add_node_labels(spatial_network, labels, node_label_name='label', nodes=None)#

A function to add labels to nodes in a spatial network. This can be used to add categorical labels (e.g. cell types) or continuous labels (e.g. gene expression levels) to nodes in the network. The labels will be added as a node attribute with the name specified by node_label (default is ‘label’).

Parameters:
spatial_networknetworkx.Graph

The spatial network to which to add node labels. Nodes should be indexed by integers.

labelsarray-like, np.ndarray or list

An array-like object containing the labels to add to the nodes. The length of this should match the number of nodes to which you want to add labels.

node_label_namestr, optional

The name of the node attribute to which to add the labels. Default is ‘label’.

nodesarray-like, np.ndarray or list, optional

An array-like object containing the indices of the nodes to which to add labels. If None, labels will be added to all nodes in the network. Default is None.

Returns:
None