I've written a script with a for() loop to process the raw microarray CEL files of five different GEO data sets in R, but it screws up when it gets to the GCRMA processing part. I get a "Was unable to process microarray data" message in my log file, but no error message, despite having an error block. Also, it works just fine when I don't use a tryCatch block, which makes me think it's something with the way I have my error handling set up. But I have the exact same setup for reading the CEL files into an Affybatch, and that works just fine. What am I doing wrong here?
Here's the GCRMA processing step (which is not working):
eset <- tryCatch( { gcrma(affy.data) }, warning = function(w) { # For warnings, write them to the output file. cat(paste("Warning in GEO data set", i, "when performing GCRMA processing:", conditionMessage(w)), file=logfile, append=TRUE, sep = "\n") }, error = function(e) { # For errors, write them to the output file and then skip to the next data set. cat(paste("Error in GEO data set", i, "when performing GCRMA processing", conditionMessage(e)), file=logfile, append=TRUE, sep = "\n") return(NULL) } ) if(is.null(eset)) { cat(paste("Was unable to process microarray data for GEO data set", i, ". Skipping to next data set."), file=logfile, append=TRUE, sep = "\n") next } else { # If everything went all right, make a note of that in the output file. cat(paste("Successfully processed GEO data set", i), file=logfile, append=TRUE, sep = "\n") }
... and here's the step for reading into an Affybatch, which is:
# Read the CEL files into an Affybatch object. affy.data <- tryCatch( { ReadAffy() }, warning = function(w) { # For warnings, write them to the output file. cat(paste("Warning in GEO data set", i, "when reading CEL files:", conditionMessage(w)), file=logfile, append=TRUE, sep = "\n") }, error = function(e) { # For errors, write them to the output file and then skip to the next data set. cat(paste("Error in GEO data set", i, "when reading CEL files:", conditionMessage(e)), file=logfile, append=TRUE, sep = "\n") return(NULL) } ) if(is.null(affy.data)) { cat(paste("Was unable to read in CEL files for GEO data set", i, ". Skipping to next data set."), file=logfile, append=TRUE, sep = "\n") next } else { cat(paste("Successfully read CEL files for GEO data set", i), file=logfile, append=TRUE, sep = "\n") }
(Btw, i
is the loop variable that holds the name of the data set.)
That did the trick! And thanks, I did not know that about tryCatch().