## JEG3 PFAS Screen Data Processing Pipeline ## BEB 12072018 ## Construction of data frame shells for Plate Maps 1-4 library(readxl) library(rlist) library(dplyr) ## Function to clean up data frames for chem ID, chem concentration, and well site ID cleanup.cheminfo<-function(x){ x<-x[-c(1)] colnames(x)<-c(1:24) rownames(x)<-c(LETTERS[1:16]) x<-as.matrix(x) x<-t(x) x<-array(x)} ## Build data frame shells for all 4 plate maps ## Set working directory to folder containing plate maps with chemical CAS #s, concentrations, and full chemical names setwd("C:/Users/Public/Documents/My Documents/JEG3/Experiments/24h 384well PFAS screen 500uM-50uM/R Data Pipeline/Plate Maps") site.id.384<-as.data.frame(read_excel("Site ID 384 well plate map.xlsx")) pm1cas<-as.data.frame(read_excel("Platemap-01 chemical CAS.xlsx")) pm1id<-as.data.frame(read_excel("Platemap-01 chemical ID.xlsx")) pm1conc<-as.data.frame(read_excel("Platemap-01 dose concentrations.xlsx")) pm2cas<-as.data.frame(read_excel("Platemap-02 chemical CAS.xlsx")) pm2id<-as.data.frame(read_excel("Platemap-02 chemical ID.xlsx")) pm2conc<-as.data.frame(read_excel("Platemap-02 dose concentrations.xlsx")) pm3cas<-as.data.frame(read_excel("Platemap-03 chemical CAS.xlsx")) pm3id<-as.data.frame(read_excel("Platemap-03 chemical ID.xlsx")) pm3conc<-as.data.frame(read_excel("Platemap-03 dose concentrations.xlsx")) pm4cas<-as.data.frame(read_excel("Platemap-04 chemical CAS.xlsx")) pm4id<-as.data.frame(read_excel("Platemap-04 chemical ID.xlsx")) pm4conc<-as.data.frame(read_excel("Platemap-04 dose concentrations.xlsx")) ## Run series of code that will bind matrices into list that correspond to well site id, ## chemical CAS, chemical name, and chemical concentration ## Then run cleanup.cheminfo function across all matrices within list ## Then cbind list items together and make into dataframe and rename column headers pm1.list<-list(site.id.384,pm1cas,pm1id,pm1conc) pm1.list.clean<-lapply(pm1.list, cleanup.cheminfo) pm1.shell<-as.data.frame(list.cbind(pm1.list.clean)) names(pm1.shell)<-c("site.id","CAS","chem.id","conc") pm2.list<-list(site.id.384,pm2cas,pm2id,pm2conc) pm2.list.clean<-lapply(pm2.list, cleanup.cheminfo) pm2.shell<-as.data.frame(list.cbind(pm2.list.clean)) names(pm2.shell)<-c("site.id","CAS","chem.id","conc") pm3.list<-list(site.id.384,pm3cas,pm3id,pm3conc) pm3.list.clean<-lapply(pm3.list, cleanup.cheminfo) pm3.shell<-as.data.frame(list.cbind(pm3.list.clean)) names(pm3.shell)<-c("site.id","CAS","chem.id","conc") pm4.list<-list(site.id.384,pm4cas,pm4id,pm4conc) pm4.list.clean<-lapply(pm4.list, cleanup.cheminfo) pm4.shell<-as.data.frame(list.cbind(pm4.list.clean)) names(pm4.shell)<-c("site.id","CAS","chem.id","conc") ## Write .csv files for data frame shells write.csv(pm1.shell, "Platemap-01 shell.csv", row.names = F) write.csv(pm2.shell, "Platemap-02 shell.csv", row.names = F) write.csv(pm3.shell, "Platemap-03 shell.csv", row.names = F) write.csv(pm4.shell, "Platemap-04 shell.csv", row.names = F)