Light wrapper around BiocParallel
functions that
automatically sets the appropriate parameters based on the number of workers
specified.
Usage
bpapply(
X,
FUN,
apply_fun = BiocParallel::bplapply,
workers = 1,
progressbar = FALSE,
force_snowparam = FALSE,
verbose = FALSE,
...
)
Arguments
- X
Any object for which methods
length
,[
, and[[
are implemented.- FUN
The
function
to be applied to each element ofX
.- apply_fun
A
BiocParallel
function to use for parallel processing. (default =BiocParallel::bplapply
)- workers
The number of workers to use for parallel processing.
- progressbar
logical(1)
Enable progress bar (based on plyr:::progress_text).- force_snowparam
A logical indicating whether to force the use of SnowParam object.
- verbose
A logical indicating whether to print verbose messages while running the function. (default = FALSE)
- ...
Arguments passed on to
BiocParallel::bplapply
,BiocParallel::bpmapply
BPPARAM
An optional
BiocParallelParam
instance determining the parallel back-end to be used during evaluation, or alist
ofBiocParallelParam
instances, to be applied in sequence for nested calls to BiocParallel functions.BPREDO
A
list
of output frombplapply
with one or more failed elements. When a list is given inBPREDO
,bpok
is used to identify errors, tasks are rerun and inserted into the original results.BPOPTIONS
Additional options to control the behavior of the parallel evaluation, see
bpoptions
.MoreArgs
List of additional arguments to
FUN
.SIMPLIFY
If
TRUE
the result will be simplified usingsimplify2array
.USE.NAMES
If
TRUE
the result will be named.
Examples
half_it <- function(arg1) return(arg1 / 2)
x <- seq_len(10)
res <- bpapply(x, half_it, workers = 2)
print(res)
#> [[1]]
#> [1] 0.5
#>
#> [[2]]
#> [1] 1
#>
#> [[3]]
#> [1] 1.5
#>
#> [[4]]
#> [1] 2
#>
#> [[5]]
#> [1] 2.5
#>
#> [[6]]
#> [1] 3
#>
#> [[7]]
#> [1] 3.5
#>
#> [[8]]
#> [1] 4
#>
#> [[9]]
#> [1] 4.5
#>
#> [[10]]
#> [1] 5
#>