######=------>
library(ADASPR)
#-------->testing code for multiligandmodel
#kon<-c(2E3, 1E5, 3E4)
kon<-c(2E3, 1E5, 3E2)
#koff<-c(1E-4, 1E-4, 5E-3)
koff<-c(1E-2, 1E-3, 1E-3)
analyteConcentrations<-c(
#5E-4, 4E-4, 3E-4, 2E-4,
#1E-5, 9E-6, 6E-6, 3E-6, 2E-6
9E-5, 7E-5, 5E-5, 3E-5, 2E-5
)
associationLength<-1000
dissociationLength<-2000
#Rmax<-c(30,120,40)
Rmax<-c(30,100,40)
mlgm<- new("MultiLigandModel", kon=kon, koff=koff, analyteConcentrations=analyteConcentrations,
associationLength=associationLength, dissociationLength=dissociationLength, Rmax=Rmax
)
set.seed(1)
sData<-Simulate(mlgm,sampleFreq=0.01, sd=0.1)
#sData[[1]]
#plotting R_AB
#plot(sData[[1]])
e_k<-rep(0, length(koff))
e_k[1]<-sum(koff/kon*(Rmax/sum(Rmax)))
e_k[2]<-sum((koff/kon)^2*(Rmax/sum(Rmax)))
e_k[3]<-sum((koff/kon)^3*(Rmax/sum(Rmax)))
e_k[4]<-sum((koff/kon)^4*(Rmax/sum(Rmax)))
#steady state
fss<-FitSteadyStateSPR(sData[[1]], degree=5, steadyStateStart=95,steadyStateEnd=100)
#non-steady state
fpc<-fitPolySPRs(sData[[1]], debug=T, degree=100,weights.step=75, weights.scale=0.1, weights.type="exp");
###======>
###following the above code, starting testing the fitting coefficient of polySPR
#first get the distribution of Rmax
E_kon<-rep(0,length(kon))
E_kon[1]<-sum(Rmax/sum(Rmax)*kon)
E_kon[2]<-sum(Rmax/sum(Rmax)*kon^2)
E_kon[3]<-sum(Rmax/sum(Rmax)*kon^3)
E_kon[4]<-sum(Rmax/sum(Rmax)*kon^4)
E_kon[5]<-sum(Rmax/sum(Rmax)*kon^5)
m<-fitCoefficientPolySPRs(fpc, analyteConcentrations,debug=T)
m/fss[1]
###=======> now following the previous code, we start testing the koffs
m<-fitPolySPRsKoff(sData[[1]], debug=T, degree=100, weights.type="exp", weights.step=0.01, weights.scale=200)
#start to get the distribution from koffs
r0<-matrix(Rmax,nrow=length(analyteConcentrations),ncol=length(Rmax), byrow=T)
for(i in 1:length(analyteConcentrations))
{
r0[i,]<-Rmax*kon*analyteConcentrations[i]/(kon*analyteConcentrations[i]+koff)*(1-exp(-(kon*analyteConcentrations[i]+koff)*associationLength))
}
#expected koff moments
E_R0<-c(sum(r0[1,]),sum(r0[2,]),sum(r0[3,]),sum(r0[4,]),sum(r0[5,]))
E_koff1<-rep(0,length(analyteConcentrations))
E_koff2<-rep(0,length(analyteConcentrations))
E_koff3<-rep(0,length(analyteConcentrations))
E_koff4<-rep(0,length(analyteConcentrations))
for(i in 1:length(analyteConcentrations))
{
E_koff1[i]<-sum(koff*r0[i,]/sum(r0[i,]))
E_koff2[i]<-sum(koff^2*r0[i,]/sum(r0[i,]))
E_koff3[i]<-sum(koff^3*r0[i,]/sum(r0[i,]))
E_koff4[i]<-sum(koff^4*r0[i,]/sum(r0[i,]))
}
#fitted koff moments
f_E_koff1<-rep(0,length(analyteConcentrations))
f_E_koff2<-rep(0,length(analyteConcentrations))
f_E_koff3<-rep(0,length(analyteConcentrations))
f_E_koff4<-rep(0,length(analyteConcentrations))
for(i in 1:length(analyteConcentrations))
{
f_E_koff1[i]<-m[[i]][[1]][2]#/m[[i]][[1]][1]
f_E_koff2[i]<-m[[i]][[1]][3]#/m[[i]][[1]][1]
f_E_koff3[i]<-m[[i]][[1]][4]#/m[[i]][[1]][1]
f_E_koff4[i]<-m[[i]][[1]][5]#/m[[i]][[1]][1]
}
###now testing the steady state koff
##based on the previous fitPolySPRsKoff
mss<-fitCoefficientPolySPRsKoff(m, analyteConcentrations, debug=T, degree=1)#, sum(Rmax))
#expected koff moments
E_koff<-rep(0,7)
E_koff[1]<-sum(Rmax)
E_koff[2]<-sum(koff*Rmax/sum(Rmax))
E_koff[3]<-sum(koff^2*Rmax/sum(Rmax))
E_koff[4]<-sum(koff^3*Rmax/sum(Rmax))
E_koff[5]<-sum(koff^4*Rmax/sum(Rmax))
E_koff[6]<-sum(koff^5*Rmax/sum(Rmax))
E_koff[7]<-sum(koff^6*Rmax/sum(Rmax))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.