From 3db888fd7b7be0df07e7f53b9e636ddb64c1f8bb Mon Sep 17 00:00:00 2001 From: Philippine Louail Date: Mon, 20 Nov 2023 11:20:01 +0100 Subject: [PATCH 1/9] fix: `bin` function --- DESCRIPTION | 2 +- NEWS.md | 6 ++++++ R/Spectra.R | 8 ++++++-- R/peaks-functions.R | 12 ++++++++++-- man/Spectra.Rd | 13 ++++++++++++- tests/testthat/test_peaks-functions.R | 9 +++++++++ 6 files changed, 44 insertions(+), 6 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 6e87cf88..841cffe8 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: Spectra Title: Spectra Infrastructure for Mass Spectrometry Data -Version: 1.11.11 +Version: 1.11.12 Description: The Spectra package defines an efficient infrastructure for storing and handling mass spectrometry spectra and functionality to subset, process, visualize and compare spectra data. It provides different diff --git a/NEWS.md b/NEWS.md index ffdf5fc3..fcab3669 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,11 @@ # Spectra 1.11 +## Changes in 1.11.12 + +- Fix issue with `bin` function (see + [issue #302](https://github.com/rformassspectrometry/Spectra/issues/303)). + Addition of `zero.rm` parameter to prevent creation of *empty* bins. + ## Changes in 1.11.11 - Fix issue with `filterFourierTransformArtefacts` function (see [issue diff --git a/R/Spectra.R b/R/Spectra.R index b62549ab..976492bf 100644 --- a/R/Spectra.R +++ b/R/Spectra.R @@ -1049,6 +1049,10 @@ NULL #' @param z For `filterPrecursorCharge`: `integer()` with the precursor charges #' to be used as filter. #' +#' @param zero.rm `logical`. For `bin`: indicating whether to remove bins with +#' zero intensity. Defaults to `TRUE`, meaning the function will discard +#' bins created with an intensity of 0 to enhance memory efficiency. +#' #' @param ... Additional arguments. #' #' @author Sebastian Gibb, Johannes Rainer, Laurent Gatto @@ -2437,7 +2441,7 @@ setMethod("reset", "Spectra", function(object, ...) { #' @exportMethod bin setMethod("bin", "Spectra", function(x, binSize = 1L, breaks = NULL, msLevel. = uniqueMsLevels(x), - FUN = sum) { + FUN = sum, zero.rm = TRUE) { if (!.check_ms_level(x, msLevel.)) return(x) if (!length(breaks)) { @@ -2449,7 +2453,7 @@ setMethod("bin", "Spectra", function(x, binSize = 1L, breaks = NULL, } mids <- (breaks[-length(breaks)] + breaks[-1L]) / 2 x <- addProcessing(x, .peaks_bin, breaks = breaks, mids = mids, - agg_fun = FUN, msLevel = msLevel., + agg_fun = FUN, msLevel = msLevel., zero.rm = zero.rm, spectraVariables = "msLevel") x@processing <- .logging(x@processing, "Spectra of MS level(s) ", diff --git a/R/peaks-functions.R b/R/peaks-functions.R index 65abec60..35b587f3 100644 --- a/R/peaks-functions.R +++ b/R/peaks-functions.R @@ -180,6 +180,11 @@ NULL #' #' @param mids mid points. This parameter is mandatory. #' +#' @param zero.rm `logical` indicating whether to remove bins with zero +#' intensity. Defaults to `TRUE`, meaning the function will discard bins +#' created with an intensity of 0 to enhance memory efficiency. +#' +#' #' @inheritParams .peaks_remove #' #' @return `matrix` with columns `"mz"` and `"intensity"` @@ -191,12 +196,15 @@ NULL by = binSize), agg_fun = sum, mids, - msLevel = spectrumMsLevel, ...) { + msLevel = spectrumMsLevel, zero.rm = TRUE, ...) { if (!(spectrumMsLevel %in% msLevel)) return(x) bins <- MsCoreUtils::bin(x[, 2], x[, 1], size = binSize, breaks = breaks, FUN = agg_fun, returnMids = FALSE) - cbind(mz = mids, intensity = bins) + if (zero.rm) { + keep <- which(bins != 0) + cbind(mz = mids[keep], intensity = bins[keep]) + } else cbind(mz = mids, intensity = bins) } #' @importFrom stats quantile diff --git a/man/Spectra.Rd b/man/Spectra.Rd index 7c7d76e5..2c22a0d2 100644 --- a/man/Spectra.Rd +++ b/man/Spectra.Rd @@ -387,7 +387,14 @@ filterPrecursorPeaks( \S4method{reset}{Spectra}(object, ...) -\S4method{bin}{Spectra}(x, binSize = 1L, breaks = NULL, msLevel. = uniqueMsLevels(x), FUN = sum) +\S4method{bin}{Spectra}( + x, + binSize = 1L, + breaks = NULL, + msLevel. = uniqueMsLevels(x), + FUN = sum, + zero.rm = TRUE +) \S4method{compareSpectra}{Spectra,Spectra}( x, @@ -686,6 +693,10 @@ Defaults to \code{binSize = 1}.} \item{breaks}{For \code{bin}: \code{numeric} defining the m/z breakpoints between bins.} +\item{zero.rm}{\code{logical}. For \code{bin}: indicating whether to remove bins with +zero intensity. Defaults to \code{TRUE}, meaning the function will discard +bins created with an intensity of 0 to enhance memory efficiency.} + \item{MAPFUN}{For \code{compareSpectra}: function to map/match peaks between the two compared spectra. See \code{\link[=joinPeaks]{joinPeaks()}} for more information and possible functions.} diff --git a/tests/testthat/test_peaks-functions.R b/tests/testthat/test_peaks-functions.R index 80675c1a..f6abd81a 100644 --- a/tests/testthat/test_peaks-functions.R +++ b/tests/testthat/test_peaks-functions.R @@ -99,6 +99,15 @@ test_that(".peaks_bin works", { spectrumMsLevel = 1L) expect_equal(res[, 1], mids) expect_equal(res[, 2], c(1, 5, 1, 0, 1, 13, 8, 1, 3, 0, 6, 15, 1, 0, 0)) + + breaks <- seq(0, 1000, by = 0.01) + mids <- (breaks[-length(breaks)] + breaks[-1L]) / 2 + res_true <- Spectra:::.peaks_bin(sciex_pks[[1]], breaks = breaks, mids = mids, + spectrumMsLevel = 1L, zero.rm = TRUE) + res_false <- Spectra:::.peaks_bin(sciex_pks[[1]], breaks = breaks, mids = mids, + spectrumMsLevel = 1L, zero.rm = FALSE) + expect_true(all(res_true[,"intensity"] != 0)) + expect_false(all(res_false == res_true)) }) test_that("joinPeaksNone works", { From 52d4fcc921e95a4f5d12d0630b63e69f29ee4801 Mon Sep 17 00:00:00 2001 From: Philippine Louail Date: Mon, 20 Nov 2023 11:57:03 +0100 Subject: [PATCH 2/9] test changes --- tests/testthat/test_Spectra.R | 2 +- tests/testthat/test_peaks-functions.R | 17 +++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/tests/testthat/test_Spectra.R b/tests/testthat/test_Spectra.R index 79380d70..59cd0518 100644 --- a/tests/testthat/test_Spectra.R +++ b/tests/testthat/test_Spectra.R @@ -1105,7 +1105,7 @@ test_that("filterRt,Spectra works", { test_that("bin,Spectra works", { sps <- Spectra(tmt_mzr) pks <- peaksData(sps) - res <- bin(sps, binSize = 2) + res <- bin(sps, binSize = 2, zero.rm = FALSE) expect_true(length(res@processingQueue) == 1) res1 <- bin(sps, msLevel = 1, binSize = 2) diff --git a/tests/testthat/test_peaks-functions.R b/tests/testthat/test_peaks-functions.R index f6abd81a..a1b4595c 100644 --- a/tests/testthat/test_peaks-functions.R +++ b/tests/testthat/test_peaks-functions.R @@ -71,11 +71,13 @@ test_that(".peaks_bin works", { int <- c(0, 1, 2, 3, 1, 0, 0, 0, 0, 1, 3, 10, 6, 2, 1, 0, 1, 2, 0, 0, 1, 5, 10, 5, 1) x <- cbind(mz = 1:length(int), intensity = int) + # x <- [, x[,"intensity"] != 0] ## this does not fix the test, bit confused by that. brks <- seq(min(x), max(x), by = 1L) brks <- MsCoreUtils:::.fix_breaks(brks, range(x)) mids <- seq_len(length(brks) -1) - res <- .peaks_bin(x, spectrumMsLevel = 1L, breaks = brks, mids = mids) + res <- .peaks_bin(x, spectrumMsLevel = 1L, breaks = brks, mids = mids, + zero.rm = FALSE) expect_identical(res[-1, 2], x[, 2]) expect_identical(res[, 1], as.numeric(mids)) @@ -83,20 +85,21 @@ test_that(".peaks_bin works", { brks <- MsCoreUtils:::.fix_breaks(brks, range(x)) mids <- (brks[-length(brks)] + brks[-1L]) / 2 res <- .peaks_bin(x, spectrumMsLevel = 1L, breaks = brks, - mids = mids) + mids = mids, zero.rm = FALSE) expect_equal(res[, 1], seq(1, 25, by = 2)) expect_equal(res[, 2], c(0, 3, 4, 0, 0, 4, 16, 3, 1, 2, 1, 15, 6)) res <- .peaks_bin(x, spectrumMsLevel = 1L, breaks = brks, - agg_fun = max, mids = mids) + agg_fun = max, mids = mids, zero.rm = FALSE) expect_equal(res[, 1], seq(1, 25, by = 2)) expect_equal(res[, 2], c(0, 2, 3, 0, 0, 3, 10, 2, 1, 2, 1, 10, 5)) - res <- .peaks_bin(x, spectrumMsLevel = 1L, msLevel = 2L, binSize = 2L) + res <- .peaks_bin(x, spectrumMsLevel = 1L, msLevel = 2L, binSize = 2L, + zero.rm = FALSE) expect_identical(res, x) brks <- seq(0.5, 30.5, by = 2) mids <- seq((length(brks) - 1)) res <- Spectra:::.peaks_bin(x, breaks = brks, mids = mids, - spectrumMsLevel = 1L) + spectrumMsLevel = 1L, zero.rm = FALSE) expect_equal(res[, 1], mids) expect_equal(res[, 2], c(1, 5, 1, 0, 1, 13, 8, 1, 3, 0, 6, 15, 1, 0, 0)) @@ -107,7 +110,9 @@ test_that(".peaks_bin works", { res_false <- Spectra:::.peaks_bin(sciex_pks[[1]], breaks = breaks, mids = mids, spectrumMsLevel = 1L, zero.rm = FALSE) expect_true(all(res_true[,"intensity"] != 0)) - expect_false(all(res_false == res_true)) + expect_false(all(res_false[,"intensity"] != 0)) + expect_false(length(res_true) == length(res_false)) + }) test_that("joinPeaksNone works", { From 67819084b1cc465a39d4464d0acdf145cee6c7d6 Mon Sep 17 00:00:00 2001 From: Philippine Louail Date: Mon, 20 Nov 2023 12:17:26 +0100 Subject: [PATCH 3/9] Update test_peaks-functions.R --- tests/testthat/test_peaks-functions.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testthat/test_peaks-functions.R b/tests/testthat/test_peaks-functions.R index a1b4595c..01406121 100644 --- a/tests/testthat/test_peaks-functions.R +++ b/tests/testthat/test_peaks-functions.R @@ -71,7 +71,7 @@ test_that(".peaks_bin works", { int <- c(0, 1, 2, 3, 1, 0, 0, 0, 0, 1, 3, 10, 6, 2, 1, 0, 1, 2, 0, 0, 1, 5, 10, 5, 1) x <- cbind(mz = 1:length(int), intensity = int) - # x <- [, x[,"intensity"] != 0] ## this does not fix the test, bit confused by that. + # x_nozero <- [x[,"intensity"] != 0, ] ## this does not fix the test, bit confused by that. brks <- seq(min(x), max(x), by = 1L) brks <- MsCoreUtils:::.fix_breaks(brks, range(x)) From 8b1eea80dc77aa60eab986f6155bc5788da884ff Mon Sep 17 00:00:00 2001 From: Philippine Louail Date: Mon, 20 Nov 2023 15:07:43 +0100 Subject: [PATCH 4/9] Update test_peaks-functions.R --- tests/testthat/test_peaks-functions.R | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/testthat/test_peaks-functions.R b/tests/testthat/test_peaks-functions.R index 01406121..b7204b46 100644 --- a/tests/testthat/test_peaks-functions.R +++ b/tests/testthat/test_peaks-functions.R @@ -71,7 +71,6 @@ test_that(".peaks_bin works", { int <- c(0, 1, 2, 3, 1, 0, 0, 0, 0, 1, 3, 10, 6, 2, 1, 0, 1, 2, 0, 0, 1, 5, 10, 5, 1) x <- cbind(mz = 1:length(int), intensity = int) - # x_nozero <- [x[,"intensity"] != 0, ] ## this does not fix the test, bit confused by that. brks <- seq(min(x), max(x), by = 1L) brks <- MsCoreUtils:::.fix_breaks(brks, range(x)) From 122dfcf2ea3d557e3a258b534636898f9d7d04f3 Mon Sep 17 00:00:00 2001 From: Philippine Louail Date: Mon, 20 Nov 2023 15:25:01 +0100 Subject: [PATCH 5/9] Update Spectra.Rmd --- vignettes/Spectra.Rmd | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/vignettes/Spectra.Rmd b/vignettes/Spectra.Rmd index 05030bc8..5cf100f6 100644 --- a/vignettes/Spectra.Rmd +++ b/vignettes/Spectra.Rmd @@ -954,10 +954,11 @@ Another way of comparing spectra would be to *bin* the spectra and to cluster them based on similar intensity values. Spectra binning ensures that the binned m/z values are comparable across all spectra. Below we bin our spectra using a bin size of 0.1 (i.e. all peaks with an m/z smaller than 0.1 are aggregated into -one binned peak. +one binned peak. Below, we explicitly set `zero.rm = FALSE` to retain all bins +generated by the function, including those with an intensity of zero. ```{r} -sps_bin <- Spectra::bin(sps, binSize = 0.1) +sps_bin <- Spectra::bin(sps, binSize = 0.1, zero.rm = FALSE) ``` All spectra will now have the same number of m/z values. From 4657ecafef9e1916a0a59fffc10508d28757fa37 Mon Sep 17 00:00:00 2001 From: Philippine Louail Date: Mon, 20 Nov 2023 15:35:16 +0100 Subject: [PATCH 6/9] devtool changes --- man/MsBackend.Rd | 17 ++++++++++------- man/MsBackendCached.Rd | 12 ++++++------ man/Spectra.Rd | 19 ++++++++++--------- man/hidden_aliases.Rd | 22 ++++++++++++++-------- 4 files changed, 40 insertions(+), 30 deletions(-) diff --git a/man/MsBackend.Rd b/man/MsBackend.Rd index 3d6a1ba5..8c6ad7aa 100644 --- a/man/MsBackend.Rd +++ b/man/MsBackend.Rd @@ -25,6 +25,7 @@ \alias{peaksVariables,MsBackend-method} \alias{centroided,MsBackend-method} \alias{centroided<-,MsBackend-method} +\alias{centroided<-,MsBackend,ANY-method} \alias{collisionEnergy,MsBackend-method} \alias{collisionEnergy<-,MsBackend-method} \alias{dataOrigin,MsBackend-method} @@ -75,6 +76,7 @@ \alias{scanIndex,MsBackend-method} \alias{selectSpectraVariables,MsBackend-method} \alias{smoothed,MsBackend-method} +\alias{smoothed<-,MsBackend,ANY-method} \alias{smoothed<-,MsBackend-method} \alias{spectraData,MsBackend-method} \alias{spectraData<-,MsBackend-method} @@ -84,10 +86,11 @@ \alias{split,MsBackend,ANY-method} \alias{supportsSetBackend,MsBackend-method} \alias{tic,MsBackend-method} +\alias{[,MsBackend,ANY,ANY,ANY-method} \alias{$,MsBackend-method} \alias{$<-,MsBackend-method} -\alias{[[,MsBackend-method} -\alias{[[<-,MsBackend-method} +\alias{[[,MsBackend,ANY,ANY-method} +\alias{[[<-,MsBackend,ANY,ANY,ANY-method} \alias{MsBackendDataFrame} \alias{backendInitialize,MsBackendDataFrame-method} \alias{MsBackendHdf5Peaks} @@ -114,7 +117,7 @@ \S4method{centroided}{MsBackend}(object) -\S4method{centroided}{MsBackend}(object) <- value +\S4method{centroided}{MsBackend,ANY}(object) <- value \S4method{collisionEnergy}{MsBackend}(object) @@ -216,7 +219,7 @@ \S4method{smoothed}{MsBackend}(object) -\S4method{smoothed}{MsBackend}(object) <- value +\S4method{smoothed}{MsBackend,ANY}(object) <- value \S4method{spectraData}{MsBackend}(object, columns = spectraVariables(object)) @@ -234,15 +237,15 @@ \S4method{tic}{MsBackend}(object, initial = TRUE) -\S4method{[}{MsBackend}(x, i, j, ..., drop = FALSE) +\S4method{[}{MsBackend,ANY,ANY,ANY}(x, i, j, ..., drop = FALSE) \S4method{$}{MsBackend}(x, name) \S4method{$}{MsBackend}(x, name) <- value -\S4method{[[}{MsBackend}(x, i, j, ...) +\S4method{[[}{MsBackend,ANY,ANY}(x, i, j, ...) -\S4method{[[}{MsBackend}(x, i, j, ...) <- value +\S4method{[[}{MsBackend,ANY,ANY,ANY}(x, i, j, ...) <- value \S4method{uniqueMsLevels}{MsBackend}(object, ...) diff --git a/man/MsBackendCached.Rd b/man/MsBackendCached.Rd index c21a2758..2b13c970 100644 --- a/man/MsBackendCached.Rd +++ b/man/MsBackendCached.Rd @@ -9,14 +9,14 @@ \alias{spectraVariables,MsBackendCached-method} \alias{spectraData,MsBackendCached-method} \alias{spectraData<-,MsBackendCached-method} -\alias{[,MsBackendCached-method} +\alias{[,MsBackendCached,ANY,ANY,ANY-method} \alias{$,MsBackendCached-method} \alias{$<-,MsBackendCached-method} \alias{selectSpectraVariables,MsBackendCached-method} \alias{show,MsBackendCached-method} \alias{acquisitionNum,MsBackendCached-method} \alias{centroided,MsBackendCached-method} -\alias{centroided<-,MsBackendCached-method} +\alias{centroided<-,MsBackendCached,ANY-method} \alias{collisionEnergy,MsBackendCached-method} \alias{collisionEnergy<-,MsBackendCached-method} \alias{dataOrigin,MsBackendCached-method} @@ -42,7 +42,7 @@ \alias{rtime<-,MsBackendCached-method} \alias{scanIndex,MsBackendCached-method} \alias{smoothed,MsBackendCached-method} -\alias{smoothed<-,MsBackendCached-method} +\alias{smoothed<-,MsBackendCached,ANY-method} \title{Base MsBackend class providing data caching mechanism} \usage{ MsBackendCached() @@ -65,7 +65,7 @@ MsBackendCached() \S4method{spectraData}{MsBackendCached}(object) <- value -\S4method{[}{MsBackendCached}(x, i, j, ..., drop = FALSE) +\S4method{[}{MsBackendCached,ANY,ANY,ANY}(x, i, j, ..., drop = FALSE) \S4method{$}{MsBackendCached}(x, name) @@ -79,7 +79,7 @@ MsBackendCached() \S4method{centroided}{MsBackendCached}(object) -\S4method{centroided}{MsBackendCached}(object) <- value +\S4method{centroided}{MsBackendCached,ANY}(object) <- value \S4method{collisionEnergy}{MsBackendCached}(object) @@ -131,7 +131,7 @@ MsBackendCached() \S4method{smoothed}{MsBackendCached}(object) -\S4method{smoothed}{MsBackendCached}(object) <- value +\S4method{smoothed}{MsBackendCached,ANY}(object) <- value } \arguments{ \item{object}{A \code{MsBackendCached} object.} diff --git a/man/Spectra.Rd b/man/Spectra.Rd index 2c22a0d2..a877eba6 100644 --- a/man/Spectra.Rd +++ b/man/Spectra.Rd @@ -30,7 +30,7 @@ \alias{peaksData,Spectra-method} \alias{peaksVariables,Spectra-method} \alias{centroided,Spectra-method} -\alias{centroided<-,Spectra-method} +\alias{centroided<-,Spectra,ANY-method} \alias{collisionEnergy,Spectra-method} \alias{collisionEnergy<-,Spectra-method} \alias{dataOrigin,Spectra-method} @@ -65,7 +65,7 @@ \alias{scanIndex,Spectra-method} \alias{selectSpectraVariables,Spectra-method} \alias{smoothed,Spectra-method} -\alias{smoothed<-,Spectra-method} +\alias{smoothed<-,Spectra,ANY-method} \alias{spectraData,Spectra-method} \alias{spectraData<-,Spectra-method} \alias{spectraNames,Spectra-method} @@ -74,8 +74,9 @@ \alias{tic,Spectra-method} \alias{$,Spectra-method} \alias{$<-,Spectra-method} -\alias{[[,Spectra-method} -\alias{[[<-,Spectra-method} +\alias{[[,Spectra,ANY,ANY-method} +\alias{[[<-,Spectra,ANY,ANY,ANY-method} +\alias{[,Spectra,ANY,ANY,ANY-method} \alias{filterAcquisitionNum,Spectra-method} \alias{filterEmptySpectra,Spectra-method} \alias{filterDataOrigin,Spectra-method} @@ -205,7 +206,7 @@ filterPrecursorPeaks( \S4method{centroided}{Spectra}(object) -\S4method{centroided}{Spectra}(object) <- value +\S4method{centroided}{Spectra,ANY}(object) <- value \S4method{collisionEnergy}{Spectra}(object) @@ -298,7 +299,7 @@ filterPrecursorPeaks( \S4method{smoothed}{Spectra}(object) -\S4method{smoothed}{Spectra}(object) <- value +\S4method{smoothed}{Spectra,ANY}(object) <- value \S4method{spectraData}{Spectra}(object, columns = spectraVariables(object)) @@ -316,11 +317,11 @@ filterPrecursorPeaks( \S4method{$}{Spectra}(x, name) <- value -\S4method{[[}{Spectra}(x, i, j, ...) +\S4method{[[}{Spectra,ANY,ANY}(x, i, j, ...) -\S4method{[[}{Spectra}(x, i, j, ...) <- value +\S4method{[[}{Spectra,ANY,ANY,ANY}(x, i, j, ...) <- value -\S4method{[}{Spectra}(x, i, j, ..., drop = FALSE) +\S4method{[}{Spectra,ANY,ANY,ANY}(x, i, j, ..., drop = FALSE) \S4method{filterAcquisitionNum}{Spectra}( object, diff --git a/man/hidden_aliases.Rd b/man/hidden_aliases.Rd index 8b72d1e8..12e6bc30 100644 --- a/man/hidden_aliases.Rd +++ b/man/hidden_aliases.Rd @@ -32,6 +32,7 @@ \alias{acquisitionNum,MsBackendDataFrame-method} \alias{peaksData,MsBackendDataFrame-method} \alias{centroided,MsBackendDataFrame-method} +\alias{centroided<-,MsBackendDataFrame,ANY-method} \alias{centroided<-,MsBackendDataFrame-method} \alias{collisionEnergy,MsBackendDataFrame-method} \alias{collisionEnergy<-,MsBackendDataFrame-method} @@ -67,6 +68,7 @@ \alias{scanIndex,MsBackendDataFrame-method} \alias{selectSpectraVariables,MsBackendDataFrame-method} \alias{smoothed,MsBackendDataFrame-method} +\alias{smoothed<-,MsBackendDataFrame,ANY-method} \alias{smoothed<-,MsBackendDataFrame-method} \alias{spectraData,MsBackendDataFrame-method} \alias{spectraData<-,MsBackendDataFrame-method} @@ -76,6 +78,7 @@ \alias{tic,MsBackendDataFrame-method} \alias{$,MsBackendDataFrame-method} \alias{$<-,MsBackendDataFrame-method} +\alias{[,MsBackendDataFrame,ANY,ANY,ANY-method} \alias{split,MsBackendDataFrame,ANY-method} \alias{filterAcquisitionNum,MsBackendDataFrame-method} \alias{backendInitialize,MsBackendHdf5Peaks-method} @@ -93,12 +96,14 @@ \alias{spectraData,MsBackendHdf5Peaks-method} \alias{spectraData<-,MsBackendHdf5Peaks-method} \alias{$<-,MsBackendHdf5Peaks-method} +\alias{[,MsBackendHdf5Peaks,ANY,ANY,ANY-method} \alias{[,MsBackendHdf5Peaks-method} \alias{backendMerge,MsBackendHdf5Peaks-method} \alias{show,MsBackendMemory-method} \alias{backendMerge,MsBackendMemory-method} \alias{acquisitionNum,MsBackendMemory-method} \alias{centroided,MsBackendMemory-method} +\alias{centroided<-,MsBackendMemory,ANY-method} \alias{centroided<-,MsBackendMemory-method} \alias{collisionEnergy,MsBackendMemory-method} \alias{collisionEnergy<-,MsBackendMemory-method} @@ -135,6 +140,7 @@ \alias{scanIndex,MsBackendMemory-method} \alias{selectSpectraVariables,MsBackendMemory-method} \alias{smoothed,MsBackendMemory-method} +\alias{smoothed<-,MsBackendMemory,ANY-method} \alias{smoothed<-,MsBackendMemory-method} \alias{spectraData,MsBackendMemory-method} \alias{spectraData<-,MsBackendMemory-method} @@ -145,7 +151,7 @@ \alias{tic,MsBackendMemory-method} \alias{$,MsBackendMemory-method} \alias{$<-,MsBackendMemory-method} -\alias{[,MsBackendMemory-method} +\alias{[,MsBackendMemory,ANY,ANY,ANY-method} \alias{split,MsBackendMemory,ANY-method} \alias{filterAcquisitionNum,MsBackendMemory-method} \alias{backendInitialize,MsBackendMzR-method} @@ -228,7 +234,7 @@ spectrapply(object, ...) \S4method{centroided}{MsBackendDataFrame}(object) -\S4method{centroided}{MsBackendDataFrame}(object) <- value +\S4method{centroided}{MsBackendDataFrame,ANY}(object) <- value \S4method{collisionEnergy}{MsBackendDataFrame}(object) @@ -298,7 +304,7 @@ spectrapply(object, ...) \S4method{smoothed}{MsBackendDataFrame}(object) -\S4method{smoothed}{MsBackendDataFrame}(object) <- value +\S4method{smoothed}{MsBackendDataFrame,ANY}(object) <- value \S4method{spectraData}{MsBackendDataFrame}(object, columns = spectraVariables(object)) @@ -316,7 +322,7 @@ spectrapply(object, ...) \S4method{$}{MsBackendDataFrame}(x, name) <- value -\S4method{[}{MsBackendDataFrame}(x, i, j, ..., drop = FALSE) +\S4method{[}{MsBackendDataFrame,ANY,ANY,ANY}(x, i, j, ..., drop = FALSE) \S4method{split}{MsBackendDataFrame,ANY}(x, f, drop = FALSE, ...) @@ -364,7 +370,7 @@ spectrapply(object, ...) \S4method{$}{MsBackendHdf5Peaks}(x, name) <- value -\S4method{[}{MsBackendHdf5Peaks}(x, i, j, ..., drop = FALSE) +\S4method{[}{MsBackendHdf5Peaks,ANY,ANY,ANY}(x, i, j, ..., drop = FALSE) \S4method{backendMerge}{MsBackendHdf5Peaks}(object, ...) @@ -376,7 +382,7 @@ spectrapply(object, ...) \S4method{centroided}{MsBackendMemory}(object) -\S4method{centroided}{MsBackendMemory}(object) <- value +\S4method{centroided}{MsBackendMemory,ANY}(object) <- value \S4method{collisionEnergy}{MsBackendMemory}(object) @@ -448,7 +454,7 @@ spectrapply(object, ...) \S4method{smoothed}{MsBackendMemory}(object) -\S4method{smoothed}{MsBackendMemory}(object) <- value +\S4method{smoothed}{MsBackendMemory,ANY}(object) <- value \S4method{spectraData}{MsBackendMemory}(object, columns = spectraVariables(object)) @@ -468,7 +474,7 @@ spectrapply(object, ...) \S4method{$}{MsBackendMemory}(x, name) <- value -\S4method{[}{MsBackendMemory}(x, i, j, ..., drop = FALSE) +\S4method{[}{MsBackendMemory,ANY,ANY,ANY}(x, i, j, ..., drop = FALSE) \S4method{split}{MsBackendMemory,ANY}(x, f, drop = FALSE, ...) From d42e0699fcbaf0199e50e7751de2b36183b97b0c Mon Sep 17 00:00:00 2001 From: Philippine Louail Date: Mon, 20 Nov 2023 15:40:44 +0100 Subject: [PATCH 7/9] Update test_Spectra.R --- tests/testthat/test_Spectra.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testthat/test_Spectra.R b/tests/testthat/test_Spectra.R index 59cd0518..3693be7c 100644 --- a/tests/testthat/test_Spectra.R +++ b/tests/testthat/test_Spectra.R @@ -1107,7 +1107,7 @@ test_that("bin,Spectra works", { pks <- peaksData(sps) res <- bin(sps, binSize = 2, zero.rm = FALSE) expect_true(length(res@processingQueue) == 1) - res1 <- bin(sps, msLevel = 1, binSize = 2) + res1 <- bin(sps, msLevel = 1, binSize = 2, zero.rm = FALSE) expect_identical(peaksData(res1)[res1$msLevel == 2], pks[sps$msLevel == 2]) From 9500cb2d05ef056b9feaca94910e2ce9a6b4d8f6 Mon Sep 17 00:00:00 2001 From: Philippine Louail Date: Mon, 20 Nov 2023 16:14:48 +0100 Subject: [PATCH 8/9] Update test_Spectra.R --- tests/testthat/test_Spectra.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testthat/test_Spectra.R b/tests/testthat/test_Spectra.R index 3693be7c..e22462cc 100644 --- a/tests/testthat/test_Spectra.R +++ b/tests/testthat/test_Spectra.R @@ -1115,7 +1115,7 @@ test_that("bin,Spectra works", { mzr <- range(unlist(mz(sps))) brks <- MsCoreUtils:::.fix_breaks( seq(floor(mzr[1]), ceiling(mzr[2]), by = 2), mzr) - res1 <- bin(sps, msLevel = 1, breaks = brks) + res1 <- bin(sps, msLevel = 1, breaks = brks, zero.rm = FALSE) res1_pks <- peaksData(res1) res_pks <- peaksData(res) expect_identical(res1_pks[res1$msLevel == 1], From 958a171cfe69c17556a37dc6f1286b52598bba59 Mon Sep 17 00:00:00 2001 From: Philippine Louail Date: Mon, 20 Nov 2023 16:47:24 +0100 Subject: [PATCH 9/9] fixes devtool --- man/MsBackend.Rd | 17 +++++++---------- man/MsBackendCached.Rd | 12 ++++++------ man/Spectra.Rd | 19 +++++++++---------- man/hidden_aliases.Rd | 22 ++++++++-------------- 4 files changed, 30 insertions(+), 40 deletions(-) diff --git a/man/MsBackend.Rd b/man/MsBackend.Rd index 8c6ad7aa..3d6a1ba5 100644 --- a/man/MsBackend.Rd +++ b/man/MsBackend.Rd @@ -25,7 +25,6 @@ \alias{peaksVariables,MsBackend-method} \alias{centroided,MsBackend-method} \alias{centroided<-,MsBackend-method} -\alias{centroided<-,MsBackend,ANY-method} \alias{collisionEnergy,MsBackend-method} \alias{collisionEnergy<-,MsBackend-method} \alias{dataOrigin,MsBackend-method} @@ -76,7 +75,6 @@ \alias{scanIndex,MsBackend-method} \alias{selectSpectraVariables,MsBackend-method} \alias{smoothed,MsBackend-method} -\alias{smoothed<-,MsBackend,ANY-method} \alias{smoothed<-,MsBackend-method} \alias{spectraData,MsBackend-method} \alias{spectraData<-,MsBackend-method} @@ -86,11 +84,10 @@ \alias{split,MsBackend,ANY-method} \alias{supportsSetBackend,MsBackend-method} \alias{tic,MsBackend-method} -\alias{[,MsBackend,ANY,ANY,ANY-method} \alias{$,MsBackend-method} \alias{$<-,MsBackend-method} -\alias{[[,MsBackend,ANY,ANY-method} -\alias{[[<-,MsBackend,ANY,ANY,ANY-method} +\alias{[[,MsBackend-method} +\alias{[[<-,MsBackend-method} \alias{MsBackendDataFrame} \alias{backendInitialize,MsBackendDataFrame-method} \alias{MsBackendHdf5Peaks} @@ -117,7 +114,7 @@ \S4method{centroided}{MsBackend}(object) -\S4method{centroided}{MsBackend,ANY}(object) <- value +\S4method{centroided}{MsBackend}(object) <- value \S4method{collisionEnergy}{MsBackend}(object) @@ -219,7 +216,7 @@ \S4method{smoothed}{MsBackend}(object) -\S4method{smoothed}{MsBackend,ANY}(object) <- value +\S4method{smoothed}{MsBackend}(object) <- value \S4method{spectraData}{MsBackend}(object, columns = spectraVariables(object)) @@ -237,15 +234,15 @@ \S4method{tic}{MsBackend}(object, initial = TRUE) -\S4method{[}{MsBackend,ANY,ANY,ANY}(x, i, j, ..., drop = FALSE) +\S4method{[}{MsBackend}(x, i, j, ..., drop = FALSE) \S4method{$}{MsBackend}(x, name) \S4method{$}{MsBackend}(x, name) <- value -\S4method{[[}{MsBackend,ANY,ANY}(x, i, j, ...) +\S4method{[[}{MsBackend}(x, i, j, ...) -\S4method{[[}{MsBackend,ANY,ANY,ANY}(x, i, j, ...) <- value +\S4method{[[}{MsBackend}(x, i, j, ...) <- value \S4method{uniqueMsLevels}{MsBackend}(object, ...) diff --git a/man/MsBackendCached.Rd b/man/MsBackendCached.Rd index 2b13c970..c21a2758 100644 --- a/man/MsBackendCached.Rd +++ b/man/MsBackendCached.Rd @@ -9,14 +9,14 @@ \alias{spectraVariables,MsBackendCached-method} \alias{spectraData,MsBackendCached-method} \alias{spectraData<-,MsBackendCached-method} -\alias{[,MsBackendCached,ANY,ANY,ANY-method} +\alias{[,MsBackendCached-method} \alias{$,MsBackendCached-method} \alias{$<-,MsBackendCached-method} \alias{selectSpectraVariables,MsBackendCached-method} \alias{show,MsBackendCached-method} \alias{acquisitionNum,MsBackendCached-method} \alias{centroided,MsBackendCached-method} -\alias{centroided<-,MsBackendCached,ANY-method} +\alias{centroided<-,MsBackendCached-method} \alias{collisionEnergy,MsBackendCached-method} \alias{collisionEnergy<-,MsBackendCached-method} \alias{dataOrigin,MsBackendCached-method} @@ -42,7 +42,7 @@ \alias{rtime<-,MsBackendCached-method} \alias{scanIndex,MsBackendCached-method} \alias{smoothed,MsBackendCached-method} -\alias{smoothed<-,MsBackendCached,ANY-method} +\alias{smoothed<-,MsBackendCached-method} \title{Base MsBackend class providing data caching mechanism} \usage{ MsBackendCached() @@ -65,7 +65,7 @@ MsBackendCached() \S4method{spectraData}{MsBackendCached}(object) <- value -\S4method{[}{MsBackendCached,ANY,ANY,ANY}(x, i, j, ..., drop = FALSE) +\S4method{[}{MsBackendCached}(x, i, j, ..., drop = FALSE) \S4method{$}{MsBackendCached}(x, name) @@ -79,7 +79,7 @@ MsBackendCached() \S4method{centroided}{MsBackendCached}(object) -\S4method{centroided}{MsBackendCached,ANY}(object) <- value +\S4method{centroided}{MsBackendCached}(object) <- value \S4method{collisionEnergy}{MsBackendCached}(object) @@ -131,7 +131,7 @@ MsBackendCached() \S4method{smoothed}{MsBackendCached}(object) -\S4method{smoothed}{MsBackendCached,ANY}(object) <- value +\S4method{smoothed}{MsBackendCached}(object) <- value } \arguments{ \item{object}{A \code{MsBackendCached} object.} diff --git a/man/Spectra.Rd b/man/Spectra.Rd index a877eba6..2c22a0d2 100644 --- a/man/Spectra.Rd +++ b/man/Spectra.Rd @@ -30,7 +30,7 @@ \alias{peaksData,Spectra-method} \alias{peaksVariables,Spectra-method} \alias{centroided,Spectra-method} -\alias{centroided<-,Spectra,ANY-method} +\alias{centroided<-,Spectra-method} \alias{collisionEnergy,Spectra-method} \alias{collisionEnergy<-,Spectra-method} \alias{dataOrigin,Spectra-method} @@ -65,7 +65,7 @@ \alias{scanIndex,Spectra-method} \alias{selectSpectraVariables,Spectra-method} \alias{smoothed,Spectra-method} -\alias{smoothed<-,Spectra,ANY-method} +\alias{smoothed<-,Spectra-method} \alias{spectraData,Spectra-method} \alias{spectraData<-,Spectra-method} \alias{spectraNames,Spectra-method} @@ -74,9 +74,8 @@ \alias{tic,Spectra-method} \alias{$,Spectra-method} \alias{$<-,Spectra-method} -\alias{[[,Spectra,ANY,ANY-method} -\alias{[[<-,Spectra,ANY,ANY,ANY-method} -\alias{[,Spectra,ANY,ANY,ANY-method} +\alias{[[,Spectra-method} +\alias{[[<-,Spectra-method} \alias{filterAcquisitionNum,Spectra-method} \alias{filterEmptySpectra,Spectra-method} \alias{filterDataOrigin,Spectra-method} @@ -206,7 +205,7 @@ filterPrecursorPeaks( \S4method{centroided}{Spectra}(object) -\S4method{centroided}{Spectra,ANY}(object) <- value +\S4method{centroided}{Spectra}(object) <- value \S4method{collisionEnergy}{Spectra}(object) @@ -299,7 +298,7 @@ filterPrecursorPeaks( \S4method{smoothed}{Spectra}(object) -\S4method{smoothed}{Spectra,ANY}(object) <- value +\S4method{smoothed}{Spectra}(object) <- value \S4method{spectraData}{Spectra}(object, columns = spectraVariables(object)) @@ -317,11 +316,11 @@ filterPrecursorPeaks( \S4method{$}{Spectra}(x, name) <- value -\S4method{[[}{Spectra,ANY,ANY}(x, i, j, ...) +\S4method{[[}{Spectra}(x, i, j, ...) -\S4method{[[}{Spectra,ANY,ANY,ANY}(x, i, j, ...) <- value +\S4method{[[}{Spectra}(x, i, j, ...) <- value -\S4method{[}{Spectra,ANY,ANY,ANY}(x, i, j, ..., drop = FALSE) +\S4method{[}{Spectra}(x, i, j, ..., drop = FALSE) \S4method{filterAcquisitionNum}{Spectra}( object, diff --git a/man/hidden_aliases.Rd b/man/hidden_aliases.Rd index 12e6bc30..8b72d1e8 100644 --- a/man/hidden_aliases.Rd +++ b/man/hidden_aliases.Rd @@ -32,7 +32,6 @@ \alias{acquisitionNum,MsBackendDataFrame-method} \alias{peaksData,MsBackendDataFrame-method} \alias{centroided,MsBackendDataFrame-method} -\alias{centroided<-,MsBackendDataFrame,ANY-method} \alias{centroided<-,MsBackendDataFrame-method} \alias{collisionEnergy,MsBackendDataFrame-method} \alias{collisionEnergy<-,MsBackendDataFrame-method} @@ -68,7 +67,6 @@ \alias{scanIndex,MsBackendDataFrame-method} \alias{selectSpectraVariables,MsBackendDataFrame-method} \alias{smoothed,MsBackendDataFrame-method} -\alias{smoothed<-,MsBackendDataFrame,ANY-method} \alias{smoothed<-,MsBackendDataFrame-method} \alias{spectraData,MsBackendDataFrame-method} \alias{spectraData<-,MsBackendDataFrame-method} @@ -78,7 +76,6 @@ \alias{tic,MsBackendDataFrame-method} \alias{$,MsBackendDataFrame-method} \alias{$<-,MsBackendDataFrame-method} -\alias{[,MsBackendDataFrame,ANY,ANY,ANY-method} \alias{split,MsBackendDataFrame,ANY-method} \alias{filterAcquisitionNum,MsBackendDataFrame-method} \alias{backendInitialize,MsBackendHdf5Peaks-method} @@ -96,14 +93,12 @@ \alias{spectraData,MsBackendHdf5Peaks-method} \alias{spectraData<-,MsBackendHdf5Peaks-method} \alias{$<-,MsBackendHdf5Peaks-method} -\alias{[,MsBackendHdf5Peaks,ANY,ANY,ANY-method} \alias{[,MsBackendHdf5Peaks-method} \alias{backendMerge,MsBackendHdf5Peaks-method} \alias{show,MsBackendMemory-method} \alias{backendMerge,MsBackendMemory-method} \alias{acquisitionNum,MsBackendMemory-method} \alias{centroided,MsBackendMemory-method} -\alias{centroided<-,MsBackendMemory,ANY-method} \alias{centroided<-,MsBackendMemory-method} \alias{collisionEnergy,MsBackendMemory-method} \alias{collisionEnergy<-,MsBackendMemory-method} @@ -140,7 +135,6 @@ \alias{scanIndex,MsBackendMemory-method} \alias{selectSpectraVariables,MsBackendMemory-method} \alias{smoothed,MsBackendMemory-method} -\alias{smoothed<-,MsBackendMemory,ANY-method} \alias{smoothed<-,MsBackendMemory-method} \alias{spectraData,MsBackendMemory-method} \alias{spectraData<-,MsBackendMemory-method} @@ -151,7 +145,7 @@ \alias{tic,MsBackendMemory-method} \alias{$,MsBackendMemory-method} \alias{$<-,MsBackendMemory-method} -\alias{[,MsBackendMemory,ANY,ANY,ANY-method} +\alias{[,MsBackendMemory-method} \alias{split,MsBackendMemory,ANY-method} \alias{filterAcquisitionNum,MsBackendMemory-method} \alias{backendInitialize,MsBackendMzR-method} @@ -234,7 +228,7 @@ spectrapply(object, ...) \S4method{centroided}{MsBackendDataFrame}(object) -\S4method{centroided}{MsBackendDataFrame,ANY}(object) <- value +\S4method{centroided}{MsBackendDataFrame}(object) <- value \S4method{collisionEnergy}{MsBackendDataFrame}(object) @@ -304,7 +298,7 @@ spectrapply(object, ...) \S4method{smoothed}{MsBackendDataFrame}(object) -\S4method{smoothed}{MsBackendDataFrame,ANY}(object) <- value +\S4method{smoothed}{MsBackendDataFrame}(object) <- value \S4method{spectraData}{MsBackendDataFrame}(object, columns = spectraVariables(object)) @@ -322,7 +316,7 @@ spectrapply(object, ...) \S4method{$}{MsBackendDataFrame}(x, name) <- value -\S4method{[}{MsBackendDataFrame,ANY,ANY,ANY}(x, i, j, ..., drop = FALSE) +\S4method{[}{MsBackendDataFrame}(x, i, j, ..., drop = FALSE) \S4method{split}{MsBackendDataFrame,ANY}(x, f, drop = FALSE, ...) @@ -370,7 +364,7 @@ spectrapply(object, ...) \S4method{$}{MsBackendHdf5Peaks}(x, name) <- value -\S4method{[}{MsBackendHdf5Peaks,ANY,ANY,ANY}(x, i, j, ..., drop = FALSE) +\S4method{[}{MsBackendHdf5Peaks}(x, i, j, ..., drop = FALSE) \S4method{backendMerge}{MsBackendHdf5Peaks}(object, ...) @@ -382,7 +376,7 @@ spectrapply(object, ...) \S4method{centroided}{MsBackendMemory}(object) -\S4method{centroided}{MsBackendMemory,ANY}(object) <- value +\S4method{centroided}{MsBackendMemory}(object) <- value \S4method{collisionEnergy}{MsBackendMemory}(object) @@ -454,7 +448,7 @@ spectrapply(object, ...) \S4method{smoothed}{MsBackendMemory}(object) -\S4method{smoothed}{MsBackendMemory,ANY}(object) <- value +\S4method{smoothed}{MsBackendMemory}(object) <- value \S4method{spectraData}{MsBackendMemory}(object, columns = spectraVariables(object)) @@ -474,7 +468,7 @@ spectrapply(object, ...) \S4method{$}{MsBackendMemory}(x, name) <- value -\S4method{[}{MsBackendMemory,ANY,ANY,ANY}(x, i, j, ..., drop = FALSE) +\S4method{[}{MsBackendMemory}(x, i, j, ..., drop = FALSE) \S4method{split}{MsBackendMemory,ANY}(x, f, drop = FALSE, ...)