1

I am trying a new library and I found a strange behaviour. I have a method of an object of a derived class of type envRefClass which stop my process even inside a tryCatch function with an error handler.

library(STRINGdb)
# Creating the object
string_db <- STRINGdb$new(version = "10", species = 9606,
                       score_threshold = 0, input_directory = "" )
# Converting ids 
string_id <- string_db$map(data.frame(gene = moduleGenes), "gene",
                           takeFirst = FALSE) 
# Ploting with plot_ppi
tryCatch({
  tryCatch({string_db$plot_ppi_enrichment(string_id$STRING_id,
                                          title = paste("Interaction enrichment of", moduleName))},
           error = function(e) {
             message("Couldn't map the enrichment of STRING")
             # sessionInfo()
             # message(e)
           })
}, error = function(e) {
  message("Another error")
  # message(e)
  }
)
'select()' returned 1:1 mapping between keys and columns
Warning:  we couldn't map to STRING 3% of your identifiersERROR: We do not support lists with more than 400 genes.
Please reduce the size of your input and rerun the analysis.    Error in get_png(string_ids, payload_id = payload_id, required_score = required_score) 

where string_id$STRING_id is a list of id of 358 elements. Whatever the error inside the plot_ppi_enrichment (which I already asked for) I did not expect to stop the process. I am using tryCatch correctly?

I have already read this question about how to use tryCatch, but it looks ok for me.

Community
  • 1
  • 1
llrs
  • 3,308
  • 35
  • 68
  • Does the function generating the error call compiled code? – snaut Oct 06 '16 at 09:03
  • Can you specify where the error happens? You could use `options(error = recover)` to stop at the point where the error happens and examine variables in the according environment. – tobiasegli_te Oct 06 '16 at 09:12
  • @snaut AFAIK it is not calling compiled code, at least I don't remember seeing any compilation when I installed the library, but it is downloading data from internet – llrs Oct 06 '16 at 09:14
  • @tobiasegli_te I couldn't ran it with that option (in interactive mode my computer freezes), I can only run this code in BATCH mode – llrs Oct 07 '16 at 09:53

0 Answers0