Last updated: 2024-10-16

Checks: 6 1

Knit directory: test-3/

This reproducible R Markdown analysis was created with workflowr (version 1.7.1). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.


The R Markdown file has unstaged changes. To know which version of the R Markdown file created these results, you’ll want to first commit it to the Git repo. If you’re still working on the analysis, you can ignore this warning. When you’re finished, you can run wflow_publish to commit the R Markdown file and build the HTML.

Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.

The command set.seed(20241016) was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.

Great job! Recording the operating system, R version, and package versions is critical for reproducibility.

Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.

Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.

Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.

The results in this page were generated with repository version 2cbdcc9. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.

Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish or wflow_git_commit). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:


Untracked files:
    Untracked:  data/Data_QC_filtered.csv

Unstaged changes:
    Modified:   analysis/ELISA_QC.Rmd
    Modified:   analysis/ELISA_visualizations.Rmd
    Modified:   data/Data_QC_flagged.csv
    Modified:   data/failed_samples.csv

Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.


These are the previous versions of the repository in which changes were made to the R Markdown (analysis/ELISA_QC.Rmd) and HTML (docs/ELISA_QC.html) files. If you’ve configured a remote Git repository (see ?wflow_git_remote), click on the hyperlinks in the table below to view the files as they were in that past version.

File Version Author Date Message
Rmd 2cbdcc9 Paloma 2024-10-16 merged data, cleaned, visualized some results
html 2cbdcc9 Paloma 2024-10-16 merged data, cleaned, visualized some results

Introduction


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

Load files

layout <- read.csv("./data/layout_wells_test3_091524.csv", stringsAsFactors = TRUE, na.strings = c("", " "))
results <- read.csv("./data/myassays_table_test3_091524.csv", stringsAsFactors = TRUE, na.strings = c("", " ", "-"))
info <- read.csv("./data/sample_info_test3_091524.csv", stringsAsFactors = TRUE, na.strings = c("", " "))

#kable(summary(c(layout, results, info)))

Merge and clean files

kable(head(layout)) 
Wells Sample
A1 NSB
A2 NSB
B1 STD1
B2 STD1
C1 STD2
C2 STD2
kable(head(results)) 
Sample Wells Raw X. Conc. Conc….Average. X.CV SD SEM
Unknown1 A3 0.403 28.8 2899 2888.0 0.565 16.3 11.5
NA A4 0.405 NA 2876 NA NA NA NA
Unknown2 B3 1.050 81.1 314.1 324.9 4.700 15.3 10.8
NA B4 1.040 NA 335.7 NA NA NA NA
Unknown3 C3 0.959 77.3 461.9 396.6 23.300 92.4 65.3
NA C4 1.040 NA 331.3 NA NA NA NA
dim(results)
[1] 82  9
results <- results %>% 
  select(!Sample) 

m <- merge(layout, results, by = "Wells")
kable(head(m)) 
Wells Sample Raw X. Conc. Conc….Average. X.CV SD SEM
A1 NSB 0.054 0.0 < Curve NA NA NA NA
A10 15 0.840 NA 694.2 NA NA NA NA
A11 32 0.656 50.0 1228 1197 3.690 44.2 31.3
A12 32 0.673 NA 1166 NA NA NA NA
A2 NSB 0.045 NA < Curve NA NA NA NA
A3 30A 0.403 28.8 2899 2888 0.565 16.3 11.5
dim(m)
[1] 82  9
m<- merge(m, info, by = c("Sample", "Wells"))
m <- na.omit(m)
kable(head(m)) 
Sample Wells Raw X. Conc. Conc….Average. X.CV SD SEM weight_mg buffer_nl spike
1 C3 0.959 77.3 461.9 396.6 23.30 92.4 65.3 13.1 250 0
10 D5 0.743 37.6 940.7 3064.0 98.00 3000.0 2120.0 17.7 60 1
11 E5 0.939 71.6 496.8 513.2 4.50 23.1 16.3 17.5 250 0
12 F5 0.422 30.0 2690 2728.0 1.92 52.5 37.1 24.1 250 1
13 G5 0.451 32.1 2412 2477.0 3.68 91.1 64.4 16.8 250 1
14 H5 0.437 31.8 2541 2504.0 2.11 52.9 37.4 13.8 250 1
dim(m)
[1] 38 12
colnames(m) <- c("Sample", "Wells", "Raw.OD", "Binding.Perc", "Concentration_pg/ml","Average_Conc_pg/ml", "CV.Perc", "SD", "SEM", "Weight_mg", "Buffer_nl", "Spike") 

m[, 3:11] <- lapply(m[, 3:11], function(x) as.numeric(as.character(x)))
m$Spike <- as.factor(m$Spike)

Identify duplicates with CV above 15% and flag them

CV_threshold <- 15.0
cv_high <- m %>% 
  filter(CV.Perc > CV_threshold) %>% 
  arrange(desc(CV.Perc))

