Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
rnai-screen-tf/src/filelist-controls.R
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
67 lines (62 sloc)
2.42 KB
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
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) |