dev/smoothNoisyData.R

######=------>
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<-200
#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
		)
sData<-Simulate(mlgm,sampleFreq=0.01, sd=0.1)	
#sData[[1]]
tlen<-2000
tm<-sData[[1]]@associationData[c(1:tlen),1]
ru<-sData[[1]]@associationData[c(1:tlen),2]
plot(c(5,10),c(129.5,130),type="n")
lines(tm,ru)
ss<-smooth.spline(ru~tm)
lines(ss,col=2)

tm<-sData[[1]]@associationData[,1]
ru<-sData[[1]]@associationData[,2]
ssAll<-smooth.spline(ru~tm)

 smoothedSData<-sData[[1]]
 smoothedSData@associationData[,2]<-ssAll[[2]]

plot(c(0,20),c(0,150),type="n")
 lines(tm,ru)
 lines(smoothedSData@associationData[,1],smoothedSData@associationData[,2], col=2)
 
 lines(ssAll,col=3)
 
 tm<-sData[[1]]@associationData[c(1:(2000/0.01)),1]
ru<-sData[[1]]@associationData[c(1:(2000/0.01)),2]
los.sm<-loess(ru~tm,span=50/(1000/0.01), degree=1,family="gaussian")
plot(c(0.1,0.2),c(55,80),type="n")
 lines(tm,ru)
 yy<-predict(los.sm,data.frame(x=tm))
lines(tm,yy,col=2) 
 fpc<-fitPolySPR(tm,yy, debug=T, degree=50,weights.step=1, weights.scale=200, weights.type="exp");

 
 #super smoother
 tm<-sData[[1]]@associationData[c(1:(1000/0.01)),1]
ru<-sData[[1]]@associationData[c(1:(1000/0.01)),2]
sps.sm<-supsmu(tm, ru,span=1/(2000/0.01), bass=0 )
plot(c(0.05,0.08),c(30,50),type="n")
 lines(tm,ru)
 #yy<-predict(los.sm,data.frame(x=tm))
lines(sps.sm,col=2) 
 
 
ffeng23/ADASPR documentation built on July 13, 2019, 1:15 p.m.