Skip to content

Commit

Permalink
refactor: cleanup NAMESPACE and dependencies and documentation
Browse files Browse the repository at this point in the history
- Re-save data object.
- Fix documentation and unit tests following the move of `MSnbase` from Depends
  to Imports.
  • Loading branch information
jorainer committed Mar 14, 2024
1 parent 97d7d4c commit 086999d
Show file tree
Hide file tree
Showing 57 changed files with 129 additions and 72 deletions.
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: xcms
Version: 4.1.10
Version: 4.1.11
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 @@ -82,14 +82,14 @@ Suggests:
signal
Enhances:
Rgraphviz,
rgl,
XML
rgl
License: GPL (>= 2) + file LICENSE
URL: https://github.com/sneumann/xcms
BugReports: https://github.com/sneumann/xcms/issues/new
VignetteBuilder: knitr
biocViews: ImmunoOncology, MassSpectrometry, Metabolomics
RoxygenNote: 7.3.1
Encoding: UTF-8
Collate:
'AllGenerics.R'
'functions-XChromatograms.R'
Expand Down
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,8 @@ importFrom("progress", "progress_bar")
exportClasses("XcmsExperiment")
exportMethods("uniqueMsLevels")
exportMethods("filterMzRange")
exportMethods("fromFile")
exportMethods("fileNames")

