VirtualMicrobes.plotting package

Submodules

VirtualMicrobes.plotting.Graphs module

class VirtualMicrobes.plotting.Graphs.AttributeMap(mol_class_dict, reactions_dict, species_markers)[source]

Bases: object

activation_color(effect, domain=(-1, 1))[source]
color_mol(mol)[source]
color_mol_class(mc)[source]
color_protein(g)[source]
color_reaction(r)[source]
init_color_maps(species_markers)[source]
init_mol_class_color_dict(mol_class_dict)[source]
protein_type_line_style(type_)[source]
class VirtualMicrobes.plotting.Graphs.BindingNetwork(base_save_dir, name, attribute_dict=None, size=(35, 35), **kwargs)[source]

Bases: VirtualMicrobes.plotting.Graphs.Network

draw_network(self_marker=None, edge_effect='effect')[source]
init_network(cell, with_self_marker=True)[source]
layout_network_positions(prog)[source]

Compute and store node positions using a layout algorithm.

Parameters:prog (str) – layout algorithm
class VirtualMicrobes.plotting.Graphs.Genome(base_save_dir, name, attribute_dict, size=(10, 10), show=True, **kwargs)[source]

Bases: VirtualMicrobes.plotting.Graphs.Grapher

plot_genome_structure(cell, labels, video=None, max_size=None)[source]

Render the genome structure as a circular (plasmid-like) representation. :param cell: which genome is plotted

exception VirtualMicrobes.plotting.Graphs.GraphNotFoundError(value)[source]

Bases: VirtualMicrobes.plotting.Graphs.GraphingError

class VirtualMicrobes.plotting.Graphs.Grapher(base_save_dir, name, show=True, attribute_dict=None, clean=True, create=True)[source]

Bases: object

backup_plots()[source]
change_save_location(base_dir=None, name=None, clean=False, create=True)[source]
class_version = '1.0'
init_attribute_mapper(mol_class_dict, reactions_dict, species_markers)[source]
init_save_dir(clean=False, create=True)[source]
save_dir
save_fig(name=None, labels=[], title=None, suffix='.svg', copy_labels=None, **kwargs)[source]

Render and save a figure.

Parameters:
  • name (str) – base name of the figure
  • labels (iterable) – additional labels in file name
  • title (str) – printable title of figure
  • suffix (str) – file extension suffix
  • copy_labels (iterable) – additional labels for the filename of a copy of the figure
Returns:

Return type:

list of filenames of the saved figure(s)

save_fig2(ext, name=None, title=None, **kwargs)[source]

Render and save a figure.

Parameters:
  • name (str) – base name of the figure
  • title (str) – printable title of figure
  • suffix (str) – file extension suffix
Returns:

Return type:

filename of the saved figure

save_video(video=None, frame=None)[source]

Concat last plot to existing video (or, if first plot is made, make single framed video)

Parameters:
  • video (str) – alias to ffmpeg that is found during initialisation
  • frane (str) – frame number
  • suffix (str) – file extension suffix
Returns:

Return type:

filename of the saved figure

update_figure(show=None)[source]
upgrade(odict)[source]

Upgrading from older pickled version of class to latest version. Version information is saved as class variable and should be updated when class invariants (e.g. fields) are added. (see also __setstate__)

Adapted from recipe at http://code.activestate.com/recipes/521901-upgradable-pickles/

exception VirtualMicrobes.plotting.Graphs.GraphingError(value)[source]

Bases: exceptions.Exception

class VirtualMicrobes.plotting.Graphs.Graphs(base_save_dir, name, utility_path, mol_class_dict, reactions_dict, population_markers, species_markers, show, clean=True, create=True, **kwargs)[source]

Bases: VirtualMicrobes.plotting.Graphs.Grapher

Produces static and online graphs of simulated data.

