April 14, 2020
Everyday you spend some money
Some days you receive money
How much money you have each day?
The income can be positive (salary) or negative (expenses)
The balance on first day is your initial money
The balance of today is the balance of yesterday plus the income of today
balance[today] <- balance[yesterday] + income[today]
We will see several “days”, represented by i
It is useful to think that
i
represents “today”i-1
represents “yesterday”The balance on first day is your initial money
balance[1] <- income[1]
The balance of today is the balance of yesterday plus the income of today
for(i in 2:length(income)) { balance[i] <- balance[i-1] + income[i] }
Biology is the study of life
Living organisms change. They are alive
To study life, we need to study how things change
For each thing that we consider, we will carry two vectors
If we know the change vector, we can always know the state vector
state[1] <- change[1] for(i in 2:length(change)) { state[i] <- state[i-1] + change[i] }
The input is change
, the output is state
As we said,
If we know the change today, we can know the state today
In real life, in particular in biology, we do not know the change until we know the state
If we know the state yesterday, we can know the change today
We will calculate change and state at the same time
In a Petri dish we have one cell
Every hour, 10% of the cells duplicate, and they never die
How many cells we have after i
hours?
(this is a toy problem, to start thinking)
Duplication process takes one cell and delivers two cells
There is only one element: the cells
There are two values important to them:
The vector cells
is the number of cells
The value cells[i]
is the number of cells on time i
The vector growth
is the growth of the number of cells
There are growth[i]
new cells between time i-1
and i
The duplication_rate
is 0.1
growth[i] <- cells[i-1]*duplication_rate
The growth on time i
depends on the cells existing on time i-1
cells
will be the cumulative sum of growth
But growth
depends on cells
Therefore, we calculate both together
One week has 168 hours
for(i in 2:168) { growth[i] <- cells[i-1]*duplication_rate cells[i] <- cells[i-1] + growth[i] }
Let’s simulate for one week
First we create empty vectors to store the result
cells <- rep(NA, 168) growth <- rep(NA, 168)
Then we start with 1 cell/cm2 and zero growth
cells[1] <- 1 growth[1] <- 0
How many cells we have after 168 hours?
duplication_rate <- 0.1 cells[1] <- 1 growth[1] <- 0 for(i in 2:168) { growth[i] <- cells[i-1]*duplication_rate cells[i] <- cells[i-1] + growth[i] }
Now we have the vector cells
. We can look at cells[168]
cells
for each hourNumber of cells increases 10% every hour
That is, it duplicates every 7:15 hours
Number of cells increases 10 times every ≈24h
In one week their volume is 80ml
In two weeks their volume is 670 cubic meters
petri_dish <- function(N, duplication_rate) { cells <- rep(NA, N) growth <- rep(NA, N) cells[1] <- 1 growth[1] <- 0 for(i in 2:N) { growth[i] <- cells[i-1]*duplication_rate cells[i] <- cells[i-1] + growth[i] } return(data.frame(cells, growth)) }
In practice cells never grow that much
There is a limited amount of food
So we need to include food in the system
How can we include food in the system?
And, what is a system?
These ideas are useful to understand the reality
A System is a set of parts that interact
Each part can be a smaller system
The behavior of the system depends on the parts AND on the interactions
Complex systems can have emergent properties
That is, the system can do things that the parts cannot do
The system is different from the parts
We will represent any system with a network with two kinds of nodes
Circles are connected to boxes with arrows and vice-versa
Circles are connected to boxes
Boxes are connected to circles
There cannot be arrows between circles or between boxes
(only between nodes of different shape)
There can be more than one arrow between a box and a circle, in any direction
The technical name of this kind of network is directed bipartite multigraph
Let’s say that initially food is 20 ng
More cells eat more food, limited by the eat rate
We assume that when a cell gets food, it divides
Let’s say that initially food[1] <- 20
More cells eat more food, limited by the eat_rate
:food_change[i] <- -cells[i-1]*food[i-1]*eat_rate
We assume that when a cell gets food, it divides:growth[i] <- cells[i-1]*food[i-1]*eat_rate
What happens now?
cells <- growth <- rep(NA, 168) food <- food_change <- rep(NA, 168) cells[1] <- 1 growth[1] <- 0 food[1] <- 20 food_change[1] <- 0 eat_rate <- 0.003 for(i in 2:168) { growth[i] <- cells[i-1]*food[i-1]*eat_rate food_change[i] <- -cells[i-1]*food[i-1]*eat_rate cells[i] <- cells[i-1] + growth[i] food[i] <- food[i-1] + food_change[i] }
Read The Biologist Toolbox: Drawing Systems
Explain —in English— what happens in the system represented by this drawing