scirpy.util.graph.layout_components
- scirpy.util.graph.layout_components(graph, component_layout='fr_size_aware', arrange_boxes='squarify', pad_x=1.0, pad_y=1.0, layout_kwargs=None)
Compute a graph layout by layouting all connected components individually.
Adapted from https://stackoverflow.com/questions/53120739/lots-of-edges-on-a-graph-plot-in-python
- Parameters
- graph :
Graph
The igraph object to plot. Requires the vertex attribute “size”, corresponding to the node size.
- component_layout :
str
(default:'fr_size_aware'
) Layout function used to layout individual components. Can be anything that can be passed to
igraph.Graph.layout
orfr_size_aware
for a modified Fruchterman-Rheingold layouting algorithm that respects node sizes. Seescirpy.util.graph.layout_fr_size_aware()
for more details.- arrange_boxes : {‘size’, ‘rpack’, ‘squarify’}
Literal
[‘size’, ‘rpack’, ‘squarify’] (default:'squarify'
) How to arrange the individual components. Can be “size” to arange them by the component size, or “rpack” to pack them as densly as possible, or “squarify” to arrange them using a treemap algorithm.
- pad_x :
float
(default:1.0
) Padding between subgraphs in the x dimension.
- pad_y :
float
(default:1.0
) Padding between subgraphs in the y dimension.
- layout_kwargs :
dict
|None
Optional
[dict
] (default:None
) Additional arguments passed to the layouting algorithm used for each component.
- graph :
- Return type
- Returns
pos n_nodes x dim array containing the layout coordinates