biocrnpyler.utils.plotting

Functions

generate_networkx_graph(CRN[, useweights, ...])

generates a networkx DiGraph object that represents the CRN. input: ========================== CRN: a CRN from mixture.get_model() for example useweights: this will attempt to represent the reaction rates by the length of edges. short edges are fast rates. It doesn't look very good usually use_pretty_print: this uses the "pretty print" function to represent reactions and nodes a bit cleaner the next three parameters are pretty_print parameters pp_show_material: default false because this is listed in "type" pp_show_rates: default true because this is useful information pp_show_attributes colordict: a dictionary containing which node types are what color based upon the following keywords: Keywords are chosen to match species.material_type {"complex": "cyan", "protein": "green", "dna": "grey", "rna": "orange", "ligand": "pink", "phosphate": "yellow", "nothing":"purple"}.

graphPlot(DG, DGspecies, DGreactions, plot)

given a directed graph, plot it! Inputs: DG: a directed graph of type DiGraph DGspecies: a directed graph which only contains the species nodes DGreactions: a directed graph which only contains the reaction nodes plot: a bokeh plot object layout: graph layout function. 'force' uses fa2 to push nodes apart 'circle' plots the nodes and reactions in two overlapping circles, with the reactions on the inside of the circle 'custom' allows user input "layoutfunc". Internally, layoutfunc is passed the three inputs (DG, DGspecies, DGreactions) and should output a position dictionary with node {<node number>:(x,y)}.

makeArrows2(graph_renderer, graph, positions)

this function draws an arrow shape at the end of graph lines

render_constructs(constructs[, color_dictionary])

wrapper around CRNPlotter class to make a bunch of constructs which are color coordinated

render_mixture(mixture, crn[, ...])

render_network_bokeh(CRN[, layout, ...])

updateLimits(limits, xvalues)

Classes

CRNPlotter([dna_renderer, rna_renderer, ...])

biocrnpyler.utils.plotting.generate_networkx_graph(CRN, useweights=False, use_pretty_print=False, pp_show_material=True, pp_show_rates=True, pp_show_attributes=True, pp_show_compartment=True, colordict=None, reactioncolordict=None, imagedict=None)[source]

generates a networkx DiGraph object that represents the CRN. input: ========================== CRN: a CRN from mixture.get_model() for example useweights: this will attempt to represent the reaction rates by the length of edges.

short edges are fast rates. It doesn’t look very good usually

use_pretty_print: this uses the “pretty print” function to represent reactions and nodes a bit cleaner the next three parameters are pretty_print parameters

pp_show_material: default false because this is listed in “type” pp_show_rates: default true because this is useful information pp_show_attributes

colordict: a dictionary containing which node types are what color based upon the following keywords:
Keywords are chosen to match species.material_type

{“complex”: “cyan”, “protein”: “green”, “dna”: “grey”, “rna”: “orange”, “ligand”: “pink”, “phosphate”: “yellow”, “nothing”:”purple”}

When using a custom colordict, the following attributes will be checked to find colors with the first keys taking precedence:

repr(species): “color” species.name: “color” (species.material_type, tuple(species.attributes)): “color” species.material_type: “color” tuple(species.attributes): “color”

imagedict is a dictionary which contains species and their corresponding image representations. This is the output generated by CRNPlotter.renderMixture()

output:

CRNgraph: the DiGraph object containing all nodes and edges CRNspeciesonly: a DiGraph object with only species CRNreactionsonly: a DiGraph object with only reactions

biocrnpyler.utils.plotting.graphPlot(DG, DGspecies, DGreactions, plot, layout='force', positions=None, plot_species=True, plot_reactions=True, plot_edges=True, plot_arrows=True, species_glyph_size=12, reaction_glyph_size=8, posscale=1.0, layoutfunc=None, iterations=2000, rseed=30, show_species_images=False)[source]

given a directed graph, plot it! Inputs: DG: a directed graph of type DiGraph DGspecies: a directed graph which only contains the species nodes DGreactions: a directed graph which only contains the reaction nodes plot: a bokeh plot object layout: graph layout function.

‘force’ uses fa2 to push nodes apart ‘circle’ plots the nodes and reactions in two overlapping circles, with the reactions on the inside of the circle ‘custom’ allows user input “layoutfunc”. Internally, layoutfunc is passed the three inputs (DG, DGspecies, DGreactions)

and should output a position dictionary with node {<node number>:(x,y)}

positions: a dictionary of node names and x,y positions. this gets passed into the layout function posscale: multiply the scaling of the plot. This only affects the arrows because the arrows are a hack :(

biocrnpyler.utils.plotting.makeArrows2(graph_renderer, graph, positions, headsize=3, headangle=0.5235987755982988, make_arrows=True)[source]

this function draws an arrow shape at the end of graph lines

biocrnpyler.utils.plotting.render_constructs(constructs, color_dictionary=None)[source]

wrapper around CRNPlotter class to make a bunch of constructs which are color coordinated