dev/testingCode_singleLigand.R

###this is the code to testing the fitting with one ligand 

######=------>
library(ADASPR)
#-------->testing code for multiligandmodel
#kon<-c(2E3, 1E5, 3E4)
kon<-c(2E3)
#koff<-c(1E-4, 1E-4, 5E-3)
koff<-c(1E-2)

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<-1000
#Rmax<-c(30,120,40)
Rmax<-c(100)

mlgm<- new("MultiLigandModel", kon=kon, koff=koff, analyteConcentrations=analyteConcentrations, 
		associationLength=associationLength, dissociationLength=dissociationLength, Rmax=Rmax
		)
set.seed(1)

#first without noise		
sData<-Simulate(mlgm,sampleFreq=0.01, sd=0.0)	
#sData[[1]]

#plot
plot(sData[[1]])

#steady state KD
fss<-fitSPR.KD(sData[[1]], degree=length(analyteConcentrations), steadyStateStart=950,steadyStateEnd=1000)

#expected
#calculate the expected moments of kD distribution
e_k<-rep(0,length(analyteConcentrations))
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)))

### kon
fpc.kon<-fitSPR.kon(sData[[1]], Rmax=sum(Rmax),debug=TRUE);

#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)

###koff
fpc.koff<-fitSPR.koff(sData[[1]], Rmax=sum(Rmax),debug=TRUE);

#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))
ffeng23/ADASPR documentation built on July 13, 2019, 1:15 p.m.