cheminfo.R 1.6 KB

1234567891011121314151617181920212223242526272829303132333435
  1. cheminfo<-function (file, masterChemFile = masterChemFile)
  2. {
  3. masterChem = read.csv(masterChemFile)
  4. masterCD <- as.data.frame(masterChem)
  5. masterCD <- masterCD[, 1:9]
  6. temp1 <- paste(masterCD$Project, masterCD$Experiment.Date,
  7. masterCD$Plate.SN, sep = "_")
  8. masterCD$filenames <- temp1
  9. masterCD <- masterCD[order(masterCD$Experiment.Date, masterCD$Plate.SN,
  10. masterCD$Well), ]
  11. shortFileName <- paste(strsplit(basename(file), "_")[[1]][1],
  12. strsplit(basename(file), "_")[[1]][2], strsplit(basename(file),
  13. "_")[[1]][3], sep = "_")
  14. plate.chem.info <- list()
  15. count = 1
  16. matchedFileName = 0
  17. for (i in which(shortFileName == masterCD$filename)) {
  18. matchedFileName = 1
  19. plate.chem.info$well[count] <- paste(masterCD$Well[i])
  20. plate.chem.info$treatment[count] <- paste(masterCD$Treatment[i])
  21. plate.chem.info$size[count] <- paste(masterCD$Size[i])
  22. plate.chem.info$dose[count] <- paste(masterCD$Dose[i])
  23. plate.chem.info$units[count] <- paste(masterCD$Units[i])
  24. count = count + 1
  25. }
  26. if (matchedFileName == 0) {
  27. print(paste("File ", shortFileName, " was not found in the possible file names \n constructed from exp log file:",
  28. unique(masterCD$filename), sep = ""))
  29. }
  30. if (!is.element(length(plate.chem.info$well), c(12, 48))) {
  31. print(paste("Info exists for ", length(plate.chem.info$well),
  32. " wells; Some wells have no data.", sep = ""))
  33. }
  34. plate.chem.info
  35. }