add_grid_graphs_data(time_point, pop_grid_data_dict, small_mol_names, data_store, scaling_dict_updates, markers_range_dict)[source]
add_mol_evo_time_course_data(time_point, ext_res_conc_dict)[source]
add_multigraph(graph)[source]
add_pop_stats_data(time, most_fecundant_death_rate, most_fecundant_production, data_store, high_freq_cutoff=10)[source]
add_prot_grid_graphs_data(time_point, small_mol_names, reaction_dict, data_store)[source]
change_save_location(base_save_dir=None, name=None, clean=False, create=True)[source]
init_binding_network(show=None, clean=True, **kwargs)[source]
init_genome_structure(show=None, clean=True, **kwargs)[source]
init_grid_graphs(mol_class_dict, markers=[], nr_cols_markers=3, show=None, mol_classes_per_row=4, clean=True, **kwargs)[source]
init_metabolic_network(metabolites, conversions, imports, show=None, clean=True, **kwargs)[source]
init_phylo_tree_graph(show=None, clean=True, **kwargs)[source]
init_pop_stats(species_markers, reactions_dict, mol_class_dict, clean=True, show=None, **kwargs)[source]
init_prot_grid_graphs(mol_class_dict, reactions_dict, nr_cols=4, show=None, mol_classes_per_row=4, reactions_per_row=4, clean=True, **kwargs)[source]
init_scaling_dict()[source]
init_time_course_graph(show=None, clean=True, **kwargs)[source]
line_colors(name, nr)[source]
plot_binding_network(*args, **kwargs)[source]
Parameters:
  • cell – Who to plot
  • prog – (???)
  • save – Save the figure Y/N
  • write – Save the network file (gml, dot, json, etc.)

Nodes: Pumping enzymes are BLUE squares (ip = importing pump, e-p = exporting pump) Generic enzymes are BLUE / TURQUOISE circles Specific enzymes are GREEN / YELLOW / RED circles TFs are BROWN diamonds Thick borders indicates self-binding

Node-labels: Labels: Metabolites with brackets are building blocks Metabolites with asterisks are energy carriers

Edges: Width shows the basal level of transcription for the TF Colours distinquish inhibiting (blue) vs activating (red) effects. Intermediates are white-ish.

!! Note: still needs the ReST references worked out !!

plot_genome_structure(**kwargs)[source]
plot_grid_concentrations(dat)[source]
plot_grid_graphs(*args, **kwargs)[source]
plot_metabolic_network(*args, **kwargs)[source]
plot_mol_class_data(ax, mol_tc_dict, **plot_params)[source]
plot_pop_stats(*args, **kwargs)[source]
plot_prot_data(ax, prot_pert_type_tc_dict, **plot_params)[source]
plot_time_course(*args, **kwargs)[source]
class VirtualMicrobes.plotting.Graphs.MetabolicNetwork(base_save_dir, name, mol_class_dict, conversions, imports, size=(30, 30), attribute_dict=None, **kwargs)[source]

Bases: VirtualMicrobes.plotting.Graphs.Network

color_reactions(conversions, imports, building_blocks=[], self_marker=None, reac_color_func=None, mol_color_func=None, edge_color_func=None)[source]
draw_network(reactions_dict=None, self_marker=None, building_blocks=None)[source]
init_network(mol_class_dict, conversions, imports)[source]
layout_network_positions()[source]
class VirtualMicrobes.plotting.Graphs.MultiGraph(base_save_dir, name, rows, cols, row_heigth=2, col_width=4, attribute_dict=None, show=True, **kwargs)[source]

Bases: VirtualMicrobes.plotting.Graphs.Grapher

