dev/testingCode_noisy_debugging_silaB.R

###testing the flipped on rate estimation code
library(ADASPR)

kon<-c(1E3, 1E3, 1E4)
koff<-c(1E-3, 5E-4, 1E-5)
analyteConcentrations<-c(3E-5, 1.5E-5, 1E-5, 7E-6, 5E-6)

associationLength<-1500 
dissociationLength<-1500
Rmax<-c(100, 80, 60)


mlgm<- new("MultiLigandModel", kon=kon, koff=koff, analyteConcentrations=analyteConcentrations, 
           associationLength=associationLength, dissociationLength=dissociationLength, Rmax=Rmax)
set.seed(2)		
sData<-Simulate(mlgm,sampleFreq=0.1, sd=0.1)	 #for kon us sampleFreq=0.05
plot(sData[[1]])

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

fss<-FitSteadyStateSPR(sData[[1]], degree=3, steadyStateStart=1450,steadyStateEnd=1500, auto=T)

##flipped and offsetted
#non-steady state
#spc<-getSprPolynomialCoef(kon,koff, Rmax, analyteConcentrations, degree=100)

#fpc.flip<-fitPolySPRsOffsetted(sData[[1]],Rmax=230, debug=T, degree=100,weights.step=1, weights.scale=60, weights.type="exp");
#fpc.reg<-fitPolySPRs(sData[[1]],#Rmax=230
#			, debug=T, degree=100,weights.step=1, weights.scale=60, weights.type="exp");

#cat("doing fitting for moments of kon.......")
#m.reg<-fitCoefficientPolySPRs(fpc.reg, analyteConcentrations, 230, debug=F, mode=1)

#m.flip<-fitCoefficientPolySPRs(fpc.flip, analyteConcentrations, 230, debug=F, mode=2)

#m.reg
#m.flip
#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)

####testing fitSPR.kon
fcp.on<-fitSPR.kon(sData[[1]],debug=T,weights.type="exp", degree=100, weights.step=1, weights.scale=10,#25
			mode=1)#step 10~20, weights.scale=8.5
####testing fitSPR.kon
fcp.on<-fitSPR.kon(sData[[1]],debug=T,weights.type="exp", degree=100, weights.step=1, weights.scale=10,#25
			mode=2, Rmax=240)#step 10~20, weights.scale=8.5

###koff
fcp.off<-fitSPR.koff(sData[[1]], debug=T,degree.fitMoments=4,weightsType.fitSPR="uniform",degree.fitSPR=5
			,weightsScale.fitSPR=20, weightsStep.fitSPR=0.5, 
			weightsType.fitMoments="exp", weightsScale.fitMoments=0.5#2
			);
			
			



#expected koff moments over Rmax
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.