cheminfo.R 1.6 KB

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