Determining PCR-product sizes

Background

The product size from PCR reactions is determined by primer design and subsequent specificity. A specific primer will produce a product length corresponding to the length of the segment amplified by the primers. If primers are unspecific, covering multiple templates, product lengths will potentially vary. PCR-product size can therefore be used to determine if a PCR reaction has targeted the expected template.

This tutorial will show how to determine sizes of PCR products from an agarose gel using ImageJ and R.

Prerequisite

Download ImageJ Fiji. Examples of data analyses below are performed in R and RStudio.

A general protocol for agarose gel electrophoresis can be found under protocols.

Measuring product migration distance in ImageJ

  • Start ImageJ, open up a gel image (Figure 1).


- Invert the image (Shift + Ctrl + I) and rotate it (Image > Transform > Rotate) so that the top of the gel (wells) are on the left (Figure 2).


- Select the Rectangle tool in ImageJ and draw a box covering the wells of interest and the ladder, press Shift + X to crop the image (Figure 3). Make sure the wells runs horizontally, adjust the rotation otherwise.


- Using the Rectangle tool, select the well containing the ladder and press Ctrl + 1, move the Rectangle to the next well and press Ctrl + 2. Select all wells of interest using Ctrl + 2 except for the last well, select the last well using Ctrl + 3. A new window will appear (Figure 4).


- The curves in the new window represents the pixel intensity of each well. Go to the Analyze > Set Measurements in ImageJ and de-select all measurement, a single decimal places is sufficient. Select the Multi-point tool and mark every peak in each well (Figure 5).


When all peaks are marked press Ctrl + M. A new window should appear with x and y measurements (Figure 6).


Calculate unknown product sizes based ladder estimates

  • Create a spreadsheet with the data collected in ImageJ, alternatively, input your data in R directly (as below). The x-values from ImageJ are the values of interest.
  • Input the data detailing the ladder (mw in the example below). We get this information from the description of the ladder. The GeneRuler 50 bp DNA Ladder (Thermo scientific) is used in this example.
# Create a data frame of known distances and molecular weights
ladder <- data.frame(dist = c(29, 43.5, 60.5,
                              80.5, 106.5,  141.5,  
                              181.5,    243.5,  281.5,
                              328.5,    390.5,  465.5,  580.5), 
                     mw = c(1000, 900, 800, 
                            700, 600, 500,
                            400, 300, 250, 
                            200, 150, 100, 50))
            

# Create a new data frame of unknowns
unknown <- data.frame(dist = c(470.5,   391.5,  528.5,
                               421.5,   507.5))
  • DNA fragment sizes will be linear to migration distance when expressed on the log scale. Create a “calibration model” using the ladder.

# Fit the model
cal <- lm(log(mw) ~ dist, data = ladder)

# Check model performance, R^2 should be ~ 1.
summary(cal)

Call:
lm(formula = log(mw) ~ dist, data = ladder)

Residuals:
      Min        1Q    Median        3Q       Max 
-0.054731 -0.040851 -0.001577  0.034241  0.063743 

Coefficients:
              Estimate Std. Error t value Pr(>|t|)    
(Intercept)  6.9957281  0.0200403  349.08  < 2e-16 ***
dist        -0.0052316  0.0000712  -73.47 3.69e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 0.0432 on 11 degrees of freedom
Multiple R-squared:  0.998, Adjusted R-squared:  0.9978 
F-statistic:  5398 on 1 and 11 DF,  p-value: 3.691e-16
  • Estimate molecular weights from migration distances using the data frame of unknowns and the predict function. Since the model is created from log transformed data we need to convert to linear scale before interpreting using exp().
preds <- exp(predict(cal, newdata = unknown) )
  • Compare the measured sizes with predicted sizes from the primer design stage.