add_axis(name, pos, rows=1, cols=1, min_max_y=None, nr_lines=0, auto_scale=True, **plot_params)[source]
add_lines(ax_name, nr_lines, **line_customization)[source]
append_data(axes_name, xdata, ydata)[source]
append_to_axes(axes_name, xdata, ydata, line_in=[], autoscale=True)[source]
append_to_lines(axes_name, xdat, ydata_dict, autoscale=True)[source]
colors = <Mock name='mock.cm.get_cmap()()' id='140282440675472'>
cols
customize_lines(lines, markers=None, line_styles=None, marker_sizes=None, marker_edge_widths=None, colors=None)[source]
fill_grid(pos, rows, cols)[source]
grid_free(pos, rows, cols)[source]
line_markers = <Mock name='mock.MarkerStyle.filled_markers' id='140282438615760'>
line_styles = ['-', ':', '--', '-.']
marker_edge_widths = [0.1]
marker_sizes = [2.0]
rows
tight_layout(**kwargs)[source]
within_grid(pos, rows, cols)[source]
class VirtualMicrobes.plotting.Graphs.MultiGridGraph(base_save_dir, name, rows, cols, row_heigth=4, col_width=4, attribute_dict=None, show=True, **kwargs)[source]

Bases: VirtualMicrobes.plotting.Graphs.MultiGraph

classdocs

add_axis(name, pos, rows=1, cols=1)[source]
append_data(axes_name, time_point, data)[source]
append_to_axes(axes_name, time_point, data)[source]
plot_in_axes(axes_name, cm_name, matrix_data=None, data_range=None, color_bar=True)[source]
set_data_range(axes_name, _range)[source]
class VirtualMicrobes.plotting.Graphs.Network(base_save_dir, name, attribute_dict, size=(10, 10), show=True, **kwargs)[source]

Bases: VirtualMicrobes.plotting.Graphs.Grapher

add_self(marker)[source]
clear_graph()[source]
color_edge_direction(i)[source]
e_attr_list(attr, selectors=[])[source]
edges_with_attr_list(selectors=[])[source]
gene_node_id(gene)[source]
gene_node_label(gene_node_id, depth=1)[source]
init_network()[source]
metabolite_edge_width(bb, cell_bb=False)[source]
n_attr_list(attr, selectors=[])[source]
nodes_with_attr_list(selectors=[])[source]
redraw_network(**kwargs)[source]
type_shape(reac_type)[source]
write_to_file(name=None, labels=[], suffix='.gml', **kwargs)[source]
class VirtualMicrobes.plotting.Graphs.PhyloTreeGraph(base_save_dir, name, attribute_dict, show=True, **kwargs)[source]

Bases: VirtualMicrobes.plotting.Graphs.Grapher

Plot phylogenetic trees and represent the data in nodes with different layout styles.

compress_root_branch(root_branch_dist=20)[source]
metabolic_type_layout(node)[source]
metabolic_with_lod_layout(node)[source]
mutation_rates_layout(node, mut_type)[source]
node_layouts = ['metabolism', 'trophic_type', 'metabolic_with_lod']
rate_features = ['point_mut_rate', 'chromosomal_mut_rate', 'stretch_mut_rate', 'sequence_mut_rate', 'chromosome_dup_rate', 'chromosome_del_rate', 'tandem_dup_rate', 'stretch_del_rate', 'external_hgt_rate', 'internal_hgt_rate']
save_fig(feature='metabolism', name=None, labels=[], suffix='.svg', rescale=None, dpi=10, **kwargs)[source]

Render tree with layout function depending on the selected feature for tree representation.

Parameters:
  • feature – feature selects for a specific layout function, determining node style
  • name – name for saving
  • labels – labels to appear in save file name
  • suffix – suffix of save file name
select_layout_fn(data_type)[source]
trophic_type_layout(node, trophic_type)[source]
update(tree)[source]

Set new ete_tree.

update_figure(show=None, feature='metabolism', **kwargs)[source]
write_to_file(name=None, labels=[], suffix='.nw', **kwargs)[source]
exception VirtualMicrobes.plotting.Graphs.PositionOutsideGridError(value)[source]

Bases: VirtualMicrobes.plotting.Graphs.GraphingError

Module contents