## saving xcms objects things
importFrom("jsonlite", "serializeJSON", "write_json", "unserializeJSON",
Expand Down
13 changes: 12 additions & 1 deletion R/AllGenerics.R
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,9 @@ setGeneric("checkBack<-", function(object, value) standardGeneric("checkBack<-")
#' @examples
#'
#' ## Load a test data set with detected peaks
#' library(MSnbase)
#' library(xcms)
#' library(MsExperiment)
#' faahko_sub <- loadXcmsData("faahko_sub2")
#'
#' ## Get EICs for every detected chromatographic peak
Expand Down Expand Up @@ -698,6 +701,8 @@ setGeneric("family<-", function(object, value) standardGeneric("family<-"))
#' @examples
#'
#' ## Load a test data set with detected peaks
#' library(xcms)
#' library(MsExperiment)
#' faahko_sub <- loadXcmsData("faahko_sub2")
#'
#' ## Disable parallel processing for this example
Expand Down Expand Up @@ -999,14 +1004,16 @@ setGeneric("filepaths<-", function(object, value) standardGeneric("filepaths<-")
#' @examples
#'
#' ## Load a test data set with identified chromatographic peaks
#' library(xcms)
#' library(MsExperiment)
#' res <- loadXcmsData("faahko_sub2")
#'
#' ## Disable parallel processing for this example
#' register(SerialParam())
#'
#' ## Perform the correspondence. We assign all samples to the same group.
#' res <- groupChromPeaks(res,
#' param = PeakDensityParam(sampleGroups = rep(1, length(fileNames(res)))))
#' param = PeakDensityParam(sampleGroups = rep(1, length(res))))
#'
#' ## For how many features do we lack an integrated peak signal?
#' sum(is.na(featureValues(res)))
Expand Down Expand Up @@ -1897,6 +1904,8 @@ setGeneric("reconstructChromPeakSpectra", function(object, ...)
#' @examples
#'
#' ## Load a test data set with detected peaks
#' library(xcms)
#' library(MsExperiment)
#' faahko_sub <- loadXcmsData("faahko_sub2")
#'
#' ## Disable parallel processing for this example
Expand Down Expand Up @@ -2047,6 +2056,8 @@ setGeneric("stitch.netCDF.new", function(object, lockMass) standardGeneric("stit
#' @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
Expand Down
13 changes: 8 additions & 5 deletions R/DataClasses.R
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ setClass("XProcessHistory",
#' detection in purely chromatographic data.
#'
#' @references
#' Ralf Tautenhahn, Christoph B\"{o}ttcher, and Steffen Neumann "Highly
#' Ralf Tautenhahn, Christoph Böttcher, and Steffen Neumann "Highly
#' sensitive feature detection for high resolution LC/MS" \emph{BMC Bioinformatics}
#' 2008, 9:504
#'
Expand Down Expand Up @@ -519,13 +519,14 @@ NULL
#' cwp
#'
#' ## Perform the peak detection using centWave on some of the files from the
#' ## faahKO package. Files are read using the readMSData from the MSnbase
#' ## package
#' ## faahKO package. Files are read using the `readMsExperiment` function
#' ## from the MsExperiment package
#' library(faahKO)
#' library(xcms)
#' library(MsExperiment)
#' fls <- dir(system.file("cdf/KO", package = "faahKO"), recursive = TRUE,
#' full.names = TRUE)
#' raw_data <- readMSData(fls[1], mode = "onDisk")
#' raw_data <- readMsExperiment(fls[1])
#'
#' ## Perform the peak detection using the settings defined above.
#' res <- findChromPeaks(raw_data, param = cwp)
Expand Down Expand Up @@ -894,7 +895,7 @@ setClass("MatchedFilterParam",
#' centWave algorithm, which includes wavelet estimation.
#'
#' @details This algorithm's performance has been tested rigorously
#' on high resolution LC/{OrbiTrap, TOF}-MS data in centroid mode.
#' on high resolution LC/(OrbiTrap, TOF)-MS data in centroid mode.
#' Simultaneous kalman filters identify chromatographic peaks and calculate
#' their area under the curve. The default parameters are set to operate on
#' a complex LC-MS Orbitrap sample. Users will find it useful to do some
Expand Down Expand Up @@ -1110,6 +1111,7 @@ NULL
#'
#' @examples
#'
#' library(MSnbase)
#' ## Create a MSWParam object
#' mp <- MSWParam()
#' ## Change snthresh parameter
Expand Down Expand Up @@ -1799,6 +1801,7 @@ setClass("MsFeatureData", contains = c("environment"),
#' @examples
#'
#' ## Load a test data set with detected peaks
#' library(MSnbase)
#' data(faahko_sub)
#' ## Update the path to the files for the local system
#' dirname(faahko_sub) <- system.file("cdf/KO", package = "faahKO")
Expand Down
23 changes: 12 additions & 11 deletions R/do_findChromPeaks-functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@
#' @family core peak detection functions
#'
#' @references
#' Ralf Tautenhahn, Christoph B\"{o}ttcher, and Steffen Neumann "Highly
#'
#' Ralf Tautenhahn, Christoph Böttcher, and Steffen Neumann "Highly
#' sensitive feature detection for high resolution LC/MS"
#' \emph{BMC Bioinformatics} 2008, 9:504
#'
Expand Down Expand Up @@ -163,7 +164,7 @@ do_findChromPeaks_centWave <- function(mz, int, scantime, valsPerSpect,
verboseColumns = verboseColumns, roiList = roiList,
firstBaselineCheck = firstBaselineCheck,
roiScales = roiScales, sleep = sleep,
extendLengthMSW = extendLengthMSW,
extendLengthMSW = extendLengthMSW,
verboseBetaColumns = verboseBetaColumns)
} else {
## message("DEBUG: using modified centWave.")
Expand Down Expand Up @@ -579,7 +580,7 @@ do_findChromPeaks_centWave <- function(mz, int, scantime, valsPerSpect,
lm <- .narrow_rt_boundaries(lm, d)
lm_seq <- lm[1]:lm[2]
pd <- d[lm_seq]

# Implement a fit of a skewed gaussian (beta distribution)
# for peak shape and within-peak signal-to-noise ratio
# See https://doi.org/10.1186/s12859-023-05533-4 and
Expand Down Expand Up @@ -1265,7 +1266,7 @@ do_findChromPeaks_centWave <- function(mz, int, scantime, valsPerSpect,
#' by specifying \code{withWave = TRUE}.
#'
#' @details This algorithm's performance has been tested rigorously
#' on high resolution LC/{OrbiTrap, TOF}-MS data in centroid mode.
#' on high resolution LC/(OrbiTrap, TOF)-MS data in centroid mode.
#' Simultaneous kalman filters identify peaks and calculate their
#' area under the curve. The default parameters are set to operate on
#' a complex LC-MS Orbitrap sample. Users will find it useful to do some
Expand Down Expand Up @@ -2673,7 +2674,7 @@ do_findChromPeaks_centWaveWithPredIsoROIs <-
verboseColumns = FALSE, roiList = list(),
firstBaselineCheck = TRUE, roiScales = NULL, snthreshIsoROIs = 6.25,
maxCharge = 3, maxIso = 5, mzIntervalExtension = TRUE,
polarity = "unknown", extendLengthMSW = FALSE,
polarity = "unknown", extendLengthMSW = FALSE,
verboseBetaColumns = FALSE) {
## Input argument checking: most of it will be done in
## do_findChromPeaks_centWave
Expand Down Expand Up @@ -3271,9 +3272,9 @@ peaksWithMatchedFilter <- function(int, rt, fwhm = 30, sigma = fwhm / 2.3548,
#' @examples
#'
#' ## Reading a file
#' library(MsExperiment)
#' library(xcms)
#' od <- readMSData(system.file("cdf/KO/ko15.CDF", package = "faahKO"),
#' mode = "onDisk")
#' od <- readMsExperiment(system.file("cdf/KO/ko15.CDF", package = "faahKO"))
#'
#' ## Extract chromatographic data for a small m/z range
#' mzr <- c(272.1, 272.2)
Expand Down Expand Up @@ -3633,9 +3634,9 @@ peaksWithCentWave <- function(int, rt,
#'
#' @examples
#'
#' library(MsExperiment)
#' library(xcms)
#' od <- readMSData(system.file("cdf/KO/ko15.CDF", package = "faahKO"),
#' mode = "onDisk")
#' od <- readMsExperiment(system.file("cdf/KO/ko15.CDF", package = "faahKO"))
#'
#' ## Extract chromatographic data for a small m/z range
#' chr <- chromatogram(od, mz = c(272.1, 272.3))[1, 1]
Expand Down Expand Up @@ -3731,7 +3732,7 @@ peaksWithCentWave <- function(int, rt,
#' @author William Kumler
#'
#' @noRd
.get_beta_values <- function(intensity, rtime = seq_along(intensity),
.get_beta_values <- function(intensity, rtime = seq_along(intensity),
skews=c(3, 3.5, 4, 4.5, 5), zero.rm = TRUE){
if (zero.rm) {
## remove 0 or NA intensities
Expand All @@ -3744,7 +3745,7 @@ peaksWithCentWave <- function(int, rt,
beta_snr <- NA
} else {
beta_sequence <- rep(.scale_zero_one(rtime), each=length(skews))
beta_vals <- t(matrix(dbeta(beta_sequence, shape1 = skews, shape2 = 5),
beta_vals <- t(matrix(dbeta(beta_sequence, shape1 = skews, shape2 = 5),
nrow = length(skews)))
# matplot(beta_vals)
beta_cors <- cor(intensity, beta_vals)
Expand Down
2 changes: 2 additions & 0 deletions R/do_groupChromPeaks-functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@
#'
#' @examples
#' ## Load the test file
#' library(xcms)
#' library(MsExperiment)
#' faahko_sub <- loadXcmsData("faahko_sub2")
#'
#' ## Disable parallel processing for this example
Expand Down
4 changes: 2 additions & 2 deletions R/functions-Chromatogram.R
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@
#'
#' @examples
#'
#' xd <- readMSData(system.file('cdf/KO/ko15.CDF', package = "faahKO"),
#' mode = "onDisk")
#' library(MsExperiment)
#' xd <- readMsExperiment(system.file('cdf/KO/ko15.CDF', package = "faahKO"))
#' chr <- chromatogram(xd, mz = c(-0.5, 0.5) + 453.2)
#' xchr <- findChromPeaks(chr, param = CentWaveParam(snthresh = 0))
#' plot(xchr)
Expand Down
1 change: 1 addition & 0 deletions R/functions-OnDiskMSnExp.R
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,7 @@ setReplaceMethod("dirname", "OnDiskMSnExp", function(path, value) {
#'
#' @examples
#'
#' library(MSnbase)
#' fl <- system.file("TripleTOF-SWATH", "PestMix1_DDA.mzML", package = "msdata")
#' pest_dda <- readMSData(fl, mode = "onDisk")
#' res <- .estimate_prec_intensity(pest_dda)
Expand Down
4 changes: 4 additions & 0 deletions R/functions-XCMSnExp.R
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,7 @@ adjustRtimePeakGroups <- function(object, param = PeakGroupsParam(),
#' @examples
#'
#' ## Load a test data set with detected peaks
#' library(MSnbase)
#' data(faahko_sub)
#' ## Update the path to the files for the local system
#' dirname(faahko_sub) <- system.file("cdf/KO", package = "faahKO")
Expand Down Expand Up @@ -964,6 +965,7 @@ isCalibrated <- function(object) {
#' @examples
#'
#' ## Load a test data set with detected peaks
#' library(MSnbase)
#' data(faahko_sub)
#' ## Update the path to the files for the local system
#' dirname(faahko_sub) <- system.file("cdf/KO", package = "faahKO")
Expand Down Expand Up @@ -1202,6 +1204,7 @@ featureSummary <- function(x, group, perSampleCounts = FALSE,
#' @examples
#'
#' ## Load a test data set with detected peaks
#' library(MSnbase)
#' data(faahko_sub)
#' ## Update the path to the files for the local system
#' dirname(faahko_sub) <- system.file("cdf/KO", package = "faahKO")
Expand Down Expand Up @@ -1854,6 +1857,7 @@ setMethod("hasFilledChromPeaks", "XCMSnExp", function(object) {
#'
#' @examples
#'
#' library(MSnbase)
#' xd <- readMSData(system.file('cdf/KO/ko15.CDF', package = "faahKO"),
#' mode = "onDisk")
#' xd <- findChromPeaks(xd, param = CentWaveParam())
Expand Down
1 change: 1 addition & 0 deletions R/functions-XChromatogram.R
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@
#'
#' @examples
#'
#' library(MSnbase)
#' ## Create a XChromatogram object
#' pks <- matrix(nrow = 1, ncol = 6)
#' colnames(pks) <- c("rt", "rtmin", "rtmax", "into", "maxo", "sn")
Expand Down
1 change: 1 addition & 0 deletions R/functions-XChromatograms.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#' ## ---- Creation of XChromatograms ----
#' ##
#' ## Create a XChromatograms from Chromatogram objects
#' library(MSnbase)
#' dta <- list(Chromatogram(rtime = 1:7, c(3, 4, 6, 12, 8, 3, 2)),
#' Chromatogram(1:10, c(4, 6, 3, 4, 7, 13, 43, 34, 23, 9)))
#'
Expand Down
2 changes: 2 additions & 0 deletions R/functions-imputation.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#'
#' @examples
#'
#' library(MSnbase)
#' library(faahKO)
#' data("faahko")
#'
Expand Down Expand Up @@ -111,6 +112,7 @@ imputeRowMin <- function(x, min_fraction = 1/2) {
#' @examples
#'
#' library(faahKO)
#' library(MSnbase)
#' data("faahko")
#'
#' xset <- group(faahko)
Expand Down
18 changes: 3 additions & 15 deletions R/functions-utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,9 @@ weightedMeanAroundApex <- function(x, w = rep(1, length(x)), i = 1) {
#'
#' @description
#'
#' **UPDATE**: please use `plot(x, type = "XIC")` from the `MSnbase` package
#' instead. See examples below.
#' **UPDATE**: please use `plot()` from the `MsExperiment` or
#' `plot(x, type = "XIC")` from the `MSnbase` package instead. See examples
#' in the vignette for more information.
#'
#' The `plotMsData` creates a plot that combines an (base peak )
#' extracted ion chromatogram on top (rt against intensity) and a plot of
Expand Down Expand Up @@ -338,19 +339,6 @@ weightedMeanAroundApex <- function(x, w = rep(1, length(x)), i = 1) {
#'
#' @md
#'
#' @examples
#'
#' ## Read two files from the faahKO package
#' library(faahKO)
#' cdfs <- dir(system.file("cdf", package = "faahKO"), full.names = TRUE,
#' recursive = TRUE)[1:2]
#' raw_data <- readMSData(cdfs, mode = "onDisk")
#'
#' ## Subset the object to a rt and mz range and plot the data.
#' raw_data |>
#' filterRt(rt = c(2700, 2900)) |>
#' filterMz(mz = c(334.9, 335.1)) |>
#' plot(type = "XIC")
plotMsData <- function(x, main = "", cex = 1, mfrow = c(2, 1),
grid.color = "lightgrey",
colramp = colorRampPalette(
Expand Down
3 changes: 3 additions & 0 deletions R/methods-Chromatogram.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#'
#' @examples
#'
#' library(MSnbase)
#' ## Loading a test data set with identified chromatographic peaks
#' faahko_sub <- loadXcmsData("faahko_sub2")
#' faahko_sub <- filterRt(faahko_sub, c(2500, 3700))
Expand Down Expand Up @@ -192,6 +193,7 @@ setMethod("findChromPeaks", signature(object = "Chromatogram",
#'
#' @examples
#'
#' library(MSnbase)
#' chr1 <- Chromatogram(rtime = 1:10 + rnorm(n = 10, sd = 0.3),
#' intensity = c(5, 29, 50, NA, 100, 12, 3, 4, 1, 3))
#' chr2 <- Chromatogram(rtime = 1:10 + rnorm(n = 10, sd = 0.3),
Expand Down Expand Up @@ -261,6 +263,7 @@ setMethod("correlate", signature = c(x = "Chromatogram", y = "Chromatogram"),
#'
#' @examples
#'
#' library(MSnbase)
#' chr <- Chromatogram(rtime = 1:10 + rnorm(n = 10, sd = 0.3),
#' intensity = c(5, 29, 50, NA, 100, 12, 3, 4, 1, 3))
#'
Expand Down
Loading

0 comments on commit 086999d

Please sign in to comment.