nufeb_tools package

Subpackages

Submodules

nufeb_tools.generate_atom module

nufeb_tools.generate_atom.clean()[source]

Remove old NUFEB runs

nufeb_tools.generate_atom.main(args)[source]

Wrapper function to generate new NUFEB simulation conditions

Parameters

args (List[str]) – command line parameters as list of strings

nufeb_tools.generate_atom.parse_args(args)[source]

Parse command line parameters

Parameters

args (List[str]) – command line parameters as list of strings (for example ["--help"]).

Returns

command line parameters namespace

Return type

argparse.Namespace

nufeb_tools.generate_atom.run()[source]

Calls main() passing the CLI arguments extracted from sys.argv

This function can be used as entry point to create console scripts with setuptools.

nufeb_tools.generate_atom.setup_logging(loglevel)[source]

Setup basic logging

Parameters

loglevel (int) – minimum loglevel for emitting messages

nufeb_tools.generate_atom_dev module

This is a script to seed NUFEB simulations

class nufeb_tools.generate_atom_dev.Cell(Species, Group, idx, args, Info={'cyano': {'Decay': 0, 'Density': 370, 'Diameter': 1e-06, 'GrowthRate': 1.67e-05, 'Inertia': {'ixx': 0, 'ixy': 0, 'ixz': 0, 'iyy': 0, 'iyz': 0, 'izz': 9.2e-23}, 'K_s': {'co2': 0.000138, 'light': 0.00035, 'o2': 0.0002, 'suc': 0.01}, 'Maintenance': 0, 'Yield': 0.55, 'max_length': 5e-06, 'min_length': 1e-06}, 'ecw': {'Decay': 2e-05, 'Density': 236, 'Diameter': 7.3e-07, 'GrowthRate': 0.00027, 'Inertia': {'ixx': 0, 'ixy': 0, 'ixz': 0, 'iyy': 0, 'iyz': 0, 'izz': 9.2e-23}, 'K_s': {'co2': 0.05, 'light': 0, 'o2': 0.001, 'suc': 3.6}, 'Maintenance': 9.5e-07, 'Yield': 0.43, 'max_length': 2.72e-06, 'min_length': 1.94e-06}})[source]

Bases: object

Bacteria object class

Atom()[source]

Function to return atom (cell) positions to render atom.in file

Bacillus()[source]

Function to return rod shape (bacillus) parameters to render atom.in file

Check()[source]

Return cell position, orientation, and size

Report()[source]

Return cell position, orientation, and size

rotate(z_dim=False)[source]

Randomly generate cell orientation displacements based on input angle

class nufeb_tools.generate_atom_dev.Culture(args)[source]

Bases: object

Create a collection of cells with defined positions, lengths, and orientations

Check()[source]

Check initial positions of each cell and move one of them if there is a collision

class nufeb_tools.generate_atom_dev.Nutrient(c, d, mw, state, bc)[source]

Bases: object

Nutrient class to define the chemicals present in the simulation volume, their concentrations, and their properties

nufeb_tools.generate_atom_dev.clean()[source]
nufeb_tools.generate_atom_dev.main(args)[source]

Wrapper function to generate new NUFEB simulation conditions

Parameters

args (List[str]) – command line parameters as list of strings

nufeb_tools.generate_atom_dev.parse_args(args)[source]

Parse command line parameters

Parameters

args (List[str]) – command line parameters as list of strings (for example ["--help"]).

Returns

command line parameters namespace

Return type

argparse.Namespace

nufeb_tools.generate_atom_dev.run()[source]

Calls main() passing the CLI arguments extracted from sys.argv

This function can be used as entry point to create console scripts with setuptools.

nufeb_tools.generate_atom_dev.setup_logging(loglevel)[source]

Setup basic logging

Parameters

loglevel (int) – minimum loglevel for emitting messages

nufeb_tools.maketestplots module

nufeb_tools.plot module

nufeb_tools.plot.average_nutrients(df, nutrient, ax=None, legend=None, **kwargs)[source]

This is a function to plot the nutrient concentration over time

Parameters
  • df (pandas.DataFrame) – Pandas Dataframe containing nutrient data

  • nutrient (str) – Name of the nutrient to plot, e.g., 'Sucrose'

  • ax – Axis on which to make the plot

  • legend (bool) – Include legend in the plot

  • **kwargs – Additional arguments to pass to plt.plot

nufeb_tools.plot.biomass_time(df, id=None, ax=None, legend=None, **kwargs)[source]

This is a function to plot the cell biomass over time

Parameters
  • df (pandas.DataFrame) – Pandas Dataframe containing biomass data

  • ax – Axis on which to make the plot

  • legend (bool) – Include legend in the plot

  • **kwargs – Additional arguments to pass to plt.plot

nufeb_tools.plot.colony(obj, time, colors=None, colony=None, ax=None, by=None, img=array([], dtype=float64), fitness=None, overlay=None, **kwargs)[source]

