A key benefit of the RDML7 package is that it enables further statistical analysis of RDML data. This section describes R packages that link with the RDML7 package. It will provide examples on how other packages allow the manipulation of RDML objects.
In this example we will employ the qpcR package
(Ritz and Spiess 2008) to calculate Cq
values after the selection of an optimal sigmoidal model, as suggested
by the Akaike’s An Information Criterion. The Cq values will then be
used to calculate the amplification efficiency from a calibration curve,
based on the effcalc function of the
chipPCR package (Rödiger et al.
2015).
Note: The data used here serve as example only. Overall, the quality of the measurement is not appropriate for further application in a study. Here, we show that the estimated amplification efficiency from the StepOne system differs from that of the proposed pipeline (RDML7 \(\rightarrow\) qpcR \(\rightarrow\) chipPCR).
In principle, the following code examples can be combined with report generating toolkits for data analysis pipelines, such as Nozzle (see Gehlenborg et al. (2013)).
In the RDML7 vignette, it was demonstrated how to
read-in RDML data. In this section we will continue with the built-in
RDML example file stepone_std.rdml. The file is opened as
described before:
At this stage, all data from the stepone_std.rdml RDML
file are available. For example, the amplification efficiency as
provided by the StepOne™ Real-Time PCR System software can be fetched
from the package via
raw_data$target[["RNase P"]]$amplificationEfficiency.
To get some information about the run we can use:
names(raw_data$experiment[["Standard Curve Example"]]$run$Run001)
#> [1] "id" "description"
#> [3] "documentation" "experimenter"
#> [5] "instrument" "dataCollectionSoftware"
#> [7] "backgroundDeterminationMethod" "cqDetectionMethod"
#> [9] "thermalCyclingConditions" "pcrFormat"
#> [11] "runDate" "react"
raw_data$experiment[["Standard Curve Example"]]$run$Run001$instrument
#> [1] "Applied Biosystems StepOne™ Instrument"
raw_data$experiment[["Standard Curve Example"]]$run$Run001$pcrFormat
#> <RDML7::pcrFormatType>
#> @ rows : int 8
#> @ columns : int 12
#> @ rowLabel : <RDML7::labelFormatType>
#> .. @ value : chr "ABC"
#> .. @ variants: chr [1:3] "ABC" "123" "A1a1"
#> @ columnLabel: <RDML7::labelFormatType>
#> .. @ value : chr "123"
#> .. @ variants: chr [1:3] "ABC" "123" "A1a1"For convenience, we use the built in pipe function |>
for further analysis. In the following, we fetch the amplification curve
data from the RDML file.
The plotting of the raw data is an important step to visually inspect the data. In this example, we use the ggplot2 package (Wickham 2009) instead of the default R graphics functions.
# Load the ggplot2 package for plotting
library(ggplot2)
# Load the reshape2 package to rearrange the data
library(reshape2)
# Rearrange and plot the raw data
fdata_gg <- melt(fdata, id.vars="cyc")
ggplot(data=fdata_gg, aes(x=cyc, y=value, color=variable)) +
geom_line() + labs(x="Cycle", y="RFU") + theme_light() +
theme(legend.position="top",
legend.direction="horizontal")During the next steps we will employ the qpcR
package. The function mselect performs sigmoid model
selection by different criteria (e.g., bias-corrected Akaike’s
Information Criterion). Note: In most cases a sigmoidal model with seven
parameters was selected.
The function efficiency calculates the qPCR Cq values,
amplification efficiency and other important qPCR parameters. In this
example, we set the parameter type of the efficiency
function to Cy0, which will calculate and report the Cy0
value. According to Guescini et al.
(2008), the Cy0 value is the intersection of a tangent on the
first derivative maximum with the abscissa. However, for all further
analyses we will use the second derivative maximum cycle as Cq value.
This supplementary material will not focus on the selection of a certain
Cq method. For an objective decision, we would like to guide the reader
to the study by Ruijter et al. (2013).
# Write a custom function that calculates the Cq values and other curve parameters
library(qpcR)
res_fit <- do.call(cbind, lapply(2L:ncol(fdata), function(block_column) {
res_model <- try(mselect(pcrfit(data=fdata, cyc=1, fluo=block_column), verbose=FALSE, do.all=TRUE), silent=TRUE)
if(class(res_model)[1] == "try-error") {
res_model <- NA
}
else{
try(efficiency(res_model, plot=FALSE, type="Cy0"), silent=TRUE)
}
}
)
)
# Assign column names
colnames(res_fit) <- colnames(fdata)[-1]
# Fetch only the Cq values (second derivative maximum) and combine them in a
# data.frame
Cq_SDM <- res_fit[rownames(res_fit)=="cpD2", ] |>
unlist() |>
as.data.frame()
colnames(Cq_SDM) <- c("Cq")
# Prepare the dilutions and calculated Cq values for further usage in the effcalc
# function from the chipPCR package
dilution <- c(as.factor("ntc"), as.factor("unk"), as.factor("unk"),
10000, 5000, 2500, 1250, 625)
Cq_values <- matrix(Cq_SDM[, "Cq"], nrow=length(dilution), ncol=3, byrow=TRUE)Below, we arbitarily selected a non-template control (negative) and an unknown sample (positive) (two out of 24 amplification curves) for the presentation of the coefficients that were calculated from the raw amplication curve data.
| A01:NTC_RNase PntcRNase P | A05:pop1_RNase PunknRNase P | |
|---|---|---|
| eff | NA | 1.01020429389141 |
| resVar | NA | 7.27e-06 |
| AICc | NA | -347.935408836205 |
| AIC | NA | -351.435408836205 |
| Rsq | NA | 0.999986082849538 |
| Rsq.ad | NA | 0.999983552458545 |
| cpD1 | NA | 32.13 |
| cpD2 | NA | 28.3 |
| cpE | NA | NA |
| cpR | NA | NA |
| cpT | NA | NA |
| Cy0 | NA | 24.95 |
| cpCQ | NA | NA |
| cpMR | NA | NA |
| fluo | NA | 0.669107421126233 |
| init1 | NA | 0.641678559940836 |
| init2 | NA | 0.519380994107653 |
| cf | NA | NA |
We now use our calculated Cq values from the dilutions steps (625,
1250, 2500, 5000, 10^{4}) to determine the efficiency from the
calibration curve. According to the StepOne software, the amplification
efficiency is approx. 93.9%. To confirm these results, the
effcalc function was employed to determine the coefficients
of the calibration curve.
The following few lines are needed to calculate the amplication efficiency based on the previously calculated Cq values.
# Load the chipPCR package
library(chipPCR)
# Use the effcalc function from the chipPCR package to calculate the amplification
# efficiency and store the results in the object res_efficiency
res_efficiency <- effcalc(dilution[-c(1:3)], Cq_values[-c(1:3), ], logx=TRUE)
# Use the %>% function from the magrittr package to plot the results (res_efficiency)
# from the effcalc function
res_efficiency |> plot(CI=TRUE, ylab="Cq (SDM)",
main="Second Derivative Maximum Method")The amplification efficiency estimated with the customized function
was 93.9%, which is comparable to the value reported in the
stepone_std.rdml file.
# Combine the sample labels and the Cq values as calculate by the Second
# Derivative Maximum Method (cpD2).
sample_Cq <- data.frame(sample=c("ntc", "unk", "unk",
10000, 5000, 2500, 1250, 625),
Cq_values)
# Print table of all Cq values
# Use the kable function from the knitr package to print a table
knitr::kable(sample_Cq, caption="Cq values as calculate by the Second Derivative
Maximum Method (cpD2). ntc, non-template control. unk, unknown sample. X1, X2
and X3 are the Cq values from a triplicate measurement.")| sample | X1 | X2 | X3 |
|---|---|---|---|
| ntc | NA | 1.00 | NA |
| unk | 28.38 | 28.30 | 28.42 |
| unk | 27.39 | 27.38 | 27.30 |
| 10000 | 26.21 | 26.20 | 26.24 |
| 5000 | 27.28 | 27.32 | 27.32 |
| 2500 | 28.38 | 28.41 | 28.33 |
| 1250 | 29.42 | 29.47 | 29.54 |
| 625 | 30.62 | 30.65 | 30.61 |
knitr::kable(res_efficiency, caption="Analysis of the amplification efficiency.
The table reports the concentration-depentent average Cq values from three
replicates per dilution step. In addition, the standard deviation (SD) and the
Coefficient of Variation (RSD [%]) are presented. The results indicate that the
data basis for the calibration curve is valid.")| Concentration | Location (Mean) | Deviation (SD) | Coefficient of Variance (RSD [%]) |
|---|---|---|---|
| 4.00000 | 26.21667 | 0.0208167 | 0.0007940 |
| 3.69897 | 27.30667 | 0.0230940 | 0.0008457 |
| 3.39794 | 28.37333 | 0.0404145 | 0.0014244 |
| 3.09691 | 29.47667 | 0.0602771 | 0.0020449 |
| 2.79588 | 30.62667 | 0.0208167 | 0.0006797 |
The Cq values (28.38, 28.3, 28.42) from the unknown sample
unk had an average Cq of 28.37 ± 0.06.