Skip to content

Commit

Permalink
Merge pull request #344 from rformassspectrometry/jomain
Browse files Browse the repository at this point in the history
tests: fix external MsBackend unit tests
  • Loading branch information
jorainer authored Dec 16, 2024
2 parents bd56acf + 46ed9f5 commit d37f0f6
Show file tree
Hide file tree
Showing 23 changed files with 187 additions and 163 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: Spectra
Title: Spectra Infrastructure for Mass Spectrometry Data
Version: 1.17.2
Version: 1.17.3
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
Expand Down
9 changes: 7 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
# Spectra 1.17

## Change in 1.17.3

- Fix `cbind2()` unit test for backends that fails if the number of spectra in
the tested backend is (by chance) equal to 4.

## Change in 1.17.2

- Add `cbind2()` method to easily add multiple `spectraVariables` and their
content to the `spectraData` of a `Spectra` object.
- Add `cbind2()` method to easily add multiple `spectraVariables` and their
content to the `spectraData` of a `Spectra` object.
See also [issue #342](https://github.com/rformassspectrometry/Spectra/issues/342)

## Changes in 1.17.1
Expand Down
36 changes: 19 additions & 17 deletions R/MsBackend.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#' @aliases supportsSetBackend
#' @aliases backendBpparam
#' @aliases backendInitialize
#' @aliases backendParallelFactor
#' @aliases backendParallelFactor,MsBackendMzR-method
#' @aliases backendParallelFactor,MsBackendHdf5Peaks-method
#' @aliases dataStorageBasePath
Expand Down Expand Up @@ -64,8 +65,8 @@
#'
#' @param BPPARAM for `backendBpparam()`: parameter object from the
#' `BiocParallel` package defining the parallel processing setup.
#' Defaults to `BPPARAM = bpparam()`. See [bpparam()] for more
#' information.
#' Defaults to `BPPARAM = bpparam()`. See [BiocParallel::bpparam()]
#' for more information.
#'
#' @param columns For `spectraData()` accessor: optional `character` with
#' column names (spectra variables) that should be included in the
Expand Down Expand Up @@ -133,7 +134,7 @@
#'
#' @param ppm For `filterPrecursorMzValues()`: `numeric(1)` with the
#' m/z-relative maximal acceptable difference for a m/z to be considered
#' matching. See [closest()] for details.
#' matching. See [MsCoreUtils::closest()] for details.
#' For `filterValues()`: `numeric` of any length allowing to define
#' a maximal accepted difference between user input `values` and the
#' `spectraVariables` values. If it is not equal to the length of the
Expand Down Expand Up @@ -171,7 +172,8 @@
#'
#' @param tolerance For `filterPrecursorMzValues()`: `numeric(1)` with the
#' maximal absolute acceptable difference for a m/z value to be considered
#' matching. See [closest()] for details. For `filterValues()`: `numeric`
#' matching. See [MsCoreUtils::closest()] for details.
#' For `filterValues()`: `numeric`
#' accepted tolerance between the `values` and the spectra variables.
#' Defaults to `tolerance = 0`. If it is not equal to the length of the
#' value provided with parameter `spectraVariables`, `tolerance[1]` will
Expand Down Expand Up @@ -358,9 +360,9 @@
#' support `logical` and eventually `character`). While being apparently
#' redundant to `[`, this methods avoids package namespace errors/problems
#' that can result in implementations of `[` being not found by R (which
#' can happen sometimes in parallel processing using the [SnowParam()]). This
#' method is used internally by `Spectra` to extract/subset its backend.
#' Implementation of this method is mandatory.
#' can happen sometimes in parallel processing using the
#' [BiocParallel::SnowParam()]). This method is used internally by `Spectra`
#' to extract/subset its backend. Implementation of this method is mandatory.
#'
#' - `filterAcquisitionNum()`: filters the object keeping only spectra matching
#' the provided acquisition numbers (argument `n`). If `dataOrigin` or
Expand Down Expand Up @@ -462,14 +464,14 @@
#' for `MsBackend` is available.
#'
#' - `intensity()`: gets the intensity values from the spectra. Returns
#' a [NumericList()] of `numeric` vectors (intensity values for each
#' a [IRanges::NumericList()] of `numeric` vectors (intensity values for each
#' spectrum). The length of the `list` is equal to the number of
#' `spectra` in `object`.
#'
#' - `intensity<-`: replaces the intensity values. `value` has to be a `list`
#' (or [NumericList()]) of length equal to the number of spectra and the
#' number of values within each list element identical to the number of
#' peaks in each spectrum (i.e. the `lengths(x)`). Note that just
#' (or [IRanges::NumericList()]) of length equal to the number of spectra
#' and the number of values within each list element identical to the
#' number of peaks in each spectrum (i.e. the `lengths(x)`). Note that just
#' writeable backends support this method.
#'
#' - `ionCount()`: returns a `numeric` with the sum of intensities for
Expand Down Expand Up @@ -512,8 +514,8 @@
#' - `msLevel<-`: replaces the spectra's MS level.
#'
#' - `mz()`: gets the mass-to-charge ratios (m/z) from the
#' spectra. Returns a [NumericList()] or length equal to the number of
#' spectra, each element a `numeric` vector with the m/z values of
#' spectra. Returns a [IRanges::NumericList()] or length equal to the
#' number of spectra, each element a `numeric` vector with the m/z values of
#' one spectrum.
#'
#' - `mz<-`: replaces the m/z values. `value` has to be a `list` of length equal
Expand Down Expand Up @@ -700,10 +702,10 @@
#' precursor.
#' - `"precursorCharge"`: `integer` with the charge of the precursor.
#' - `"collisionEnergy"`: `numeric` with the collision energy.
#' - `"mz"`: [NumericList()] of `numeric` vectors representing the m/z values
#' for each spectrum.
#' - `"intensity"`: [NumericList()] of `numeric` vectors representing the
#' intensity values for each spectrum.
#' - `"mz"`: [IRanges::NumericList()] of `numeric` vectors representing the
#' m/z values for each spectrum.
#' - `"intensity"`: [IRanges::NumericList()] of `numeric` vectors
#' representing the intensity values for each spectrum.
#'
#' Additional columns are allowed too.
#'
Expand Down
6 changes: 3 additions & 3 deletions R/MsBackendCached.R
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ setClassUnion("characterOrInteger", c("character", "integer"))
#' the mzML file from which the data was read.
#'
#' - `intensity()`: gets the intensity values from the spectra. Returns
#' a [NumericList()] of `numeric` vectors (intensity values for each
#' a [IRanges::NumericList()] of `numeric` vectors (intensity values for each
#' spectrum). The length of the `list` is equal to the number of
#' `spectra` in `object`.
#'
Expand Down Expand Up @@ -136,8 +136,8 @@ setClassUnion("characterOrInteger", c("character", "integer"))
#' level for each spectrum (or `NA_integer_` if not available).
#'
#' - `mz()`: gets the mass-to-charge ratios (m/z) from the
#' spectra. Returns a [NumericList()] or length equal to the number of
#' spectra, each element a `numeric` vector with the m/z values of
#' spectra. Returns a [IRanges::NumericList()] or length equal to the
#' number of spectra, each element a `numeric` vector with the m/z values of
#' one spectrum.
#'
#' - `polarity()`, `polarity<-`: gets or sets the polarity for each
Expand Down
3 changes: 2 additions & 1 deletion R/Spectra-estimatePrecursorMz.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@
#' m/z. See documentation of parameter `tolerance` for more information.
#'
#' @param BPPARAM parallel processing setup. Defaults to
#' `BPPARAM = SerialParam()`. See [SerialParam()] for more information.
#' `BPPARAM = SerialParam()`. See [BiocParallel::SerialParam()] for
#' more information.
#'
#' @return `numeric` of length equal to the number of spectra in `object` with
#' the fragment spectra's estimated precursor m/z values. For MS1 spectra
Expand Down
11 changes: 6 additions & 5 deletions R/Spectra-functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,8 @@ NULL
#' @param ... Additional parameters for `FUN`.
#'
#' @param BPPARAM Optional settings for `BiocParallel`-based parallel
#' processing. See [bpparam()] for more informations and options.
#' processing. See [BiocParallel::bpparam()] for more informations and
#' options.
#'
#' @return A `list` with the result of `FUN`.
#'
Expand Down Expand Up @@ -959,8 +960,8 @@ filterPrecursorPeaks <- function(object, tolerance = 0, ppm = 20,
#' per file parallel processing if `f` or `chunkSize` is not defined.
#' Other on-disk backends: only if requested by the user.
#'
#' @param BPPARAM Parallel setup configuration. See [bpparam()] for more
#' information.
#' @param BPPARAM Parallel setup configuration. See [BiocParallel::bpparam()]
#' for more information.
#'
#' @param object `Spectra` object.
#'
Expand Down Expand Up @@ -1039,8 +1040,8 @@ filterPrecursorPeaks <- function(object, tolerance = 0, ppm = 20,
#' For these, the `backendBpparam()` function will always return a
#' `SerialParam()` independently on how parallel processing was defined.
#'
#' @param BPPARAM Parallel setup configuration. See [bpparam()] for more
#' information.
#' @param BPPARAM Parallel setup configuration. See [BiocParallel::bpparam()]
#' for more information.
#'
#' @param object `Spectra` object.
#'
Expand Down
Loading

0 comments on commit d37f0f6

Please sign in to comment.