rnaglib.drawing

Draw RNA

rnaglib.drawing.rna_draw.make_label(s)
rnaglib.drawing.rna_draw.process_axis(axis, g, subtitle=None, highlight_edges=None, node_color=None, node_labels=None, node_ids=False, layout='spring', label='LW')[source]

Draw a graph on a given axis.

Parameters:
  • axis – matplotlib axis to draw on

  • g – networkx graph to draw

  • subtitle – string to use as a subtitle on this axis

  • highlight_edges – A list of edges to highlight on the drawing

  • node_color

  • node_labels

  • node_ids

  • label

Returns:

rnaglib.drawing.rna_draw.rna_draw(g, title='', node_ids=False, highlight_edges=None, node_labels=None, node_colors=None, num_clusters=None, pos=None, pos_offset=(0, 0), scale=1, ax=None, show=False, alpha=1, save=False, node_size=250, fontsize=12, format='pdf', seed=None, layout='circular')[source]

Draw an RNA with the edge labels used by Leontis Westhof

Parameters:
  • nx_g

  • title

  • highlight_edges

  • node_colors

  • num_clusters

Returns:

rnaglib.drawing.rna_draw.rna_draw_pair(graphs, subtitles=None, highlight_edges=None, node_colors=None, save=None, show=False, node_ids=False)[source]

Plot a line of plots of graphs along with a value for each graph. Useful for graph comparison vizualisation

Parameters:
  • graphs – iterable nx graphs

  • estimated_value – iterable of values of comparison (optional)

  • iihighlight_edges

  • node_colors – iterable of node colors

Returns:

rnaglib.drawing.rna_draw.rna_draw_grid(graphs, subtitles=None, highlight_edges=None, node_colors=None, row_labels=None, save=None, show=False, format='png', grid_shape=None)[source]

Plot a line of plots of graphs along with a value for each graph. Useful for graph comparison vizualisation

Parameters:
  • graphs – list of lists containing nx graphs all lists must have the same dimension along axis 1. To skip a cell, add a None instead of graph.

  • estimated_value – iterable of values of comparison (optional)

  • highlight_edges

  • node_colors – iterable of node colors

Returns:

Draw RNA layout

rnaglib.drawing.rna_layout.rescale_layout(pos, scale=1)[source]

Return scaled position array to (-scale, scale) in all axes.

The function acts on NumPy arrays which hold position information. Each position is one row of the array. The dimension of the space equals the number of columns. Each coordinate in one column.

To rescale, the mean (center) is subtracted from each axis separately. Then all values are scaled so that the largest magnitude value from all axes equals scale (thus, the aspect ratio is preserved). The resulting NumPy Array is returned (order of rows unchanged).

Parameters:
  • pos (numpy array) – positions to be scaled. Each row is a position.

  • scale (number (default: 1)) – The size of the resulting extent in all directions.

Returns:

pos – scaled positions. Each row is a position.

Return type:

numpy array

rnaglib.drawing.rna_layout.circular_layout(G, scale=1, center=None, dim=2)[source]

Position nodes on a circle.

Parameters:
  • G (NetworkX graph or list of nodes) – A position will be assigned to every node in G.

  • scale (number (default: 1)) – Scale factor for positions.

  • center (array-like or None) – Coordinate pair around which to center the layout.

  • dim (int) – Dimension of layout. If dim>2, the remaining dimensions are set to zero in the returned positions.

Returns:

pos – A dictionary of positions keyed by node

Return type:

dict

Examples

>>> G = nx.path_graph(4)
>>> pos = nx.circular_layout(G)

Notes

This algorithm currently only works in two dimensions and does not try to minimize edge crossings.