spateo.plotting.static.networks¶
Classes¶
Functions¶
|
Network graph using plotly, used to plot intercellular GRN as inferred by Spateo. |
Module Contents¶
- class spateo.plotting.static.networks.PlotNetwork(G: networkx.Graph | networkx.DiGraph, layout: str)[source]¶
-
- generate_node_traces(colorscale: str, colorbar_title: str, color_method: str | List[str], node_label: str, node_text: List[str], node_label_size: int, node_label_position: str, node_opacity: float, size_method: str | List[str], show_colorbar: bool = True) plotly.graph_objects.Scatter [source]¶
Formatting for nodes.
- Parameters:
- colorscale
Colormap to use for nodes
- colorbar_title
Title for the colorbar
- color_method
Either label of node property or list containing the color of each node
- node_label
Node property to be used as label
- node_text
List containing properties to be displayed when hovering over nodes
- node_label_size
Font size of node text
- node_label_position
Position of node labels. Options: ‘top left’, ‘top center’, ‘top right’, ‘middle left’, ‘middle center’, ‘middle right’, ‘bottom left’, ‘bottom center’, ‘bottom right’
- node_opacity
Transparency of nodes
- size_method
Either label of node property or list containing the size of each node
- show_colorbar
Set True to include colorbar, False to remove from plotting window
- Returns:
Plotly graph objects scatter plot
- Return type:
node_trace
- generate_edge_traces(edge_label: str, edge_label_size: int, edge_label_position: str, edge_text: List[str], edge_attribute_for_linestyle: str | None = None, edge_attribute_for_thickness: str | None = None, add_text: bool = False) Tuple[List[plotly.graph_objects.Scatter], plotly.graph_objects.Scatter] [source]¶
Formatting for edges
- Parameters:
- edge_label
Edge property to be used as label
- edge_label_size
Font size of edge text
- edge_label_position
Position of edge labels. Options: ‘top left’, ‘top center’, ‘top right’, ‘middle left’, ‘middle center’, ‘middle right’, ‘bottom left’, ‘bottom center’, ‘bottom right’
- edge_text
List containing properties to be displayed when hovering over edges
- edge_attribute_for_linestyle
Optional edge property to use for linestyle. If not given, will default to property given to ‘edge_label’.
- edge_attribute_for_thickness
Optional edge property to use for thickness. If not given, all edges will have thickness 1.
- add_text
If True, will add text corresponding to edge_label onto the edges rather than only adding different line styles.
- Returns:
Plotly graph objects scatter plots middle_node_trace: Labels are created by adding invisible nodes to the middle of each edge. This
trace contains information for these invisible nodes.
- Return type:
edge_traces
- generate_figure(node_trace: plotly.graph_objects.Scatter, edge_traces: List[plotly.graph_objects.Scatter], middle_node_trace: plotly.graph_objects.Scatter, title: str, title_font_size: int, arrow_size: float, transparent_background: bool, highlight_neighbors_on_hover: bool, upper_margin: float = 40, lower_margin: float = 20, left_margin: float = 50, right_margin: float = 50) plotly.graph_objects.FigureWidget [source]¶
Generate figure for graph
- spateo.plotting.static.networks.plot_network(G: networkx.Graph | networkx.DiGraph, title: str, size_method: str | List[float], color_method: str | List[str], layout: str | None = None, node_label: str | None = None, node_label_position: str = 'top center', node_text: List[str] = None, nodefont_size: int = 8, edge_label: str | None = None, edge_thickness_attr: str | None = None, edge_label_position: str = 'middle center', edge_text: List[str] = None, edgefont_size: int = 8, titlefont_size: int = 16, show_colorbar: bool = True, colorscale: str = 'YlGnBu', colorbar_title: str | None = None, node_opacity: float = 0.8, arrow_size: float = 2, transparent_background: bool = True, highlight_neighbors_on_hover: bool = True, upper_margin: float = 40, lower_margin: float = 20, left_margin: float = 50, right_margin: float = 50) plotly.graph_objects.FigureWidget [source]¶
Network graph using plotly, used to plot intercellular GRN as inferred by Spateo.
- Parameters:
- G
Networkx graph object
- title
Title of the plot
- size_method
Either label of node property or list containing the size of each node
- color_method
Either label of node property or list containing the color of each node
- layout
Controls shape of the plot. Options: - random (default): Position nodes uniformly at random in the unit square.
For every node, a position is generated by choosing each of dim coordinates uniformly at random on the interval [0.0, 1.0).
circular: Position nodes on a circle
kamada: Position nodes using Kamada-Kawai path-length cost-function
planar: Position nodes without edges intersecting (only if possible)
spring: Position nodes using Fruchterman-Reingold force-directed algorithm
spectral: Position nodes using eigenvectors of the graph Laplacian
spiral: Position nodes in a spiral layout
- node_label
Node property to be used as label
- node_label_position
Position of node labels. Options: ‘top left’, ‘top center’, ‘top right’, ‘middle left’, ‘middle center’, ‘middle right’, ‘bottom left’, ‘bottom center’, ‘bottom right’
- node_text
List containing properties to be displayed when hovering over nodes
- nodefont_size
Size of ‘node_label’
- edge_label
Edge property to be used as label
- edge_label_position
Position of edge labels. Options: ‘top left’, ‘top center’, ‘top right’, ‘middle left’, ‘middle center’, ‘middle right’, ‘bottom left’, ‘bottom center’, ‘bottom right’
- edge_thickness_attr
Edge property to be used for determining edge thickness
- edge_text
List containing properties to be displayed when hovering over edges
- edgefont_size
Size of ‘edge_label’
- titlefont_size
Size of title
- show_colorbar
Set True to display colorbar
- colorscale
Colormap used for the colorbar. Options: ‘Greys’, ‘YlGnBu’, ‘Greens’, ‘YlOrRd’, ‘Bluered’, ‘RdBu’, ‘Reds’, ‘Blues’, ‘Picnic’, ‘Rainbow’, ‘Portland’, ‘Jet’, ‘Hot’, ‘Blackbody’, ‘Earth’, ‘Electric’, ‘Viridis’
- colorbar_title
Colorbar title
- node_opacity
Node transparency, from 0 to 1, where 0 is completely transparent
- arrow_size
Size of the arrow for directed graphs, by default 2
- transparent_background
Set True for transparent background
- highlight_neighbours_on_hover
Set True to highlight neighbors of a node (by name) when hovering over it
- upper_margin
Margin between top of the plot and top of the figure
- lower_margin
Margin between bottom of the plot and bottom of the figure
- left_margin
Margin between left of the plot and left of the figure
- right_margin
Margin between right of the plot and right of the figure
- Returns:
Plotly figure widget object
- Return type:
fig