Fig. S2 Plot
Eandtheta = rbind(
c(1,0),
c(3,1),
c(5,2),
c(7,3)
)
# working directory
setwd("") # enter appropriate working directory for N2 WT foraging worms
# load eigenworms [Broekmans et al. 2016]
ew = read.csv("eigenworms.txt", header=F, sep="") # adjust as appropriate
# filenames
filenames = c(
'1.txt',
'2.txt',
'3.txt',
'4.txt',
'5.txt',
'6.txt',
'7.txt',
'8.txt',
'9.txt',
'10.txt',
'11.txt',
'12.txt'
)
datasections = rbind(
c(10001,12000), #worm1
c(10001,12000), #worm2
c(8501,10500), #worm3
c(10501,12500), #worm4
c(10501,12500), #worm5
c(10501,12500), #worm6
c(10501,12500), #worm7
c(10501,12500), #worm8
c(11001,13000), #worm9
c(11001,13000), #worm10
c(11001,13000), #worm11
c(11001,13000) #worm12
)
# calculate the errors for first 3 worms
worm = 1
data = read.csv(filenames[worm], header=F, sep="")
data = data[datasections[worm,1]:datasections[worm,2],1:5]
w1_detailsens = run_sensitivity_simple(data, lib, pred, Eandtheta, tau, tp)
worm = 2
data = read.csv(filenames[worm], header=F, sep="")
data = data[datasections[worm,1]:datasections[worm,2],1:5]
w2_detailsens = run_sensitivity_simple(data, lib, pred, Eandtheta, tau, tp)
worm = 3
data = read.csv(filenames[worm], header=F, sep="")
data = data[datasections[worm,1]:datasections[worm,2],1:5]
w3_detailsens = run_sensitivity_simple(data, lib, pred, Eandtheta, tau, tp)
# plot supp fig
m = matrix(c(1,2,3), nrow=3, ncol=1, byrow=TRUE)
layout(m)
par(mai=c(0.3,0.3,0.35,0.1), omi=c(0,0,0,0), cex=1, mgp=c(1.5,0.5,0))
cols = c(rgb(1,0,0,0.7), 'orange', rgb(0,0,0.5,1))
# first plot
y = w1_detailsens[1,]
plot(y, type='o', col='gray', pch='', lty=1, lwd=1, xlab='', ylab='')
for (i in c(2:4)) {
y = w1_detailsens[i,]
lines(y, col=cols[i-1], lty=1, lwd=1)
}
# second plot
y = w2_detailsens[1,]
plot(y, type='o', col='gray', pch='', lty=1, lwd=1, xlab='', ylab='')
for (i in c(2:4)) {
y = w2_detailsens[i,]
lines(y, col=cols[i-1], lty=1, lwd=1)
}
# third plot
y = w3_detailsens[1,]
plot(y, type='o', col='gray', pch='', lty=1, lwd=1, xlab='', ylab='')
for (i in c(2:4)) {
y = w3_detailsens[i,]
lines(y, col=cols[i-1], lty=1, lwd=1)
}
Functions for Plotting
eplots <- function(indata) {
xdata = Es # same sequence of E values used to generate the data
linecolor = rgb(0,0,0.7,0.5)
linecolor2 = rgb(0,0,0.7,1)
symbol = '.'
smallwidth = 0.25
bigwidth = 3
thetaindex = 5
y = indata[,thetaindex,1]
plot(xdata, y, type='o', col=linecolor, pch=symbol, lty=1, lwd=smallwidth, xlab='',
ylab='', ylim=c(min(indata[,thetaindex,]),max(indata[,thetaindex,])))
for (i in c(2:dim(indata)[3])) {
y = indata[,thetaindex,i]
points(xdata, y, col=linecolor, pch=symbol)
lines(xdata, y, col=linecolor, lty=1, lwd=smallwidth)
}
y = rowMeans(indata[,thetaindex,])
lines(xdata, y, col=linecolor2, lty=1, lwd=bigwidth)
}
thetaplots <- function(indata){
xdata = thetas # same sequence of thetas used to generate the data
linecolor = rgb(0.7,0,0,0.5)
linecolor2 = rgb(0.7,0,0,1)
symbol = '.'
smallwidth = 0.25
bigwidth = 3
eindex = 5
y = indata[eindex,,1]
plot(xdata, y, type='o', col=linecolor, pch=symbol, lty=1, lwd=smallwidth, xlab='',
ylim=c(min(indata[eindex,,]),max(indata[eindex,,])), ylab='')
for (i in c(2:dim(indata)[3])) {
y = indata[eindex,,i]
points(xdata, y, col=linecolor, pch=symbol)
lines(xdata, y, col=linecolor, lty=1, lwd=smallwidth)
}
y = rowMeans(indata[eindex,,])
lines(xdata, y, col=linecolor2, lty=1, lwd=bigwidth)
}