In Silico Experimentation (cont'd)

M. Drew LaMar
October 24, 2016

Class announcements

  • Reading Assignment (NO QUIZ): “Dynamics of Genes in Populations” (up until Random Genetic Drift)

Example: Simple Birth Rates

BehaviorSpace

Example: Simple Birth Rates

mydata <- read.csv("Simple Birth Rates experiment-table.csv", header=TRUE, skip=6)
str(mydata)
'data.frame':   300 obs. of  6 variables:
 $ X.run.number.    : int  4 3 2 6 5 7 8 9 11 12 ...
 $ red.fertility    : int  2 2 2 2 2 2 2 2 2 2 ...
 $ carrying.capacity: int  1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 ...
 $ blue.fertility   : num  2.1 2.1 2.1 2.1 2.1 2.1 2.1 2.1 2.2 2.2 ...
 $ X.step.          : int  121 149 200 97 139 140 150 123 70 78 ...
 $ ticks            : int  121 149 200 97 139 140 150 123 70 78 ...

Example: Simple Birth Rates

We need to replicate this figure:

Replicate This

Example: Simple Birth Rates

First, we need the blue fertility values:

(bf.vals <- unique(mydata$blue.fertility))
 [1] 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.0 3.1 3.2 3.3 3.4 3.5 3.6 3.7
[18] 3.8 3.9 4.0 4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8 4.9 5.0

Example: Simple Birth Rates

Second, we need to compute the average ticks until red extinction.

N <- length(bf.vals) # How many bf.vals?
time.to.red.extinction <- rep(0,N) # Initialize
sdev <- rep(0,N)
for (i in 1:N) {
  # Subset the data
  tmp <- subset(mydata, mydata$blue.fertility == bf.vals[i])

  # Compute average over subsetted data
  time.to.red.extinction[i] <- mean(tmp$ticks)

  # Compute standard deviation over subsetted data
  sdev[i] <- sd(tmp$ticks)
}

Example: Simple Birth Rates

Let's plot!

plot(bf.vals, time.to.red.extinction, pch=19, xlab="Blue fertility", ylab="Ticks until red extinction")

arrows(bf.vals, time.to.red.extinction-sdev, bf.vals, time.to.red.extinction+sdev, length=0.05, angle=90, code=3)

Example: Simple Birth Rates

plot of chunk unnamed-chunk-5

Replicate This