nufeb_tools package
Subpackages
Submodules
nufeb_tools.generate_atom module
-
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
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
-
class
nufeb_tools.generate_atom_dev.
Culture
(args)[source] Bases:
object
Create a collection of cells with defined positions, lengths, and orientations
-
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.
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
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)
-
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
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
-
biomass
Pandas Dataframe containing the biomass vs time data from biomass.csv
- Type
-
ntypes
Pandas Dataframe containing the cell number vs time data from ntypes.csv
- Type
-
avg_con
Pandas Dataframe containing the average nutrient concentrations vs time data from avg_concentration.csv
- Type
-
positions
Pandas Dataframe containing the single cell biomass over time of all cell ids present at the timepoint
- Type
-
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
-
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_fitness
(timestep, cellID)[source] Get the fitness of an individual cell based on the relative Monod growth rate at a given timestep
-
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
-
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
-
get_neighbor_distance
(id, timepoint)[source] Get the nearest neighbor cell distances
- Parameters
- Returns
Dataframe containing ID, type, Distance
- Return type
-
-
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.
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)) –