Plot bacterial colonies at a specific timepoint

Parameters
  • obj (nufeb_tools.utils.get_data) – Object containing cell locations

  • time (int) – Simulation timestep to plot

  • colors (dict, optional) – Dictionary of colors to plot each colony. Defaults to random.

  • colony (int, optional) – Plot a specific colony. Defaults to None.

  • ax (matplotlib.pyplot.axes, optional) – Axis to plot on. Defaults to None.

  • by (str, optional) – Plot by species. Defaults to None.

  • img (np.array, optional) – Image array to overlay colonies onto.

  • fitness (pandas.DataFrame,optional) – Takes a dataframe containing spatial metrics data as an input or if bool, will calculate the metrics internally. Defaults to None.

  • overlay (bool, optional) – If True, plot a specific colony on top of the others.

nufeb_tools.plot.colorFaderRGB(c1, c2, n)[source]

fade (linear interpolate) from color c1 (at mix=0) to c2 (mix=1)

Parameters
  • c1 (str) – Starting color

  • c2 (str) – Ending color

  • n (int) – Number of gradations

Returns

List containing tuples of RGB colors

Return type

list(tuple)

nufeb_tools.plot.get_growth_intervals(dataframe, cellID)[source]
nufeb_tools.plot.growth_curve_panel(df, **kwargs)[source]

Make growth curves panel with all cells

Parameters
  • df (pandas.DataFrame) – Pandas Dataframe containing biomass data

  • **kwargs – Additional arguments to pass to plt.plot

nufeb_tools.plot.growth_rate_div(df, **kwargs)[source]

Plot a heatmap of the single cell growth rates relative to each division

Parameters
  • df (pandas.DataFrame) – Pandas Dataframe containing biomass data

  • **kwargs – Additional arguments to pass to plt.plot

nufeb_tools.plot.growth_rate_mu(df, **kwargs)[source]

Plot a heatmap of the single cell growth rates relative to each division

Parameters
  • df (pandas.DataFrame) – Pandas Dataframe containing biomass data

  • **kwargs – Additional arguments to pass to plt.plot

nufeb_tools.plot.growth_rate_time(df, period=3)[source]

Plot a heatmap of the single cell growth rates over time

Parameters
  • df (pandas.DataFrame) – Pandas Dataframe containing biomass data

  • period (int) – Number of timesteps to average growth rate calculation over

  • **kwargs – Additional arguments to pass to plt.plot

Returns

matplotlib.figure.Figure

nufeb_tools.plot.overall_growth(df, ax=None, **kwargs)[source]

This is a function to generate growth curve plots

Parameters
  • df (pandas.DataFrame) – Pandas Dataframe containing biomass data over time

  • ax (plt.ax) – Axis to plot data on

  • **kwargs

nufeb_tools.spatial module

nufeb_tools.spatial.fitness_metrics(obj)[source]

Function to calculate colony-level fitness metrics.

Mother cell: Cell ID which seeded the colony

Type: Cell type - cyanobacteria are type 1 and E. coli are type 2

Voronoi area: Area of species-specific Voronoi Tesselation at the beginning of the simulation

IPTG: Sucrose induction level

total biomass: Biomass of each colony at the end of the simulation (fg)

Nearest 1: Distance to nearest cyanobacteria colony

Nearest 2: Distance to nearest E. coli colony

Nearest Neighbor: Distance to nearest colony

IC1: Average distance to nearest cyanobacteria colony

IC2: Average distance to nearest E. coli colony

IC: Average distance to nearest colony

Relative Neighbor Dist 1: Distance to nearest cyanobacteria colony divided by IC1

Relative Neighbor Dist 2: Distance to nearest E. coli colony divided by IC2

Relative Neighbor Dist: Distance to nearest colony divided by IC

Z1: Relative neighbor distance 1 divided by sqrt(D_sucrose/mu_cyano)

Z2: Relative neighbor distance 2 divided by sqrt(D_sucrose/mu_ecw)

Z1_2: Relative neighbor distance 1 divided by sqrt(D_sucrose/mu_ecw)

Z2_1: Relative neighbor distance 2 divided by sqrt(D_sucrose/mu_cyano)

LogNearest 1: log(Nearest 1)

LogNearest 2: log(Nearest 2)

LogNearest: log(Nearest Neighbor)

Inv1: Inverse sum of neighbor distance 1

Inv2: Inverse sum of neighbor distance 2

Log Inv1: Log squared inverse sum of neighbor distance 1

Log Inv2: Log squared inverse sum of neighbor distance 2

Colony Area: 2D area of colony at the end of the simulation

Parameters

obj (nufeb_tools.utils.get_data) – Data object collected with nufeb_tools.utils.get_data

Returns

Dataframe containing colony number (mother cell ID), cell type, total biomass, colony area, Voronoi area, nearest neighbor, mean neighbor distance, etc.

Return type

