kinfit: Kinetic Data Fitting of Protein-Ligand Sensorgram

Description Usage Arguments Value See Also Examples

View source: R/kinfit.R

Description

kinfit is for fitting a biosensor kinetic data.

Usage

1
2
kinfit(par, dat, concs, t2, model = c("simple1to1", "dimer"), lower = NULL,
  upper = NULL, jac = NULL, control = minpack.lm::nls.lm.control())

Arguments

par

The initial parameters to be fitted.

dat

A data frame. The first column in the data frame is "Time" followed by the response (nm) recorded from a biosensor experiment or from a simulation at the corresponding concentration of the ligand.

concs

The oncentrations. It is usally a series of two-times dilution of the ligand concentration.

t2

The beggining of dissociation.

model

The model. Choose the model from "simple1to1" or "dimer".

jac

A function to return the Jacobian for the fn function. see nls.lm for detail.

control

An optional list of control settings. See nls.lm and nls.lm.control for the names of the settable control values and their effect.

bound

The upper and lower limits of the parameters used in fitting. It should match with the corresponding parameters of par.

Value

A list with components returned from minpack.lm::nls.lm, including par, hessian, fvec, info, message, diag, niter, rsstrace and deviance. see nls.lm.

The par component also includes "concs", "t2", and "time", which is taken from the input variables.

See Also

kinsim

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# Simulation  ----------------------------------------------------------
Do a simulation first before the perform the following fitting.
\code{\link{kinsim}}


# Fit the simulated data into the corresponding model--------------------

# Prepare fitting parameters
initPar_test = list(kon =1, koff = 1, rmax = 1)
t2  = par$t2 # t2 is the beginning of the diassociation.
concs        = par$concs
dat          = xySimulated

fit <- kinfit(par = initPar_test, dat = dat, concs = concs, t2 = t2, model = "simple1to1")
names(fit)

cbind(simulation= par, init = initPar_test, fitting = fit$par)

# Predict  -------------------------------------------------------------
predFit <- kinsim(par = fit$par, model = model, noise = 0)


# Plot -----------------------------------------------------------------

# Plotting the simulation
xy <-reshape2::melt(data = xySimulated,
id.vars = "Time",
measure.vars = rev(1:6),
variable.name = "Conc")

g <- ggplot()  + xlab("Time (sec)") + ylab("Response (nm)") +
    labs(linetype= 'title') +
   ylim(-0.025,1) +
   theme_classic() +
   theme(legend.position=c(0.9, 0.65),
         legend.text=element_text(size = rel(1)),
         legend.key.size=unit(0.9,"line"));
g <- g + geom_line(data = xy, aes(x = Time, y = value, color = Conc));
print(g)

# Plotting the prediction from the fitted parameters
predFit <- reshape2::melt(predFit, id.vars = "Time")
g + geom_line(data=predFit, aes(x = Time, y = value, group = variable) )

huangrenhuai/sgfit documentation built on May 16, 2017, 11:28 p.m.