Description Usage Arguments Details Value Author(s) References Examples
This is the workhorse function of the qpcR package that fits one of the available models to qPCR data using (weighted) nonlinear least-squares (Levenberg-Marquardt) fitting from nlsLM
of the 'minpack.lm' package.
1 2 |
data |
the name of the dataframe containing the qPCR runs. |
cyc |
the column containing the cycle data. Defaults to 1. |
fluo |
the column(s) containing the raw fluorescence data of the run(s). If more than one column is given, the model will be built with the replicates. See 'Details' and 'Examples'. |
model |
the model to be used for the analysis. Defaults to 'l4'. |
start |
a vector of starting values that can be supplied externally. |
offset |
an offset cycle number from the second derivative cut-off cycle for all |
weights |
a vector with same length as |
verbose |
logical. If |
... |
other parameters to be passed to |
This is a newer (from qpcR 1.3-7 upwards) version of pcrfit
. It is a much simpler implementation containing only the LM-Algorithm for fitting, but this fitting routine has proven to be so robust that other optimization routines (such as in optim
) could safely be removed. The fitting is done with the new nlsLM
function of the 'minpack.lm' package, which gives a model of class 'nls' as output.
This function is to be used at the single run level or on replicates (by giving several columns). The latter will build a single model based on the replicate values. If many models should be built on a cohort of replicates, use modlist
and replist
.
The offset
value defines the offset cycles from the second derivative maximum that is used as a cut-off criterion in the MAK
methods. See 'Examples'.
Since version 1.3-7, an expression given as a character string can be supplied to the weights
argument.
This expression, which is transferred to qpcR:::wfct
, defines how the vector of weights is calculated from the data. In principle, five different parameters can be used to define weights:
"x"
relates to the cycles x_i,
"y"
relates to the raw fluorescence values y_i,
"error"
relates to the error σ(y_{i, j}) of replicates j,
"fitted"
relates to the fitted values \hat{y}_i of the fit,
"resid"
relates to the residuals y_i - \hat{y}_i of the fit.
For "fitted"
and "resid"
, the model is fit unweighted by pcrfit
, the fitted/residual values extracted and these subsequently used for refitting the model with weights.
These parameters can be used solely or combined to create a weights vector for different regimes. The most commonly used are (see also 'Examples'):
Inverse of response (raw fluorescence) \frac{1}{y_i}: "1/y"
Square root of predictor (Cycles) √{x_i}: "sqrt(x)"
Inverse square of fitted values: \frac{1}{\hat{y}^2_i}: "1/fitted^2"
Inverse variance \frac{1}{σ^2(y_{i, j})}: "1/error^2"
A model of class 'nls' and 'pcrfit' with the following items attached:
DATA |
the initial data used for fitting. |
MODEL |
the model used for fitting. |
call2 |
the call to |
parMat |
the trace of the parameter values. Can be used to track problems. |
opt.method |
defaults to |
Andrej-Nikolai Spiess
Bioassay analysis using R.
Ritz C & Streibig JC.
J Stat Soft (2005), 12: 1-22.
A Method for the Solution of Certain Problems in Least Squares.
K. Levenberg.
Quart Appl Math (1944), 2: 164-168.
An Algorithm for Least-Squares Estimation of Nonlinear Parameters.
D. Marquardt.
SIAM J Appl Math (1963), 11: 431-441.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | ## Simple l4 fit of F1.1 of the 'reps' dataset.
m1 <- pcrfit(reps, 1, 2, l4)
plot(m1)
## Supply own starting values.
pcrfit(reps, 1, 2, l4, start = c(-5, -0.05, 11, 16))
## Make a replicate model,
## use inverse variance as weights.
m2 <- pcrfit(reps, 1, 2:5, l5, weights = "1/error^2")
plot(m2)
## Fit a mechanistic 'mak2' model
## to -1 cycle from SDM.
m3 <- pcrfit(reps, 1, 2, mak2, offset = -1)
plot(m3)
|
Loading required package: MASS
Loading required package: minpack.lm
Loading required package: rgl
Loading required package: robustbase
Loading required package: Matrix
Warning messages:
1: In rgl.init(initValue, onlyNULL) : RGL: unable to open X11 display
2: 'rgl_init' failed, running with rgl.useNULL = TRUE
3: .onUnload failed in unloadNamespace() for 'rgl', details:
call: fun(...)
error: object 'rgl_quit' not found
Nonlinear regression model
model: Fluo ~ c + (d - c)/(1 + exp(b * (log(Cycles) - log(e))))
data: DATA
b c d e
-12.07385 0.06789 11.32611 17.59882
residual sum-of-squares: 0.3445
Number of iterations to convergence: 7
Achieved convergence tolerance: 1.49e-08
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.