knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.width=7, fig.height=4, out.width="100%", dpi = 200 )
library(amplify) library(dplyr)
When RNA libraries are generated, their absolute concentrations need to be established so they can be evenly loaded onto the chip with the correct concentration. In order to measure RNA library concentration, qPCR with a standard curve is performed. amplify offers several functions to both:
amplify takes 'results' (.xls(x)
) files exported from QuantStudio. They can be read in with read_pcr
and tidied easily by providing a path to tidy_lab
. We also add pad_zero = TRUE
, which changes the default value of, say Sample 1
to Sample 01
. This will help with out plotting order down the line.
tidy_lib <- system.file("extdata", "untidy-standard-curve.xlsx", package = "amplify") |> read_pcr() |> tidy_lab(pad_zero = TRUE) # scrub - from {mop} - turns an object into a data.frame scrub(tidy_lib)
By default, pcr_tidy
assumes you have a standards serial dilution starting at 6.8, diluted by a factor of 10, going all the way down to 0.00068, and that you want all of them. There are a couple instances in which this might not be the case:
In that instance, you would supply a numeric vector to the usr_standards
argument. If you wish to omit a given set of standards, simply do not include them in this vector:
custom_lib <- system.file("extdata", "untidy-standard-curve.xlsx", package = "amplify") |> read_pcr() |> tidy_lab(pad_zero = TRUE, usr_standards = c(6.8, .68, .068, .0068)) scrub(custom_lib)
This will automatically update the slope column of the dataframe as well. This can be called standalone (say, after manually removing a few standards replicates from your dataset) by running pcr_calc_slope
Before we can perform quality control, we first need to calculate the concentration of RNA library in our samples. We supply a dilution factor to calculate the concentration of the original libraries from the concentration of libraries in the assay (here we diluted them 1:1000).
lib_conc <- tidy_lib |> pcr_lib_calc(dil_factor = 1000) lib_conc |> scrub() |> select(sample_name, concentration)
Quality control metrics also need to be calculated. We can do this by calling pcr_lib_qc
on data output from pcr_lib_calc
:
lib_qc <- lib_conc |> pcr_lib_qc() lib_qc
This output is generally not useful by itself. Using pcr_lib_qc_plot_*
functions on it, however, generates plots that display valuable visual QC summaries
Making standard curve for libraries requires making a serial dilution of standards. It is important we determine that this serial dilution was diluted properly, or the results calculated from it will be unreliable. The standard dilution plot helps with this:
lib_qc |> pcr_lib_qc_plot_dil()
From this plot, we can see the relative dilution factors between samples. From this example, we can see a 9.3x dilution between the first and second, 12.2x dilution between second and third, etc. They gray dots represent where our blue dots should land if all the dilutions are perfect AND if efficiency is 100%. The red dots represent where the samples lie.
This plot can catch three sources of issues:
Determining efficiency issues vs consistently under-pipetting is impossible to determine with the data alone. Ensure you have calibrated pipettes and are practicing proper pipetting techniques to ensure not only consistent, but accurate volumes.
lib_qc |> pcr_lib_qc_plot_slope()
In this plot, the log10 of the theoretical values of the standards is plotted against the Ct values of the standards. In a perfect world, we would expect that a standard 1/10th of the concentration would reach the same level of amplification in around 3.3 cycles. Why? Because in a perfect world, we expect perfect doubling of the product. $2^{3.3}\approx 10$.
Thus, in a perfect world we expect to see a slope of -3.3, an $R^2$ of 1, and an efficiency of 100%.
Things are rarely perfect, however. 100% efficiency is an upper bound. Therefore, an efficiency >80% is considered acceptable.
If there is an outlier in your standards it may make the efficiency artificially low or high. In some cases you can remove those standards and recalculate the slope to still get accurate concentrations, without having to redo the qPCR run:
One instances in which it is not recommended to simply remove the outliers: when standards that are within the range or above your sample concentrations. This is because a poor dilution done upstream of your samples will affect all concentrations downstream, making accurate determination of absolute library concentration impossible. If you are ever in doubt, you should probably bite the bullet and redo the qPCR.
lib_qc |> pcr_lib_qc_plot_outliers()
It's often best to remove technical replicate outliers in order to obtain an accurate estimate of concentration. A point is deemed an outlier if it is >3Z away from the mean of the other two. Shown above, the outliers are in gray, and the zone of inclusion is in blue. Particularly egregious outliers are shown with (<<<) or (>>>) and the number of standard deviations away they are. In the instance above, 463Z away! New estimates, sans these outliers, are found in the quant_adj
column of sample_summary
:
lib_qc$sample_summary
These can be visualized using pcr_lib_qc_conc
:
lib_qc |> pcr_lib_qc_plot_conc()
This plot shows the unadjusted concentrations in gray, and the concentrations after outlier removal in blue.
A full HTML report can be produced by running pcr_lib_qc_report
:
lib_qc |> amplify::pcr_lib_qc_report("path/to/file.html")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.