VirtualMicrobes.plotting package

Submodules

VirtualMicrobes.plotting.Graphs module

Created on Sep 13, 2014 @author: thocu

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]
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, **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]
change_save_location(base_save_dir=None, name=None, clean=False, create=True)[source]
init_binding_network(show=None, **kwargs)[source]
init_genome_structure(show=None, **kwargs)[source]
init_grid_graphs(mol_class_dict, markers=[], nr_cols_markers=3, show=None, mol_classes_per_row=4, **kwargs)[source]
init_metabolic_network(metabolites, conversions, imports, show=None, **kwargs)[source]
init_phylo_tree(show=None, **kwargs)[source]
init_pop_stats(species_markers, reactions_dict, mol_class_dict, show=None, **kwargs)[source]
init_scaling_dict()[source]
init_time_course_graph(show=None, **kwargs)[source]
line_colors(name, nr)[source]
plot_binding_network(obj, *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(*args, **kwargs)[source]
plot_grid_concentrations(dat)[source]
plot_grid_graphs(obj, *args, **kwargs)[source]
plot_metabolic_network(obj, *args, **kwargs)[source]
plot_mol_class_data(ax, mol_tc_dict, **plot_params)[source]
plot_phylo_tree(*args, **kwargs)[source]
plot_pop_stats(obj, *args, **kwargs)[source]
plot_prot_data(ax, prot_pert_type_tc_dict, **plot_params)[source]
plot_time_course(obj, *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 = array([[ 0. , 0. , 0.5 , 1. ], [ 0. , 0. , 0.58912656, 1. ], [ 0. , 0. , 0.67825312, 1. ], [ 0. , 0. , 0.76737968, 1. ], [ 0. , 0. , 0.85650624, 1. ], [ 0. , 0. , 0.96345811, 1. ], [ 0. , 0. , 1. , 1. ], [ 0. , 0.06470588, 1. , 1. ], [ 0. , 0.14313725, 1. , 1. ], [ 0. , 0.2372549 , 1. , 1. ], [ 0. , 0.31568627, 1. , 1. ], [ 0. , 0.39411765, 1. , 1. ], [ 0. , 0.47254902, 1. , 1. ], [ 0. , 0.55098039, 1. , 1. ], [ 0. , 0.64509804, 1. , 1. ], [ 0. , 0.72352941, 1. , 1. ], [ 0. , 0.80196078, 1. , 1. ], [ 0. , 0.88039216, 0.98355471, 1. ], [ 0.06008855, 0.9745098 , 0.90765338, 1. ], [ 0.12333966, 1. , 0.84440228, 1. ], [ 0.18659077, 1. , 0.78115117, 1. ], [ 0.24984187, 1. , 0.71790006, 1. ], [ 0.31309298, 1. , 0.65464896, 1. ], [ 0.38899431, 1. , 0.57874763, 1. ], [ 0.45224541, 1. , 0.51549652, 1. ], [ 0.51549652, 1. , 0.45224541, 1. ], [ 0.57874763, 1. , 0.38899431, 1. ], [ 0.65464896, 1. , 0.31309298, 1. ], [ 0.71790006, 1. , 0.24984187, 1. ], [ 0.78115117, 1. , 0.18659077, 1. ], [ 0.84440228, 1. , 0.12333966, 1. ], [ 0.90765338, 1. , 0.06008855, 1. ], [ 0.98355471, 0.94480755, 0. , 1. ], [ 1. , 0.87218591, 0. , 1. ], [ 1. , 0.79956427, 0. , 1. ], [ 1. , 0.72694263, 0. , 1. ], [ 1. , 0.63979666, 0. , 1. ], [ 1. , 0.56717502, 0. , 1. ], [ 1. , 0.49455338, 0. , 1. ], [ 1. , 0.42193174, 0. , 1. ], [ 1. , 0.34931009, 0. , 1. ], [ 1. , 0.26216412, 0. , 1. ], [ 1. , 0.18954248, 0. , 1. ], [ 1. , 0.11692084, 0. , 1. ], [ 0.96345811, 0.0442992 , 0. , 1. ], [ 0.85650624, 0. , 0. , 1. ], [ 0.76737968, 0. , 0. , 1. ], [ 0.67825312, 0. , 0. , 1. ], [ 0.58912656, 0. , 0. , 1. ], [ 0.5 , 0. , 0. , 1. ]])
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 = (u'o', u'v', u'^', u'<', u'>', u'8', u's', u'p', u'*', u'h', u'H', u'D', u'd')
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]
init_tree_style_dict(layouts=None)[source]
make_tree_style(layout=None, mode='c', leaf_names=False, face_overlap=True, arc_span=360, scale=None, branch_lengths=False, branch_vertical_margin=0)[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