| srapply {ShortRead} | R Documentation |
DEFUNCT; use the BiocParallel package instead.
This lapply like function evaluates locally or, if Rmpi
or parallel is loaded (and Rmpi workers spawned) and
options(srapply_fapply) set appropriately (see below), across
nodes in a cluster. Errors in evaluation of FUN generate
warnings; results are trimmed to exclude results where the error
occurs.
srapply(X, FUN, ..., fapply = .fapply(), reduce = .reduce(),
USE.NAMES = FALSE, verbose = FALSE)
X |
Tasks to be distributed. |
FUN |
A function to be applied to each element of |
... |
Additional arguments, passed to |
fapply |
An optional argument defining an |
reduce |
Optional function accepting a list (the result of
|
USE.NAMES |
If |
verbose |
Report whether evaluation is local or mpi-based; also
forwarded to |
The default value for fapply is available with
ShortRead:::.fapply(). It tests
getOption("srapply_fapply") for value “Rmpi” or
“parallel”.
If Rmpi is indicated, fapply ensures that
ShortRead is required on all workers, and then invokes
mpi.parLapply with arguments X, FUN,
..., and verbose. The function FUN is wrapped
so that errors are returned as objects of class SRError with
type RemoteError. If no workers are available, the code
evaluates FUN so that errors are reported as with remote
evaluation.
If parallel is indicated, fapply invokes
mclapply with arguments as for mpi.parLapply.
Custom reduce functions might be written as
reduce=function(lst) unlist(lst, use.names=TRUE).
The returned value depends on the value of reduce, but by
default is a list with elements containing the results of FUN
applied to each of X. Evaluations resulting in an error have
been removed, and a warning generated.
Martin Morgan <mtmorgan@fhcrc.org>
## Not run:
## DEFUNCT; use BiocParallel::bplapply instead
srapply(1:10, function(i, ...) i)
## collapse result to vector
srapply(1:10, function(i, ...) i, reduce=unlist)
x <- srapply(1:10, function(i, ...) {
if (runif(1)<.2) stop("oops") else i
})
length(x) ## trimmed to exclude errors
## End(Not run)