2.1.4. fluxpy.illustrations

Provide functions to ullistrate metaboloc modeling alaysis findings.

Submodules

Functions

plot_prod_env_3D(v1, v2, v3[, width, height])

This function takes as arguments 3 columns of the cobra production_envelope() result

plot_ranging_medium_compounds(model, dictionary_with_plots)

Plots the behavior of medium compounds in a metabolic model across different concentrations.

plot_nutrients_gradient(gradient[, nutrients, ...])

For each nutrient on a gradient it returns differences for the minimum and maximum cases

qcfa_subgraphs(H[, run_app, save_cx2, cx2_output_path])

Creates and runs a Dash application to visualize the QCFA subgraphs using a network graph.

flux_cone_example([facets, radius, cone_height, ...])

Generates a 3D plot of a flux cone with random points inside it.

Package Contents

fluxpy.illustrations.plot_prod_env_3D(v1: pandas.Series, v2: pandas.Series, v3: pandas.Series, width=800, height=600)[source]

This function takes as arguments 3 columns of the cobra production_envelope() result to return a 3D scatter plot of those.

Parameters:
  • x-axis (v1 -- flux vector for) –

  • y-axis (v2 -- flux vector for) –

  • values (v3 -- flux vector for z-axis which is used for the weight) –

Returns:

A 3D plolty.Figure object.

Usage example:

from cobra.io import load_model
model = load_model("textbook")
from cobra.flux_analysis import production_envelope
prod_env = production_envelope(model, ["EX_glc__D_e", "EX_o2_e"])
prod_env.head(3)
carbon_source   flux_minimum    carbon_yield_minimum    mass_yield_minimum      flux_maximum    carbon_yield_maximum    mass_yield_maximum      EX_glc__D_e     EX_o2_e
0       EX_glc__D_e     0.0     0.0     0.0     0.000000        0.000000        0.000000        -10.0   -60.000000
1       EX_glc__D_e     0.0     0.0     0.0     1.578947        0.052632        0.051748        -10.0   -56.842105
2       EX_glc__D_e     0.0     0.0     0.0     3.157895        0.105263        0.103496        -10.0   -53.684211
x=prod_env['EX_o2_e']
y=prod_env['EX_glc__D_e']
z=prod_env['flux_maximum']
fluxpy.illustrations.plot_ranging_medium_compounds(model: cobra.Model, dictionary_with_plots, dpi=500)[source]

Plots the behavior of medium compounds in a metabolic model across different concentrations.

Parameters:
  • model (object) – The metabolic model object.

  • dictionary_with_plots (dict) – A dictionary where keys are compound IDs, and values are tuples containing lists of concentrations and corresponding flux values to plot.

  • dpi (int, optional) – Dots per inch (resolution) for the saved figure. Default is 500.

Returns:

A .png file

fluxpy.illustrations.plot_nutrients_gradient(gradient, nutrients=None, threshold=0.2, width_size=12, height_size=12, save_fig=False, path='gradient.png', dpi=500)[source]

For each nutrient on a gradient it returns differences for the minimum and maximum cases and plots a heatmap for each where reaction that are affected with the increase of the upper bound at least threshold*max_difference are displayed.

gradient – output of the utils.get_nutrients_gradient() nutrients – list with the reaction ids to be considered threshold – per centage of the max difference that will be used to filter differences width_size – width of each subplot height_size – height of eash subplot

fluxpy.illustrations.qcfa_subgraphs(H: networkx.Graph, run_app=False, save_cx2=False, cx2_output_path='qfca_graph.cx2')[source]

Creates and runs a Dash application to visualize the QCFA subgraphs using a network graph.

Parameters:
  • H (networkx.Graph, mandatory) – A NetworkX graph where nodes represent reactions and edges represent relationships between them. The edge colors denote different types of couplings.

  • save_cx2 (boolean, optional) – Export dash cytoscape to a .cx2 format and save it as a file that can be then loaded in Cytoscape Desktop

  • cx2_output_path (string, optional) – Path and output filename for the .cx2 file

Returns:

An _ExportedGraph object with either a dash Cytoscape graph or both a dash Cytoscape and a .cx2 formatted graph with the QFCA-oriented graph. To access each:

fluxpy.illustrations.flux_cone_example(facets=5, radius=5, cone_height=5, width=1000, height=1000)[source]

Generates a 3D plot of a flux cone with random points inside it.

Parameters:
  • facets (int) – Number of facets (sides) for the cone surface.

  • radius (float) – Radius of the base of the cone.

  • cone_height (float) – Height of the cone.

  • width (int) – Width of the plot in pixels.

  • height (int) – Height of the plot in pixels.

Returns:

A Plotly figure object containing the 3D plot of the cone and the points inside it.

Return type:

plotly.graph_objects.Figure