xcmsPapply {xcms} | R Documentation

## xcmsPapply

### Description

An apply-like function which uses Rmpi to distribute the processing evenly across a cluster. Will use a non-MPI version if distributed processing is not available.

### Usage

        xcmsPapply(arg_sets, papply_action, papply_commondata = list(),
               show_errors = TRUE, do_trace = FALSE, also_trace = c())

### Arguments

`arg_sets` | a list, where each item will be given as an argument to papply_action
`papply_action` | A function which takes one argument. It will be called on each element of arg_sets
`papply_commondata` | A list containing the names and values of variables to be accessible to the papply_action. 'attach' is used locally to import this list.
`show_errors` | If set to TRUE, overrides Rmpi's default, and messages for errors which occur in R slaves are produced.
`do_trace` | If set to TRUE, causes the papply_action function to be traced. i.e. Each statement is output before it is executed by the slaves.
`also_trace` | If supplied an array of function names, as strings, tracing will also occur for the specified functions.

### Details

Similar to apply and lapply, applies a function to all items of a list, and returns a list with the corresponding results.

Uses Rmpi to implement a pull idiom in order to distribute the processing evenly across a cluster. If Rmpi is not available, or there are no slaves, implements this as a non-parallel algorithm.

`xcmsPapply` is a modified version of the papply function from package papply 0.2 (Duane Currie). Parts of the slave function were wrapped in try() to make it failsafe and progress output was added.

Make sure `Rmpi` was installed properly by executing the example below. `Rmpi` was tested with

- OpenMPI : Unix, http://www.open-mpi.org/, don't forget to export `MPI_ROOT` before installing Rmpi e.g. `export MPI_ROOT=/usr/lib/openmpi`
- DeinoMPI : Windows, http://mpi.deino.net/, also see http://www.stats.uwo.ca/faculty/yu/Rmpi/

### Value

A list of return values from papply_action. Each value corresponds to the element of arg_sets used as a parameter to papply_action

### Note

Does not support distributing recursive calls in parallel. If papply is used inside papply_action, it will call a non-parallel version

### Author(s)

Duane Currie <duane.currie@acadiau.ca>, modified by Ralf Tautenhahn <rtautenh@ipb-halle.de>.

### References

http://ace.acadiau.ca/math/ACMMaC/software/papply/

### Examples

    ## Not run:
    library(Rmpi)
    library(xcms)

    number_lists <- list(1:10,4:40,2:27)

    mpi.spawn.Rslaves(nslaves=2)

    results <- xcmsPapply(number_lists,sum)
    results

    mpi.close.Rslaves()

    ## End(Not run)

[Package xcms version 1.16.3 Index]