pandas.DataFrame

nufeb_tools.utils module

nufeb_tools.utils.download_test_data(urls=['https://github.com/Jsakkos/nufeb-tools/raw/main/data/runs.tar'])[source]

Get an example dataset from the Github repo. Downloads to “home/.nufeb_tools/data”

Parameters

urls (List(str)) –

class nufeb_tools.utils.get_data(directory=None, id=None, test=None, timestep=10)[source]

Bases: object

Collect results for analysis.

NUFEB simulation data class to collect results for analysis

test

Set test = True to get example data from the Github repository

Type

bool

directory

Path to the directory containing NUFEB simulation data.

Type

str

timestep

Length of simulation timestep in seconds

Type

int

SucRatio

Relative cyanobacterial sucrose secretion level, 0-100

Type

int

timepoints

List of timepoints in the simulation

Type

List(str)

dims

Size of the simulation boundaries in micrometers

Type

List(str)

numsteps

Number of timepoints

Type

int

biomass

Pandas Dataframe containing the biomass vs time data from biomass.csv

Type

pandas.DataFrame

ntypes

Pandas Dataframe containing the cell number vs time data from ntypes.csv

Type

pandas.DataFrame

avg_con

Pandas Dataframe containing the average nutrient concentrations vs time data from avg_concentration.csv

Type

pandas.DataFrame

positions

Pandas Dataframe containing the single cell biomass over time of all cell ids present at the timepoint

Type

pandas.DataFrame

calc_biomass()[source]
collect_fitness()[source]
collect_positions(h5)[source]

Extract the x, y, z position of each cell during the simulation.

Parameters

timepoint (int) – The simulation timestep to get the position data from.

Returns

Dataframe containing Timestep, ID, type, radius, x, y, z columns

Return type

pandas.DataFrame

convert_units_avg_con()[source]

Convert the object attribute avg_con, which contains the average nutrient concentration, units to hours and mM.

convert_units_biomass()[source]

Convert the object attribute biomass units to hours and femtograms.

count_colony_area(timestep)[source]

Count the 2d area in pixel dimensions of each colony at a given timestep.

Parameters

timestep (int) – Timestep to count

get_colony_areas()[source]

Count colony areas for all timesteps

get_fitness(timestep, cellID)[source]

Get the fitness of an individual cell based on the relative Monod growth rate at a given timestep

Parameters
  • timestep (int) – The timestep at which to check the concentration

  • cellID (int) – The cell identification number

Returns

The Monod growth rate (1/s)

Return type

float

get_local_con(timestep, cellID)[source]

Get the local nutrient concentration of a cell

Parameters
  • timestep (int) – The timestep at which to check the concentration

  • cellID (int) – The cell identification number

Returns

The concentration of the specified nutrient within the cell’s grid

Return type

Nutrient Concentration (float)

get_local_data()[source]

Collect NUFEB simulation data from a local directory.

get_mothers()[source]

Assign mother cells based on initial cells in the simulation.

Returns

Dataframe containing Timestep, ID, type, position, radius, biomass, total biomass, and mother_cell

Return type

pandas.DataFrame

get_mothers__old()[source]

Assign mother cells based on initial cells in the simulation.

Returns

Dataframe containing ID, type, position, radius, and mother_cell

Return type

pandas.DataFrame

get_neighbor_distance(id, timepoint)[source]

Get the nearest neighbor cell distances

Parameters
  • id (int) – The ID of the reference cell

  • timepoint (int) – The timepoint to check the neighbor distances from

Returns

Dataframe containing ID, type, Distance

Return type

pandas.DataFrame

get_neighbors(timestep)[source]

Get the nearest neighbor cell distances

Parameters

timestep (int) – The timepoint to check the neighbor distances from

Returns

Pandas dataframe containing pairwise neighbor distances

Return type

pd.DataFrame

get_nutrient_grid(h5)[source]
nufeb_tools.utils.get_grid_idx(array, value)[source]

Find the nutrient grid index value. Taken from https://stackoverflow.com/questions/2566412/find-nearest-value-in-numpy-array.

Parameters
  • array (numpy.array) – 1D Array containing the grid positions

  • value (float) – Cell location to map to the grid

Returns

Grid index

Return type

index (int)

nufeb_tools.whole_culture_growth_curves module

Created on Fri Jun 4 11:40:31 2021

@author: Jonathan Sakkos

nufeb_tools.whole_culture_growth_curves.main(args)[source]

Wrapper function

Parameters

args (List[str]) – command line parameters as list of strings (for example ["--verbose", "42"]).

nufeb_tools.whole_culture_growth_curves.parse_args(args)[source]

Argument parser

Parameters

args (List(str)) –

nufeb_tools.whole_culture_growth_curves.run()[source]

Calls main() passing the CLI arguments extracted from sys.argv

nufeb_tools.whole_culture_growth_curves.whole_culture_growth_curves(args)[source]

Module contents