inder {chipPCR} | R Documentation |
Interpolate derivatives
Description
A function inder
("in" + "der" = interpolate derivatives) for
interpolating first and second derivatives using the five-point stencil.
Therefore this function can be used to estimate the Cq (cycle of
quantification) of an amplification curve. First positive derivative also
known as First Derivative Maximum (FDM) and the Second Derivative Maximum
(SDM) are calculated this way (Ruijter et al. 2013). However, from the
mathematical point of view it can also be used to calculate the melting
point for melting curve analysis (compare Roediger et al. 2013) provided
that the sign of the derivative is changed.
Usage
inder(x, y, Nip = 4, logy = FALSE, smooth.method = "spline")
Arguments
x |
is a |
y |
is a vector of dependent variable. Omitted if |
Nip |
is a value which defines how often an interpolation takes place at n
equally
spaced points spanning the interval (default 4). |
logy |
If |
smooth.method |
a character vector of length 1 or |
Details
The function y = f(x)
is numerically derived using the five-point stencil.
This method does not require any assumptions regarding the function f
.
A smoothing procedure greatly enhances calculating derivative calculation. inder
uses two smoothing algorithms best suited for this approach. A smoothing can
be omitted by setting smooth.method
to NULL
, which is advisable in case of
the already smoothed data.
Value
An object of der
class.
Author(s)
Stefan Roediger, Michal Burdukiewicz
References
Ruijter JM, Pfaffl MW, Zhao S, et al. (2013) Evaluation of qPCR curve analysis methods for reliable biomarker discovery: bias, resolution, precision, and implications. Methods San Diego Calif 59:32–46.
Surface Melting Curve Analysis with R. S. Roediger, A. Boehm and I. Schimke. The R Journal. 5(2):37–52, 2013. https://journal.r-project.org
Examples
# First example
# Derive sinus
x <- 1:100/10
y <- sin(x)
ders <- inder(x, y)
plot(x, y, type = "l")
lines(ders[, "x"], ders[, "d1y"], col = "red")
lines(ders[, "x"], ders[, "d2y"], col = "green")
legend("topright", c("f(x)", "f'(x)", "f''(x)"), lty = 1, col = c("black",
"red", "green"))
# Second example
# Determine the approximate second derivative maximum
# for a qPCR experiment. SDM,
isPCR <- AmpSim(cyc = 1:40)
res <- inder(isPCR)
plot(isPCR, xlab = "Cycle", ylab = "RFU", ylim = c(-0.15,1),
main = "Approximate Second Derivative Maximum (SDM)",
type = "b", pch = 20)
lines(res[, "x"], res[, "d1y"], col = "blue")
lines(res[, "x"], res[, "d2y"], col = "red")
summ <- summary(res, print = FALSE)
abline(v = c(summ["SDM"], summ["SDm"], summ["SDC"]), col = c(3,4,5))
text(summ["SDM"], 0.5, paste0("SDM ~ ", round(summ["SDM"], 2)),
cex = 1.5, col = 3)
text(summ["SDC"], 0.7, paste0("SDC ~ ", round(summ["SDC"], 2)),
cex = 1.5, col = 5)
text(summ["SDm"], 0.9, paste0("SDm ~ ", round(summ["SDm"], 2)),
cex = 1.5, col = 4)
text(summ["FDM"] + 10, 0.65, paste("FDM ~ ", round(summ["FDM"], 2)),
cex = 1.5, col = 1)
legend(1, 1, c("raw", "first derivative", "second derivative"),
col = c(1,4,2), lty = c(2,1,1), cex = 1.2)