nichesphere.tl.assign_properties#
- nichesphere.tl.assign_properties(g, communities, colors, pos=None, node_coord_sf=200, simmilarity_weights=False, g_unsigned=None, alpha=1)#
Assign properties to network g to visualize with gravis interactive networks
- Parameters:
g (nx.Graph) – Graph object with cell cell interaction scores as weights
communities (list of sets) – cell type communities
colors (list) – list of colors (one per community)
pos (dict (default: None)) – dictionary of node positions in a layout. Keys are cell types and values are arrays of x,y coordinates
node_coord_sf (int (default: 200)) – node coordinate scale factor to adapt to gravis
simmilarity_weights (bool (default: False)) – whether or not to have the simmilarity based weights (from the unsigned network)
g_unsigned (nx.Graph (default: None)) – Unsigned network generated directly from the adjacency matrix derived from the differential co-localization scores (with nx.from_pandas_adjacency)
alpha (float (default: 1)) – edge transparency parameter (from 0 to 1)
- Returns:
g – Graph object with cell cell interaction scores as weights and added properties (different options for node size scaling, like ‘size_betweeness’, ‘size_pagerank’ and ‘size_pagerank_uw’, node shape, color, x and y coordinates, options for edge weights, like ‘weight_signed’ (from co-localization/communication statistical test), ‘weight_abs’ (absolute values without signs), ‘weight_exp’ (exponentially scaled) and ‘weight_simmilarity’, edge color and size). Edges and nodes visualization options can be managed interactively with th gravis library
- Return type:
nx.Graph