Last data update: 2014.03.03

R: Parallel lapply-like functionality
bplapplyR Documentation

Parallel lapply-like functionality

Description

bplapply applies FUN to each element of X. Any type of object X is allowed, provided length, [, and [[ methods are available. The return value is a list of length equal to X, as with lapply.

Usage

bplapply(X, FUN, ..., BPREDO = list(), BPPARAM=bpparam())

Arguments

X

Any object for which methods length, [, and [[ are implemented.

FUN

The function to be applied to each element of X.

...

Additional arguments for FUN, as in lapply.

BPPARAM

An optional BiocParallelParam instance determining the parallel back-end to be used during evaluation, or a list of BiocParallelParam instances, to be applied in sequence for nested calls to BiocParallel functions.

BPREDO

A list of output from bplapply with one or more failed elements. When a list is given in BPREDO, bpok is used to identify errors, tasks are rerun and inserted into the original results.

Details

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

Value

See lapply.

Author(s)

Martin Morgan mailto:mtmorgan@fhcrc.org. Original code as attributed in mclapply.

See Also

  • bpvec for parallel, vectorized calculations.

  • BiocParallelParam for possible values of BPPARAM.

Examples

showMethods("bplapply")

## ten tasks (1:10) so ten calls to FUN default registered parallel
## back-end. Compare with bpvec.
fun <- function(v) {
    message("working") ## 10 tasks
    sqrt(v)
}
bplapply(1:10, fun) 

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(BiocParallel)
> png(filename="/home/ddbj/snapshot/RGM3/R_BC/result/BiocParallel/bplapply.Rd_%03d_medium.png", width=480, height=480)
> ### Name: bplapply
> ### Title: Parallel lapply-like functionality
> ### Aliases: bplapply bplapply,ANY,list-method bplapply,ANY,missing-method
> ###   bplapply,ANY,BiocParallelParam-method
> ###   bplapply,ANY,BatchJobsParam-method bplapply,ANY,DoparParam-method
> ###   bplapply,ANY,SerialParam-method bplapply,ANY,SnowParam-method
> ### Keywords: manip
> 
> ### ** Examples
> 
> showMethods("bplapply")
Function: bplapply (package BiocParallel)
X="ANY", BPPARAM="BatchJobsParam"
X="ANY", BPPARAM="DoparParam"
X="ANY", BPPARAM="SerialParam"
X="ANY", BPPARAM="SnowParam"
X="ANY", BPPARAM="list"
X="ANY", BPPARAM="missing"

> 
> ## ten tasks (1:10) so ten calls to FUN default registered parallel
> ## back-end. Compare with bpvec.
> fun <- function(v) {
+     message("working") ## 10 tasks
+     sqrt(v)
+ }
> bplapply(1:10, fun) 
working
working
working
working
working
working
working
working
working
working
[[1]]
[1] 1

[[2]]
[1] 1.414214

[[3]]
[1] 1.732051

[[4]]
[1] 2

[[5]]
[1] 2.236068

[[6]]
[1] 2.44949

[[7]]
[1] 2.645751

[[8]]
[1] 2.828427

[[9]]
[1] 3

[[10]]
[1] 3.162278

> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>