---
title: "repressilator"
author: "fichant"
date: "5 d�cembre 2019"
output: html_document
---

```{r }
library(deSolve)
#library(MESS)
#library(plot3D)

state <- c(
  LacI = 59.54242368,
  CI = 1.265613207e-6,
  TetR = 66.02094157
)

parameters <- c(
		a0_trans = 0.001000000683, 
		a_tr     = 19.14497295,
		Ki       = 8.176402117,
		n        = 3.999998706,
		gamma_prot = 0.03648081183
)

```
```{r }
comp <-function(t, state, parameters) {
	with(as.list(c(state, parameters)),{
	  dLacI = a0_trans + (a_tr * Ki^n)/(Ki^n + CI^n) - gamma_prot * LacI
	  dCI = a0_trans + (a_tr * Ki^n)/(Ki^n + TetR^n)- gamma_prot * CI
	  dTetR = a0_trans + (a_tr * Ki^n)/(Ki^n + LacI^n)- gamma_prot * TetR
	  list(c(dLacI, dCI, dTetR))
	})
}
### Set Time steps
times <- seq(0,500)
```
```{r }
#read experimatal data WT
data_exp=read.table("C:/Users/fichant/Documents/M2Bioinfo/BioSyst_2017/TP_2017/TP_corriges/tp_repressilator/Gwen/final/Copasy/repressilator_continu_2018_time_serie_500.csv",header=T,sep=",")
print(data_exp)
print(data_exp$CI)
```
```{r }
out_simulation <- ode(y = state, times = times, func = comp, parms = parameters, method = "lsoda")
#print(out_simulation)

plot(out_simulation[,"time"],out_simulation[,"LacI"],type="l", col="blue",lwd = 1.5,xlab="Time (min)",ylab="Protein levels (a.u.)",cex.lab=1.2,xlim=c(0,500),ylim=c(0,500))
  lines(out_simulation[,"time"],out_simulation[,"CI"],type="l", col="red",lwd = 1.5,ylim=c(0,500),xlab="Time",ylab="Proteins level")
  lines(out_simulation[,"time"],out_simulation[,"TetR"],type="l", col="darkgreen",lwd = 1.5)
lines(data_exp$Time,data_exp$CI, pch=3, cex =0.3,col="red", type="p")
lines(data_exp$Time,data_exp$LacI, pch=3,cex =0.3, col="blue", type="p")
lines(data_exp$Time,data_exp$TetR, pch=3,cex =0.3, col="darkgreen", type="p")
```