Skip to content

Commit

Permalink
refactor: add parameter f to more functions
Browse files Browse the repository at this point in the history
  • Loading branch information
jorainer committed Nov 24, 2023
1 parent 194f104 commit 0e555dc
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 13 deletions.
15 changes: 9 additions & 6 deletions R/Spectra.R
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,8 @@ NULL
#' splitted. For `filterPrecursorScan`:
#' defining which spectra belong to the same original data file (sample).
#' Defaults to `f = dataOrigin(x)`.
#' For `intensity`, `mz` and `peaksData`: factor defining how data should
#' be chunk-wise loaded an processed. Defaults to [processingChunkFactor()].
#'
#' @param FUN For `addProcessing`: function to be applied to the peak matrix
#' of each spectrum in `object`. For `compareSpectra`: function to compare
Expand Down Expand Up @@ -1630,8 +1632,8 @@ setMethod("acquisitionNum", "Spectra", function(object)
#' @rdname Spectra
setMethod(
"peaksData", "Spectra",
function(object, columns = c("mz", "intensity"), ..., BPPARAM = bpparam()) {
f <- .parallel_processing_factor(object)
function(object, columns = c("mz", "intensity"),
f = processingChunkFactor(object), ..., BPPARAM = bpparam()) {
if (length(object@processingQueue) || length(f))
SimpleList(.peaksapply(object, columns = columns, f = f))
else SimpleList(peaksData(object@backend, columns = columns))
Expand Down Expand Up @@ -1692,8 +1694,9 @@ setMethod("dropNaSpectraVariables", "Spectra", function(object) {
})

#' @rdname Spectra
setMethod("intensity", "Spectra", function(object, ...) {
f <- .parallel_processing_factor(object)
setMethod("intensity", "Spectra", function(object,
f = processingChunkFactor(object),
...) {
if (length(object@processingQueue) || length(f))
NumericList(.peaksapply(object, FUN = function(z, ...) z[, 2],
f = f, ...), compress = FALSE)
Expand Down Expand Up @@ -1835,8 +1838,8 @@ setMethod("length", "Spectra", function(x) length(x@backend))
setMethod("msLevel", "Spectra", function(object) msLevel(object@backend))

#' @rdname Spectra
setMethod("mz", "Spectra", function(object, ...) {
f <- .parallel_processing_factor(object)
setMethod("mz", "Spectra", function(object, f = processingChunkFactor(object),
...) {
if (length(object@processingQueue) || length(f))
NumericList(.peaksapply(object, FUN = function(z, ...) z[, 1],
f = f, ...), compress = FALSE)
Expand Down
16 changes: 12 additions & 4 deletions man/Spectra.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions vignettes/Spectra-large-scale.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,12 @@ chunk-wise) processing. These functions are:
- `estimatePrecursorIntensity`: parameter `f` (defaults to `dataOrigin(x)`)
defines the splitting and processing. This should represent the original data
files the spectra data derives from.
- `intensity`: parameter `f` (defaults to `processingChunkFactor(object)`)
defines if and how the data should be split for parallel processing.
- `mz`: parameter `f` (defaults to `processingChunkFactor(object)`)
defines if and how the data should be split for parallel processing.
- `peaksData`: parameter `f` (defaults to `processingChunkFactor(object)`)
defines if and how the data should be split for parallel processing.
- `setBackend`: parameter `f` (defaults to `processingChunkFactor(object)`)
defines if and how the data should be split for parallel processing.

Expand All @@ -223,12 +229,9 @@ on the `processingChunkFactor`:

- `containsMz`.
- `containsNeutralLoss`.
- `intensity`.
- `ionCount`.
- `isCentroided`.
- `isEmpty`.
- `mz`.
- `peaksData`.



Expand Down

0 comments on commit 0e555dc

Please sign in to comment.