Skip to content

Commit

Permalink
Merge branch 'devel' into phili
Browse files Browse the repository at this point in the history
  • Loading branch information
philouail committed Oct 1, 2024
2 parents a45ff10 + 08e1649 commit 1465d7f
Show file tree
Hide file tree
Showing 27 changed files with 425 additions and 884 deletions.
27 changes: 1 addition & 26 deletions .github/workflows/check-bioc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,32 +124,7 @@ jobs:
- name: Install macOS system dependencies
if: matrix.config.os == 'macOS-latest'
run: |
## Enable installing XML from source if needed
brew install libxml2
echo "XML_CONFIG=/usr/local/opt/libxml2/bin/xml2-config" >> $GITHUB_ENV
## Required to install magick as noted at
## https://github.com/r-lib/usethis/commit/f1f1e0d10c1ebc75fd4c18fa7e2de4551fd9978f#diff-9bfee71065492f63457918efcd912cf2
brew install imagemagick@6
## For textshaping, required by ragg, and required by pkgdown
brew install harfbuzz fribidi
## For installing usethis's dependency gert
brew install libgit2
## required for ncdf4
## brew install netcdf ## Does not work as it is compiled with gcc
## Use pre-compiled libraries from https://mac.r-project.org/libs-4/
# curl -O https://mac.r-project.org/libs-4/netcdf-4.7.4-darwin.17-x86_64.tar.gz
# tar fvxzm netcdf-4.7.4-darwin.17-x86_64.tar.gz -C /
# rm netcdf-4.7.4-darwin.17-x86_64.tar.gz
# curl -O https://mac.r-project.org/libs-4/hdf5-1.12.0-darwin.17-x86_64.tar.gz
# tar fvxzm hdf5-1.12.0-darwin.17-x86_64.tar.gz -C /
# rm hdf5-1.12.0-darwin.17-x86_64.tar.gz
# curl -O https://mac.r-project.org/libs-4/szip-2.1.1-darwin.17-x86_64.tar.gz
# tar fvxzm szip-2.1.1-darwin.17-x86_64.tar.gz -C /
# rm szip-2.1.1-darwin.17-x86_64.tar.gz
shell: Rscript {0}

