Search
Question: BiocParallel exporting function?
0
gravatar for ioannis.vardaxis
12 months ago by
Norway/Trondheim/NTNU
ioannis.vardaxis10 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

ADD COMMENTlink written 12 months ago by ioannis.vardaxis10

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 12 months ago by Vincent J. Carey, Jr.6.2k

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.

ADD REPLYlink written 12 months ago by ioannis.vardaxis10
0
gravatar for Martin Morgan
12 months ago by
Martin Morgan ♦♦ 20k
United States
Martin Morgan ♦♦ 20k 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)
ADD COMMENTlink written 12 months ago by Martin Morgan ♦♦ 20k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.2.0
Traffic: 325 users visited in the last hour