Usage
Chemostats.jl simulates individual cells in a Chemostat object.
Chemostats
Chemostats.Chemostat — Type
struct Chemostat{C,P}
pop::Vector{C}
p::P
snaps::Vector{Snapshot}
endChemostat object. The field pop contains the current population of cells. The field p can be a user-defined parameter object (defaults to nothing). snaps contains a list of Snapshots saved at different times.
Chemostats.simulate! — Function
simulate!(chem, tmax, alg, ensalg = EnsembleThreads(); saveat = [])Simulates the chemostat until time tmax with algorithm alg (see Simulation Algorithms for a list of algorithms). ensalg can be EnsembleSerial() for single-threaded simulations, or EnsembleThreads() for multithreading (if alg support multithreading). The default ensalg is EnsembleThreads() for multithreaded algorithms, or EnsembleSerial() for single-threaded algorithms.
Chemostats.get_snapshot — Function
get_snapshot(chem::Chemostat, t = chem.t)
get_snapshot(snaps::AbstractVector{Snapshot}, t = snaps[end].t)Searches and returns for a population snapshot saved at time t. Errors if no snapshots are found. If multiple snapshots at time t exist, this function returns the last one.
Estimating population sizes
Chemostats.Snapshot — Type
struct Snapshot
t::Float64
N::Int
nsim::Int
log_f::Float64
endSaves the state of a simulate dpopulation at a fixed time t. Here N is the observed size of the population, and log_f is minus the log fraction of the true population observed. This allows us to use subsampling algorithms (see Simulation Algorithms) that only track a small subset of a full population and extrapolate.
The true population size can be estimated using est_logN or est_N. The field nsim counts the number of cells simulated until the current snapshot (including partially simulated and removed cells).
Chemostats.est_Λ — Function
est_Λ(snap1::Snapshot, snap2::Snapshot)Estimates the growth rates from two snapshots at times $t_1$ and $t_2$ via
$\hat \Lambda(t_1, t_2) = \frac{\log \hat N(t_2) - \log \hat N(t_1)}{t_2 - t_1}$
Here $\hat N(t_1)$ and $\hat N(t_2)$ are estimated via est_N.
est_Λ(snaps::AbstractVector{Snapshot}, t1 = 0., t2)Estimates the growth rate of a population between times t1 and t2 by combining get_snapshot and est_Λ. snaps can alternatively be a Chemostat instance.
Chemostats.est_N — Function
est_N(snap::Snapshot)Estimates the true population size from a snapshot.
Chemostats.est_logN — Function
est_logN(snap::Snapshot)Estimates the true log-population size from a snapshot.
est_logN(snaps::AbstractVector{Snapshot}, t)Estimates the log-size of a population at time t by combining get_snapshot and est_logN. snaps can alternatively be a Chemostat instance.
The Cell API
Cells in Chemostat.jl can be of an user-defined type that implements the following functions. For models defined using DifferentialEquations.jl, the DECell class provides a direct wrapper.
(Mention step!)
Chemostats.get_curr_t — Function
get_curr_t(cell)Returns the current simulation time t of the cell.
Chemostats.get_state — Function
get_state(cell)Returns the current cell state, see CellState.
Chemostats.divide! — Function
divide!(cell)Called after a cell divides, as determined by Chemostats.get_offspring. After this call, Chemostats.get_state should return Divided.
Chemostats.die! — Function
die!(cell)Called after a cell dies, as determined by Chemostats.get_offspring. After this call, Chemostats.get_state should return Dead.
Chemostats.kill! — Function
kill!(cell, t)Called when a cell is killed by the simulation algorithm. The argument t is the time at which a cell is killed. After this call, Chemostats.get_state should return Killed.
Chemostats.get_offspring — Function
get_offspring(chem, cell; save_lineages=false)Returns an array of cells representing the offspring of the given cell. Here chem is the surrounding chemostat. If save_lineages is true, the resulting offspring should keep track of the parent cell.
Chemostats.clone_cell — Function
clone_cell(cell, t)Creates an independent of the copy of the cell at time t. Used by Chemostats.Strict to maintain a constant population size.
Chemostats.CellState — Module
@enumx CellStateThe current state of a cell as returned by Chemostats.get_state.
Newborn: Newborn cell that has not been simulated yet.Alive: Cell that is currently being simulated, but has not reached its end of life.EndOfLive: Cell that has reached its end of life, before its offspring are determined.Dead: Cell that has died, leaving no offspring.Divided: Cell that has divided into daughter cells.Killed: Cell that has been killed (e.g. removed), by the Simulation Algorithm.