- name: Install Windows system dependencies
if: runner.os == 'Windows'
Expand Down
14 changes: 5 additions & 9 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: xcms
Version: 4.3.1
Version: 4.3.3
Title: LC-MS and GC-MS Data Analysis
Description: Framework for processing and visualization of chromatographically
separated and single-spectra mass spectral data. Imports from AIA/ANDI NetCDF,
Expand Down Expand Up @@ -54,7 +54,7 @@ Imports:
methods,
Biobase,
BiocGenerics,
ProtGenerics (>= 1.35.4),
ProtGenerics (>= 1.37.1),
lattice,
MassSpecWavelet (>= 1.66.0),
S4Vectors,
Expand All @@ -63,9 +63,8 @@ Imports:
MsCoreUtils (>= 1.15.5),
MsFeatures,
MsExperiment (>= 1.5.4),
Spectra (>= 1.13.7),
Spectra (>= 1.15.7),
progress,
jsonlite,
RColorBrewer,
MetaboCoreUtils (>= 1.11.2)
Suggests:
Expand Down Expand Up @@ -93,7 +92,7 @@ URL: https://github.com/sneumann/xcms
BugReports: https://github.com/sneumann/xcms/issues/new
VignetteBuilder: knitr
biocViews: ImmunoOncology, MassSpectrometry, Metabolomics
RoxygenNote: 7.3.1
RoxygenNote: 7.3.2
Encoding: UTF-8
Collate:
'AllGenerics.R'
Expand All @@ -104,12 +103,9 @@ Collate:
'MPI.R'
'MsExperiment-functions.R'
'MsExperiment.R'
'MzTabParam.R'
'XcmsExperiment.R'
'PlainTextParam.R'
'RDataParam.R'
'XcmsExperiment-functions.R'
'XcmsExperiment-plotting.R'
'XcmsExperiment.R'
'c.R'
'cwTools.R'
'databases.R'
Expand Down
20 changes: 8 additions & 12 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import("methods")
importMethodsFrom("ProtGenerics", "peaks", "chromatogram", "writeMSData",
"polarity<-", "centroided", "isCentroided", "peaks<-",
"isolationWindowTargetMz", "quantify", "bin", "spectrapply",
"filterFeatures", "filterMzRange", "filterRt", "filterMz", "filterMsLevel")
"filterFeatures", "filterMzRange", "filterRt", "filterMz", "filterMsLevel",
"estimatePrecursorIntensity")
importClassesFrom("ProtGenerics", "Param")
importFrom("BiocGenerics", "updateObject", "fileName", "subset",
"dirname", "dirname<-")
Expand Down Expand Up @@ -72,6 +73,7 @@ importMethodsFrom("MSnbase", "intensity", "mz", "rtime", "fileNames", "fromFile"
importFrom("MSnbase", "as.data.frame.Spectrum", "Chromatogram",
"MChromatograms", "MSpectra", "requiredFvarLabels", "selectFeatureData")


export(
"etg",
"medianFilter",
Expand Down Expand Up @@ -249,18 +251,19 @@ export(
"hasFilledChromPeaks",
"plotAdjustedRtime",
"groupOverlaps",
"estimatePrecursorIntensity",
"featureArea",
"loadXcmsData",
"matchLamasChromPeaks",
"summarizeLamaMatch",
"matchedRtimes"
"matchedRtimes",
"XcmsExperiment"
)

## New analysis methods
exportMethods(
"showError",
"findChromPeaks",
"estimatePrecursorIntensity",
"groupChromPeaks",
"adjustRtime",
"findChromPeaksIsolationWindow",
Expand Down Expand Up @@ -566,7 +569,8 @@ importMethodsFrom("Spectra", "precursorMz")
importMethodsFrom("Spectra", "$")
importMethodsFrom("Spectra", "uniqueMsLevels")
importMethodsFrom("Spectra", "backendBpparam")
importFrom("Spectra", "MsBackendMemory")
importMethodsFrom("Spectra", "estimatePrecursorIntensity")
importFrom("Spectra", "MsBackendMemory", "filterEmptySpectra")

## MsExperiment things
importClassesFrom("MsExperiment", "MsExperiment")
Expand All @@ -590,14 +594,6 @@ exportMethods("filterMzRange")
exportMethods("fromFile")
exportMethods("fileNames")

## saving xcms objects things
importFrom("jsonlite", "serializeJSON", "write_json", "unserializeJSON",
"read_json")
export("RDataParam")
export("PlainTextParam")
export("MzTabParam")
exportMethods("storeResults")

## filtering features things
importFrom("MetaboCoreUtils", "rowRsd", "rowDratio", "rowPercentMissing",
"rowBlank", "mclosest")
Expand Down
15 changes: 15 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# xcms 4.3

## Changes in version 4.3.3

- Fix issue #755: `chromatogram()` with `msLevel = 2` fails to extract
chromatographic data if `isolationWindowTargetMz` is not specified or
available (e.g. for MSe data).
- Support coercing from `XcmsExperiment` to `XCMSnExp` with
`as(object, "XCMSnExp")`.
- Change `estimatePrecursorIntensity()` to a method and add an implementation
for `MsExperiment` objects.

## Changes in version 4.3.2

- Remove data/results import/export functionality as it is being developed in
the *MsIO* package.

## Changes in version 4.3.1

- Support excluding samples or sample groups from defining features with
Expand Down
69 changes: 0 additions & 69 deletions R/AllGenerics.R
Original file line number Diff line number Diff line change
Expand Up @@ -2050,75 +2050,6 @@ setGeneric("stitch", function(object, lockMass, ...) standardGeneric("stitch"))
setGeneric("stitch.xml", function(object, lockMass) standardGeneric("stitch.xml"))
setGeneric("stitch.netCDF", function(object, lockMass) standardGeneric("stitch.netCDF"))
setGeneric("stitch.netCDF.new", function(object, lockMass) standardGeneric("stitch.netCDF.new"))

#' @title Save xcms result objects in a specified format
#'
#' @description
#'
#' The `storeResults` function saves an `object` resulting from processing with
#' the `xcms` package (mainly `XcmsExperiment`). Multiple formats for storing
#' and exporting are available and can be defined by the `param` argument.
#'
#' Supported `param` objects are:
#'
#' - [`RDataParam`]: Save in an .RData format file. The name of the file can be
#' specified in the `fileName` argument.
#'
#' - [`PlainTextParam`]: Store `MsExperiment` and `XcmsExperiment` objects as a
#' folder of plain text files, folder path defined in the `path` argument.
#'
#' - [`MzTabParam`]: Save an `XcmsExperiment` object as a .mztabm format. file
#' path defined in the `path` argument.
#'
#' For specific examples, see the help pages of the individual parameter classes
#' listed above.
#'
#' @param object `MsExperiment` or `XcmsExperiment` The data object that needs
#' to be saved.
#'
#' @param param The parameter object selecting and configuring the format for
#' saving. It can be one of the following classes: [`RDataParam`],
#' [`PlainTextParam`], or [`MzTabParam`].
#'
#' @param ... Optional parameters.
#'
#' @name storeResults
#'
#' @author Philippine Louail
#'
#' @examples
#'
#' ## Load a test data set with detected peaks
#' library(xcms)
#' library(MsExperiment)
#' faahko_sub <- loadXcmsData("faahko_sub2")
#'
#' ## Set up parameter to save as .RData file
#' param <- RDataParam(fileName = "example_xcms_results")
#'
#' ## save as .RData
#' storeResults(object = faahko_sub, param = param)
#'
#' ## Set up parameter to save as a collection of plain text file
#' param <- PlainTextParam(path = "test/path/")
#'
#' ## Save as a collection of plain text files
#' storeResults(object = faahko_sub, param = param)
#'
#' ## Get XcmsExperiment object with defined metadata
#' test_xcms <- loadXcmsData()
#'
#' ## Define param
#' param <- MzTabParam(studyId = "test",
#' polarity = "positive",
#' sampleDataColumn = "sample_type",
#' path = "test/path/")
#'
#' ## Save as a .mzTabm file
#' storeResults(object = test_xcms, param = param)
#'
#' @md
setGeneric("storeResults", function(object, param, ...) standardGeneric("storeResults"))
setGeneric("subset<-", function(object, value) standardGeneric("subset<-"))
setGeneric("subsetAdjust", function(object, ...) standardGeneric("subsetAdjust"))
setGeneric("subsetAdjust<-", function(object, value) standardGeneric("subsetAdjust<-"))
Expand Down
2 changes: 1 addition & 1 deletion R/MsExperiment-functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@
if (length(msLevel) != npks)
msLevel <- rep(msLevel[1L], npks)
if (!length(isolationWindow))
isolationWindow <- rep(1L, npks)
isolationWindow <- rep(NA_real_, npks)
if (length(isolationWindow) && length(isolationWindow) != npks)
stop("Length of 'isolationWindow' (if provided) should match the ",
"number of chromatograms to extract.")
Expand Down
13 changes: 13 additions & 0 deletions R/MsExperiment.R
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,16 @@ setMethod(
msLevel = msLevel, isolationWindow = isolationWindowTargetMz,
chunkSize = chunkSize, BPPARAM = BPPARAM)
})

#' @rdname estimatePrecursorIntensity
setMethod(
"estimatePrecursorIntensity", "MsExperiment",
function(object, ppm = 10, tolerance = 0,
method = c("previous", "interpolation"),
BPPARAM = bpparam()) {
method <- match.arg(method)
estimatePrecursorIntensity(spectra(object), ppm = ppm,
tolerance = tolerance, method = method,
f = spectraSampleIndex(object),
BPPARAM = BPPARAM)
})
Loading

0 comments on commit 1465d7f

Please sign in to comment.