Hello,
I am trying to figure out to correct way to load a package inside a function called with bplapply. The function resides in a package inside a S4 method call
setMethod( f = "analyze", signature = signature(.Object = "testClass" , experimentNo = "numeric"), definition = function(.Object, experimentNo){ # here some stuff happens, which generates a list of inputFiles FUN <- function(x, .Object, workDir){ requireNamespace("tools", quietly = TRUE) requireNamespace("Rsamtools", quietly = TRUE) requireNamespace("S4Vectors", quietly = TRUE) fileNameReadCache <- paste0(workDir, "cache_", md5sum(x),".RData") if(!file.exists(fileNameReadCache)){ # Call to an S4 function reading in a Bam file and returning a DataFrame resReads <- .summarizeReadData(.Object, x) save(resReads, file = fileNameReadCache) } else { load(fileNameReadCache) } } list <- bplapply(inputFiles, FUN, .Object = .Object, workDir = workDir) # do some stuff with the data } )
This cause the following output to be displayed in the console several times (for each worker):
<environment: namespace:base> cpu elapsed transient <environment: namespace:base> package ... quietly [1] e [2] <environment: namespace:tools> files
I tried setting the log threshold to WARN but this did not help.
bpparam <- bpparam() bpthreshold(bpparam) <- "WARN" register(bpparam, default = TRUE)
Does anyone have any advice for me?
Thanks in advance.
Edit:
- added sessionInfo() output
- modified example function
> sessionInfo() R version 3.4.1 (2017-06-30) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows >= 8 x64 (build 9200) Matrix products: default locale: [1] LC_COLLATE=German_Germany.1252 LC_CTYPE=German_Germany.1252 LC_MONETARY=German_Germany.1252 LC_NUMERIC=C [5] LC_TIME=German_Germany.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] RPF_0.1.1.9076 loaded via a namespace (and not attached): [1] Category_2.42.1 bitops_1.0-6 matrixStats_0.52.2 bit64_0.9-7 [5] httr_1.3.1 RColorBrewer_1.1-2 GenomeInfoDb_1.12.2 Rgraphviz_2.20.0 [9] tools_3.4.1 backports_1.1.0 R6_2.2.2 KernSmooth_2.23-15 [13] rpart_4.1-11 Hmisc_4.0-3 DBI_0.7 lazyeval_0.2.0 [17] BiocGenerics_0.22.0 colorspace_1.3-2 nnet_7.3-12 gridExtra_2.2.1 [21] DESeq2_1.16.1 bit_1.1-12 compiler_3.4.1 graph_1.54.0 [25] Biobase_2.36.2 htmlTable_1.9 Cairo_1.5-9 xtail_1.1.5 [29] DelayedArray_0.2.7 rtracklayer_1.36.4 KEGGgraph_1.38.1 caTools_1.17.1 [33] scales_0.4.1 checkmate_1.8.3 genefilter_1.58.1 RBGL_1.52.0 [37] stringr_1.2.0 digest_0.6.12 Rsamtools_1.28.0 foreign_0.8-69 [41] AnnotationForge_1.18.1 XVector_0.16.0 base64enc_0.1-3 pkgconfig_2.0.1 [45] htmltools_0.3.6 limma_3.32.5 htmlwidgets_0.9 rlang_0.1.2 [49] RSQLite_2.0 bindr_0.1 GOstats_2.42.0 gtools_3.5.0 [53] BiocParallel_1.10.1 xlsx_0.5.7 acepack_1.4.1 dplyr_0.7.2 [57] RCurl_1.95-4.8 magrittr_1.5 GO.db_3.4.1 GenomeInfoDbData_0.99.0 [61] Formula_1.2-2 Matrix_1.2-11 Rcpp_0.12.12 munsell_0.4.3 [65] S4Vectors_0.14.3 pathview_1.16.5 stringi_1.1.5 SummarizedExperiment_1.6.3 [69] zlibbioc_1.22.0 gplots_3.0.1 plyr_1.8.4 grid_3.4.1 [73] blob_1.1.0 gdata_2.18.0 parallel_3.4.1 lattice_0.20-35 [77] Biostrings_2.44.2 splines_3.4.1 xlsxjars_0.6.1 GenomicFeatures_1.28.4 [81] annotate_1.54.0 KEGGREST_1.16.1 locfit_1.5-9.1 knitr_1.17 [85] GenomicRanges_1.28.4 reshape2_1.4.2 geneplotter_1.54.0 codetools_0.2-15 [89] biomaRt_2.32.1 stats4_3.4.1 XML_3.98-1.9 glue_1.1.1 [93] latticeExtra_0.6-28 data.table_1.10.4 png_0.1-7 foreach_1.4.3 [97] RDAVIDWebService_1.14.0 gtable_0.2.0 assertthat_0.2.0 ggplot2_2.2.1 [101] xtable_1.8-2 survival_2.41-3 tibble_1.3.3 rJava_0.9-8 [105] iterators_1.0.8 GenomicAlignments_1.12.2 AnnotationDbi_1.38.2 memoise_1.1.0 [109] IRanges_2.10.2 bindrcpp_0.2 cluster_2.0.6 LSD_3.0 [113] GSEABase_1.38.0
Can you provide (edit your question) the output of sessionInfo(), and also a completely reproducible example? I can't replicate your problem from the information you provide.
Thanks for the reply. I changed the initial post accordingly.
Do you know, how this output is created? I don't recognize it from its format. It is not a startup message nor a warning.
To add a bit more context, I switched from using parallel to BiocParallel. It did not change anything inside the functions and that is, when the output started to appear.
Hi Martin,
I did so more digging. It looks to me that this might be an output, which one could get from selectMethod
This another example. The output is mile long (more than 1000 lines), so I don't want to post it here in full. I recognize function names, which I use, but apart from that, I cannot add anymore or more precisely I don't know, what to add in addition to this.
Thanks for any help in advance.