Skip to content

Commit

Permalink
PR addressing Issue #214 (#218)
Browse files Browse the repository at this point in the history
fix: implemented BiocParallel functionality into `tune.spls()` via restructuring of the main portion of the function. bplapply() iterates over all pairs of input keepX/Y so only reduces runtime for long lists of test.keepX/Y

refactor: previous PR left duplicate function used for development. this is rectified and more comments are added

test: added test cases for `tune.spls()`. These are just placeholders as more robust testing criteria needs to be established as well as this document will be fully updated as part of PR #206

tests: updated tests to assess actual values alongside RNG control of parallel function calls.

refactor: replaced all calls to `cpus` to `BPPARAM` in `tune()`

docs: updated `tune.Rd` file with cpus -> BPPARAM shift
  • Loading branch information
Max-Bladen authored Dec 13, 2022
1 parent f098019 commit ba154b5
Show file tree
Hide file tree
Showing 4 changed files with 376 additions and 329 deletions.
19 changes: 4 additions & 15 deletions R/tune.R
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@
#' @param tol Numeric, convergence tolerance criteria.
#' @param light.output if set to FALSE, the prediction/classification of each
#' sample for each of \code{test.keepX} and each comp is returned.
#' @param cpus Integer, number of cores to use for parallel processing.
#' Currently only available for \code{method = "spls"}
#' @param BPPARAM A \linkS4class{BiocParallelParam} object indicating the type
#' of parallelisation. See examples.
#' @return Depending on the type of analysis performed and the input arguments,
#' a list that may contain:
#'
Expand Down Expand Up @@ -202,7 +202,7 @@ tune <-
#pca
light.output = TRUE,
# mint, splsda
cpus = 1
BPPARAM = SerialParam()

)
{
Expand Down Expand Up @@ -292,23 +292,12 @@ tune <-
nrepeat = nrepeat,
logratio = logratio,
multilevel = multilevel,
light.output = light.output,
cpus = cpus)
light.output = light.output)
} else if (method == "spls") {
if(missing(multilevel))
{
message("Calling 'tune.spls'")

if (cpus > 1)
{
if (.onUnix())
BPPARAM <- BiocParallel::MulticoreParam(workers = cpus)
else
BPPARAM <- BiocParallel::SnowParam(workers = cpus)
} else
{
BPPARAM <- BiocParallel::SerialParam()
}
result = tune.spls(X = X,
Y = Y,
test.keepX = test.keepX,
Expand Down
Loading

0 comments on commit ba154b5

Please sign in to comment.