Biology is the study of life
Life is a complex phenomenon
To understand life, biologists invented Systems Theory
April 21, 2020
Biology is the study of life
Life is a complex phenomenon
To understand life, biologists invented Systems Theory
Systems Theory was invented in 1948 by the biologist Ludwig von Bertalanffy
Today it is used by engineers, psychologists, managers, and other scientists
It is going to be one of the important ways of thinking in this century
A system is a group of parts that are interconnected and affect each other
Today we will study a system with two items
and one process
The arrows going into a box show which items are required for the process
At any given moment, there is some amount of each item in the system
Also, we can know how much did the amount changed between the previous moment and this moment
Each item (circle) has two values, that change with time
We will represent these values with vectors
item
d_item
Dynamical system means that the system changes with time
We will represent time by a positive integer number
Time i
represents “now”. The units can be seconds, hours, days, years, or whatever is best to understand the system
If we use “days”, then i-1
means “yesterday”. It can also be “last year” or “one second ago”
cells[i]
food[i]
In any fixed time, the state is all the values of items’ quantities
cells[i]
, food[i]
The “boxes” of the system represent processes
They do not change with time
The have one constant value called rate
For each process we have a value process_rate
The new state depends only on the past states, nothing else
If we know the initial state and rate constants, we can calculate everything
For each box in the graph we get only one term
We multiply the rate constant and each of the amount variables of the circles connected by incoming arrows
We use the index i-1
. Processes depend on the previous values
If there are several incoming arrows from the same circle, then the variable is multiplied several times
The outgoing arrows are not important in this part
We will write the formulas for the cell–food system
There are two arrows coming into the eating box
The formula for this box is
eating_rate * cells[i-1] * food[i-1]
We use the index i-1
because we do not know yet the value of cells[i]
or food[i]
We will calculate them later
At the begin of “today” we only know “yesterday”
To get the formula for each circle
This value is assigned to the delta variable of the circle.
In our example the formula for delta_food is
d_food[i] <- -eating_rate * cells[i-1] * food[i-1]
since the food circle has only one outgoing arrow
The cell circle has two incoming arrows
from eat and one outgoing arrow to eat.
Therefore
d_cells[i] <- eating_rate * cells[i-1] * food[i-1] + eating_rate * cells[i-1] * food[i-1] - eating_rate * cells[i-1] * food[i-1]
which, after simplification, is just
d_cells[i] <- eating_rate * cells[i-1] * food[i-1]
resulting on a final result of one positive incoming arrow
In the last slide we had several arrows between the cells circle and the eating box
It is easy to see that we only care about the resulting number and direction of arrows
Two input - One output = One input
d_food[i] <- -eating_rate * cells[i-1] * food[i-1] d_cells[i] <- eating_rate * cells[i-1] * food[i-1]
Finally, the amount variables have to be updated
Each amount variable is the cumulative sum of the delta variables
food[i] <- food[i-1] + d_food[i] cells[i] <- cells[i-1] + d_cells[i]
The last missing piece are the initial values of the circles’ variables.
The value of cells[i]
depends on the value of cells[i-1]
, and we can only calculate that for i >= 2
We will use the variables cells_ini
and food_ini
to define the values used in cells[1]
and food[1]
For the delta variables, we can assume that they are initially zero.
N <- 168 cells <- d_cells <- rep(NA, N) food <- d_food <- rep(NA, N) cells[1] <- 1 food[1] <- 20 d_cells[1] <- d_food[1] <- 0 for(i in 2:N) { d_cells[i] <- cells[i-1]*food[i-1]*eating_rate d_food[i] <- -cells[i-1]*food[i-1]*eating_rate cells[i] <- cells[i-1] + d_cells[i] food[i] <- food[i-1] + d_food[i] }
cell_culture <- function(N, eating_rate, cells_ini, food_ini) { cells <- d_cells <- rep(NA, N) food <- d_food <- rep(NA, N) cells[1] <- cells_ini food[1] <- food_ini d_cells[1] <- d_food[1] <- 0 for(i in 2:N) { d_cells[i] <- cells[i-1]*food[i-1]*eating_rate d_food[i] <- -cells[i-1]*food[i-1]*eating_rate cells[i] <- cells[i-1] + d_cells[i] food[i] <- food[i-1] + d_food[i] } return(data.frame(cells, food, d_cells, d_food)) }
system_name <- function(N, rates, initial_cond) { state <- d_state <- rep(NA, N) state[1] <- initial_cond d_state[1] <- 0 for(i in 2:N) { d_state[i] <- some formula state[i] <- state[i-1] + d_state[i] } return(data.frame(state, d_state)) }
In R we can write several assignments in one line
Instead of
A <- rep(NA, N) B <- rep(NA, N) C <- rep(NA, N)
we can write
A <- B <- C <- rep(NA, N)
This online material will show you the big picture
We will only do the simple cases