wepy.analysis.network_layouts.tree module¶
Class for generating layouts for resampling trees.
Routines¶
ResamplingTreeLayout.layout
-
class
wepy.analysis.network_layouts.tree.
ResamplingTreeLayout
(node_radius=1.0, row_spacing=5.0, step_spacing=20.0, central_axis=0.0)[source]¶ Bases:
object
Class that wraps the parameters for generating resampling tree layouts.
Use the ‘layout’ method to generate inputs to a LayoutGraph for rendering.
Constructing the object is just a setting of the parameters and collection of methods for generating layout positions.
- Parameters
node_radius (float, optional) –
- Default node radius to use.
(Default value = 1.0)
row_spacing (float) –
- Spacing between nodes in a single row in layout.
(Default value = 5.0)
step_spacing (float) –
- Spacing between the rows of nodes in each step of the layout.
(Default value = 20.0)
central_axis (float) –
- X coordinate value to center each row around in the tree layout.
(Default value = 0.0)
-
_node_row_length
(node_positions, node_radii)[source]¶ Get the edge to edge length of a row of nodes.
- Parameters
node_positions –
node_radii –
- Returns
row_length
- Return type
-
_simple_gen_distribution
(nodes_x, node_radii)[source]¶ - Parameters
nodes_x –
node_radii –
- Returns
- Return type
new_nodes_positions
-
_simple_next_gen
(parents_x, children_parent_idxs, node_radii)[source]¶ - Parameters
parents_x –
children_parent_idxs –
node_radii –
- Returns
- Return type
children_x
-
_initial_parent_distribution
(node_radii)[source]¶ - Parameters
node_radii –
- Returns
- Return type
positions
-
_center_row
(positions, radii, center)[source]¶ Centers the midpoint of a row of nodes around a number.
- Parameters
positions –
radii –
center (float) –
- Returns
- Return type
centered_positions
-
_layout_array
(parent_table, radii_array)[source]¶ Generates the structured array of positions for nodes in the parent forest tree layout given the corresponding radii.
- Parameters
parent_table –
radii_array –
- Returns
- Return type
node_positions
-
layout
(parent_forest, node_radii=None)[source]¶ Given a parent forest object, returns a dictionary mapping nodes to their xyz layout coordinates.
If the node radii are given (as a dictionary mapping node ID to the desired radius) these are used as the the node radii and the default node radius parameter of the layout object is ignored.
Radii are needed to calculate the proper positions so there is no overlaps between nodes.
- Parameters
parent_forest (ParentForest object) –
node_radii (dict of node_id: float) –
- A dictionary mapping the nodes to node radii.
(Default value = None)
- Returns
node_coords – x, y, z coordinates for all nodes. Z will be 0 for all.
- Return type
dict of node_id: array_like of float of dim (3,)
- Raises
ValueError – If an invalid node_id is given.
- Warns
If some but not all nodes were given assigned radii. Uses
default value for unspecified nodes.