BiocParallel (version 1.0.3)

bpvec: Parallel, vectorized evaluation

Description

bpvec applies FUN to subsets of X. Any type of object X is allowed, provided length, [, and c methods are available. The return value is a vector of length equal to X, as with FUN(X).

Usage

bpvec(X, FUN, ..., AGGREGATE=c, BPPARAM=bpparam())
"bpvec"(X, FUN, ..., AGGREGATE=c, BPPARAM=bpparam())
"bpvec"(X, FUN, ..., AGGREGATE=c, BPPARAM=bpparam())
"bpvec"(X, FUN, ..., AGGREGATE=c, BPPARAM=bpparam())

Arguments

X
Any object for which methods length, [, and c are implemented.
FUN
The function to be applied to subsets of X.
...
Additional arguments for FUN.
AGGREGATE
A function taking any number of arguments ... called to reduce results (elements of the ... argument of AGGREGATE from parallel jobs. The default, c, concatenates objects and is appropriate for vectors; rbind might be appropriate for data frames.
BPPARAM
A optional BiocParallelParam instance determining the parallel back-end to be used during evaluation.

Value

The result should be identical to FUN(X, ...) (assuming that AGGREGATE is set appropriately).

Details

When BPPARAM is an instance of a class derived from BiocParallelParam for which no other method applies, this method creates a vector of indexes and uses these in conjunction with bplapply to arrange for parallel evaluation.

When BPPARAM is a class for which no method is defined (e.g., SerialParam), FUN(X) is used.

See showMethods{bpvec} for additional methods, e.g., method?bpvec("MulticoreParam").

See Also

bplapply for parallel lapply.

BiocParallelParam for possible values of BPPARAM.

Examples

Run this code
showMethods("bpvec")

## ten tasks (1:10), called with as many back-end elements are specified
## by BPPARAM.  Compare with bplapply
system.time(result <- bpvec(1:10, function(v) {
    message("working") ## 10 tasks
    sqrt(v)
}))
result

Run the code above in your browser using DataCamp Workspace