BiocParallel exporting function?
1
0
Entering edit mode
@ioannisvardaxis-11763
Last seen 18 months ago
Norway/Oslo

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 • 2.1k views
ADD COMMENT
0
Entering edit mode

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 REPLY
0
Entering edit mode

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 REPLY
0
Entering edit mode
@martin-morgan-1513
Last seen 4 months ago
United States

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 COMMENT

Login before adding your answer.

Traffic: 739 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6