# NOT RUN {
# Load the FCSlib package
library(FCSlib)
g <- fcs(x = Cy5$f,nPoints = 2048)
len <- 1:length(g)
tau <-Cy5_100nM$t[len]
G<-data.frame(tau,g)
G<-G[-1,]
# Once the correlation curve 'g' has been generated,
# a data frame containing known parameters must be then defined
df<-data.frame(G, s = 0.27, k = 3)
head(df)
# The radius of the focal volume must computed experimentally.
# For this example, we choose a s = 0.27~ mu m
# Then, three lists that contain the initial values of the data,
# as well as the upper and lower limits of these values, must be defined.
# The input values here are the expected values for the real experimental data
# to be very similar or close to, so that the function calculates them accurately.
# Initial values:
start <- list(D = 100, G0 = 0.1)
up <- list(D = 1E3, G0 = 10)
low <- list(D = 1E-1, G0 = 1E-2)
# Once the known parameters are defined, we now proceed to use the fitFCS() function.
# The result will be a nls object
modelFCS <- fitFCS(df, start, low, up, type = "D3D", trace = F)
# summary(modelFCS)
# By using the predict() function, the object generated in the previous step
# is transformed into a vector that contains the curve fitted by the desired model.
fit <- predict(modelFCS, tau)
# Finally, use the following command to obtain the resulting graph,
# where the blue line corresponds to the fitted data and the black surface
# corresponds to the unfitted
plot (G, log = "x", type = "l", xlab = expression(tau(s)),
ylab = expression(G(tau)), main = "Cy5")
lines(fit~G$tau, col = "blue")
# To acquire access to the physical coefficients of the model type
s<-summary(modelFCS)
s$coefficients[,1]
# }
Run the code above in your browser using DataLab