Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
ENH: Create control well filelist to optimize CellProfiler pipeline
- Loading branch information
Showing
1 changed file
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
suppressPackageStartupMessages({ | ||
library(tidyverse) | ||
library(magrittr) | ||
library(readxl) | ||
library(stringr) | ||
library(methods) # For Rscript per http://stackoverflow.com/a/41797025 | ||
}) | ||
|
||
## Configuration values. | ||
files_plate <- "../data/DRSC_TF_Library_Distribution.xls" | ||
path_images <- "../results/z_projection" | ||
file_filelist <- "../results/cellprofiler/2017-02-20/filelist" | ||
|
||
## Plate 504 was run at the last minute, and so the controls are not | ||
## reflected in the Excel spreadsheet provided by the core facility. | ||
## Therefore below is the list of added wells, which we will later | ||
## merge with the spreadsheet data: | ||
wells_control <- tibble::tribble( | ||
~well, ~symbol, | ||
##---|------ | ||
"I04", "BROWN", | ||
"E09", "CAL1", | ||
"L03", "FACT", | ||
"E16", "Rho1", | ||
"L16", "Thread", | ||
"H21", "water") %>% | ||
bind_rows(tibble( | ||
symbol = "LacZ", | ||
well = c("C03", "C22", "D12", "D13", "E05", "E20", "F11", | ||
"F14", "G07", "G18", "H09", "H16", "I09", "I16", | ||
"J07", "J18", "K11", "K14", "L05", "L20", "M12", | ||
"M13", "N03", "N22"))) %>% | ||
rename(symbol_control = symbol) %>% # Prepare for join. | ||
arrange(well) | ||
## FIXME: Need to confirm what type of control Thread is. | ||
wells_layout <- | ||
read_excel(files_plate, sheet = 3) %>% | ||
setNames(tolower(names(.))) %>% | ||
select(plate, well, `symbol(s)`, `fbgn(s)`, amplicon) %>% | ||
rename(symbol = `symbol(s)`, | ||
fbgn = `fbgn(s)`) %>% arrange(plate, well) | ||
wells_layout %<>% | ||
left_join(wells_control) %>% | ||
mutate(symbol = ifelse(is.na(symbol_control), symbol, symbol_control)) %>% | ||
select(-symbol_control) %>% | ||
mutate(control = ifelse( | ||
symbol %in% c("CAL1", "FACT", "Rho1"), ## Rho1 gives binucleates | ||
"positive", NA)) %>% | ||
mutate(control = ifelse( | ||
symbol %in% c("LacZ", "Empty", "BROWN", "water"), | ||
"negative", control)) %>% | ||
mutate(control = ifelse( | ||
is.na(control) & is.na(amplicon), | ||
"unknown", control)) | ||
|
||
## List all controls | ||
wells_control <- wells_layout %>% | ||
filter(!is.na(control)) %>% | ||
mutate(plate = ifelse(plate == "504", "160415_015529-V", plate)) %>% | ||
mutate(file_glob = paste0(plate, "*_", well, "_*")) | ||
|
||
## Glob for files | ||
filelist <- Sys.glob(file.path(normalizePath(path_images), | ||
wells_control$file_glob)) | ||
|
||
## Save the list | ||
writeLines(filelist, file_filelist) |