dev/testingCode_flippingOffsetted.R

###testing the flipped on rate estimation code
library(ADASPR)
kon<-c(3E4, 2E4, 1E4)
#koff<-c(1E-5, 1E-4, 1E-5)
koff<-c(1E-4, 1E-3, 1E-4)
analyteConcentrations<-c(2E-6, 
						1E-6, 
						5E-7,
						2.5E-7, 
						1.25E-7#,
						#6.25e-8#, #3.125e-8#, 1.25e-8#, 6.25e-9, 3.125e-9
						)

associationLength<-1000
dissociationLength<-3  #3000
Rmax<-c(80, 80, 70)


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=5, steadyStateStart=3450,steadyStateEnd=4000, 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

####testing fitSPR.kon
fcp.on<-fitSPR.kon(sData[[1]],debug=T,weights.type="exp", degree=100, weights.step=1, weights.scale=60,#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=60,#25
			mode=2, Rmax=230)#step 10~20, weights.scale=8.5
ffeng23/ADASPR documentation built on July 13, 2019, 1:15 p.m.