ecoli.analysis.colony.snapshots

class ecoli.analysis.colony.snapshots.LineWidthData(*args, **kwargs)[source]

Bases: Line2D

_get_lw()[source]
property _linewidth
_set_lw(lw)[source]
set(*, agg_filter=<UNSET>, alpha=<UNSET>, animated=<UNSET>, antialiased=<UNSET>, clip_box=<UNSET>, clip_on=<UNSET>, clip_path=<UNSET>, color=<UNSET>, dash_capstyle=<UNSET>, dash_joinstyle=<UNSET>, dashes=<UNSET>, data=<UNSET>, drawstyle=<UNSET>, fillstyle=<UNSET>, gapcolor=<UNSET>, gid=<UNSET>, in_layout=<UNSET>, label=<UNSET>, linestyle=<UNSET>, linewidth=<UNSET>, marker=<UNSET>, markeredgecolor=<UNSET>, markeredgewidth=<UNSET>, markerfacecolor=<UNSET>, markerfacecoloralt=<UNSET>, markersize=<UNSET>, markevery=<UNSET>, mouseover=<UNSET>, path_effects=<UNSET>, picker=<UNSET>, pickradius=<UNSET>, rasterized=<UNSET>, sketch_params=<UNSET>, snap=<UNSET>, solid_capstyle=<UNSET>, solid_joinstyle=<UNSET>, transform=<UNSET>, url=<UNSET>, visible=<UNSET>, xdata=<UNSET>, ydata=<UNSET>, zorder=<UNSET>)

Set multiple properties at once.

Supported properties are

Properties:

agg_filter: a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array and two offsets from the bottom left corner of the image alpha: scalar or None animated: bool antialiased or aa: bool clip_box: ~matplotlib.transforms.BboxBase or None clip_on: bool clip_path: Patch or (Path, Transform) or None color or c: :mpltype:`color` dash_capstyle: .CapStyle or {‘butt’, ‘projecting’, ‘round’} dash_joinstyle: .JoinStyle or {‘miter’, ‘round’, ‘bevel’} dashes: sequence of floats (on/off ink in points) or (None, None) data: (2, N) array or two 1D arrays drawstyle or ds: {‘default’, ‘steps’, ‘steps-pre’, ‘steps-mid’, ‘steps-post’}, default: ‘default’ figure: ~matplotlib.figure.Figure fillstyle: {‘full’, ‘left’, ‘right’, ‘bottom’, ‘top’, ‘none’} gapcolor: :mpltype:`color` or None gid: str in_layout: bool label: object linestyle or ls: {‘-’, ‘–’, ‘-.’, ‘:’, ‘’, (offset, on-off-seq), …} linewidth or lw: float marker: marker style string, ~.path.Path or ~.markers.MarkerStyle markeredgecolor or mec: :mpltype:`color` markeredgewidth or mew: float markerfacecolor or mfc: :mpltype:`color` markerfacecoloralt or mfcalt: :mpltype:`color` markersize or ms: float markevery: None or int or (int, int) or slice or list[int] or float or (float, float) or list[bool] mouseover: bool path_effects: list of .AbstractPathEffect picker: float or callable[[Artist, Event], tuple[bool, dict]] pickradius: float rasterized: bool sketch_params: (scale: float, length: float, randomness: float) snap: bool or None solid_capstyle: .CapStyle or {‘butt’, ‘projecting’, ‘round’} solid_joinstyle: .JoinStyle or {‘miter’, ‘round’, ‘bevel’} transform: ~matplotlib.transforms.Transform url: str visible: bool xdata: 1D array ydata: 1D array zorder: float

ecoli.analysis.colony.snapshots.add_time_axis(fig, grid, n_rows, n_cols, n_snapshots, snapshot_times, time_unit='s')[source]
ecoli.analysis.colony.snapshots.color_phylogeny(ancestor_id, phylogeny, baseline_hsv, phylogeny_colors=None)[source]

get colors for all descendants of the ancestor through recursive calls to each generation

ecoli.analysis.colony.snapshots.format_snapshot_data(data)[source]
ecoli.analysis.colony.snapshots.get_agent_colors(agents, phylogeny_names=True, agent_fill_color=None)[source]
ecoli.analysis.colony.snapshots.get_agent_ids(agents)[source]
ecoli.analysis.colony.snapshots.get_field_range(fields, time_vec, include_fields=None, skip_fields=None, min_pct=0.95, max_pct=1)[source]
ecoli.analysis.colony.snapshots.get_phylogeny_colors_from_names(agent_ids)[source]

