Question: BiocParallel exporting function?
0
2.9 years ago by
Norway/Oslo
ioannis.vardaxis30 wrote:

Hi,

I am trying to replace doMC package with BiocParallel and I have some questions:

1: Is there a way of registering a backhead and then use plyr package with parallel=TRUE? I have tried everything but it does not seem to work, then I changed dlply etc with bplapply and everything works, however i had to make a lot of ugly modifications to my code in order to use bplapply as it does not break a data.frame like dlply does for example.

2: Now the FUN argument in bplapply is a function which calls another function (function1) and this function1 calls another (function2). I get an error with bplapply that function1 and 2 do not exist. However if i give function1 as an argument, then bplapply does recognize function1 but not function2. Even if i give function2 as an argument, i get the same error, that it does not exist. I guess that this happens because function2 is nested. How can I solve that if I cannot export all those functions to the global environment?

Best

biocparallel • 556 views
written 2.9 years ago by ioannis.vardaxis30

You mean .parallel=TRUE, right?  I think it will be very hard to get advice on these questions without concise reproducible examples illustrating the concerns.  the .parallel parameter to dlply determines whether iteration will occur using foreach, and I believe there are ways to achieve the export functionality you are looking for with bplapply and DoparParam, but you will have to look closely at foreach documentation (and perhaps sources) to do this.

ADD REPLYlink written 2.9 years ago by Vincent J. Carey, Jr.6.3k

Yes for .parallel=TRUE.

I have changed the code now to bplapply, the problem is that when I read the instructions for using bplapply, bioconductor states that the BPPARAM argument should be given by the user. So this is where one has to specify which functions to export if I am not wrong. But there are a lot of functions in my package which need to be exported and they are not visible to the user, and at the same time it is not practical for the user to do that.

Answer: C: BiocParallel exporting function?
0
2.9 years ago by
Martin Morgan ♦♦ 23k
United States
Martin Morgan ♦♦ 23k wrote:

Usually in package code one does not specify BPPARAM(); it then comes from the result of registered()[1] which defaults to MulticoreParam() on Linux / Mac and SnowParam() on Windows. The user can choose a backend using register().

There is no need to export functions referenced by your own package, as in https://github.com/mtmorgan/PkgA/tree/bplapply-pkg-deps where (exported) function foo() calls (internal) function bar().

biocLite("mtmorgan/PkgA@bplapply-pkg-deps")  ## requires devtools
library(PkgA)
foo(2)    # default backend, for me, MulticoreParam()
BiocParallel::register(BiocParallel(SnowParam()))  # BiocParallel is loaded but not attached, so fully resolve symbols
foo(2)