0

I am using R and the GEOQuery package for downloading a set of GEO profiles. For doing this I use the following instructions:

library(Biobase)
library(GEOquery)
gdsAcc<-getGEO('GDS1245',destdir=".")

which downloads the GDS1245.soft.gz in the specified directory.

The problem is that some GEO profiles have been removed, so when I use the above mentioned instructions in a loop and I came with something like:

gdsAcc<-getGEO('GDS450',destdir=".")

in the last case the profile GDS450 does not exist so it throws an error and the program stops. I would like to know how I can catch that error so that in case that the profile does not exist the program will continue looking for the other profiles.

My algorithm is something like:

for (i in 1:length_GEO_profiles){
    disease<-GEOname
    gdsName<-paste("GDS",disease,sep="")
    gdsAcc<-getGEO(gdsName,destdir=".")
}

Any help?

Thanks

Layla
  • 5,234
  • 15
  • 51
  • 66

1 Answers1

0

You should look at try and tryCatch. Here's an example to get you started:

for(i in 1:3) { 
  if(i == 1)
    gdsAcc <- try(getGEO('GDS450',destdir="."))
  cat(i, "\n")
}

If you want to do something with the error, then use an if statement:

if(class(gdsAcc) == "try-error") cat("HELP")

Related questions

Community
  • 1
  • 1
csgillespie
  • 59,189
  • 14
  • 150
  • 185