Get agent colors using phlogeny saved in agent_ids This assumes the names use daughter_phylogeny_id() from meta_division

ecoli.analysis.colony.snapshots.get_tag_ranges(agents, tagged_molecules, time_indices, convert_to_concs, tag_colors)[source]
ecoli.analysis.colony.snapshots.init_axes(fig, edge_length_x, edge_length_y, grid, row_idx, col_idx, time, molecule, ylabel_size=20, title_size=12)[source]
ecoli.analysis.colony.snapshots.make_snapshots_figure(agents, fields, bounds, n_snapshots, time_indices, snapshot_times, time_unit='s', plot_width=12, field_range=None, agent_colors=None, dead_color=[0, 0, 0], membrane_width=0.1, membrane_color=[1, 1, 1], default_font_size=36, field_label_size=32, agent_shape='segment', agent_alpha=1, colorbar_decimals=3, show_timeline=True, scale_bar_length=1, scale_bar_color='black', xlim=None, ylim=None, min_color='white', max_color='gray', out_dir=None, filename='snapshots', figsize=None)[source]
Parameters:
  • bounds (tuple) – The dimensions of the environment.

  • field_label_size (float) – Font size of the field label.

  • dead_color (list of 3 float) – Color for dead cells in HSV. Defaults to [0, 0, 0], which is black.

  • default_font_size (float) – Font size for titles and axis labels.

  • agent_shape (str) – the shape of the agents. select from rectangle, segment

  • agent_alpha (float) – Alpha for agent plots.

  • colorbar_decimals (int) – number of decimals in colorbar.

  • scale_bar_length (float) – Length of scale bar. Defaults to 1 (in units of micrometers). If 0, no bar plotted.

  • scale_bar_color (str) – Color of scale bar

  • xlim (tuple of float) – Tuple of lower and upper x-axis limits.

  • ylim (tuple of float) – Tuple of lower and upper y-axis limits.

  • min_color (any valid matplotlib color) – Color for minimum field values.

  • max_color (any valid matplotlib color) – Color for maximum field values.

  • out_dir (str) – Output directory, which is out by default.

  • filename (str) – Base name of output file. snapshots by default.

  • figsize (tuple) – Dimensions of figure in inches (takes precedence over plot_width)

ecoli.analysis.colony.snapshots.make_tags_figure(agents, bounds, time_indices, snapshot_times, tag_ranges=None, tag_colors=None, min_color='black', agent_colors=None, n_snapshots=6, scale_bar_length=1, scale_bar_color='black', show_timeline=True, show_colorbar=True, time_unit='s', tagged_molecules=None, out_dir=False, filename='tags', agent_shape='segment', background_color='black', colorbar_decimals=1, tag_path_name_map=None, tag_label_size=20, plot_width=12, default_font_size=36, convert_to_concs=True, membrane_width=0.1, membrane_color=None, xlim=None, ylim=None, figsize=None, highlight_agent=None)[source]

Plot snapshots of the simulation over time

The snapshots depict the agents and the levels of tagged molecules in each agent by agent color intensity.

Parameters:

data (dict) –

A dictionary with the following keys:

  • agents (dict): A mapping from times to dictionaries of agent data at that timepoint. Agent data dictionaries should have the same form as the hierarchy tree rooted at agents.

  • n_snapshots (int): Number of snapshots to show per row (i.e. for each molecule). Defaults to 6.

  • out_dir (str): Output directory, which is out by default.

  • filename (str): Base name of output file. tags by default.

  • tagged_molecules (typing.Iterable): The tagged molecules whose concentrations will be indicated by agent color. Each molecule should be specified as a tuple of the path in the agent compartment to where the molecule’s count can be found, with the last value being the molecule’s count variable.

  • convert_to_concs (bool): if True, convert counts to concentrations.

  • background_color (str): use matplotlib colors, black by default

  • colorbar_decimals (int): number of decimals in colorbar.

  • tag_label_size (float): The font size for the tag name label

  • default_font_size (float): Font size for titles and axis labels.

  • membrane_width (float): Width to use for

    drawing agent edges.

  • membrane_color (list): RGB color to use

    for drawing agent edges.

  • tag_colors (dict): Mapping from tag ID to

    the HSV color to use for that tag as a list. Alternatively, each tag ID is mapped to a dictionary containing the cmp and norm keys with the matplotlib.colors.Colormap and the matplotlib.colors.Normalize instance to use for that tag. Using dictionaries will override min_color

  • figsize (tuple): Dimensions of figure in

    inches (takes precedence over plot_width)

  • highlight_agent (dict): Mapping of agent IDs to

    membrane_color and membrane_width. Useful for highlighting specific agents, with rest using default color / width

