| dsApply.GenericDataFileSet {R.filesets} | R Documentation |
Applies a function to each file in the file set.
WARNING: dsApply(ds, FUN, ...) will soon be deprecated.
Instead, use future_lapply(ds, FUN, ...).
## S3 method for class 'GenericDataFileSet'
dsApply(ds, IDXS=NULL, DROP=is.null(IDXS), AS=as.list, FUN, ..., args=list(), skip=FALSE,
verbose=FALSE, .parallel=c("none", "future", "BatchJobs", "BiocParallel::BatchJobs"),
.control=list(dW = 1))
ds, ds1, ds2 |
|
IDXS |
A (named) |
DROP |
If |
AS |
(optional) A |
FUN |
A |
... |
Arguments passed to |
args |
(optional) A |
skip |
If |
verbose |
See |
.parallel |
A |
.control |
(internal) A named |
Returns a named list where the names are those of argument IDXS.
Henrik Bengtsson
The future, BiocParallel and BatchJobs packages are utilized for parallel/distributed processing, depending on settings.
## Not run:
isPackageInstalled <- R.utils::isPackageInstalled
# - - - - - - - - - - - - - - - - - - - - - - - -
# Setting up a file set
# - - - - - - - - - - - - - - - - - - - - - - - -
path <- system.file(package="R.filesets")
ds <- GenericDataFileSet$byPath(path)
# - - - - - - - - - - - - - - - - - - - - - - - -
# Get the size of each file
# - - - - - - - - - - - - - - - - - - - - - - - -
# Alt 1.
res1 <- lapply(ds, FUN=getFileSize)
print(res1)
# Alt 2. (according to current settings; see package startup message)
res2 <- dsApply(ds, FUN=getFileSize)
print(res2)
stopifnot(identical(res2, res1))
# Alt 3. (via an internal loop)
res2 <- dsApply(ds, FUN=getFileSize, .parallel="none")
print(res2)
stopifnot(identical(res2, res1))
# Alt 4. (via BiocParallel + BatchJobs)
if (isPackageInstalled("BiocParallel") && isPackageInstalled("BatchJobs")) {
res3 <- dsApply(ds, FUN=getFileSize, .parallel="BiocParallel::BatchJobs")
print(res3)
stopifnot(identical(res3, res1))
}
## End(Not run)