pcrsim {qpcR}R Documentation

Simulation of sigmoidal qPCR data with goodness-of-fit analysis for different models

Description

Simulated sigmoidal qPCR curves are generated from an initial model to which some user-defined noise is added. One or more models can then be fit to this random data and goodness-of-fit (GOF) measures are calculated for each of the models. This is essentially a Monte-Carlo approach testing for the best model in dependence to some noise structure in sigmodal models.

Usage

pcrsim(cyc = 1:30, model = l4, par = NULL, nsim = 10,        
       error = 0.02, errfun = function(y) 1, plot = TRUE,
       fitmodel = NULL, select = FALSE, 
       statfun = function(y) mean(y, na.rm = TRUE), ...)

Arguments

cyc the number of cycles to be simulated.
model the initial model used for generating the simulated curves.
par a numeric vector (required) with the parameter values for model.
nsim the number of simulated curves.
error the gaussian error used for the simulation. See 'Details'.
errfun an optional function for the error distribution. See 'Details'.
plot should the simulated and fitted curves be displayed?
fitmodel a model or model list to test against the initial model.
select if TRUE, a matrix is returned with the best model in respect to each of the GOF measures.
statfun a function to be finally applied to all collected GOF measures, default is the average.
... other parameters to be passed on to plot or pcrfit.

Details

The value defined under error is just the standard deviation added plainly to each y_i value from the initial model, thus generating a dataset with random homoscedastic noise. With aid of errfun, the distribution of the error along the y_i values can be altered and therefore be used to generate heteroscedastic variance along the curve, so that the standard deviation is a function of the magnitude.

Example:
errfun = function(y) 1
same variance for all y_i, as is.

errfun = function(y) y
variance as a function of the y-magnitude.

errfun = function(y) 1/y
variance as an inverse function of the y-magnitude.

For the effect, see 'Examples'.

Value

A list containing the following items:

cyc same as in 'arguments'.
fluoMat a matrix with the simulated qPCR data in columns.
coefList a list with the coefficients from the fits for each model, as subitems.
gofList a list with the GOF measures for each model, as subitems.
statList a list with the GOF measures summarized by statfun for each model, as subitems.
modelMat if select = TRUE, a matrix with the best model for each GOF measure and each simulation.

Author(s)

Andrej-Nikolai Spiess

Examples

## generate initial model
m <- pcrfit(reps, 1, 2, l4)

## simulate homoscedastic error
## and test initial model, w3 and l5 
## model on data
res <- pcrsim(cyc = 1:30, model = l4, par = coef(m),
              error = 0.2, nsim = 20, fitmodel = list(l4, w3, l5))

## use heteroscedastic noise typical for 
## qPCR: more noise at lower fluorescence
## Not run: 
res2 <- pcrsim(cyc = 1:30, model = l4, par = coef(m),
              error = 0.01, errfun = function(y) 1/y,
              nsim = 20, fitmodel = list(l4, w3, l5))
## End(Not run)

## get 95% confidence interval for 
## the models GOF in question (l4, w3, l5) 
## Not run: 
res <- pcrsim(cyc = 1:30, model = l4, par = coef(m),
              error = 0.2, nsim = 20, fitmodel = list(l4, w3, l5),
              statfun = function(y) quantile(y, c(0.025, 0.975)))
res$statList  
## End(Not run)  

## show best model for each simulation
## based on different GOF measures
## Not run: 
res <- pcrsim(cyc = 1:30, model = l4, par = coef(m),
              error = 0.2, nsim = 20, fitmodel = list(l4, w3, l5),
              select = TRUE)
res$modelMat
## End(Not run) 

[Package qpcR version 1.2-4 Index]