ecoli.analysis.colony.snapshots.make_video(data, bounds, plot_type='fields', step=1, highlight_agents=None, show_timeseries=None, highlight_color=[0, 1, 1], out_dir='out', filename='snapshot_vid', cpus=1, **kwargs)[source]

Make a video with snapshots across time

Parameters:

plot_type – (str) select either ‘fields’ or ‘tags’. ‘fields’ is the default

ecoli.analysis.colony.snapshots.mutate_color(baseline_hsv)[source]
ecoli.analysis.colony.snapshots.plot(params, conn, history_sql, config_sql, sim_data_paths, validation_data_paths, outdir, variant_metadata, variant_name)[source]
Parameters:
ecoli.analysis.colony.snapshots.plot_agent(ax, data, color, agent_shape, membrane_width=0.1, membrane_color=[0, 0, 0], alpha=1)[source]

Plot an agent

Parameters:
  • ax – The axes to draw on.

  • data (dict) – The agent data dictionary.

  • color (list) – HSV color of agent body.

  • agent_shape (str) – One of rectangle, segment, and circle.

  • membrane_width (float) – Width of drawn agent boundary.

  • membrane_color (list) – RGB color of drawn agent boundary.

ecoli.analysis.colony.snapshots.plot_agents(ax, agents, agent_colors=None, agent_shape='segment', dead_color=None, membrane_width=0.1, membrane_color=[1, 1, 1], alpha=1, highlight_agent=None)[source]

Plot agents.

Parameters:
  • ax – the axis for plot

  • agents (dict) – a mapping from agent ID to that agent’s data, which should have keys location, angle, length, and width.

  • agent_colors (dict) – Mapping from agent ID to HSV color.

  • dead_color (list) – List of 3 floats that define HSV color to use for dead cells. Dead cells only get treated differently if this is set.

  • membrane_width (float) – Width of agent outline to draw.

  • membrane_color (list) – List of 3 floats that define the RGB color to use for agent outlines.

  • alpha – Alpha value for agents.

  • highlight_agent – Mapping of agent ID to membrane_color and membrane_width. Useful for highlighting specific agents, with rest using default membrane_width and membrane_color

ecoli.analysis.colony.snapshots.plot_snapshots(bounds, agents=None, fields=None, n_snapshots=5, snapshot_times=None, agent_fill_color=None, agent_colors=None, phylogeny_names=True, skip_fields=None, include_fields=None, out_dir=None, filename='snapshots', min_pct=0.95, max_pct=1, **kwargs)[source]

Plot snapshots of the simulation over time

The snapshots depict the agents and environmental molecule concentrations.

Parameters:

data (dict) –

A dictionary with the following keys:

  • bounds (tuple): The dimensions of the environment.

  • agents (dict): A mapping from times to dictionaries of agent data at that timepoint. Agent data dictionaries should have the same form as the hierarchy tree rooted at agents.

  • fields (dict): A mapping from times to dictionaries of environmental field data at that timepoint. Field data dictionaries should have the same form as the hierarchy tree rooted at fields.

  • n_snapshots (int): Number of snapshots to show per row (i.e. for each molecule). Defaults to 6.

  • phylogeny_names (bool): This selects agent colors based on phylogenies seved in their names using meta_division.py daughter_phylogeny_id()

  • skip_fields (Iterable): Keys of fields to exclude from the plot. This takes priority over include_fields.

  • include_fields (Iterable): Keys of fields to plot.

  • snapshot_times (Iterable): Times to plot snapshots for. Defaults to None, in which case n_snapshots is used.

  • out_dir (str): Output directory, which is out by default.

  • filename (str): Base name of output file. snapshots by default.

  • min_pct (float): Percent of minimum value to use as minimum in colorbar (1 = 100%)

  • max_pct (float): Percent of maximum value to use as maximum in colorbar (1 = 100%)

ecoli.analysis.colony.snapshots.plot_tags(data, bounds, snapshot_times=None, n_snapshots=5, **kwargs)[source]
ecoli.analysis.colony.snapshots.save_snapshot_figure(data_at_time, kwargs)[source]
ecoli.analysis.colony.snapshots.save_tags_figure(data_at_time, kwargs)[source]
ecoli.analysis.colony.snapshots.save_timeseries_figure(t_index, kwargs)[source]
ecoli.analysis.colony.snapshots.video_from_images(img_paths, out_file)[source]