Tidy a PCR Excel File
pcr_tidy.Rd
Takes in a fresh results output from qPCR and converts it into a tidy format. Useful for downstream analyses.
Arguments
- file_path
Path to an excel file containing the results of a qPCR run.
- pad_zero
logical. Should 'Sample 1' become 'Sample 01'?
- usr_standards
optional numeric vector specifying standard concentrations. If not supplied, if they exist they will be guessed. See details.
Details
If a standards argument is not supplied AND if the experiment uses standards (ie is not a comparative Ct experiment), the standards will be guessed from the unique quantities with a 'STANDARD' task.
If standards ARE supplied, they will be matched to their nearest quantity, rounding UP. That is, if 1, .1, .01... and the actual quantities are 6.8, .68, .068..., 1 will be rounded to 6.8, .1 will be rounded to .68, etc (despite being numerically closer were they rounded down).
If standards are missing, (ie, only 1 and .01 are supplied), they will be dropped with a message. This is useful if you want to exclude an outlier sample from downstream analysis.
Examples
dat_path <- system.file("extdata", "untidy-pcr-example.xls", package = "amplify")
# Before tidying
dat_dirty <- readxl::read_excel(dat_path, sheet = "Results")
#> New names:
#> * `` -> ...3
#> * `` -> ...4
#> * `` -> ...5
#> * `` -> ...6
#> * `` -> ...7
#> * ...
dat_dirty[1:10, 1:5]
#> # A tibble: 10 x 5
#> `Block Type` `384-Well Block` ...3 ...4 ...5
#> <chr> <chr> <chr> <chr> <chr>
#> 1 Calibration Background is expired Yes NA NA NA
#> 2 Calibration Background performed on 01-13-2020 NA NA NA
#> 3 Calibration Normalization FAM-ROX is expi~ Yes NA NA NA
#> 4 Calibration Normalization FAM-ROX perform~ 01-13-2020 NA NA NA
#> 5 Calibration Normalization VIC-ROX is expi~ Yes NA NA NA
#> 6 Calibration Normalization VIC-ROX perform~ 01-13-2020 NA NA NA
#> 7 Calibration Pure Dye FAM is expired Yes NA NA NA
#> 8 Calibration Pure Dye FAM performed on 01-13-2020 NA NA NA
#> 9 Calibration Pure Dye NED is expired Yes NA NA NA
#> 10 Calibration Pure Dye NED performed on 01-13-2020 NA NA NA
# After tidying
dat_clean <- pcr_tidy(dat_path)
dat_clean[1:10, 1:5]
#> # A tibble: 10 x 5
#> well well_position omit sample_name target_name
#> <chr> <chr> <lgl> <chr> <chr>
#> 1 26 B2 FALSE RD1 GENE1
#> 2 27 B3 FALSE RD1 GENE1
#> 3 28 B4 FALSE RD1 GENE1
#> 4 29 B5 FALSE RD1 GENE2
#> 5 30 B6 FALSE RD1 GENE2
#> 6 31 B7 FALSE RD1 GENE2
#> 7 32 B8 FALSE RD1 GENE3
#> 8 33 B9 FALSE RD1 GENE3
#> 9 34 B10 FALSE RD1 GENE3
#> 10 35 B11 FALSE RD1 GENE4