2023-08-29 qPCR Analysis

Author

Dan Rice

Published

August 29, 2023

Objectives

  • Compare several wastewater filtering options by measuring the nucleic acid content by qPCR. Experimental design here.
  • Get Dan up to speed with working with this data.
  • Explore options for data analysis workflows.

Preliminary work

  • Ari put the .eds files into Google Drive from the lab computer. (He also exported some Excel files but we’re not using those.)
  • Dan installed the Google Drive desktop app and Design and Analysis on his Mac, opened the .eds files, and fixed some missing data in the plate layout
  • Dan used the “Analyze” in Design and Analysis to automatically calculate thresholds and compute c_q values.
  • Dan exported the data to .csv.
  • Symlinked the google drive folder for the airport experiment to ~/airport/ on his computer so I don’t have to refer to the whole filepath here.

Data import

library(readr)
library(dplyr)

Attaching package: 'dplyr'
The following objects are masked from 'package:stats':

    filter, lag
The following objects are masked from 'package:base':

    intersect, setdiff, setequal, union
library(purrr)

data_dir <- "~/airport/[2023-08-29] CP Prefilters vs Vacuum Filters/Test 1 qPCR Results/csv/"
filename_pattern <- "Results"
raw_data <- list.files(
  data_dir,
  pattern = filename_pattern,
  full.names = TRUE
) |>
  map(function(f) read_csv(f, skip = 23)) |>
  list_rbind()
Rows: 36 Columns: 21
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (8): Well Position, Sample, Target, Task, Reporter, Quencher, Amp Status...
dbl (8): Well, Amp Score, Cq Confidence, Cq Mean, Cq SD, Threshold, Baseline...
lgl (5): Omit, Curve Quality, Result Quality Issues, Auto Threshold, Auto Ba...

ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Rows: 29 Columns: 21
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (8): Well Position, Sample, Target, Task, Reporter, Quencher, Amp Status...
dbl (8): Well, Amp Score, Cq Confidence, Cq Mean, Cq SD, Threshold, Baseline...
lgl (5): Omit, Curve Quality, Result Quality Issues, Auto Threshold, Auto Ba...

ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
print(raw_data)
# A tibble: 65 × 21
    Well `Well Position` Omit  Sample Target Task    Reporter Quencher
   <dbl> <chr>           <lgl> <chr>  <chr>  <chr>   <chr>    <chr>   
 1     1 A1              FALSE 1      CrA    UNKNOWN FAM      NFQ-MGB 
 2     2 A2              FALSE 1      CrA    UNKNOWN FAM      NFQ-MGB 
 3     3 A3              FALSE 1      CrA    UNKNOWN FAM      NFQ-MGB 
 4     5 A5              FALSE 1      16S    UNKNOWN FAM      NFQ-MGB 
 5     6 A6              FALSE 1      16S    UNKNOWN FAM      NFQ-MGB 
 6     7 A7              FALSE 1      16S    UNKNOWN FAM      NFQ-MGB 
 7    13 B1              FALSE 2      CrA    UNKNOWN FAM      NFQ-MGB 
 8    14 B2              FALSE 2      CrA    UNKNOWN FAM      NFQ-MGB 
 9    15 B3              FALSE 2      CrA    UNKNOWN FAM      NFQ-MGB 
10    17 B5              FALSE 2      16S    UNKNOWN FAM      NFQ-MGB 
# ℹ 55 more rows
# ℹ 13 more variables: `Amp Status` <chr>, `Amp Score` <dbl>,
#   `Curve Quality` <lgl>, `Result Quality Issues` <lgl>, Cq <chr>,
#   `Cq Confidence` <dbl>, `Cq Mean` <dbl>, `Cq SD` <dbl>,
#   `Auto Threshold` <lgl>, Threshold <dbl>, `Auto Baseline` <lgl>,
#   `Baseline Start` <dbl>, `Baseline End` <dbl>
coding <- list(
  "1" = "Normal centrifugation/filtration, regular CP",
  "2" = "Normal centrifugation/filtration, regular CP",
  "3" = "Normal centrifugation, no filtration, prefilter CP",
  "4" = "Normal centrifugation, no filtration, prefilter CP",
  "5" = "No centrifugation/filtration, prefilter CP",
  "6" = "No centrifugation/filtration, prefilter CP"
)
tidy_data <- raw_data |>
  mutate(
    Cq = as.double(Cq),
    Treatment = recode(Sample, !!!coding)
  )
Warning: There was 1 warning in `mutate()`.
ℹ In argument: `Cq = as.double(Cq)`.
Caused by warning:
! NAs introduced by coercion
library(ggplot2)
tidy_data |>
  ggplot(mapping = aes(x = Cq, y = Treatment, color = Sample)) +
  geom_point(alpha = 0.5) +
  facet_wrap(facets = ~Target)
Warning: Removed 11 rows containing missing values (`geom_point()`).

TODO

  • Figure out what the Sample numbers mean with respect to the different treatments
  • There are a few NaNs that show up as missing points and aren’t evident in the plot. Will investigate later.