twinfer.plotting.network_plots.plot_grn
- twinfer.plotting.network_plots.plot_grn(matrix, node_labels=None, figsize=None, node_color='#1a1a1a', font_size=None, label_font_size=None, font_color='black', title=None, ax=None, fixed_pos=None, show_colorbar=True, vmin=None, vmax=None, *, terminal_spread=0.38, terminal_angle_tolerance=1.1, reciprocal_separation=0.3, reciprocal_curve=0.18, terminal_depth_step=0.35, max_shift_fraction=0.92, edge_halo=True, edge_styles=None, undirected_edges=None, colorbar_label='Edge Weight', edge_colors=None, edge_signs=None)[source]
Plot a signed, weighted directed GRN.
Matrix convention
matrix[i, j] represents:
node i -> node j
- Positive value:
activation arrow
- Negative value:
repression bar
Reciprocal-pair rule
If both u -> v and v -> u exist:
- lower-index source -> higher-index target:
straight
- higher-index source -> lower-index target:
curved
- param terminal_spread:
Angular spacing between neighboring crowded terminals.
- param terminal_angle_tolerance:
Natural terminal directions within this angular distance are treated as crowded.
- param reciprocal_separation:
Small endpoint separation retained for reciprocal edges.
- param reciprocal_curve:
Magnitude of the curve used for one edge in each reciprocal pair.
- param terminal_depth_step:
Radial staggering of crowded target symbols, in node-radius units.
- param edge_styles:
Optional dict {(source, target): Matplotlib line style}, e.g. {(0, 1): “–”} draws the edge 0 -> 1 dashed. Edges not in the dict are solid. Arrowheads and repression bars stay solid.
- param undirected_edges:
Optional collection of (source, target) edges drawn as a plain line without arrowhead or repression bar (an association with no direction). Give each such pair once: matrix[source, target] must be non-zero and matrix[target, source] zero.
- param colorbar_label:
Label of the colour bar (when show_colorbar is True).
- param edge_colors:
Optional dict {(source, target): Matplotlib colour}, e.g. {(0, 1): “tab:blue”}: the edge 0 -> 1 (line, arrowhead or bar) is drawn in that colour instead of the colour of its weight. Edges not in the dict are coloured by weight.
- param edge_signs:
Optional dict {(source, target): +1 or -1}: arrowhead (+1) or repression bar (-1) of that edge, instead of the sign of its weight; the colour still follows the weight. Edges not in the dict take the sign of their weight.
Notes
network_from_scenarios builds the matrix, edge_styles, undirected_edges and edge_colors from the output of twinfer.inference.covariance_decomposition_z_scores.infer_with_twinfer.