This app allows exploration of a somewhat extended bacteria (or other extracellular pathogens) infection model.
Compared with the Basic Bacteria app, this model has one additional compartment and a few more processes.
Read about the model in The Model tab. Then, work through the tasks described in the What To Do tab.
In this simple model, we track bacteria and some (fairly abstract) notion of innate and adaptive immune response, using the following notation:
In addition to specifying the compartments or variables of a model, we need to specify the dynamics determining the changes for each compartment. Broadly speaking, there are processes or flows that increase the numbers in a given compartment/stage, and processes that lead to a reduction. Those processes are sometimes called in-flows and out-flows.
For our system, we specify the following processes/flows:
A very good way to describe compartmental models and move from a verbal description toward a mathematical/computational formulation is by using diagrams. Being able to go back and forth between verbal description, diagram and mathematical/computational model is a crucial skill when building models. The diagram for a compartmental model is often called flow diagram. It consists of a box for each compartment/variable (here B and I), and arrows pointing in and out of boxes to describe flows and interactions. For the model described above, the flow diagram looks as follows:
Model Diagram
For the diagrams in this R package, solid arrows indicate physical flows, i.e. movement from a compartment to another (e.g. bacteria moving out of the compartment because of death, or bacteria increasing in the compartment due to growth), while dashed arrows indicate interactions without physical flow (e.g. infected cells killing bacteria). This notation is not universal and it is common in the literature to see no distinction made between these 2 types of flows and only solid arrows being used.
The most common way to implement compartmental models is as a continuous-time, deterministic process, formulated as a set of ordinary differential equations (ODEs). Each compartment/variable gets an equation. The right side of each equations specifies the processes going on in the system and how they change the numbers in each compartment via inflows and outflows. For the model described above, the equations look like this:
\[\begin{align} \dot B &= g B (1-\frac{B}{B_{max}}) - d_B B - k_I B I - k_A B A \\ \dot I &= r_I B (1 -\frac{I}{I_{max}} ) - d_I I \\ \dot A &= r_A \frac{\log(I)}{h+\log(I)} A - d_A A \end{align}\]
The tasks below are described in a way that assumes everything is in units of days (rate parameters, therefore, have units of inverse days). If any quantity is not given in those units, you need to convert it first (e.g. if it says a cell lives for a week, you need to convert it to 7 days, then take the inverse if you want a death rate, which is what usually goes into the model).
This app and the Basic Bacteria app are very similar. Compare the model equations between the two apps.
Record
Further tasks to come. For now, you are free to explore on your own.
Record
This app (and all others) are structured such that the Shiny part
(the graphical interface you see and the server-side function that goes
with it) calls an underlying R script (or several) which runs the
simulation for the model of interest and returns the results. For this
app, the underlying function running the simulation is called
simulate_extendedbacteria_ode
. You can call it directly,
without going through the shiny app. Use the help()
command
for more information on how to use the function directly. If you go that
route, you need to use the results returned from this function and
produce useful output (such as a plot) yourself.
You can also download all simulator functions and modify them for your own purposes. Of course to modify these functions, you’ll need to do some coding.
For examples on using the simulators directly and how to modify them,
read the package vignette by typing vignette('DSAIRM')
into
the R console.
For further reading on some simple bacteria models, see the references in the basic bacteria app.