Workhorse function for qPCR model fitting
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.
pcrfit(data, cyc = 1, fluo, model = l4, start = NULL, offset = 0, weights = NULL, verbose = TRUE, ...)
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.
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.
## 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)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.