kable(cv_high)
Sample Wells Raw.OD Binding.Perc Concentration_pg/ml Average_Conc_pg/ml CV.Perc SD SEM Weight_mg Buffer_nl Spike
10 D5 0.743 37.6 940.7 3064.0 98.0 3000.0 2120.0 17.7 60 1
35 D11 0.548 33.8 1727.0 2443.0 41.5 1010.0 716.0 32.1 60 0
1 C3 0.959 77.3 461.9 396.6 23.3 92.4 65.3 13.1 250 0
20 F7 0.538 43.6 1785.0 1550.0 21.4 332.0 235.0 30.1 60 0
4 F3 1.070 80.6 295.8 334.5 16.3 54.6 38.6 11.7 250 0
2 D3 0.675 53.8 1159.0 1045.0 15.3 160.0 113.0 17.2 60 0
# flag high CV

m1 <- m %>%
  mutate(CV_categ = ifelse(CV.Perc > CV_threshold, "HIGH CV", NA))

Identify samples outside the curve and flag them

out_curve <- m %>% 
  filter(Binding.Perc < 20.0 | Binding.Perc > 80.0) %>% 
  arrange(desc(Binding.Perc))

kable(out_curve)
Sample Wells Raw.OD Binding.Perc Concentration_pg/ml Average_Conc_pg/ml CV.Perc SD SEM Weight_mg Buffer_nl Spike
17 C7 1.08 84.3 278.0 270.6 3.86 10.5 7.39 24.5 60 0
30B B3 1.05 81.1 314.1 324.9 4.70 15.3 10.80 29.6 250 0
4 F3 1.07 80.6 295.8 334.5 16.30 54.6 38.60 11.7 250 0
# flag samples outside the curve

m2 <- m1 %>%
  mutate(Binding.Perc_categ = ifelse(Binding.Perc > 80, "ABOVE 80% binding", ifelse(Binding.Perc < 20, "UNDER 20% binding", NA)))

m2 <- m2 %>%
  mutate(Failed_samples = ifelse(!is.na(CV_categ) & !is.na(Binding.Perc_categ), 
                             paste(CV_categ, Binding.Perc_categ, sep = ";"), 
                             coalesce(CV_categ, Binding.Perc_categ))) %>%
  select(!c(CV_categ, Binding.Perc_categ))

# dataset with problematic samples flagged

kable(head(m2))
Sample Wells Raw.OD Binding.Perc Concentration_pg/ml Average_Conc_pg/ml CV.Perc SD SEM Weight_mg Buffer_nl Spike Failed_samples
1 C3 0.959 77.3 461.9 396.6 23.30 92.4 65.3 13.1 250 0 HIGH CV
10 D5 0.743 37.6 940.7 3064.0 98.00 3000.0 2120.0 17.7 60 1 HIGH CV
11 E5 0.939 71.6 496.8 513.2 4.50 23.1 16.3 17.5 250 0 NA
12 F5 0.422 30.0 2690.0 2728.0 1.92 52.5 37.1 24.1 250 1 NA
13 G5 0.451 32.1 2412.0 2477.0 3.68 91.1 64.4 16.8 250 1 NA
14 H5 0.437 31.8 2541.0 2504.0 2.11 52.9 37.4 13.8 250 1 NA
write.csv(m2, "./data/Data_QC_flagged.csv", row.names = FALSE) 


# dataset with high cv samples removed
data.no_cv <- m2 %>% 
 filter(CV.Perc > CV_threshold) 


write.csv(data.no_cv, "./data/Data_QC_filtered.csv", row.names = FALSE) 

# table with samples that failed
failed_samples <- rbind(cv_high, out_curve)
write.csv(failed_samples, "./data/failed_samples.csv", row.names = FALSE) 

sessionInfo()
R version 4.1.0 (2021-05-18)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19045)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252 
[2] LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] ggplot2_3.5.1 knitr_1.48    dplyr_1.1.2  

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.10       pillar_1.9.0      compiler_4.1.0    bslib_0.8.0      
 [5] later_1.3.0       jquerylib_0.1.4   git2r_0.31.0      workflowr_1.7.1  
 [9] tools_4.1.0       digest_0.6.31     gtable_0.3.5      jsonlite_1.8.9   
[13] evaluate_1.0.0    lifecycle_1.0.4   tibble_3.2.1      pkgconfig_2.0.3  
[17] rlang_1.1.0       cli_3.6.1         rstudioapi_0.16.0 yaml_2.3.7       
[21] xfun_0.47         fastmap_1.1.1     withr_3.0.1       stringr_1.5.1    
[25] generics_0.1.3    fs_1.5.2          vctrs_0.6.5       sass_0.4.9       
[29] grid_4.1.0        tidyselect_1.2.0  rprojroot_2.0.4   glue_1.6.2       
[33] R6_2.5.1          fansi_1.0.4       rmarkdown_2.28    magrittr_2.0.3   
[37] whisker_0.4.1     scales_1.3.0      promises_1.2.0.1  htmltools_0.5.8.1
[41] colorspace_2.1-0  httpuv_1.6.9      utf8_1.2.3        stringi_1.7.12   
[45] munsell_0.5.1     cachem_1.0.7