diff --git a/DESCRIPTION b/DESCRIPTION index 2f83a268f..9798aab9b 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: xcms -Version: 1.51.10 -Date: 2017-03-15 +Version: 1.51.11 +Date: 2017-04-16 Title: LC/MS and GC/MS Data Analysis Author: Colin A. Smith , Ralf Tautenhahn , @@ -12,19 +12,19 @@ Maintainer: Steffen Neumann Depends: R (>= 2.14.0), methods, - mzR (>= 1.1.6), - BiocGenerics, - ProtGenerics, Biobase, + BiocParallel (>= 1.8.0), MSnbase (>= 2.1.10) Imports: + mzR (>= 1.1.6), + BiocGenerics, + ProtGenerics, lattice, RColorBrewer, plyr, RANN, multtest, MassSpecWavelet (>= 1.5.2), - BiocParallel (>= 1.8.0), S4Vectors Suggests: BiocStyle, @@ -46,7 +46,7 @@ VignetteBuilder: knitr BugReports: https://github.com/sneumann/xcms/issues/new biocViews: MassSpectrometry, Metabolomics RoxygenNote: 6.0.1 -Collate: +Collate: 'AllGenerics.R' 'DataClasses.R' 'Deprecated.R' @@ -67,6 +67,7 @@ Collate: 'functions-OnDiskMSnExp.R' 'functions-ProcessHistory.R' 'functions-XCMSnExp.R' + 'functions-normalization.R' 'functions-xcmsEIC.R' 'functions-xcmsFragments.R' 'functions-xcmsRaw.R' diff --git a/NAMESPACE b/NAMESPACE index 3c990626b..f397d240d 100755 --- a/NAMESPACE +++ b/NAMESPACE @@ -4,7 +4,12 @@ importFrom("utils", "capture.output") import("methods") importFrom("ProtGenerics", "peaks") importFrom("BiocGenerics", "updateObject", "fileName") -import("Biobase") +## import("Biobase") +importFrom("Biobase", "AnnotatedDataFrame") +importClassesFrom("Biobase", "AnnotatedDataFrame", "Versioned") +importMethodsFrom("Biobase", "classVersion", "classVersion<-", "phenoData", + "phenoData<-", "pData", "rowMedians") + importFrom("graphics", "plot", "image", "boxplot") importFrom("mzR", "peaks", "close", "openMSfile", "header") importFrom("lattice", "levelplot", "panel.rect", "panel.levelplot") diff --git a/R/functions-normalization.R b/R/functions-normalization.R new file mode 100644 index 000000000..5f1c7fb47 --- /dev/null +++ b/R/functions-normalization.R @@ -0,0 +1,118 @@ +#' @include DataClasses.R functions-utils.R + + +#' @title Fit linear model row-wise to a matrix or data.frame +#' +#' @description Simple function to fit linear models row-wise to the provided +#' data. +#' +#' @details For \code{method = "lmrob"} robust regression is performed using +#' the \code{\link[robustbase]{lmrob}} function with settings +#' \code{settings = "KS2014"} and \code{method = "SMDB"}. +#' The function will perform by default parallel fitting of the models +#' based on the global parallel processing settings. +#' +#' @note Between batch correction in the form of \code{y ~ idx * batch} is +#' currently problematic, because we don't yet check if there are too few +#' values within each batch. +#' +#' @param formula \code{formula} representing the model. +#' +#' @param data \code{data.frame} containing the data to be fitted (e.g. the +#' \code{pData} of an \code{\link{XCMSnExp}} object. +#' +#' @param y \code{matrix} or \code{data.frame} with the response variable. The +#' model is fit to each row of this matrix (which can be e.g. the +#' \code{\link{featureValues}} matrix). +#' +#' @param minVals \code{integer(1)} defining the minimum number of values to be +#' used for the fitting. Model fitting is skipped for rows in \code{y} with +#' less than \code{minVals} non-NA values. +#' +#' @param method \code{character} defining the method/function to be used for +#' model fitting. Allowed values are \code{"lm"} for least squares +#' regression and \code{"lmrob"} for robust regression using the +#' \code{\link[robustbase]{lmrob}} function. +#' +#' @param BPPARAM optional parameter specifying parallel processing settings. +#' +#' @return A \code{list} with the fitted linear models or \code{NULL} for rows +#' with too few data points. +#' +#' @noRd +#' +#' @author Johannes Rainer +fitModel <- function(formula, data, y, minVals = 4, + method = c("lm", "lmrob"), BPPARAM = bpparam()) { + method <- match.arg(method, c("lm", "lmrob")) + if (missing(formula) || !is(formula, "formula")) + stop("'formula' has to be submitted and should be a formula!") + if (missing(data) || !is(data, "data.frame")) + stop("'data' has to be a 'data.frame'!") + if (missing(y)) + stop("'y' is missing with no default.") + if (ncol(y) != nrow(data)) + stop("ncol(y) has to match nrow(data)!") + ## Check that 'data' contains the variables we're looking for. + vars <- all.vars(formula) + if (vars[1] != "y") + stop("'formula' should start with 'y ~'") + if (!all(vars[-1] %in% colnames(data))) + stop("All of the variables from 'formula' have to be present in 'data'") + ## data shouldn't contain a column y. + if (any(colnames(data) == "y")) + stop("'data' should not contain a column named 'y'") + ## Done with checking. + force(y) + force(data) + force(formula) + force(minVals) + force(method) + force(BPPARAM) + ## Subset data to contain only explanatory variables + data <- data[, vars[-1], drop = FALSE] + if (is.null(rownames(y))) + rownames(y) <- 1:nrow(y) + y <- split.data.frame(y, f = rownames(y)) + ## Determine fetures we skip because of too few data points. + do_em <- which(unlist(lapply(y, function(z) sum(!is.na(z)) >= minVals))) + res <- vector("list", length(y)) + names(res) <- names(y) + sttngs <- list() + if (method == "lmrob") { + ## Force use of the KS2014 settings in lmrob and increase the + ## scale-finding iterations to avoid some of the warnings. + ## sttngs <- robustbase::lmrob.control("KS2014") + ## sttngs$maxit.scale <- 10000 + ## sttngs$k.max <- 10000 + ## sttngs$refine.tol <- 1e-7 + } + if (length(do_em)) { + ## fit the model + res[do_em] <- bplapply(y[do_em], FUN = function(z, formula., data., + minVals., lmeth, + sttngs) { + ## TODO: need to check what happens if we're also performing between + ## batch correction and we have too few samples per batch! + ## ## Removing all missing values - could eventually skip that. + ## z <- as.numeric(z) + ## not_na <- !is.na(z) + ## data. <- droplevels(data.frame(y = z[not_na], + ## data.[not_na, , drop = FALSE])) + data. <- data.frame(y = as.numeric(z), data.) + if (lmeth == "lm") + return(lm(formula., data = data., model = FALSE)) + if (lmeth == "lmrob") { + ## set.seed(123) + ## return(robustbase::lmrob(formula., data = data., model = FALSE, + ## setting = sttngs)) + } + if (lmeth == "rlm") + stop("Not yet implemented") + ## return(MASS::rlm(formula., data = data.)) + }, formula. = formula, data. = data, minVals. = minVals, lmeth = method, + sttngs = sttngs, BPPARAM = BPPARAM) + } + res +} + diff --git a/R/functions-utils.R b/R/functions-utils.R index bc05c5eb8..3f26387cc 100644 --- a/R/functions-utils.R +++ b/R/functions-utils.R @@ -104,32 +104,44 @@ useOriginalCode <- function(x) { ##' @title Create the profile matrix ##' ##' @description This function creates a \emph{profile} matrix, i.e. a rt times -##' m/z matrix of aggregated intensity values with values aggregated within bins -##' along the m/z dimension. +##' m/z matrix of aggregated intensity values with values aggregated within +##' bins along the m/z dimension. ##' ##' @details This is somewhat the successor function for the deprecated -##' \code{profBin} methods (\code{profBinM}, \code{profBinLinM}, -##' \code{profBinLinBaseM} and \code{profIntLin}). +##' \code{profBin} methods (\code{profBinM}, \code{profBinLinM}, +##' \code{profBinLinBaseM} and \code{profIntLin}). ##' ##' @param mz Numeric representing the m/z values across all scans/spectra. +##' ##' @param int Numeric representing the intensity values across all -##' scans/spectra. +##' scans/spectra. +##' ##' @param valsPerSpect Numeric representing the number of measurements for each -##' scan/spectrum. +##' scan/spectrum. +##' ##' @param method A character string specifying the profile matrix generation -##' method. Allowed are \code{"bin"}, \code{"binlin"}, -##' \code{"binlinbase"} and \code{"intlin"}. +##' method. Allowed are \code{"bin"}, \code{"binlin"}, +##' \code{"binlinbase"} and \code{"intlin"}. +##' ##' @param step Numeric specifying the size of the m/z bins. +##' ##' @param baselevel Numeric specifying the base value. +##' ##' @param basespace Numeric. +##' ##' @param mzrange. numeric(2) optionally specifying the mz value range -##' for binning. This is to adopt the old profStepPad<- method used for obiwarp -##' retention time correction that did the binning from whole-number limits. +##' for binning. This is to adopt the old profStepPad<- method used for +##' obiwarp retention time correction that did the binning from +##' whole-number limits. +##' ##' @param returnBreaks logical(1): hack to return the breaks of the bins. -##' Setting this to TRUE causes the function to return a \code{list} with -##' elements \code{"$profMat"} and \code{"breaks"}. +##' Setting this to TRUE causes the function to return a \code{list} with +##' elements \code{"$profMat"} and \code{"breaks"}. +##' ##' @param baseValue numeric(1) defining the value to be returned if no signal -##' was found in the corresponding bin. Defaults to 0 for backward compatibility. +##' was found in the corresponding bin. Defaults to 0 for backward +##' compatibility. +##' ##' @noRd .createProfileMatrix <- function(mz, int, valsPerSpect, method, step = 0.1, baselevel = NULL, @@ -144,7 +156,7 @@ useOriginalCode <- function(x) { brks <- NULL if (length(mzrange.) != 2) { - mrange <- range(mz) + mrange <- range(mz, na.rm = TRUE) mzrange. <- c(floor(mrange[1] / step) * step, ceiling(mrange[2] / step) * step) } @@ -153,6 +165,14 @@ useOriginalCode <- function(x) { ## Calculate the "real" bin size; old xcms code oddity that that's different ## from step. bin_size <- (mass[mlength] - mass[1]) / (mlength - 1) + ## Define the breaks. + toIdx <- cumsum(valsPerSpect) + fromIdx <- c(1L, toIdx[-length(toIdx)] + 1L) + shiftBy <- TRUE + binFromX <- min(mass) + binToX <- max(mass) + brks <- breaks_on_nBins(fromX = binFromX, toX = binToX, + nBins = mlength, shiftByHalfBinSize = TRUE) ## for profIntLinM we have to use the old code. if (impute == "intlin") { profFun <- "profIntLinM" @@ -164,13 +184,6 @@ useOriginalCode <- function(x) { TRUE)) } else { ## Binning the data. - toIdx <- cumsum(valsPerSpect) - fromIdx <- c(1L, toIdx[-length(toIdx)] + 1L) - shiftBy <- TRUE - binFromX <- min(mass) - binToX <- max(mass) - brks <- breaks_on_nBins(fromX = binFromX, toX = binToX, - nBins = mlength, shiftByHalfBinSize = TRUE) binRes <- binYonX(mz, int, breaks = brks, fromIdx = fromIdx, diff --git a/R/functions-xcmsRaw.R b/R/functions-xcmsRaw.R index 4d97b577b..3f7f7d11a 100644 --- a/R/functions-xcmsRaw.R +++ b/R/functions-xcmsRaw.R @@ -537,3 +537,198 @@ remakeTIC<-function(object){ } return(object) } + +############################################################ +## getPeaks +#' @description Replacement function for the original getPeaks method/function +#' that does no longer use the deprecated \code{profFun} functions. This +#' function uses the \code{binYonX} and \code{imputeLinInterpol} to perform +#' the binning (and missing value imputation). +#' +#' @param object An \code{xcmsRaw} object. +#' +#' @param peakrange \code{matrix} with 4 required columns \code{"mzmin"}, +#' \code{"mzmax"}, \code{"rtmin"} and \code{"rtmax"}. +#' +#' @param step \code{numeric(1)} defining the bin size for the profile matrix +#' generation. +#' +#' @author Johannes Rainer +#' +#' @noRd +.getPeaks_new <- function(object, peakrange, step = 0.1) { + ## Here we're avoiding the profFun call. + if (all(c("mzmin","mzmax","rtmin","rtmax") %in% colnames(peakrange))) + peakrange <- peakrange[,c("mzmin","mzmax","rtmin","rtmax"),drop=FALSE] + stime <- object@scantime + + pi <- profinfo(object) + method <- pi$method + if (missing(step)) + step <- pi$step + if (step == 0) + step <- 0.1 + baselevel <- pi$baselevel + basespace <- pi$basespace + vps <- diff(c(object@scanindex, length(object@env$mz))) + + cat("method: ", method, "\n") + cat("step: ", step, "\n") + ## Create the profile matrix: + pMat <- .createProfileMatrix(mz = object@env$mz, int = object@env$intensity, + valsPerSpect = vps, + method = method, + step = step, + baselevel = baselevel, + basespace = basespace, + returnBreaks = TRUE, + baseValue = 0, + mzrange. = NULL) + brks <- pMat$breaks + pMat <- pMat$profMat ## rows are masses, cols are retention times/scans. + bin_size <- diff(brks[1:2]) + bin_half <- bin_size / 2 + ## Calculate the mean mass per bin using the breaks used for the binning. + ## Note: these define the real mass breaks as they have been used for the + ## binning. Simply using seq(floor...) as in the original code is wrong + ## because the mass bins are calculated wrongly. The bin size is != step, + ## bin size is marginally smaller and, for larger mz the correct mass + ## bin will be wrongly identified. + mass <- brks[-length(brks)] + bin_half ## midpoint for the breaks + mass_range <- range(mass) + + ## Prepare the result matrix. + cnames <- c("mz", "mzmin", "mzmax", "rt", "rtmin", "rtmax", "into", "maxo") + rmat <- matrix(nrow = nrow(peakrange), ncol = length(cnames)) + colnames(rmat) <- cnames + + for (i in order(peakrange[, 1])) { + imz <- findRange(mass, c(peakrange[i, 1] - bin_half, + peakrange[i, 2] + bin_half), TRUE) + iret <- findRange(stime, peakrange[i, 3:4], TRUE) + idx_imz <- imz[1]:imz[2] + idx_iret <- iret[1]:iret[2] + ## Extract the intensity matrix for the mz-rt range: rows are mz, cols + ## rt values. + ymat <- pMat[idx_imz, idx_iret, drop = FALSE] + ## Define the maximum intensity, is one value per mz. + ymax <- colMax(ymat) + iymax <- which.max(ymax) + + ## The width in rt. + pwid <- diff(stime[iret])/diff(iret) + + ## Calculate sum across rt. For each mz we get one value. + rosm <- rowSums(ymat) + limz <- length(idx_imz) + if (length(rosm) != limz) { ## that happens for some reason + warning("weighted.mean : x and w must have the same length \n") + rosm <- rep(1, limz) ## fallback to mean + } + ## mean mz: + rmat[i, 1] <- weighted.mean(mass[idx_imz], rosm) ## mz; its not the + ## position of the largest intensity! + if (is.nan(rmat[i,1]) || is.na(rmat[i,1])) ## R2.11 : weighted.mean() + ## results in NA (not NaN) for zero weights + rmat[i, 1] <- mean(peakrange[i, 1:2]) + + rmat[i, 2:3] <- peakrange[i, 1:2] ## mzmin, mzmax + rmat[i, 4] <- stime[idx_iret][iymax] ## rt + rmat[i, 5:6] <- peakrange[i, 3:4] ## rtmin, rtmax + + if (peakrange[i, 3] < stime[1] || + peakrange[i, 4] > stime[length(stime)] || + is.nan(pwid)) { + warning("getPeaks: Peak m/z:", peakrange[i, 1], "-", + peakrange[i, 2], ", RT:", peakrange[i, 3], "-", + peakrange[i, 4], "is out of retention time range for ", + "this sample (", object@filepath, + "), using zero intensity value.\n") + rmat[i, 7:8] <- 0 + } else { + rmat[i, 7] <- pwid * sum(ymax) ## into + rmat[i, 8] <- ymax[iymax] ## maxo + } + } + invisible(rmat) +} + +#' @description Original getPeaks function. This should be removed at some point +#' as it uses deprecated API. +#' @noRd +.getPeaks_orig <- function(object, peakrange, step = 0.1) { + profFun <- match.profFun(object) + if (all(c("mzmin","mzmax","rtmin","rtmax") %in% colnames(peakrange))) + peakrange <- peakrange[,c("mzmin","mzmax","rtmin","rtmax"),drop=FALSE] + stime <- object@scantime + +### Create EIC buffer + ## This is NOT calculated for the full file. + mrange <- range(peakrange[,1:2]) + ## These mass bins are slightly different from the ones that are used + ## by the binning function, since within the binning function the step/bin + ## size is recalculated! + mass <- seq(floor(mrange[1]/step)*step, ceiling(mrange[2]/step)*step, by = step) + bufsize <- min(100, length(mass)) + buf <- profFun(object@env$mz, object@env$intensity, object@scanindex, + bufsize, mass[1], mass[bufsize], TRUE, object@profparam) + bufidx <- integer(length(mass)) + idxrange <- c(1, bufsize) + bufidx[idxrange[1]:idxrange[2]] <- 1:bufsize + + cnames <- c("mz", "mzmin", "mzmax", "rt", "rtmin", "rtmax", "into", "maxo") + rmat <- matrix(nrow = nrow(peakrange), ncol = length(cnames)) + colnames(rmat) <- cnames + + for (i in order(peakrange[,1])) { + imz <- findRange(mass, c(peakrange[i,1]-.5*step, peakrange[i,2]+.5*step), TRUE) + iret <- findRange(stime, peakrange[i,3:4], TRUE) + +### Update EIC buffer if necessary + if (bufidx[imz[2]] == 0) { + bufidx[idxrange[1]:idxrange[2]] <- 0 + idxrange <- c(max(1, imz[1]), min(bufsize+imz[1]-1, length(mass))) + bufidx[idxrange[1]:idxrange[2]] <- 1:(diff(idxrange)+1) + buf <- profFun(object@env$mz, object@env$intensity, object@scanindex, + diff(idxrange)+1, mass[idxrange[1]], mass[idxrange[2]], + TRUE, object@profparam) + } + ## Extract the intensity matrix for the mz-rt range: rows are mz, cols + ## rt values. + ymat <- buf[bufidx[imz[1]:imz[2]],iret[1]:iret[2],drop=FALSE] + ## Define the maximum intensity, is one value per mz. + ymax <- colMax(ymat) + iymax <- which.max(ymax) + + ## The width in rt. + pwid <- diff(stime[iret])/diff(iret) + + ## Calculate sum across rt. For each mz we get one value. + rosm <- rowSums(ymat) + limz <- length(imz[1]:imz[2]) + if (length(rosm) != limz) { ## that happens for some reason + warning("weighted.mean : x and w must have the same length \n") + rosm <- rep(1, limz) ## fallback to mean + } + ## mean mz: + rmat[i,1] <- weighted.mean(mass[imz[1]:imz[2]], rosm) ## mz; its not the + ## position of the largest intensity! + if (is.nan(rmat[i,1]) || is.na(rmat[i,1])) ## R2.11 : weighted.mean() results in NA (not NaN) for zero weights + rmat[i,1] <- mean(peakrange[i,1:2]) + + rmat[i,2:3] <- peakrange[i,1:2] ## mzmin, mzmax + rmat[i,4] <- stime[iret[1]:iret[2]][iymax] ## rt + rmat[i,5:6] <- peakrange[i,3:4] ## rtmin, rtmax + + if (peakrange[i,3] < stime[1] || peakrange[i,4] > stime[length(stime)] || is.nan(pwid)) { + warning("getPeaks: Peak m/z:",peakrange[i,1],"-",peakrange[i,2], ", RT:",peakrange[i,3],"-",peakrange[i,4], + "is out of retention time range for this sample (",object@filepath,"), using zero intensity value.\n") + rmat[i,7:8] <- 0 + } else { + rmat[i,7] <- pwid*sum(ymax) ## into + rmat[i,8] <- ymax[iymax] ## maxo + } + } + invisible(rmat) + +} diff --git a/R/functions-xcmsSet.R b/R/functions-xcmsSet.R index 551aa048b..aba8d0b8b 100644 --- a/R/functions-xcmsSet.R +++ b/R/functions-xcmsSet.R @@ -10,9 +10,11 @@ xcmsSet <- function(files = NULL, snames = NULL, sclass = NULL, progressCallback=NULL, scanrange=NULL, BPPARAM=bpparam(), stopOnError = TRUE, ...) { - if (nSlaves != 0) - warning("Use of argument 'nSlaves' is deprecated!", - " Please use 'BPPARAM' instead.") + if (nSlaves != 0) { + message("Use of argument 'nSlaves' is deprecated,", + " please use 'BPPARAM' instead.") + options(mc.cores = nSlaves) + } if (!is.logical(stopOnError)) stop("'stopOnError' has to be a logical.") ## Overwriting the stop.on.error in BPPARAM: @@ -759,33 +761,33 @@ filtfft <- function(y, filt) { ## .validProcessHistory ## Check the validity of the .processHistory slot. .validProcessHistory <- function(x) { - msg <- validMsg(NULL, NULL) + msg <- character() if (.hasSlot(x, ".processHistory")) { if (length(x@.processHistory) > 0) { ## All elements have to inherit from ProcessHistory if (!all(unlist(lapply(x@.processHistory, function(z) { return(inherits(z, "ProcessHistory")) })))) - msg <- validMsg(msg, paste0("All objects in slot .processHistory", - " have to be 'ProcessHistory' objects!")) + msg <- c(msg, paste0("All objects in slot .processHistory", + " have to be 'ProcessHistory' objects!")) ## Each element has to be valid vals <- lapply(x@.processHistory, validObject) for (i in seq_along(vals)) { if (!is.logical(vals[[i]])) - msg <- validMsg(msg, vals[[i]]) + msg <- c(msg, vals[[i]]) } ## The fileIndex has to be within 1:length(filepaths(x)) fidx <- 1:length(filepaths(x)) for (z in x@.processHistory) { if (length(z@fileIndex) == 0 | !(all(z@fileIndex %in% fidx))) - msg <- validMsg(msg, paste0("Value of 'fileIndex' slot of some", - " ProcessHistory objects does not", - " match the number of available", - " files!")) + msg <- c(msg, paste0("Value of 'fileIndex' slot of some", + " ProcessHistory objects does not", + " match the number of available", + " files!")) } } } - if (is.null(msg)) TRUE - else msg + if (length(msg)) msg + else TRUE } diff --git a/R/methods-Params.R b/R/methods-Params.R index 9b3f47cc4..29823944b 100644 --- a/R/methods-Params.R +++ b/R/methods-Params.R @@ -24,6 +24,7 @@ setMethod("initialize", "GenericParam", function(.Object, ...) { callNextMethod(.Object, ...) }) #' @param object \code{GenericParam} object. +#' #' @rdname GenericParam setMethod("show", "GenericParam", function(object) { cat("Object of class: ", class(object), "\n") @@ -46,9 +47,7 @@ setMethod("initialize", "CentWaveParam", function(.Object, ...) { callNextMethod(.Object, ...) }) -## ##' @rdname findChromPeaks-centWave -## setMethod("print", "CentWaveParam", function(x, ...) show(x)) -##' @rdname findChromPeaks-centWave +#' @rdname findChromPeaks-centWave setMethod("show", "CentWaveParam", function(object) { cat("Object of class: ", class(object), "\n") cat("Parameters:\n") @@ -67,183 +66,222 @@ setMethod("show", "CentWaveParam", function(object) { cat(" roiScales length:", length(roiScales(object)), "\n") }) -##' @aliases ppm -##' @description \code{ppm},\code{ppm<-}: getter and setter for the \code{ppm} -##' slot of the object. -##' @rdname findChromPeaks-centWave +#' @aliases ppm +#' +#' @description \code{ppm},\code{ppm<-}: getter and setter for the \code{ppm} +#' slot of the object. +#' +#' @rdname findChromPeaks-centWave setMethod("ppm", "CentWaveParam", function(object){ return(object@ppm)}) -##' @aliases ppm<- -##' @param value The value for the slot. -##' @rdname findChromPeaks-centWave +#' @aliases ppm<- +#' +#' @param value The value for the slot. +#' +#' @rdname findChromPeaks-centWave setReplaceMethod("ppm", "CentWaveParam", function(object, value) { object@ppm <- value if (validObject(object)) return(object) }) -##' @aliases peakwidth -##' @description \code{peakwidth},\code{peakwidth<-}: getter and setter for the -##' \code{peakwidth} slot of the object. -##' @rdname findChromPeaks-centWave +#' @aliases peakwidth +#' +#' @description \code{peakwidth},\code{peakwidth<-}: getter and setter for the +#' \code{peakwidth} slot of the object. +#' +#' @rdname findChromPeaks-centWave setMethod("peakwidth", "CentWaveParam", function(object) return(object@peakwidth)) -##' @aliases peakwidth<- -##' @rdname findChromPeaks-centWave +#' @aliases peakwidth<- +#' +#' @rdname findChromPeaks-centWave setReplaceMethod("peakwidth", "CentWaveParam", function(object, value) { object@peakwidth <- value if (validObject(object)) return(object) }) -##' @aliases snthresh -##' @description \code{snthresh},\code{snthresh<-}: getter and setter for the -##' \code{snthresh} slot of the object. -##' @rdname findChromPeaks-centWave +#' @aliases snthresh +#' +#' @description \code{snthresh},\code{snthresh<-}: getter and setter for the +#' \code{snthresh} slot of the object. +#' +#' @rdname findChromPeaks-centWave setMethod("snthresh", "CentWaveParam", function(object) return(object@snthresh)) -##' @aliases snthresh<- -##' @rdname findChromPeaks-centWave +#' @aliases snthresh<- +#' +#' @rdname findChromPeaks-centWave setReplaceMethod("snthresh", "CentWaveParam", function(object, value) { object@snthresh <- value if (validObject(object)) return(object) }) -##' @aliases prefilter -##' @description \code{prefilter},\code{prefilter<-}: getter and setter for the -##' \code{prefilter} slot of the object. -##' @rdname findChromPeaks-centWave +#' @aliases prefilter +#' +#' @description \code{prefilter},\code{prefilter<-}: getter and setter for the +#' \code{prefilter} slot of the object. +#' +#' @rdname findChromPeaks-centWave setMethod("prefilter", "CentWaveParam", function(object) return(object@prefilter)) -##' @aliases prefilter<- -##' @rdname findChromPeaks-centWave +#' @aliases prefilter<- +#' +#' @rdname findChromPeaks-centWave setReplaceMethod("prefilter", "CentWaveParam", function(object, value) { object@prefilter <- value if (validObject(object)) return(object) }) -##' @aliases mzCenterFun -##' @description \code{mzCenterFun},\code{mzCenterFun<-}: getter and setter for the -##' \code{mzCenterFun} slot of the object. -##' @rdname findChromPeaks-centWave +#' @aliases mzCenterFun +#' +#' @description \code{mzCenterFun},\code{mzCenterFun<-}: getter and setter for the +#' \code{mzCenterFun} slot of the object. +#' +#' @rdname findChromPeaks-centWave setMethod("mzCenterFun", "CentWaveParam", function(object) return(object@mzCenterFun)) -##' @aliases mzCenterFun<- -##' @rdname findChromPeaks-centWave +#' @aliases mzCenterFun<- +#' +#' @rdname findChromPeaks-centWave setReplaceMethod("mzCenterFun", "CentWaveParam", function(object, value) { object@mzCenterFun <- value if (validObject(object)) return(object) }) -##' @description \code{integrate},\code{integrate<-}: getter and setter for the -##' \code{integrate} slot of the object. -##' @param f For \code{integrate}: a \code{CentWaveParam} object. -##' -##' @rdname findChromPeaks-centWave +#' @description \code{integrate},\code{integrate<-}: getter and setter for the +#' \code{integrate} slot of the object. +#' +#' @param f For \code{integrate}: a \code{CentWaveParam} object. +#' +#' @rdname findChromPeaks-centWave setMethod("integrate", signature(f = "CentWaveParam"), function(f) return(f@integrate)) -##' @aliases integrate<- -##' @rdname findChromPeaks-centWave +#' @aliases integrate<- +#' +#' @rdname findChromPeaks-centWave setReplaceMethod("integrate", "CentWaveParam", function(object, value) { object@integrate <- as.integer(value) if (validObject(object)) return(object) }) -##' @aliases mzdiff -##' @description \code{mzdiff},\code{mzdiff<-}: getter and setter for the -##' \code{mzdiff} slot of the object. -##' @rdname findChromPeaks-centWave +#' @aliases mzdiff +#' +#' @description \code{mzdiff},\code{mzdiff<-}: getter and setter for the +#' \code{mzdiff} slot of the object. +#' +#' @rdname findChromPeaks-centWave setMethod("mzdiff", "CentWaveParam", function(object) return(object@mzdiff)) -##' @aliases mzdiff<- -##' @rdname findChromPeaks-centWave +#' @aliases mzdiff<- +#' +#' @rdname findChromPeaks-centWave setReplaceMethod("mzdiff", "CentWaveParam", function(object, value) { object@mzdiff <- value if (validObject(object)) return(object) }) -##' @aliases fitgauss -##' @description \code{fitgauss},\code{fitgauss<-}: getter and setter for the -##' \code{fitgauss} slot of the object. -##' @rdname findChromPeaks-centWave +#' @aliases fitgauss +#' +#' @description \code{fitgauss},\code{fitgauss<-}: getter and setter for the +#' \code{fitgauss} slot of the object. +#' +#' @rdname findChromPeaks-centWave setMethod("fitgauss", "CentWaveParam", function(object) return(object@fitgauss)) -##' @aliases fitgauss<- -##' @rdname findChromPeaks-centWave +#' @aliases fitgauss<- +#' +#' @rdname findChromPeaks-centWave setReplaceMethod("fitgauss", "CentWaveParam", function(object, value) { object@fitgauss <- value if (validObject(object)) return(object) }) -##' @aliases noise -##' @description \code{noise},\code{noise<-}: getter and setter for the -##' \code{noise} slot of the object. -##' @rdname findChromPeaks-centWave +#' @aliases noise +#' +#' @description \code{noise},\code{noise<-}: getter and setter for the +#' \code{noise} slot of the object. +#' +#' @rdname findChromPeaks-centWave setMethod("noise", "CentWaveParam", function(object) return(object@noise)) -##' @aliases noise<- -##' @rdname findChromPeaks-centWave +#' @aliases noise<- +#' +#' @rdname findChromPeaks-centWave setReplaceMethod("noise", "CentWaveParam", function(object, value) { object@noise <- value if (validObject(object)) return(object) }) -##' @aliases verboseColumns -##' @description \code{verboseColumns},\code{verboseColumns<-}: getter and -##' setter for the \code{verboseColumns} slot of the object. -##' @rdname findChromPeaks-centWave +#' @aliases verboseColumns +#' +#' @description \code{verboseColumns},\code{verboseColumns<-}: getter and +#' setter for the \code{verboseColumns} slot of the object. +#' +#' @rdname findChromPeaks-centWave setMethod("verboseColumns", "CentWaveParam", function(object) return(object@verboseColumns)) -##' @aliases verboseColumns<- -##' @rdname findChromPeaks-centWave +#' @aliases verboseColumns<- +#' +#' @rdname findChromPeaks-centWave setReplaceMethod("verboseColumns", "CentWaveParam", function(object, value) { object@verboseColumns <- value if (validObject(object)) return(object) }) -##' @aliases roiList -##' @description \code{roiList},\code{roiList<-}: getter and setter for the -##' \code{roiList} slot of the object. -##' @rdname findChromPeaks-centWave +#' @aliases roiList +#' +#' @description \code{roiList},\code{roiList<-}: getter and setter for the +#' \code{roiList} slot of the object. +#' +#' @rdname findChromPeaks-centWave setMethod("roiList", "CentWaveParam", function(object) return(object@roiList)) -##' @aliases roiList<- -##' @rdname findChromPeaks-centWave +#' @aliases roiList<- +#' +#' @rdname findChromPeaks-centWave setReplaceMethod("roiList", "CentWaveParam", function(object, value) { object@roiList <- value if (validObject(object)) return(object) }) -##' @aliases firstBaselineCheck -##' @description \code{fistBaselineCheck},\code{firstBaselineCheck<-}: getter -##' and setter for the \code{firstBaselineCheck} slot of the object. -##' @rdname findChromPeaks-centWave +#' @aliases firstBaselineCheck +#' +#' @description \code{fistBaselineCheck},\code{firstBaselineCheck<-}: getter +#' and setter for the \code{firstBaselineCheck} slot of the object. +#' +#' @rdname findChromPeaks-centWave setMethod("firstBaselineCheck", "CentWaveParam", function(object) return(object@firstBaselineCheck)) -##' @aliases firstBaselineCheck<- -##' @rdname findChromPeaks-centWave +#' @aliases firstBaselineCheck<- +#' +#' @rdname findChromPeaks-centWave setReplaceMethod("firstBaselineCheck", "CentWaveParam", function(object, value) { object@firstBaselineCheck <- value if (validObject(object)) return(object) }) -##' @aliases roiScales -##' @description \code{roiScales},\code{roiScales<-}: getter and setter for the -##' \code{roiScales} slot of the object. -##' @rdname findChromPeaks-centWave +#' @aliases roiScales +#' +#' @description \code{roiScales},\code{roiScales<-}: getter and setter for the +#' \code{roiScales} slot of the object. +#' +#' @rdname findChromPeaks-centWave setMethod("roiScales", "CentWaveParam", function(object) return(object@roiScales)) -##' @aliases roiScales<- -##' @rdname findChromPeaks-centWave +#' @aliases roiScales<- +#' +#' @rdname findChromPeaks-centWave setReplaceMethod("roiScales", "CentWaveParam", function(object, value) { object@roiScales <- value if (validObject(object)) @@ -257,7 +295,7 @@ setMethod("initialize", "MatchedFilterParam", function(.Object, ...) { classVersion(.Object)["MatchedFilterParam"] <- "0.0.1" callNextMethod(.Object, ...) }) -##' @rdname findChromPeaks-matchedFilter +#' @rdname findChromPeaks-matchedFilter setMethod("show", "MatchedFilterParam", function(object) { cat("Object of class: ", class(object), "\n") cat("Parameters:\n") @@ -274,150 +312,179 @@ setMethod("show", "MatchedFilterParam", function(object) { cat(" index:", index(object), "\n") }) -##' @aliases binSize -##' @description \code{binSize},\code{binSize<-}: getter and setter for the -##' \code{binSize} slot of the object. -##' @rdname findChromPeaks-matchedFilter +#' @aliases binSize +#' +#' @description \code{binSize},\code{binSize<-}: getter and setter for the +#' \code{binSize} slot of the object. +#' +#' @rdname findChromPeaks-matchedFilter setMethod("binSize", "MatchedFilterParam", function(object) return(object@binSize)) -##' @aliases binSize<- -##' @param value The value for the slot. -##' @rdname findChromPeaks-matchedFilter +#' @aliases binSize<- +#' +#' @param value The value for the slot. +#' +#' @rdname findChromPeaks-matchedFilter setReplaceMethod("binSize", "MatchedFilterParam", function(object, value) { object@binSize <- value if (validObject(object)) return(object) }) -##' @description \code{impute},\code{impute<-}: getter and setter for the -##' \code{impute} slot of the object. -##' @rdname findChromPeaks-matchedFilter +#' @description \code{impute},\code{impute<-}: getter and setter for the +#' \code{impute} slot of the object. +#' +#' @rdname findChromPeaks-matchedFilter setMethod("impute", "MatchedFilterParam", function(object) return(object@impute)) -##' @aliases impute<- -##' @rdname findChromPeaks-matchedFilter +#' @aliases impute<- +#' +#' @rdname findChromPeaks-matchedFilter setReplaceMethod("impute", "MatchedFilterParam", function(object, value) { object@impute <- value if (validObject(object)) return(object) }) -##' @aliases baseValue -##' @description \code{baseValue},\code{baseValue<-}: getter and setter for the -##' \code{baseValue} slot of the object. -##' @rdname findChromPeaks-matchedFilter +#' @aliases baseValue +#' +#' @description \code{baseValue},\code{baseValue<-}: getter and setter for the +#' \code{baseValue} slot of the object. +#' +#' @rdname findChromPeaks-matchedFilter setMethod("baseValue", "MatchedFilterParam", function(object) return(object@baseValue)) -##' @aliases baseValue<- -##' @rdname findChromPeaks-matchedFilter +#' @aliases baseValue<- +#' +#' @rdname findChromPeaks-matchedFilter setReplaceMethod("baseValue", "MatchedFilterParam", function(object, value) { object@baseValue <- value if (validObject(object)) return(object) }) -##' @aliases distance -##' @description \code{distance},\code{distance<-}: getter and setter for the -##' \code{distance} slot of the object. -##' @rdname findChromPeaks-matchedFilter +#' @aliases distance +#' +#' @description \code{distance},\code{distance<-}: getter and setter for the +#' \code{distance} slot of the object. +#' +#' @rdname findChromPeaks-matchedFilter setMethod("distance", "MatchedFilterParam", function(object) return(object@distance)) -##' @aliases distance<- -##' @rdname findChromPeaks-matchedFilter +#' @aliases distance<- +#' +#' @rdname findChromPeaks-matchedFilter setReplaceMethod("distance", "MatchedFilterParam", function(object, value) { object@distance <- value if (validObject(object)) return(object) }) -##' @aliases fwhm -##' @description \code{fwhm},\code{fwhm<-}: getter and setter for the -##' \code{fwhm} slot of the object. -##' @rdname findChromPeaks-matchedFilter +#' @aliases fwhm +#' +#' @description \code{fwhm},\code{fwhm<-}: getter and setter for the +#' \code{fwhm} slot of the object. +#' +#' @rdname findChromPeaks-matchedFilter setMethod("fwhm", "MatchedFilterParam", function(object) return(object@fwhm)) -##' @aliases fwhm<- -##' @rdname findChromPeaks-matchedFilter +#' @aliases fwhm<- +#' +#' @rdname findChromPeaks-matchedFilter setReplaceMethod("fwhm", "MatchedFilterParam", function(object, value) { object@fwhm <- value if (validObject(object)) return(object) }) -##' @aliases sigma -##' @description \code{sigma},\code{sigma<-}: getter and setter for the -##' \code{sigma} slot of the object. -##' @rdname findChromPeaks-matchedFilter +#' @aliases sigma +#' +#' @description \code{sigma},\code{sigma<-}: getter and setter for the +#' \code{sigma} slot of the object. +#' +#' @rdname findChromPeaks-matchedFilter setMethod("sigma", "MatchedFilterParam", function(object) return(object@sigma)) -##' @aliases sigma<- -##' @rdname findChromPeaks-matchedFilter +#' @aliases sigma<- +#' +#' @rdname findChromPeaks-matchedFilter setReplaceMethod("sigma", "MatchedFilterParam", function(object, value) { object@sigma <- value if (validObject(object)) return(object) }) -##' @description \code{max},\code{max<-}: getter and setter for the -##' \code{max} slot of the object. -##' @param x For \code{max}: a \code{MatchedFilterParam} object. -##' @rdname findChromPeaks-matchedFilter +#' @description \code{max},\code{max<-}: getter and setter for the +#' \code{max} slot of the object. +#' +#' @param x For \code{max}: a \code{MatchedFilterParam} object. +#' +#' @rdname findChromPeaks-matchedFilter setMethod("max", signature(x="MatchedFilterParam"), function(x) return(x@max)) -##' @aliases max<- -##' @rdname findChromPeaks-matchedFilter +#' @aliases max<- +#' +#' @rdname findChromPeaks-matchedFilter setReplaceMethod("max", "MatchedFilterParam", function(object, value) { object@max <- value if (validObject(object)) return(object) }) -##' @description \code{snthresh},\code{snthresh<-}: getter and setter for the -##' \code{snthresh} slot of the object. -##' @rdname findChromPeaks-matchedFilter +#' @description \code{snthresh},\code{snthresh<-}: getter and setter for the +#' \code{snthresh} slot of the object. +#' +#' @rdname findChromPeaks-matchedFilter setMethod("snthresh", "MatchedFilterParam", function(object) return(object@snthresh)) -##' @rdname findChromPeaks-matchedFilter +#' @rdname findChromPeaks-matchedFilter setReplaceMethod("snthresh", "MatchedFilterParam", function(object, value) { object@snthresh <- value if (validObject(object)) return(object) }) -##' @aliases steps -##' @description \code{steps},\code{steps<-}: getter and setter for the -##' \code{steps} slot of the object. -##' @rdname findChromPeaks-matchedFilter +#' @aliases steps +#' +#' @description \code{steps},\code{steps<-}: getter and setter for the +#' \code{steps} slot of the object. +#' +#' @rdname findChromPeaks-matchedFilter setMethod("steps", "MatchedFilterParam", function(object) return(object@steps)) -##' @aliases steps<- -##' @rdname findChromPeaks-matchedFilter +#' @aliases steps<- +#' +#' @rdname findChromPeaks-matchedFilter setReplaceMethod("steps", "MatchedFilterParam", function(object, value) { object@steps <- value if (validObject(object)) return(object) }) -##' @description \code{mzdiff},\code{mzdiff<-}: getter and setter for the -##' \code{mzdiff} slot of the object. -##' @rdname findChromPeaks-matchedFilter +#' @description \code{mzdiff},\code{mzdiff<-}: getter and setter for the +#' \code{mzdiff} slot of the object. +#' +#' @rdname findChromPeaks-matchedFilter setMethod("mzdiff", "MatchedFilterParam", function(object) return(object@mzdiff)) -##' @rdname findChromPeaks-matchedFilter +#' @rdname findChromPeaks-matchedFilter setReplaceMethod("mzdiff", "MatchedFilterParam", function(object, value) { object@mzdiff <- value if (validObject(object)) return(object) }) -##' @aliases index -##' @description \code{index},\code{index<-}: getter and setter for the -##' \code{index} slot of the object. -##' @rdname findChromPeaks-matchedFilter +#' @aliases index +#' +#' @description \code{index},\code{index<-}: getter and setter for the +#' \code{index} slot of the object. +#' +#' @rdname findChromPeaks-matchedFilter setMethod("index", "MatchedFilterParam", function(object) return(object@index)) -##' @aliases index<- -##' @rdname findChromPeaks-matchedFilter +#' @aliases index<- +#' +#' @rdname findChromPeaks-matchedFilter setReplaceMethod("index", "MatchedFilterParam", function(object, value) { object@index <- value if (validObject(object)) @@ -432,7 +499,7 @@ setMethod("initialize", "MassifquantParam", function(.Object, ...) { callNextMethod(.Object, ...) }) -##' @rdname findChromPeaks-massifquant +#' @rdname findChromPeaks-massifquant setMethod("show", "MassifquantParam", function(object) { cat("Object of class: ", class(object), "\n") cat("Parameters:\n") @@ -453,150 +520,167 @@ setMethod("show", "MassifquantParam", function(object) { cat(" withWave:", withWave(object), "\n") }) -##' @description \code{ppm},\code{ppm<-}: getter and setter for the \code{ppm} -##' slot of the object. -##' @rdname findChromPeaks-massifquant +#' @description \code{ppm},\code{ppm<-}: getter and setter for the \code{ppm} +#' slot of the object. +#' +#' @rdname findChromPeaks-massifquant setMethod("ppm", "MassifquantParam", function(object){ return(object@ppm)}) -##' @param value The value for the slot. -##' @rdname findChromPeaks-massifquant +#' @param value The value for the slot. +#' +#' @rdname findChromPeaks-massifquant setReplaceMethod("ppm", "MassifquantParam", function(object, value) { object@ppm <- value if (validObject(object)) return(object) }) -##' @description \code{peakwidth},\code{peakwidth<-}: getter and setter for the -##' \code{peakwidth} slot of the object. -##' @rdname findChromPeaks-massifquant +#' @description \code{peakwidth},\code{peakwidth<-}: getter and setter for the +#' \code{peakwidth} slot of the object. +#' +#' @rdname findChromPeaks-massifquant setMethod("peakwidth", "MassifquantParam", function(object) return(object@peakwidth)) -##' @rdname findChromPeaks-massifquant +#' @rdname findChromPeaks-massifquant setReplaceMethod("peakwidth", "MassifquantParam", function(object, value) { object@peakwidth <- value if (validObject(object)) return(object) }) -##' @description \code{snthresh},\code{snthresh<-}: getter and setter for the -##' \code{snthresh} slot of the object. -##' @rdname findChromPeaks-massifquant +#' @description \code{snthresh},\code{snthresh<-}: getter and setter for the +#' \code{snthresh} slot of the object. +#' +#' @rdname findChromPeaks-massifquant setMethod("snthresh", "MassifquantParam", function(object) return(object@snthresh)) -##' @rdname findChromPeaks-massifquant +#' @rdname findChromPeaks-massifquant setReplaceMethod("snthresh", "MassifquantParam", function(object, value) { object@snthresh <- value if (validObject(object)) return(object) }) -##' @description \code{prefilter},\code{prefilter<-}: getter and setter for the -##' \code{prefilter} slot of the object. -##' @rdname findChromPeaks-massifquant +#' @description \code{prefilter},\code{prefilter<-}: getter and setter for the +#' \code{prefilter} slot of the object. +#' +#' @rdname findChromPeaks-massifquant setMethod("prefilter", "MassifquantParam", function(object) return(object@prefilter)) -##' @rdname findChromPeaks-massifquant +#' @rdname findChromPeaks-massifquant setReplaceMethod("prefilter", "MassifquantParam", function(object, value) { object@prefilter <- value if (validObject(object)) return(object) }) -##' @description \code{mzCenterFun},\code{mzCenterFun<-}: getter and setter for the -##' \code{mzCenterFun} slot of the object. -##' @rdname findChromPeaks-massifquant +#' @description \code{mzCenterFun},\code{mzCenterFun<-}: getter and setter for the +#' \code{mzCenterFun} slot of the object. +#' +#' @rdname findChromPeaks-massifquant setMethod("mzCenterFun", "MassifquantParam", function(object) return(object@mzCenterFun)) -##' @rdname findChromPeaks-massifquant +#' @rdname findChromPeaks-massifquant setReplaceMethod("mzCenterFun", "MassifquantParam", function(object, value) { object@mzCenterFun <- value if (validObject(object)) return(object) }) -##' @description \code{integrate},\code{integrate<-}: getter and setter for the -##' \code{integrate} slot of the object. -##' @param f For \code{integrate}: a \code{MassifquantParam} object. -##' -##' @rdname findChromPeaks-massifquant +#' @description \code{integrate},\code{integrate<-}: getter and setter for the +#' \code{integrate} slot of the object. +#' +#' @param f For \code{integrate}: a \code{MassifquantParam} object. +#' +#' @rdname findChromPeaks-massifquant setMethod("integrate", signature(f = "MassifquantParam"), function(f) return(f@integrate)) -##' @rdname findChromPeaks-massifquant +#' @rdname findChromPeaks-massifquant setReplaceMethod("integrate", "MassifquantParam", function(object, value) { object@integrate <- as.integer(value) if (validObject(object)) return(object) }) -##' @description \code{mzdiff},\code{mzdiff<-}: getter and setter for the -##' \code{mzdiff} slot of the object. -##' @rdname findChromPeaks-massifquant +#' @description \code{mzdiff},\code{mzdiff<-}: getter and setter for the +#' \code{mzdiff} slot of the object. +#' +#' @rdname findChromPeaks-massifquant setMethod("mzdiff", "MassifquantParam", function(object) return(object@mzdiff)) -##' @rdname findChromPeaks-massifquant +#' @rdname findChromPeaks-massifquant setReplaceMethod("mzdiff", "MassifquantParam", function(object, value) { object@mzdiff <- value if (validObject(object)) return(object) }) -##' @description \code{fitgauss},\code{fitgauss<-}: getter and setter for the -##' \code{fitgauss} slot of the object. -##' @rdname findChromPeaks-massifquant +#' @description \code{fitgauss},\code{fitgauss<-}: getter and setter for the +#' \code{fitgauss} slot of the object. +#' +#' @rdname findChromPeaks-massifquant setMethod("fitgauss", "MassifquantParam", function(object) return(object@fitgauss)) -##' @rdname findChromPeaks-massifquant +#' @rdname findChromPeaks-massifquant setReplaceMethod("fitgauss", "MassifquantParam", function(object, value) { object@fitgauss <- value if (validObject(object)) return(object) }) -##' @description \code{noise},\code{noise<-}: getter and setter for the -##' \code{noise} slot of the object. -##' @rdname findChromPeaks-massifquant +#' @description \code{noise},\code{noise<-}: getter and setter for the +#' \code{noise} slot of the object. +#' +#' @rdname findChromPeaks-massifquant setMethod("noise", "MassifquantParam", function(object) return(object@noise)) -##' @rdname findChromPeaks-massifquant +#' @rdname findChromPeaks-massifquant setReplaceMethod("noise", "MassifquantParam", function(object, value) { object@noise <- value if (validObject(object)) return(object) }) -##' @description \code{verboseColumns},\code{verboseColumns<-}: getter and -##' setter for the \code{verboseColumns} slot of the object. -##' @rdname findChromPeaks-massifquant +#' @description \code{verboseColumns},\code{verboseColumns<-}: getter and +#' setter for the \code{verboseColumns} slot of the object. +#' +#' @rdname findChromPeaks-massifquant setMethod("verboseColumns", "MassifquantParam", function(object) return(object@verboseColumns)) -##' @rdname findChromPeaks-massifquant +#' @rdname findChromPeaks-massifquant setReplaceMethod("verboseColumns", "MassifquantParam", function(object, value) { object@verboseColumns <- value if (validObject(object)) return(object) }) -##' @aliases criticalValue -##' @description \code{criticalValue},\code{criticalValue<-}: getter and -##' setter for the \code{criticalValue} slot of the object. -##' @rdname findChromPeaks-massifquant +#' @aliases criticalValue +#' +#' @description \code{criticalValue},\code{criticalValue<-}: getter and +#' setter for the \code{criticalValue} slot of the object. +#' +#' @rdname findChromPeaks-massifquant setMethod("criticalValue", "MassifquantParam", function(object) return(object@criticalValue)) -##' @aliases criticalValue<- -##' @rdname findChromPeaks-massifquant +#' @aliases criticalValue<- +#' +#' @rdname findChromPeaks-massifquant setReplaceMethod("criticalValue", "MassifquantParam", function(object, value) { object@criticalValue <- value if (validObject(object)) return(object) }) -##' @aliases consecMissedLimit -##' @description \code{consecMissedLimit},\code{consecMissedLimit<-}: getter and -##' setter for the \code{consecMissedLimit} slot of the object. -##' @rdname findChromPeaks-massifquant +#' @aliases consecMissedLimit +#' +#' @description \code{consecMissedLimit},\code{consecMissedLimit<-}: getter and +#' setter for the \code{consecMissedLimit} slot of the object. +#' +#' @rdname findChromPeaks-massifquant setMethod("consecMissedLimit", "MassifquantParam", function(object) return(object@consecMissedLimit)) -##' @aliases consecMissedLimit<- -##' @rdname findChromPeaks-massifquant +#' @aliases consecMissedLimit<- +#' +#' @rdname findChromPeaks-massifquant setReplaceMethod("consecMissedLimit", "MassifquantParam", function(object, value) { object@consecMissedLimit <- as.integer(value) @@ -604,42 +688,51 @@ setReplaceMethod("consecMissedLimit", "MassifquantParam", return(object) }) -##' @aliases unions -##' @description \code{unions},\code{unions<-}: getter and -##' setter for the \code{unions} slot of the object. -##' @rdname findChromPeaks-massifquant +#' @aliases unions +#' +#' @description \code{unions},\code{unions<-}: getter and +#' setter for the \code{unions} slot of the object. +#' +#' @rdname findChromPeaks-massifquant setMethod("unions", "MassifquantParam", function(object) return(object@unions)) -##' @aliases unions<- -##' @rdname findChromPeaks-massifquant +#' @aliases unions<- +#' +#' @rdname findChromPeaks-massifquant setReplaceMethod("unions", "MassifquantParam", function(object, value) { object@unions <- as.integer(value) if (validObject(object)) return(object) }) -##' @aliases checkBack -##' @description \code{checkBack},\code{checkBack<-}: getter and -##' setter for the \code{checkBack} slot of the object. -##' @rdname findChromPeaks-massifquant +#' @aliases checkBack +#' +#' @description \code{checkBack},\code{checkBack<-}: getter and +#' setter for the \code{checkBack} slot of the object. +#' +#' @rdname findChromPeaks-massifquant setMethod("checkBack", "MassifquantParam", function(object) return(object@checkBack)) -##' @aliases checkBack<- -##' @rdname findChromPeaks-massifquant +#' @aliases checkBack<- +#' +#' @rdname findChromPeaks-massifquant setReplaceMethod("checkBack", "MassifquantParam", function(object, value) { object@checkBack <- as.integer(value) if (validObject(object)) return(object) }) -##' @aliases withWave -##' @description \code{withWave},\code{withWave<-}: getter and -##' setter for the \code{withWave} slot of the object. -##' @rdname findChromPeaks-massifquant +#' @aliases withWave +#' +#' @description \code{withWave},\code{withWave<-}: getter and +#' setter for the \code{withWave} slot of the object. +#' +#' @rdname findChromPeaks-massifquant setMethod("withWave", "MassifquantParam", function(object) return(object@withWave)) -##' @aliases withWave<- -##' @rdname findChromPeaks-massifquant +#' @aliases withWave<- +#' +#' @rdname findChromPeaks-massifquant setReplaceMethod("withWave", "MassifquantParam", function(object, value) { object@withWave <- value if (validObject(object)) @@ -655,7 +748,7 @@ setMethod("initialize", "MSWParam", function(.Object, ...) { callNextMethod(.Object, ...) }) -##' @rdname findPeaks-MSW +#' @rdname findPeaks-MSW setMethod("show", "MSWParam", function(object) { cat("Object of class: ", class(object), "\n") cat("Parameters:\n") @@ -678,149 +771,178 @@ setMethod("show", "MSWParam", function(object) { } }) -##' @description \code{snthresh},\code{snthresh<-}: getter and setter for the -##' \code{snthresh} slot of the object. -##' @rdname findPeaks-MSW +#' @description \code{snthresh},\code{snthresh<-}: getter and setter for the +#' \code{snthresh} slot of the object. +#' +#' @rdname findPeaks-MSW setMethod("snthresh", "MSWParam", function(object){ return(object@snthresh)}) -##' @param value The value for the slot. -##' @rdname findPeaks-MSW +#' @param value The value for the slot. +#' +#' @rdname findPeaks-MSW setReplaceMethod("snthresh", "MSWParam", function(object, value) { object@snthresh <- value if (validObject(object)) return(object) }) -##' @description \code{verboseColumns},\code{verboseColumns<-}: getter and setter -##' for the \code{verboseColumns} slot of the object. -##' @rdname findPeaks-MSW +#' @description \code{verboseColumns},\code{verboseColumns<-}: getter and setter +#' for the \code{verboseColumns} slot of the object. +#' +#' @rdname findPeaks-MSW setMethod("verboseColumns", "MSWParam", function(object){ return(object@verboseColumns)}) -##' @rdname findPeaks-MSW +#' @rdname findPeaks-MSW setReplaceMethod("verboseColumns", "MSWParam", function(object, value) { object@verboseColumns <- value if (validObject(object)) return(object) }) -##' @aliases scales -##' @description \code{scales},\code{scales<-}: getter and setter for the -##' \code{scales} slot of the object. -##' @rdname findPeaks-MSW +#' @aliases scales +#' +#' @description \code{scales},\code{scales<-}: getter and setter for the +#' \code{scales} slot of the object. +#' +#' @rdname findPeaks-MSW setMethod("scales", "MSWParam", function(object){ return(object@scales)}) -##' @aliases scales<- -##' @rdname findPeaks-MSW +#' @aliases scales<- +#' +#' @rdname findPeaks-MSW setReplaceMethod("scales", "MSWParam", function(object, value) { object@scales <- value if (validObject(object)) return(object) }) -##' @aliases nearbyPeak -##' @description \code{nearbyPeak},\code{nearbyPeak<-}: getter and setter for the -##' \code{nearbyPeak} slot of the object. -##' @rdname findPeaks-MSW +#' @aliases nearbyPeak +#' +#' @description \code{nearbyPeak},\code{nearbyPeak<-}: getter and setter for the +#' \code{nearbyPeak} slot of the object. +#' +#' @rdname findPeaks-MSW setMethod("nearbyPeak", "MSWParam", function(object){ return(object@nearbyPeak)}) -##' @aliases nearbyPeak<- -##' @rdname findPeaks-MSW +#' @aliases nearbyPeak<- +#' +#' @rdname findPeaks-MSW setReplaceMethod("nearbyPeak", "MSWParam", function(object, value) { object@nearbyPeak <- value if (validObject(object)) return(object) }) -##' @aliases peakScaleRange -##' @description \code{peakScaleRange},\code{peakScaleRange<-}: getter and setter -##' for the \code{peakScaleRange} slot of the object. -##' @rdname findPeaks-MSW +#' @aliases peakScaleRange +#' +#' @description \code{peakScaleRange},\code{peakScaleRange<-}: getter and setter +#' for the \code{peakScaleRange} slot of the object. +#' +#' @rdname findPeaks-MSW setMethod("peakScaleRange", "MSWParam", function(object){ return(object@peakScaleRange)}) -##' @aliases peakScaleRange<- -##' @rdname findPeaks-MSW +#' @aliases peakScaleRange<- +#' +#' @rdname findPeaks-MSW setReplaceMethod("peakScaleRange", "MSWParam", function(object, value) { object@peakScaleRange <- value if (validObject(object)) return(object) }) -##' @aliases ampTh -##' @description \code{ampTh},\code{ampTh<-}: getter and setter for the -##' \code{ampTh} slot of the object. -##' @rdname findPeaks-MSW +#' @aliases ampTh +#' +#' @description \code{ampTh},\code{ampTh<-}: getter and setter for the +#' \code{ampTh} slot of the object. +#' +#' @rdname findPeaks-MSW setMethod("ampTh", "MSWParam", function(object){ return(object@ampTh)}) -##' @aliases ampTh<- -##' @rdname findPeaks-MSW +#' @aliases ampTh<- +#' +#' @rdname findPeaks-MSW setReplaceMethod("ampTh", "MSWParam", function(object, value) { object@ampTh <- value if (validObject(object)) return(object) }) -##' @aliases minNoiseLevel -##' @description \code{minNoiseLevel},\code{minNoiseLevel<-}: getter and setter -##' for the \code{minNoiseLevel} slot of the object. -##' @rdname findPeaks-MSW +#' @aliases minNoiseLevel +#' +#' @description \code{minNoiseLevel},\code{minNoiseLevel<-}: getter and setter +#' for the \code{minNoiseLevel} slot of the object. +#' +#' @rdname findPeaks-MSW setMethod("minNoiseLevel", "MSWParam", function(object){ return(object@minNoiseLevel)}) -##' @aliases minNoiseLevel<- -##' @rdname findPeaks-MSW +#' @aliases minNoiseLevel<- +#' +#' @rdname findPeaks-MSW setReplaceMethod("minNoiseLevel", "MSWParam", function(object, value) { object@minNoiseLevel <- value if (validObject(object)) return(object) }) -##' @aliases ridgeLength -##' @description \code{ridgeLength},\code{ridgeLength<-}: getter and setter for -##' the \code{ridgeLength} slot of the object. -##' @rdname findPeaks-MSW +#' @aliases ridgeLength +#' +#' @description \code{ridgeLength},\code{ridgeLength<-}: getter and setter for +#' the \code{ridgeLength} slot of the object. +#' +#' @rdname findPeaks-MSW setMethod("ridgeLength", "MSWParam", function(object){ return(object@ridgeLength)}) -##' @aliases ridgeLength<- -##' @rdname findPeaks-MSW +#' @aliases ridgeLength<- +#' +#' @rdname findPeaks-MSW setReplaceMethod("ridgeLength", "MSWParam", function(object, value) { object@ridgeLength <- value if (validObject(object)) return(object) }) -##' @aliases peakThr -##' @description \code{peakThr},\code{peakThr<-}: getter and setter for the -##' \code{peakThr} slot of the object. -##' @rdname findPeaks-MSW +#' @aliases peakThr +#' +#' @description \code{peakThr},\code{peakThr<-}: getter and setter for the +#' \code{peakThr} slot of the object. +#' +#' @rdname findPeaks-MSW setMethod("peakThr", "MSWParam", function(object){ return(object@peakThr)}) -##' @aliases peakThr<- -##' @rdname findPeaks-MSW +#' @aliases peakThr<- +#' +#' @rdname findPeaks-MSW setReplaceMethod("peakThr", "MSWParam", function(object, value) { object@peakThr <- value if (validObject(object)) return(object) }) -##' @aliases tuneIn -##' @description \code{tuneIn},\code{tuneIn<-}: getter and setter for the -##' \code{tuneIn} slot of the object. -##' @rdname findPeaks-MSW +#' @aliases tuneIn +#' +#' @description \code{tuneIn},\code{tuneIn<-}: getter and setter for the +#' \code{tuneIn} slot of the object. +#' +#' @rdname findPeaks-MSW setMethod("tuneIn", "MSWParam", function(object){ return(object@tuneIn)}) -##' @aliases tuneIn<- -##' @rdname findPeaks-MSW +#' @aliases tuneIn<- +#' +#' @rdname findPeaks-MSW setReplaceMethod("tuneIn", "MSWParam", function(object, value) { object@tuneIn <- value if (validObject(object)) return(object) }) -##' @aliases addParams -##' @description \code{addParams},\code{addParams<-}: getter and setter for the -##' \code{addParams} slot of the object. This slot stores optional additional -##' parameters to be passed to the -##' \code{\link[MassSpecWavelet]{identifyMajorPeaks}} and -##' \code{\link[MassSpecWavelet]{sav.gol}} functions from the -##' \code{MassSpecWavelet} package. -##' -##' @rdname findPeaks-MSW +#' @aliases addParams +#' +#' @description \code{addParams},\code{addParams<-}: getter and setter for the +#' \code{addParams} slot of the object. This slot stores optional additional +#' parameters to be passed to the +#' \code{\link[MassSpecWavelet]{identifyMajorPeaks}} and +#' \code{\link[MassSpecWavelet]{sav.gol}} functions from the +#' \code{MassSpecWavelet} package. +#' +#' @rdname findPeaks-MSW setMethod("addParams", "MSWParam", function(object){ return(object@addParams)}) -##' @aliases addParams<- -##' @rdname findPeaks-MSW +#' @aliases addParams<- +#' +#' @rdname findPeaks-MSW setReplaceMethod("addParams", "MSWParam", function(object, value) { object@addParams <- value if (validObject(object)) @@ -850,7 +972,7 @@ setMethod("initialize", "CentWavePredIsoParam", function(.Object, ...) { callNextMethod(.Object, ...) }) -##' @rdname findChromPeaks-centWaveWithPredIsoROIs +#' @rdname findChromPeaks-centWaveWithPredIsoROIs setMethod("show", "CentWavePredIsoParam", function(object) { cat("Object of class: ", class(object), "\n") cat("Parameters:\n") @@ -874,56 +996,68 @@ setMethod("show", "CentWavePredIsoParam", function(object) { cat(" polarity:", polarity(object), "\n") }) -##' @aliases snthreshIsoROIs -##' @description \code{snthreshIsoROIs},\code{snthreshIsoROIs<-}: getter and -##' setter for the \code{snthreshIsoROIs} slot of the object. -##' @rdname findChromPeaks-centWaveWithPredIsoROIs +#' @aliases snthreshIsoROIs +#' +#' @description \code{snthreshIsoROIs},\code{snthreshIsoROIs<-}: getter and +#' setter for the \code{snthreshIsoROIs} slot of the object. +#' +#' @rdname findChromPeaks-centWaveWithPredIsoROIs setMethod("snthreshIsoROIs", "CentWavePredIsoParam", function(object){ return(object@snthreshIsoROIs)}) -##' @aliases snthreshIsoROIs<- -##' @rdname findChromPeaks-centWaveWithPredIsoROIs +#' @aliases snthreshIsoROIs<- +#' +#' @rdname findChromPeaks-centWaveWithPredIsoROIs setReplaceMethod("snthreshIsoROIs", "CentWavePredIsoParam", function(object, value) { object@snthreshIsoROIs <- value if (validObject(object)) return(object) }) -##' @aliases maxCharge -##' @description \code{maxCharge},\code{maxCharge<-}: getter and -##' setter for the \code{maxCharge} slot of the object. -##' @rdname findChromPeaks-centWaveWithPredIsoROIs +#' @aliases maxCharge +#' +#' @description \code{maxCharge},\code{maxCharge<-}: getter and +#' setter for the \code{maxCharge} slot of the object. +#' +#' @rdname findChromPeaks-centWaveWithPredIsoROIs setMethod("maxCharge", "CentWavePredIsoParam", function(object){ return(object@maxCharge)}) -##' @aliases maxCharge<- -##' @rdname findChromPeaks-centWaveWithPredIsoROIs +#' @aliases maxCharge<- +#' +#' @rdname findChromPeaks-centWaveWithPredIsoROIs setReplaceMethod("maxCharge", "CentWavePredIsoParam", function(object, value) { object@maxCharge <- as.integer(value) if (validObject(object)) return(object) }) -##' @aliases maxIso -##' @description \code{maxIso},\code{maxIso<-}: getter and -##' setter for the \code{maxIso} slot of the object. -##' @rdname findChromPeaks-centWaveWithPredIsoROIs +#' @aliases maxIso +#' +#' @description \code{maxIso},\code{maxIso<-}: getter and +#' setter for the \code{maxIso} slot of the object. +#' +#' @rdname findChromPeaks-centWaveWithPredIsoROIs setMethod("maxIso", "CentWavePredIsoParam", function(object){ return(object@maxIso)}) -##' @aliases maxIso<- -##' @rdname findChromPeaks-centWaveWithPredIsoROIs +#' @aliases maxIso<- +#' +#' @rdname findChromPeaks-centWaveWithPredIsoROIs setReplaceMethod("maxIso", "CentWavePredIsoParam", function(object, value) { object@maxIso <- as.integer(value) if (validObject(object)) return(object) }) -##' @aliases mzIntervalExtension -##' @description \code{mzIntervalExtension},\code{mzIntervalExtension<-}: getter -##' and setter for the \code{mzIntervalExtension} slot of the object. -##' @rdname findChromPeaks-centWaveWithPredIsoROIs +#' @aliases mzIntervalExtension +#' +#' @description \code{mzIntervalExtension},\code{mzIntervalExtension<-}: getter +#' and setter for the \code{mzIntervalExtension} slot of the object. +#' +#' @rdname findChromPeaks-centWaveWithPredIsoROIs setMethod("mzIntervalExtension", "CentWavePredIsoParam", function(object){ return(object@mzIntervalExtension)}) -##' @aliases mzIntervalExtension<- -##' @rdname findChromPeaks-centWaveWithPredIsoROIs +#' @aliases mzIntervalExtension<- +#' +#' @rdname findChromPeaks-centWaveWithPredIsoROIs setReplaceMethod("mzIntervalExtension", "CentWavePredIsoParam", function(object, value) { object@mzIntervalExtension <- value @@ -931,13 +1065,15 @@ setReplaceMethod("mzIntervalExtension", "CentWavePredIsoParam", return(object) }) -##' @description \code{polarity},\code{polarity<-}: getter and -##' setter for the \code{polarity} slot of the object. -##' @rdname findChromPeaks-centWaveWithPredIsoROIs +#' @description \code{polarity},\code{polarity<-}: getter and +#' setter for the \code{polarity} slot of the object. +#' +#' @rdname findChromPeaks-centWaveWithPredIsoROIs setMethod("polarity", "CentWavePredIsoParam", function(object){ return(object@polarity)}) -##' @aliases polarity<- -##' @rdname findChromPeaks-centWaveWithPredIsoROIs +#' @aliases polarity<- +#' +#' @rdname findChromPeaks-centWaveWithPredIsoROIs setReplaceMethod("polarity", "CentWavePredIsoParam", function(object, value) { object@polarity <- value if (validObject(object)) @@ -952,9 +1088,7 @@ setMethod("initialize", "PeakDensityParam", function(.Object, ...) { callNextMethod(.Object, ...) }) -## ##' @rdname groupChromPeaks-density -## setMethod("print", "CentWaveParam", function(x, ...) show(x)) -##' @rdname groupChromPeaks-density +#' @rdname groupChromPeaks-density setMethod("show", "PeakDensityParam", function(object) { cat("Object of class: ", class(object), "\n") cat("Parameters:\n") @@ -967,83 +1101,100 @@ setMethod("show", "PeakDensityParam", function(object) { cat(" maxFeatures:", maxFeatures(object), "\n") }) -##' @aliases sampleGroups -##' @description \code{sampleGroups},\code{sampleGroups<-}: getter and setter -##' for the \code{sampleGroups} slot of the object. -##' @rdname groupChromPeaks-density +#' @aliases sampleGroups +#' +#' @description \code{sampleGroups},\code{sampleGroups<-}: getter and setter +#' for the \code{sampleGroups} slot of the object. +#' +#' @rdname groupChromPeaks-density setMethod("sampleGroups", "PeakDensityParam", function(object){ return(object@sampleGroups)}) -##' @aliases sampleGroups<- -##' @param value The value for the slot. -##' @rdname groupChromPeaks-density +#' @aliases sampleGroups<- +#' +#' @param value The value for the slot. +#' +#' @rdname groupChromPeaks-density setReplaceMethod("sampleGroups", "PeakDensityParam", function(object, value) { object@sampleGroups <- value if (validObject(object)) return(object) }) -##' @aliases bw -##' @description \code{bw},\code{bw<-}: getter and setter for the \code{bw} slot -##' of the object. -##' @rdname groupChromPeaks-density +#' @aliases bw +#' +#' @description \code{bw},\code{bw<-}: getter and setter for the \code{bw} slot +#' of the object. +#' +#' @rdname groupChromPeaks-density setMethod("bw", "PeakDensityParam", function(object){ return(object@bw)}) -##' @aliases bw<- -##' @rdname groupChromPeaks-density +#' @aliases bw<- +#' +#' @rdname groupChromPeaks-density setReplaceMethod("bw", "PeakDensityParam", function(object, value) { object@bw <- value if (validObject(object)) return(object) }) -##' @aliases minFraction -##' @description \code{minFraction},\code{minFraction<-}: getter and setter for -##' the \code{minFraction} slot of the object. -##' @rdname groupChromPeaks-density +#' @aliases minFraction +#' +#' @description \code{minFraction},\code{minFraction<-}: getter and setter for +#' the \code{minFraction} slot of the object. +#' +#' @rdname groupChromPeaks-density setMethod("minFraction", "PeakDensityParam", function(object){ return(object@minFraction)}) -##' @aliases minFraction<- -##' @rdname groupChromPeaks-density +#' @aliases minFraction<- +#' +#' @rdname groupChromPeaks-density setReplaceMethod("minFraction", "PeakDensityParam", function(object, value) { object@minFraction <- value if (validObject(object)) return(object) }) -##' @aliases minSamples -##' @description \code{minSamples},\code{minSamples<-}: getter and setter for the -##' \code{minSamples} slot of the object. -##' @rdname groupChromPeaks-density +#' @aliases minSamples +#' +#' @description \code{minSamples},\code{minSamples<-}: getter and setter for the +#' \code{minSamples} slot of the object. +#' +#' @rdname groupChromPeaks-density setMethod("minSamples", "PeakDensityParam", function(object){ return(object@minSamples)}) -##' @aliases minSamples<- -##' @rdname groupChromPeaks-density +#' @aliases minSamples<- +#' +#' @rdname groupChromPeaks-density setReplaceMethod("minSamples", "PeakDensityParam", function(object, value) { object@minSamples <- value if (validObject(object)) return(object) }) -##' @description \code{binSize},\code{binSize<-}: getter and setter for the -##' \code{binSize} slot of the object. -##' @rdname groupChromPeaks-density +#' @description \code{binSize},\code{binSize<-}: getter and setter for the +#' \code{binSize} slot of the object. +#' +#' @rdname groupChromPeaks-density setMethod("binSize", "PeakDensityParam", function(object){ return(object@binSize)}) -##' @rdname groupChromPeaks-density +#' @rdname groupChromPeaks-density setReplaceMethod("binSize", "PeakDensityParam", function(object, value) { object@binSize <- value if (validObject(object)) return(object) }) -##' @aliases maxFeatures -##' @description \code{maxFeatures},\code{maxFeatures<-}: getter and setter for -##' the \code{maxFeatures} slot of the object. -##' @rdname groupChromPeaks-density +#' @aliases maxFeatures +#' +#' @description \code{maxFeatures},\code{maxFeatures<-}: getter and setter for +#' the \code{maxFeatures} slot of the object. +#' +#' @rdname groupChromPeaks-density setMethod("maxFeatures", "PeakDensityParam", function(object){ return(object@maxFeatures)}) -##' @aliases maxFeatures<- -##' @rdname groupChromPeaks-density +#' @aliases maxFeatures<- +#' +#' @rdname groupChromPeaks-density setReplaceMethod("maxFeatures", "PeakDensityParam", function(object, value) { object@maxFeatures <- value if (validObject(object)) @@ -1058,9 +1209,7 @@ setMethod("initialize", "MzClustParam", function(.Object, ...) { callNextMethod(.Object, ...) }) -## ##' @rdname groupChromPeaks-mzClust -## setMethod("print", "CentWaveParam", function(x, ...) show(x)) -##' @rdname groupChromPeaks-mzClust +#' @rdname groupChromPeaks-mzClust setMethod("show", "MzClustParam", function(object) { cat("Object of class: ", class(object), "\n") cat("Parameters:\n") @@ -1072,63 +1221,71 @@ setMethod("show", "MzClustParam", function(object) { cat(" minSamples:", minSamples(object), "\n") }) -##' @description \code{sampleGroups},\code{sampleGroups<-}: getter and setter -##' for the \code{sampleGroups} slot of the object. -##' @rdname groupChromPeaks-mzClust +#' @description \code{sampleGroups},\code{sampleGroups<-}: getter and setter +#' for the \code{sampleGroups} slot of the object. +#' +#' @rdname groupChromPeaks-mzClust setMethod("sampleGroups", "MzClustParam", function(object){ return(object@sampleGroups)}) -##' @param value The value for the slot. -##' @rdname groupChromPeaks-mzClust +#' @param value The value for the slot. +#' +#' @rdname groupChromPeaks-mzClust setReplaceMethod("sampleGroups", "MzClustParam", function(object, value) { object@sampleGroups <- value if (validObject(object)) return(object) }) -##' @description \code{ppm},\code{ppm<-}: getter and setter for the \code{ppm} -##' slot of the object. -##' @rdname groupChromPeaks-mzClust +#' @description \code{ppm},\code{ppm<-}: getter and setter for the \code{ppm} +#' slot of the object. +#' +#' @rdname groupChromPeaks-mzClust setMethod("ppm", "MzClustParam", function(object){ return(object@ppm)}) -##' @rdname groupChromPeaks-mzClust +#' @rdname groupChromPeaks-mzClust setReplaceMethod("ppm", "MzClustParam", function(object, value) { object@ppm <- value if (validObject(object)) return(object) }) -##' @aliases absMz -##' @description \code{absMz},\code{absMz<-}: getter and setter for the -##' \code{absMz} slot of the object. -##' @rdname groupChromPeaks-mzClust +#' @aliases absMz +#' +#' @description \code{absMz},\code{absMz<-}: getter and setter for the +#' \code{absMz} slot of the object. +#' +#' @rdname groupChromPeaks-mzClust setMethod("absMz", "MzClustParam", function(object){ return(object@absMz)}) -##' @aliases absMz<- -##' @rdname groupChromPeaks-mzClust +#' @aliases absMz<- +#' +#' @rdname groupChromPeaks-mzClust setReplaceMethod("absMz", "MzClustParam", function(object, value) { object@absMz <- value if (validObject(object)) return(object) }) -##' @description \code{minFraction},\code{minFraction<-}: getter and setter for -##' the \code{minFraction} slot of the object. -##' @rdname groupChromPeaks-mzClust +#' @description \code{minFraction},\code{minFraction<-}: getter and setter for +#' the \code{minFraction} slot of the object. +#' +#' @rdname groupChromPeaks-mzClust setMethod("minFraction", "MzClustParam", function(object){ return(object@minFraction)}) -##' @rdname groupChromPeaks-mzClust +#' @rdname groupChromPeaks-mzClust setReplaceMethod("minFraction", "MzClustParam", function(object, value) { object@minFraction <- value if (validObject(object)) return(object) }) -##' @description \code{minSamples},\code{minSamples<-}: getter and setter for the -##' \code{minSamples} slot of the object. -##' @rdname groupChromPeaks-mzClust +#' @description \code{minSamples},\code{minSamples<-}: getter and setter for the +#' \code{minSamples} slot of the object. +#' +#' @rdname groupChromPeaks-mzClust setMethod("minSamples", "MzClustParam", function(object){ return(object@minSamples)}) -##' @rdname groupChromPeaks-mzClust +#' @rdname groupChromPeaks-mzClust setReplaceMethod("minSamples", "MzClustParam", function(object, value) { object@minSamples <- value if (validObject(object)) @@ -1143,7 +1300,7 @@ setMethod("initialize", "NearestPeaksParam", function(.Object, ...) { callNextMethod(.Object, ...) }) -##' @rdname groupChromPeaks-nearest +#' @rdname groupChromPeaks-nearest setMethod("show", "NearestPeaksParam", function(object) { cat("Object of class: ", class(object), "\n") cat("Parameters:\n") @@ -1155,67 +1312,79 @@ setMethod("show", "NearestPeaksParam", function(object) { cat(" kNN:", object@kNN, "\n") }) -##' @description \code{sampleGroups},\code{sampleGroups<-}: getter and setter -##' for the \code{sampleGroups} slot of the object. -##' @rdname groupChromPeaks-nearest +#' @description \code{sampleGroups},\code{sampleGroups<-}: getter and setter +#' for the \code{sampleGroups} slot of the object. +#' +#' @rdname groupChromPeaks-nearest setMethod("sampleGroups", "NearestPeaksParam", function(object){ return(object@sampleGroups)}) -##' @param value The value for the slot. -##' @rdname groupChromPeaks-nearest +#' @param value The value for the slot. +#' +#' @rdname groupChromPeaks-nearest setReplaceMethod("sampleGroups", "NearestPeaksParam", function(object, value) { object@sampleGroups <- value if (validObject(object)) return(object) }) -##' @aliases mzVsRtBalance -##' @description \code{mzVsRtBalance},\code{mzVsRtBalance<-}: getter and setter -##' for the \code{mzVsRtBalance} slot of the object. -##' @rdname groupChromPeaks-nearest +#' @aliases mzVsRtBalance +#' +#' @description \code{mzVsRtBalance},\code{mzVsRtBalance<-}: getter and setter +#' for the \code{mzVsRtBalance} slot of the object. +#' +#' @rdname groupChromPeaks-nearest setMethod("mzVsRtBalance", "NearestPeaksParam", function(object){ return(object@mzVsRtBalance)}) -##' @aliases mzVsRtBalance<- -##' @rdname groupChromPeaks-nearest +#' @aliases mzVsRtBalance<- +#' +#' @rdname groupChromPeaks-nearest setReplaceMethod("mzVsRtBalance", "NearestPeaksParam", function(object, value) { object@mzVsRtBalance <- value if (validObject(object)) return(object) }) -##' @description \code{absMz},\code{absMz<-}: getter and setter for the -##' \code{absMz} slot of the object. -##' @rdname groupChromPeaks-nearest +#' @description \code{absMz},\code{absMz<-}: getter and setter for the +#' \code{absMz} slot of the object. +#' +#' @rdname groupChromPeaks-nearest setMethod("absMz", "NearestPeaksParam", function(object){ return(object@absMz)}) -##' @rdname groupChromPeaks-nearest +#' @rdname groupChromPeaks-nearest setReplaceMethod("absMz", "NearestPeaksParam", function(object, value) { object@absMz <- value if (validObject(object)) return(object) }) -##' @aliases absRt -##' @description \code{absRt},\code{absRt<-}: getter and setter for the -##' \code{absRt} slot of the object. -##' @rdname groupChromPeaks-nearest +#' @aliases absRt +#' +#' @description \code{absRt},\code{absRt<-}: getter and setter for the +#' \code{absRt} slot of the object. +#' +#' @rdname groupChromPeaks-nearest setMethod("absRt", "NearestPeaksParam", function(object){ return(object@absRt)}) -##' @aliases absRt<- -##' @rdname groupChromPeaks-nearest +#' @aliases absRt<- +#' +#' @rdname groupChromPeaks-nearest setReplaceMethod("absRt", "NearestPeaksParam", function(object, value) { object@absRt <- value if (validObject(object)) return(object) }) -##' @aliases kNN -##' @description \code{kNN},\code{kNN<-}: getter and setter for the -##' \code{kNN} slot of the object. -##' @rdname groupChromPeaks-nearest +#' @aliases kNN +#' +#' @description \code{kNN},\code{kNN<-}: getter and setter for the +#' \code{kNN} slot of the object. +#' +#' @rdname groupChromPeaks-nearest setMethod("kNN", "NearestPeaksParam", function(object){ return(object@kNN)}) -##' @aliases kNN<- -##' @rdname groupChromPeaks-nearest +#' @aliases kNN<- +#' +#' @rdname groupChromPeaks-nearest setReplaceMethod("kNN", "NearestPeaksParam", function(object, value) { object@kNN <- value if (validObject(object)) @@ -1230,7 +1399,7 @@ setMethod("initialize", "PeakGroupsParam", function(.Object, ...) { callNextMethod(.Object, ...) }) -##' @rdname adjustRtime-peakGroups +#' @rdname adjustRtime-peakGroups setMethod("show", "PeakGroupsParam", function(object) { cat("Object of class: ", class(object), "\n") cat("Parameters:\n") @@ -1244,84 +1413,102 @@ setMethod("show", "PeakGroupsParam", function(object) { cat(" number of peak groups:", nrow(pgm), "\n") }) -##' @description \code{minFraction},\code{minFraction<-}: getter and setter -##' for the \code{minFraction} slot of the object. -##' @rdname adjustRtime-peakGroups +#' @description \code{minFraction},\code{minFraction<-}: getter and setter +#' for the \code{minFraction} slot of the object. +#' +#' @rdname adjustRtime-peakGroups setMethod("minFraction", "PeakGroupsParam", function(object){ return(object@minFraction)}) -##' @param value The value for the slot. -##' @rdname adjustRtime-peakGroups +#' @param value The value for the slot. +#' +#' @rdname adjustRtime-peakGroups setReplaceMethod("minFraction", "PeakGroupsParam", function(object, value) { object@minFraction <- value if (validObject(object)) return(object) }) -##' @aliases extraPeaks -##' @description \code{extraPeaks},\code{extraPeaks<-}: getter and setter -##' for the \code{extraPeaks} slot of the object. -##' @rdname adjustRtime-peakGroups +#' @aliases extraPeaks +#' +#' @description \code{extraPeaks},\code{extraPeaks<-}: getter and setter +#' for the \code{extraPeaks} slot of the object. +#' +#' @rdname adjustRtime-peakGroups setMethod("extraPeaks", "PeakGroupsParam", function(object){ return(object@extraPeaks)}) -##' @aliases extraPeaks<- -##' @rdname adjustRtime-peakGroups +#' @aliases extraPeaks<- +#' +#' @rdname adjustRtime-peakGroups setReplaceMethod("extraPeaks", "PeakGroupsParam", function(object, value) { object@extraPeaks <- value if (validObject(object)) return(object) }) -##' @aliases smooth -##' @description \code{smooth},\code{smooth<-}: getter and setter -##' for the \code{smooth} slot of the object. -##' @param x a \code{PeakGroupsParam} object. -##' @rdname adjustRtime-peakGroups +#' @aliases smooth +#' +#' @description \code{smooth},\code{smooth<-}: getter and setter +#' for the \code{smooth} slot of the object. +#' +#' @param x a \code{PeakGroupsParam} object. +#' +#' @rdname adjustRtime-peakGroups setMethod("smooth", "PeakGroupsParam", function(x){ return(x@smooth)}) -##' @aliases smooth<- -##' @rdname adjustRtime-peakGroups +#' @aliases smooth<- +#' +#' @rdname adjustRtime-peakGroups setReplaceMethod("smooth", "PeakGroupsParam", function(object, value) { object@smooth <- value if (validObject(object)) return(object) }) -##' @aliases span -##' @description \code{span},\code{span<-}: getter and setter -##' for the \code{span} slot of the object. -##' @rdname adjustRtime-peakGroups +#' @aliases span +#' +#' @description \code{span},\code{span<-}: getter and setter +#' for the \code{span} slot of the object. +#' +#' @rdname adjustRtime-peakGroups setMethod("span", "PeakGroupsParam", function(object){ return(object@span)}) -##' @aliases span<- -##' @rdname adjustRtime-peakGroups +#' @aliases span<- +#' +#' @rdname adjustRtime-peakGroups setReplaceMethod("span", "PeakGroupsParam", function(object, value) { object@span <- value if (validObject(object)) return(object) }) -##' @aliases family -##' @description \code{family},\code{family<-}: getter and setter -##' for the \code{family} slot of the object. -##' @rdname adjustRtime-peakGroups +#' @aliases family +#' +#' @description \code{family},\code{family<-}: getter and setter +#' for the \code{family} slot of the object. +#' +#' @rdname adjustRtime-peakGroups setMethod("family", "PeakGroupsParam", function(object){ return(object@family)}) -##' @aliases family<- -##' @rdname adjustRtime-peakGroups +#' @aliases family<- +#' +#' @rdname adjustRtime-peakGroups setReplaceMethod("family", "PeakGroupsParam", function(object, value) { object@family <- value if (validObject(object)) return(object) }) -##' @aliases peakGroupsMatrix -##' @description \code{peakGroupsMatrix},\code{peakGroupsMatrix<-}: getter and -##' setter for the \code{peakGroupsMatrix} slot of the object. -##' @rdname adjustRtime-peakGroups +#' @aliases peakGroupsMatrix +#' +#' @description \code{peakGroupsMatrix},\code{peakGroupsMatrix<-}: getter and +#' setter for the \code{peakGroupsMatrix} slot of the object. +#' +#' @rdname adjustRtime-peakGroups setMethod("peakGroupsMatrix", "PeakGroupsParam", function(object){ return(object@peakGroupsMatrix)}) -##' @aliases peakGroupsMatrix<- -##' @rdname adjustRtime-peakGroups +#' @aliases peakGroupsMatrix<- +#' +#' @rdname adjustRtime-peakGroups setReplaceMethod("peakGroupsMatrix", "PeakGroupsParam", function(object, value) { object@peakGroupsMatrix <- value if (validObject(object)) @@ -1336,7 +1523,7 @@ setMethod("initialize", "ObiwarpParam", function(.Object, ...) { callNextMethod(.Object, ...) }) -##' @rdname adjustRtime-obiwarp +#' @rdname adjustRtime-obiwarp setMethod("show", "ObiwarpParam", function(object) { cat("Object of class: ", class(object), "\n") cat("Parameters:\n") @@ -1352,65 +1539,78 @@ setMethod("show", "ObiwarpParam", function(object) { cat(" initPenalty:", initPenalty(object), "\n") }) -##' @description \code{binSize},\code{binSize<-}: getter and setter -##' for the \code{binSize} slot of the object. -##' @rdname adjustRtime-obiwarp +#' @description \code{binSize},\code{binSize<-}: getter and setter +#' for the \code{binSize} slot of the object. +#' +#' @rdname adjustRtime-obiwarp setMethod("binSize", "ObiwarpParam", function(object){ return(object@binSize)}) -##' @param value The value for the slot. -##' @rdname adjustRtime-obiwarp +#' @param value The value for the slot. +#' +#' @rdname adjustRtime-obiwarp setReplaceMethod("binSize", "ObiwarpParam", function(object, value) { object@binSize <- value if (validObject(object)) return(object) }) -##' @aliases centerSample -##' @description \code{centerSample},\code{centerSample<-}: getter and setter -##' for the \code{centerSample} slot of the object. -##' @rdname adjustRtime-obiwarp +#' @aliases centerSample +#' +#' @description \code{centerSample},\code{centerSample<-}: getter and setter +#' for the \code{centerSample} slot of the object. +#' +#' @rdname adjustRtime-obiwarp setMethod("centerSample", "ObiwarpParam", function(object){ return(object@centerSample)}) -##' @aliases centerSample<- -##' @rdname adjustRtime-obiwarp +#' @aliases centerSample<- +#' +#' @rdname adjustRtime-obiwarp setReplaceMethod("centerSample", "ObiwarpParam", function(object, value) { object@centerSample <- as.integer(value) if (validObject(object)) return(object) }) -##' @aliases response -##' @description \code{response},\code{response<-}: getter and setter -##' for the \code{response} slot of the object. -##' @rdname adjustRtime-obiwarp +#' @aliases response +#' +#' @description \code{response},\code{response<-}: getter and setter +#' for the \code{response} slot of the object. +#' +#' @rdname adjustRtime-obiwarp setMethod("response", "ObiwarpParam", function(object){ return(object@response)}) -##' @aliases response<- -##' @rdname adjustRtime-obiwarp +#' @aliases response<- +#' +#' @rdname adjustRtime-obiwarp setReplaceMethod("response", "ObiwarpParam", function(object, value) { object@response <- as.integer(value) if (validObject(object)) return(object) }) -##' @aliases distFun -##' @description \code{distFun},\code{distFun<-}: getter and setter -##' for the \code{distFun} slot of the object. -##' @rdname adjustRtime-obiwarp +#' @aliases distFun +#' +#' @description \code{distFun},\code{distFun<-}: getter and setter +#' for the \code{distFun} slot of the object. +#' +#' @rdname adjustRtime-obiwarp setMethod("distFun", "ObiwarpParam", function(object){ return(object@distFun)}) -##' @aliases distFun<- -##' @rdname adjustRtime-obiwarp +#' @aliases distFun<- +#' +#' @rdname adjustRtime-obiwarp setReplaceMethod("distFun", "ObiwarpParam", function(object, value) { object@distFun <- value if (validObject(object)) return(object) }) -##' @aliases gapInit -##' @description \code{gapInit},\code{gapInit<-}: getter and setter -##' for the \code{gapInit} slot of the object. -##' @rdname adjustRtime-obiwarp +#' @aliases gapInit +#' +#' @description \code{gapInit},\code{gapInit<-}: getter and setter +#' for the \code{gapInit} slot of the object. +#' +#' @rdname adjustRtime-obiwarp setMethod("gapInit", "ObiwarpParam", function(object){ if (length(object@gapInit) == 0) { if (object@distFun == "cor" | object@distFun == "cor_opt") @@ -1421,18 +1621,21 @@ setMethod("gapInit", "ObiwarpParam", function(object){ return(0.9) } return(object@gapInit)}) -##' @aliases gapInit<- -##' @rdname adjustRtime-obiwarp +#' @aliases gapInit<- +#' +#' @rdname adjustRtime-obiwarp setReplaceMethod("gapInit", "ObiwarpParam", function(object, value) { object@gapInit <- value if (validObject(object)) return(object) }) -##' @aliases gapExtend -##' @description \code{gapExtend},\code{gapExtend<-}: getter and setter -##' for the \code{gapExtend} slot of the object. -##' @rdname adjustRtime-obiwarp +#' @aliases gapExtend +#' +#' @description \code{gapExtend},\code{gapExtend<-}: getter and setter +#' for the \code{gapExtend} slot of the object. +#' +#' @rdname adjustRtime-obiwarp setMethod("gapExtend", "ObiwarpParam", function(object){ if (length(object@gapExtend) == 0) { if (object@distFun == "cor" | object@distFun == "cor_opt") @@ -1445,64 +1648,77 @@ setMethod("gapExtend", "ObiwarpParam", function(object){ return(7.8) } return(object@gapExtend)}) -##' @aliases gapExtend<- -##' @rdname adjustRtime-obiwarp +#' @aliases gapExtend<- +#' +#' @rdname adjustRtime-obiwarp setReplaceMethod("gapExtend", "ObiwarpParam", function(object, value) { object@gapExtend <- value if (validObject(object)) return(object) }) -##' @aliases factorDiag -##' @description \code{factorDiag},\code{factorDiag<-}: getter and setter -##' for the \code{factorDiag} slot of the object. -##' @rdname adjustRtime-obiwarp +#' @aliases factorDiag +#' +#' @description \code{factorDiag},\code{factorDiag<-}: getter and setter +#' for the \code{factorDiag} slot of the object. +#' +#' @rdname adjustRtime-obiwarp setMethod("factorDiag", "ObiwarpParam", function(object){ return(object@factorDiag)}) -##' @aliases factorDiag<- -##' @rdname adjustRtime-obiwarp +#' @aliases factorDiag<- +#' +#' @rdname adjustRtime-obiwarp setReplaceMethod("factorDiag", "ObiwarpParam", function(object, value) { object@factorDiag <- value if (validObject(object)) return(object) }) -##' @aliases factorGap -##' @description \code{factorGap},\code{factorGap<-}: getter and setter -##' for the \code{factorGap} slot of the object. -##' @rdname adjustRtime-obiwarp +#' @aliases factorGap +#' +#' @description \code{factorGap},\code{factorGap<-}: getter and setter +#' for the \code{factorGap} slot of the object. +#' +#' @rdname adjustRtime-obiwarp setMethod("factorGap", "ObiwarpParam", function(object){ return(object@factorGap)}) -##' @aliases factorGap<- -##' @rdname adjustRtime-obiwarp +#' @aliases factorGap<- +#' +#' @rdname adjustRtime-obiwarp setReplaceMethod("factorGap", "ObiwarpParam", function(object, value) { object@factorGap <- value if (validObject(object)) return(object) }) -##' @aliases localAlignment -##' @description \code{localAlignment},\code{localAlignment<-}: getter and setter -##' for the \code{localAlignment} slot of the object. -##' @rdname adjustRtime-obiwarp +#' @aliases localAlignment +#' +#' @description \code{localAlignment},\code{localAlignment<-}: getter and setter +#' for the \code{localAlignment} slot of the object. +#' +#' @rdname adjustRtime-obiwarp setMethod("localAlignment", "ObiwarpParam", function(object){ return(object@localAlignment)}) -##' @aliases localAlignment<- -##' @rdname adjustRtime-obiwarp +#' @aliases localAlignment<- +#' +#' @rdname adjustRtime-obiwarp setReplaceMethod("localAlignment", "ObiwarpParam", function(object, value) { object@localAlignment <- value if (validObject(object)) return(object) }) -##' @aliases initPenalty -##' @description \code{initPenalty},\code{initPenalty<-}: getter and setter -##' for the \code{initPenalty} slot of the object. -##' @rdname adjustRtime-obiwarp +#' @aliases initPenalty +#' +#' @description \code{initPenalty},\code{initPenalty<-}: getter and setter +#' for the \code{initPenalty} slot of the object. +#' +#' @rdname adjustRtime-obiwarp setMethod("initPenalty", "ObiwarpParam", function(object){ return(object@initPenalty)}) -##' @aliases initPenalty<- -##' @rdname adjustRtime-obiwarp +#' @aliases initPenalty<- +#' +#' @rdname adjustRtime-obiwarp setReplaceMethod("initPenalty", "ObiwarpParam", function(object, value) { object@initPenalty <- value if (validObject(object)) @@ -1526,8 +1742,9 @@ setMethod("show", "FillChromPeaksParam", function(object) { }) #' @aliases expandMz +#' #' @description \code{expandMz},\code{expandMz<-}: getter and setter -#' for the \code{expandMz} slot of the object. +#' for the \code{expandMz} slot of the object. #' #' @param value The value for the slot. #' @@ -1535,6 +1752,7 @@ setMethod("show", "FillChromPeaksParam", function(object) { setMethod("expandMz", "FillChromPeaksParam", function(object){ return(object@expandMz)}) #' @aliases expandMz<- +#' #' @rdname fillChromPeaks setReplaceMethod("expandMz", "FillChromPeaksParam", function(object, value) { object@expandMz <- value @@ -1543,12 +1761,15 @@ setReplaceMethod("expandMz", "FillChromPeaksParam", function(object, value) { }) #' @aliases expandRt +#' #' @description \code{expandRt},\code{expandRt<-}: getter and setter -#' for the \code{expandRt} slot of the object. +#' for the \code{expandRt} slot of the object. +#' #' @rdname fillChromPeaks setMethod("expandRt", "FillChromPeaksParam", function(object){ return(object@expandRt)}) #' @aliases expandRt<- +#' #' @rdname fillChromPeaks setReplaceMethod("expandRt", "FillChromPeaksParam", function(object, value) { object@expandRt <- value @@ -1557,7 +1778,8 @@ setReplaceMethod("expandRt", "FillChromPeaksParam", function(object, value) { }) #' @description \code{ppm},\code{ppm<-}: getter and setter -#' for the \code{ppm} slot of the object. +#' for the \code{ppm} slot of the object. +#' #' @rdname fillChromPeaks setMethod("ppm", "FillChromPeaksParam", function(object){ return(object@ppm)}) diff --git a/R/methods-XCMSnExp.R b/R/methods-XCMSnExp.R index cf6f20cf1..c371f2043 100644 --- a/R/methods-XCMSnExp.R +++ b/R/methods-XCMSnExp.R @@ -10,7 +10,7 @@ setMethod("initialize", "XCMSnExp", function(.Object, ...) { return(.Object) }) -##' @rdname XCMSnExp-class +#' @rdname XCMSnExp-class setMethod("show", "XCMSnExp", function(object) { callNextMethod() ## And not XCMSnExp related stuff. @@ -53,53 +53,54 @@ setMethod("show", "XCMSnExp", function(object) { } }) -##' @aliases hasAdjustedRtime -##' -##' @description \code{hasAdjustedRtime}: whether the object provides adjusted -##' retention times. -##' -##' @rdname XCMSnExp-class +#' @aliases hasAdjustedRtime +#' +#' @description \code{hasAdjustedRtime}: whether the object provides adjusted +#' retention times. +#' +#' @rdname XCMSnExp-class setMethod("hasAdjustedRtime", "XCMSnExp", function(object) { return(hasAdjustedRtime(object@msFeatureData)) }) -##' @aliases hasFeatures -##' -##' @description \code{hasFeatures}: whether the object contains correspondence -##' results (i.e. features). -##' -##' @rdname XCMSnExp-class +#' @aliases hasFeatures +#' +#' @description \code{hasFeatures}: whether the object contains correspondence +#' results (i.e. features). +#' +#' @rdname XCMSnExp-class setMethod("hasFeatures", "XCMSnExp", function(object) { return(hasFeatures(object@msFeatureData)) }) -##' @aliases hasChromPeaks -##' -##' @description \code{hasChromPeaks}: whether the object contains peak -##' detection results. -##' -##' @rdname XCMSnExp-class +#' @aliases hasChromPeaks +#' +#' @description \code{hasChromPeaks}: whether the object contains peak +#' detection results. +#' +#' @rdname XCMSnExp-class setMethod("hasChromPeaks", "XCMSnExp", function(object) { return(hasChromPeaks(object@msFeatureData)) }) -##' @aliases adjustedRtime -##' -##' @description \code{adjustedRtime},\code{adjustedRtime<-}: -##' extract/set adjusted retention times. \code{adjustedRtime<-} should not be -##' called manually, it is called internally by the \code{\link{adjustRtime}} -##' methods. For \code{XCMSnExp} objects, \code{adjustedRtime<-} does also apply -##' the retention time adjustment to the chromatographic peaks in the object. -##' The \code{bySample} parameter allows to specify whether the adjusted -##' retention time should be grouped by sample (file). -##' -##' @return For \code{adjustedRtime}: if \code{bySample = FALSE} a \code{numeric} -##' vector with the adjusted retention for each spectrum of all files/samples -##' within the object. If \code{bySample = TRUE } a \code{list} (length equal to -##' the number of samples) with adjusted retention times grouped by sample. -##' Returns \code{NULL} if no adjusted retention times are present. -##' -##' @rdname XCMSnExp-class +#' @aliases adjustedRtime +#' +#' @description \code{adjustedRtime},\code{adjustedRtime<-}: +#' extract/set adjusted retention times. \code{adjustedRtime<-} should not +#' be called manually, it is called internally by the +#' \code{\link{adjustRtime}} methods. For \code{XCMSnExp} objects, +#' \code{adjustedRtime<-} does also apply the retention time adjustment to +#' the chromatographic peaks in the object. The \code{bySample} parameter +#' allows to specify whether the adjusted retention time should be grouped +#' by sample (file). +#' +#' @return For \code{adjustedRtime}: if \code{bySample = FALSE} a \code{numeric} +#' vector with the adjusted retention for each spectrum of all files/samples +#' within the object. If \code{bySample = TRUE } a \code{list} (length equal +#' to the number of samples) with adjusted retention times grouped by +#' sample. Returns \code{NULL} if no adjusted retention times are present. +#' +#' @rdname XCMSnExp-class setMethod("adjustedRtime", "XCMSnExp", function(object, bySample = FALSE) { res <- adjustedRtime(object@msFeatureData) if (length(res) == 0) @@ -116,9 +117,9 @@ setMethod("adjustedRtime", "XCMSnExp", function(object, bySample = FALSE) { } return(res) }) -##' @aliases adjustedRtime<- -##' -##' @rdname XCMSnExp-class +#' @aliases adjustedRtime<- +#' +#' @rdname XCMSnExp-class setReplaceMethod("adjustedRtime", "XCMSnExp", function(object, value) { if (!is.list(value)) stop("'value' is supposed to be a list of retention time values!") @@ -153,29 +154,29 @@ setReplaceMethod("adjustedRtime", "XCMSnExp", function(object, value) { return(object) }) -##' @aliases featureDefinitions -##' -##' @description \code{featureDefinitions}, \code{featureDefinitions<-}: extract -##' or set the correspondence results, i.e. the mz-rt features (peak groups). -##' -##' @return For \code{featureDefinitions}: a \code{DataFrame} with peak grouping -##' information, each row corresponding to one mz-rt feature (grouped peaks -##' within and across samples) and columns \code{"mzmed"} (median mz value), -##' \code{"mzmin"} (minimal mz value), \code{"mzmax"} (maximum mz value), -##' \code{"rtmed"} (median retention time), \code{"rtmin"} (minimal retention -##' time), \code{"rtmax"} (maximal retention time) and \code{"peakidx"}. -##' Column \code{"peakidx"} contains a \code{list} with indices of -##' chromatographic peaks (rows) in the matrix returned by the -##' \code{chromPeaks} method that belong to that feature group. The method -##' returns \code{NULL} if no feature definitions are present. -##' -##' @rdname XCMSnExp-class +#' @aliases featureDefinitions +#' +#' @description \code{featureDefinitions}, \code{featureDefinitions<-}: extract +#' or set the correspondence results, i.e. the mz-rt features (peak groups). +#' +#' @return For \code{featureDefinitions}: a \code{DataFrame} with peak grouping +#' information, each row corresponding to one mz-rt feature (grouped peaks +#' within and across samples) and columns \code{"mzmed"} (median mz value), +#' \code{"mzmin"} (minimal mz value), \code{"mzmax"} (maximum mz value), +#' \code{"rtmed"} (median retention time), \code{"rtmin"} (minimal retention +#' time), \code{"rtmax"} (maximal retention time) and \code{"peakidx"}. +#' Column \code{"peakidx"} contains a \code{list} with indices of +#' chromatographic peaks (rows) in the matrix returned by the +#' \code{chromPeaks} method that belong to that feature group. The method +#' returns \code{NULL} if no feature definitions are present. +#' +#' @rdname XCMSnExp-class setMethod("featureDefinitions", "XCMSnExp", function(object) { return(featureDefinitions(object@msFeatureData)) }) -##' @aliases featureDefinitions<- -##' -##' @rdname XCMSnExp-class +#' @aliases featureDefinitions<- +#' +#' @rdname XCMSnExp-class setReplaceMethod("featureDefinitions", "XCMSnExp", function(object, value) { if (hasFeatures(object)) object <- dropFeatureDefinitions(object) @@ -192,66 +193,110 @@ setReplaceMethod("featureDefinitions", "XCMSnExp", function(object, value) { } }) -##' @aliases chromPeaks -##' -##' @description \code{chromPeaks}, \code{chromPeaks<-}: extract or set -##' the matrix containing the information on identified chromatographic peaks. -##' Parameter \code{bySample} allows to specify whether peaks should be -##' returned ungrouped (default \code{bySample = FALSE}) or grouped by sample ( -##' \code{bySample = TRUE}). The \code{chromPeaks<-} method for \code{XCMSnExp} -##' objects removes also all correspondence (peak grouping) and retention time -##' correction (alignment) results. -##' See description of the return value for details on the returned matrix. Users -##' usually don't have to use the \code{chromPeaks<-} method directly as detected -##' chromatographic peaks are added to the object by the -##' \code{\link{findChromPeaks}} method. -##' -##' @return For \code{chromPeaks}: if \code{bySample = FALSE} a \code{matrix} with -##' at least the following columns: -##' \code{"mz"} (intensity-weighted mean of mz values of the peak across scans/ -##' retention times), -##' \code{"mzmin"} (minimal mz value), -##' \code{"mzmax"} (maximal mz value), -##' \code{"rt"} (retention time for the peak apex), -##' \code{"rtmin"} (minimal retention time), -##' \code{"rtmax"} (maximal retention time), -##' \code{"into"} (integrated, original, intensity of the peak), -##' \code{"maxo"} (maximum intentity of the peak), -##' \code{"sample"} (sample index in which the peak was identified) and -##' \code{"is_filled"} defining whether the chromatographic peak was identified -##' by the peak picking algorithm (\code{0}) or was added by the -##' \code{fillChromPeaks} method (\code{1}). -##' Depending on the employed peak detection algorithm and the -##' \code{verboseColumns} parameter of it additional columns might be returned. -##' For \code{bySample = TRUE} the chronatographic peaks are returned as a -##' \code{list} of matrices, each containing the chromatographic peaks of a -##' specific sample. For samples in which no peaks were detected a matrix -##' with 0 rows is returned. -##' -##' @rdname XCMSnExp-class -setMethod("chromPeaks", "XCMSnExp", function(object, bySample = FALSE) { +#' @aliases chromPeaks +#' +#' @description \code{chromPeaks}, \code{chromPeaks<-}: extract or set +#' the matrix containing the information on identified chromatographic +#' peaks. Parameter \code{bySample} allows to specify whether peaks should +#' be returned ungrouped (default \code{bySample = FALSE}) or grouped by +#' sample (\code{bySample = TRUE}). The \code{chromPeaks<-} method for +#' \code{XCMSnExp} objects removes also all correspondence (peak grouping) +#' and retention time correction (alignment) results. The optional +#' arguments \code{rt}, \code{mz} and \code{ppm} allow to extract only +#' chromatographic peaks overlapping (if \code{type = "any"}) or completely +#' within (if \code{type = "within"}) the defined retention time and mz +#' ranges. +#' See description of the return value for details on the returned matrix. +#' Users usually don't have to use the \code{chromPeaks<-} method directly +#' as detected chromatographic peaks are added to the object by the +#' \code{\link{findChromPeaks}} method. +#' +#' @param rt optional \code{numeric(2)} defining the retention time range for +#' which chromatographic peaks should be returned. +#' +#' @param mz optional \code{numeric(2)} defining the mz range for which +#' chromatographic peaks should be returned. +#' +#' @param ppm optional \code{numeric(1)} specifying the ppm by which the +#' \code{mz} range should be extended. For a value of \code{ppm = 10}, all +#' peaks within \code{mz[1] - ppm / 1e6} and \code{mz[2] + ppm / 1e6} are +#' returned. +#' +#' @return For \code{chromPeaks}: if \code{bySample = FALSE} a \code{matrix} +#' with at least the following columns: +#' \code{"mz"} (intensity-weighted mean of mz values of the peak across +#' scans/retention times), +#' \code{"mzmin"} (minimal mz value), +#' \code{"mzmax"} (maximal mz value), +#' \code{"rt"} (retention time for the peak apex), +#' \code{"rtmin"} (minimal retention time), +#' \code{"rtmax"} (maximal retention time), +#' \code{"into"} (integrated, original, intensity of the peak), +#' \code{"maxo"} (maximum intentity of the peak), +#' \code{"sample"} (sample index in which the peak was identified) and +#' \code{"is_filled"} defining whether the chromatographic peak was +#' identified by the peak picking algorithm (\code{0}) or was added by the +#' \code{fillChromPeaks} method (\code{1}). +#' Depending on the employed peak detection algorithm and the +#' \code{verboseColumns} parameter of it additional columns might be +#' returned. For \code{bySample = TRUE} the chronatographic peaks are +#' returned as a \code{list} of matrices, each containing the +#' chromatographic peaks of a specific sample. For samples in which no +#' peaks were detected a matrix with 0 rows is returned. +#' +#' @rdname XCMSnExp-class +setMethod("chromPeaks", "XCMSnExp", function(object, bySample = FALSE, + rt = numeric(), mz = numeric(), + ppm = 10, type = "any") { + pks <- chromPeaks(object@msFeatureData) + type <- match.arg(type, c("any", "within")) + ## Select peaks within rt range. + if (length(rt)) { + rt <- range(rt) + if (type == "within") + keep <- which(pks[, "rtmin"] >= rt[1] & pks[, "rtmax"] <= rt[2]) + else + keep <- which(pks[, "rtmax"] >= rt[1] & pks[, "rtmin"] <= rt[2]) + pks <- pks[keep, , drop = FALSE] + } + ## Select peaks within mz range, considering also ppm + if (length(mz) && length(pks)) { + mz <- range(mz) + ## Increase mz by ppm. + mz[1] <- mz[1] - mz[1] * ppm / 1e6 + mz[2] <- mz[2] + mz[2] * ppm / 1e6 + if (type == "within") + keep <- which(pks[, "mzmin"] >= mz[1] & pks[, "mzmax"] <= mz[2]) + else + keep <- which(pks[, "mzmax"] >= mz[1] & pks[, "mzmin"] <= mz[2]) + pks <- pks[keep, , drop = FALSE] + } if (bySample) { - tmp <- split(chromPeaks(object), f = chromPeaks(object)[, "sample"]) ## Ensure we return something for each sample in case there is a sample ## without detected peaks. res <- vector("list", length(fileNames(object))) names(res) <- as.character(1:length(res)) - tmp <- split.data.frame(chromPeaks(object), - f = chromPeaks(object)[, "sample"]) - res[as.numeric(names(tmp))] <- tmp - if (any(lengths(res) == 0)) { - emat <- matrix(nrow = 0, ncol = ncol(tmp[[1]])) - colnames(emat) <- colnames(tmp[[1]]) - res[lengths(res) == 0] <- emat + if (length(pks)) { + tmp <- split.data.frame(pks, + f = pks[, "sample"]) + res[as.numeric(names(tmp))] <- tmp + if (any(lengths(res) == 0)) { + emat <- matrix(nrow = 0, ncol = ncol(tmp[[1]])) + colnames(emat) <- colnames(tmp[[1]]) + for (i in which(lengths(res) == 0)) + res[[i]] <- emat + } + } else { + for(i in 1:length(res)) + res[[i]] <- pks } - return(res) - } else { - return(chromPeaks(object@msFeatureData)) - } + res + } else + pks }) -##' @aliases chromPeaks<- -##' -##' @rdname XCMSnExp-class +#' @aliases chromPeaks<- +#' +#' @rdname XCMSnExp-class setReplaceMethod("chromPeaks", "XCMSnExp", function(object, value) { newFd <- new("MsFeatureData") ## Dropping all alignment results and all retention time corrections. @@ -268,24 +313,24 @@ setReplaceMethod("chromPeaks", "XCMSnExp", function(object, value) { } }) -##' @description \code{rtime}: extracts the retention time for each -##' scan. The \code{bySample} parameter allows to return the values grouped -##' by sample/file and \code{adjusted} whether adjusted or raw retention times -##' should be returned. By default the method returns adjusted retention times, -##' if they are available (i.e. if retention times were adjusted using the -##' \code{\link{adjustRtime}} method). -##' -##' @param bySample logical(1) specifying whether results should be grouped by -##' sample. -##' -##' @param adjusted logical(1) whether adjusted or raw (i.e. the original -##' retention times reported in the files) should be returned. -##' -##' @return For \code{rtime}: if \code{bySample = FALSE} a numeric vector with the -##' retention times of each scan, if \code{bySample = TRUE} a \code{list} of -##' numeric vectors with the retention times per sample. -##' -##' @rdname XCMSnExp-class +#' @description \code{rtime}: extracts the retention time for each +#' scan. The \code{bySample} parameter allows to return the values grouped +#' by sample/file and \code{adjusted} whether adjusted or raw retention +#' times should be returned. By default the method returns adjusted +#' retention times, if they are available (i.e. if retention times were +#' adjusted using the \code{\link{adjustRtime}} method). +#' +#' @param bySample logical(1) specifying whether results should be grouped by +#' sample. +#' +#' @param adjusted logical(1) whether adjusted or raw (i.e. the original +#' retention times reported in the files) should be returned. +#' +#' @return For \code{rtime}: if \code{bySample = FALSE} a numeric vector with +#' the retention times of each scan, if \code{bySample = TRUE} a +#' \code{list} of numeric vectors with the retention times per sample. +#' +#' @rdname XCMSnExp-class setMethod("rtime", "XCMSnExp", function(object, bySample = FALSE, adjusted = hasAdjustedRtime(object)) { if (adjusted) { @@ -310,18 +355,18 @@ setMethod("rtime", "XCMSnExp", function(object, bySample = FALSE, return(res) }) -##' @description \code{mz}: extracts the mz values from each scan of -##' all files within an \code{XCMSnExp} object. These values are extracted from -##' the original data files and eventual processing steps are applied -##' \emph{on the fly}. Using the \code{bySample} parameter it is possible to -##' switch from the default grouping of mz values by spectrum/scan to a grouping -##' by sample/file. -##' -##' @return For \code{mz}: if \code{bySample = FALSE} a \code{list} with the mz -##' values (numeric vectors) of each scan. If \code{bySample = TRUE} a -##' \code{list} with the mz values per sample. -##' -##' @rdname XCMSnExp-class +#' @description \code{mz}: extracts the mz values from each scan of +#' all files within an \code{XCMSnExp} object. These values are extracted +#' from the original data files and eventual processing steps are applied +#' \emph{on the fly}. Using the \code{bySample} parameter it is possible to +#' switch from the default grouping of mz values by spectrum/scan to a +#' grouping by sample/file. +#' +#' @return For \code{mz}: if \code{bySample = FALSE} a \code{list} with the mz +#' values (numeric vectors) of each scan. If \code{bySample = TRUE} a +#' \code{list} with the mz values per sample. +#' +#' @rdname XCMSnExp-class setMethod("mz", "XCMSnExp", function(object, bySample = FALSE, BPPARAM = bpparam()) { res <- callNextMethod(object = object, BPPARAM = BPPARAM) @@ -334,18 +379,19 @@ setMethod("mz", "XCMSnExp", function(object, bySample = FALSE, return(res) }) -##' @description \code{intensity}: extracts the intensity values from -##' each scan of all files within an \code{XCMSnExp} object. These values are -##' extracted from the original data files and eventual processing steps are -##' applied \emph{on the fly}. Using the \code{bySample} parameter it is possible -##' to switch from the default grouping of intensity values by spectrum/scan to -##' a grouping by sample/file. -##' -##' @return For \code{intensity}: if \code{bySample = FALSE} a \code{list} with -##' the intensity values (numeric vectors) of each scan. If -##' \code{bySample = TRUE} a \code{list} with the intensity values per sample. -##' -##' @rdname XCMSnExp-class +#' @description \code{intensity}: extracts the intensity values from +#' each scan of all files within an \code{XCMSnExp} object. These values are +#' extracted from the original data files and eventual processing steps are +#' applied \emph{on the fly}. Using the \code{bySample} parameter it is +#' possible to switch from the default grouping of intensity values by +#' spectrum/scan to a grouping by sample/file. +#' +#' @return For \code{intensity}: if \code{bySample = FALSE} a \code{list} with +#' the intensity values (numeric vectors) of each scan. If +#' \code{bySample = TRUE} a \code{list} with the intensity values per +#' sample. +#' +#' @rdname XCMSnExp-class setMethod("intensity", "XCMSnExp", function(object, bySample = FALSE, BPPARAM = bpparam()) { res <- callNextMethod(object = object, BPPARAM = BPPARAM) @@ -358,25 +404,25 @@ setMethod("intensity", "XCMSnExp", function(object, bySample = FALSE, return(res) }) -##' @description \code{spectra}: extracts the -##' \code{\link[MSnbase]{Spectrum}} objects containing all data from -##' \code{object}. The values are extracted from the original data files and -##' eventual processing steps are applied \emph{on the fly}. By setting -##' \code{bySample = TRUE}, the spectra are returned grouped by sample/file. If -##' the \code{XCMSnExp} object contains adjusted retention times, these are -##' returned by default in the \code{Spectrum} objects (can be overwritten -##' by setting \code{adjusted = FALSE}). -##' -##' @param BPPARAM Parameter class for parallel processing. See -##' \code{\link[BiocParallel]{bpparam}}. -##' -##' @return For \code{spectra}: if \code{bySample = FALSE} a \code{list} with -##' \code{\link[MSnbase]{Spectrum}} objects. If \code{bySample = TRUE} the result -##' is grouped by sample, i.e. as a \code{list} of \code{lists}, each element in -##' the \emph{outer} \code{list} being the \code{list} of spectra of the specific -##' file. -##' -##' @rdname XCMSnExp-class +#' @description \code{spectra}: extracts the +#' \code{\link[MSnbase]{Spectrum}} objects containing all data from +#' \code{object}. The values are extracted from the original data files and +#' eventual processing steps are applied \emph{on the fly}. By setting +#' \code{bySample = TRUE}, the spectra are returned grouped by sample/file. +#' If the \code{XCMSnExp} object contains adjusted retention times, these +#' are returned by default in the \code{Spectrum} objects (can be +#' overwritten by setting \code{adjusted = FALSE}). +#' +#' @param BPPARAM Parameter class for parallel processing. See +#' \code{\link[BiocParallel]{bpparam}}. +#' +#' @return For \code{spectra}: if \code{bySample = FALSE} a \code{list} with +#' \code{\link[MSnbase]{Spectrum}} objects. If \code{bySample = TRUE} the +#' result is grouped by sample, i.e. as a \code{list} of \code{lists}, each +#' element in the \emph{outer} \code{list} being the \code{list} of spectra +#' of the specific file. +#' +#' @rdname XCMSnExp-class setMethod("spectra", "XCMSnExp", function(object, bySample = FALSE, adjusted = hasAdjustedRtime(object), BPPARAM = bpparam()) { @@ -399,28 +445,34 @@ setMethod("spectra", "XCMSnExp", function(object, bySample = FALSE, return(res) }) -## processHistory -##' @aliases processHistory -##' @description \code{processHistory}: returns a \code{list} with -##' \code{\link{ProcessHistory}} objects (or objects inheriting from this base -##' class) representing the individual processing steps that have been performed, -##' eventually along with their settings (\code{Param} parameter class). Optional -##' arguments \code{fileIndex} and \code{type} allow to restrict to process steps -##' of a certain type or performed on a certain file. -##' -##' @param fileIndex For \code{processHistory}: optional \code{numeric} -##' specifying the index of the files/samples for which the -##' \code{\link{ProcessHistory}} objects should be retrieved. -##' -##' @param type For \code{processHistory}: restrict returned -##' \code{\link{ProcessHistory}} objects to analysis steps of a certain type. Use -##' the \code{processHistoryTypes} to list all supported values. -##' -##' @return For \code{processHistory}: a \code{list} of -##' \code{\link{ProcessHistory}} objects providing the details of the individual -##' data processing steps that have been performed. -##' -##' @rdname XCMSnExp-class +#' @aliases processHistory +#' +#' @description \code{processHistory}: returns a \code{list} with +#' \code{\link{ProcessHistory}} objects (or objects inheriting from this +#' base class) representing the individual processing steps that have been +#' performed, eventually along with their settings (\code{Param} parameter +#' class). Optional arguments \code{fileIndex} and \code{type} allow to +#' restrict to process steps of a certain type or performed on a certain +#' file. +#' +#' @param fileIndex For \code{processHistory}: optional \code{numeric} +#' specifying the index of the files/samples for which the +#' \code{\link{ProcessHistory}} objects should be retrieved. +#' +#' @param type For \code{processHistory}: restrict returned +#' \code{\link{ProcessHistory}} objects to analysis steps of a certain +#' type. Use the \code{processHistoryTypes} to list all supported values. +#' For \code{chromPeaks}: \code{character} specifying which peaks to return +#' if \code{rt} or \code{mz} are defined. For \code{type = "any"} all +#' chromatographic peaks that \emph{overlap} the range defined by the +#' \code{mz} or by the \code{rt}. For \code{type = "within"} only peaks +#' completely within the range(s) are returned. +#' +#' @return For \code{processHistory}: a \code{list} of +#' \code{\link{ProcessHistory}} objects providing the details of the +#' individual data processing steps that have been performed. +#' +#' @rdname XCMSnExp-class setMethod("processHistory", "XCMSnExp", function(object, fileIndex, type) { ph <- object@.processHistory if (length(ph)) { @@ -448,12 +500,13 @@ setMethod("processHistory", "XCMSnExp", function(object, fileIndex, type) { } }) -##' @description \code{addProcessHistory}: adds (appends) a single -##' \code{\link{ProcessHistory}} object to the \code{.processHistory} slot. -##' -##' @return The \code{addProcessHistory} method returns the input object with the -##' provided \code{\link{ProcessHistory}} appended to the process history. -##' @noRd +#' @description \code{addProcessHistory}: adds (appends) a single +#' \code{\link{ProcessHistory}} object to the \code{.processHistory} slot. +#' +#' @return The \code{addProcessHistory} method returns the input object with the +#' provided \code{\link{ProcessHistory}} appended to the process history. +#' +#' @noRd setMethod("addProcessHistory", "XCMSnExp", function(object, ph) { if (!inherits(ph, "ProcessHistory")) stop("Argument 'ph' has to be of type 'ProcessHistory' or a class ", @@ -463,16 +516,16 @@ setMethod("addProcessHistory", "XCMSnExp", function(object, ph) { return(object) }) -##' @aliases dropChromPeaks -##' -##' @description \code{dropChromPeaks}: drops any identified chromatographic -##' peaks and returns the object without that information. Note that for -##' \code{XCMSnExp} objects the method drops all results from a correspondence -##' (peak grouping) or alignment (retention time adjustment) too. -##' For \code{XCMSnExp} objects the method drops also any related process -##' history steps. -##' -##' @rdname XCMSnExp-class +#' @aliases dropChromPeaks +#' +#' @description \code{dropChromPeaks}: drops any identified chromatographic +#' peaks and returns the object without that information. Note that for +#' \code{XCMSnExp} objects the method drops all results from a +#' correspondence (peak grouping) or alignment (retention time adjustment) +#' too. For \code{XCMSnExp} objects the method drops also any related +#' process history steps. +#' +#' @rdname XCMSnExp-class setMethod("dropChromPeaks", "XCMSnExp", function(object) { if (hasChromPeaks(object)) { object <- dropProcessHistories(object, type = .PROCSTEP.PEAK.DETECTION) @@ -498,31 +551,33 @@ setMethod("dropChromPeaks", "XCMSnExp", function(object) { if (validObject(object)) return(object) }) -##' @aliases dropFeatureDefinitions -##' -##' @description \code{dropFeatureDefinitions}: drops the results from a -##' correspondence (peak grouping) analysis, i.e. the definition of the mz-rt -##' features and returns the object without that information. Note that for -##' \code{XCMSnExp} objects the method will also drop retention time adjustment -##' results, if these were performed after the last peak grouping (i.e. which -##' base on the results from the peak grouping that are going to be removed). -##' For \code{XCMSnExp} objects also all related process history steps are -##' removed. Also eventually filled in peaks (by \code{\link{fillChromPeaks}}) -##' will be removed too. -##' -##' @param keepAdjRtime For \code{dropFeatureDefinitions,XCMSnExp}: -##' \code{logical(1)} defining whether eventually present retention time -##' adjustment should not be dropped. By default dropping feature definitions -##' drops retention time adjustment results too. -##' -##' @param dropLastN For \code{dropFeatureDefinitions,XCMSnExp}: -##' \code{numeric(1)} defining the number of peak grouping related process -##' history steps to remove. By default \code{dropLastN = -1}, dropping the -##' chromatographic peaks removes all process history steps related to peak -##' grouping. Setting e.g. \code{dropLastN = 1} will only remove the most recent -##' peak grouping related process history step. -##' -##' @rdname XCMSnExp-class + +#' @aliases dropFeatureDefinitions +#' +#' @description \code{dropFeatureDefinitions}: drops the results from a +#' correspondence (peak grouping) analysis, i.e. the definition of the mz-rt +#' features and returns the object without that information. Note that for +#' \code{XCMSnExp} objects the method will also drop retention time +#' adjustment results, if these were performed after the last peak grouping +#' (i.e. which base on the results from the peak grouping that are going to +#' be removed). +#' For \code{XCMSnExp} objects also all related process history steps are +#' removed. Also eventually filled in peaks (by \code{\link{fillChromPeaks}} +#' ) will be removed too. +#' +#' @param keepAdjRtime For \code{dropFeatureDefinitions,XCMSnExp}: +#' \code{logical(1)} defining whether eventually present retention time +#' adjustment should not be dropped. By default dropping feature definitions +#' drops retention time adjustment results too. +#' +#' @param dropLastN For \code{dropFeatureDefinitions,XCMSnExp}: +#' \code{numeric(1)} defining the number of peak grouping related process +#' history steps to remove. By default \code{dropLastN = -1}, dropping the +#' chromatographic peaks removes all process history steps related to peak +#' grouping. Setting e.g. \code{dropLastN = 1} will only remove the most +#' recent peak grouping related process history step. +#' +#' @rdname XCMSnExp-class setMethod("dropFeatureDefinitions", "XCMSnExp", function(object, keepAdjRtime = FALSE, dropLastN = -1) { @@ -574,19 +629,19 @@ setMethod("dropFeatureDefinitions", "XCMSnExp", function(object, return(object) }) -##' @aliases dropAdjustedRtime -##' -##' @description \code{dropAdjustedRtime}: drops any retention time -##' adjustment information and returns the object without adjusted retention -##' time. For \code{XCMSnExp} object this also reverts the retention times -##' reported for the chromatographic peaks in the peak matrix to the original, -##' raw, ones (after chromatographic peak detection). Note that for -##' \code{XCMSnExp} objects the method drops also all peak grouping results -##' if these were performed \emph{after} the retention time adjustment. -##' For \code{XCMSnExp} objects the method drops also any related process history -##' steps. -##' -##' @rdname XCMSnExp-class +#' @aliases dropAdjustedRtime +#' +#' @description \code{dropAdjustedRtime}: drops any retention time +#' adjustment information and returns the object without adjusted retention +#' time. For \code{XCMSnExp} object this also reverts the retention times +#' reported for the chromatographic peaks in the peak matrix to the +#' original, raw, ones (after chromatographic peak detection). Note that +#' for \code{XCMSnExp} objects the method drops also all peak grouping +#' results if these were performed \emph{after} the retention time +#' adjustment. For \code{XCMSnExp} objects the method drops also any +#' related process history steps. +#' +#' @rdname XCMSnExp-class setMethod("dropAdjustedRtime", "XCMSnExp", function(object) { if (hasAdjustedRtime(object)) { ## Get the process history types to determine the order of the analysis @@ -647,39 +702,40 @@ setMethod("dropAdjustedRtime", "XCMSnExp", function(object) { }) -##' @title XCMSnExp data manipulation methods inherited from MSnbase -##' -##' @description The methods listed on this page are \code{\link{XCMSnExp}} -##' methods inherited from its parent, the \code{\link[MSnbase]{OnDiskMSnExp}} -##' class from the \code{MSnbase} package, that alter the raw data or are related -##' to data subsetting. Thus calling any of these methods causes all \code{xcms} -##' pre-processing results to be removed from the \code{\link{XCMSnExp}} object -##' to ensure its data integrity. -##' -##' The \code{[} method allows to subset a \code{\link{XCMSnExp}} object by -##' spectra. For more details and examples see the documentation for -##' \code{\link[MSnbase]{OnDiskMSnExp}}. -##' -##' @param x For \code{[}: an \code{\link{XCMSnExp}} object. -##' -##' @param i For \code{[}: \code{numeric} or \code{logical} vector specifying to -##' which spectra the data set should be reduced. -##' -##' @param j For \code{[}: not supported. -##' -##' @param drop For \code{[}: not supported. -##' -##' @return For all methods: a \code{XCMSnExp} object. -##' -##' @rdname XCMSnExp-inherited-methods -##' -##' @seealso \code{\link{XCMSnExp-filter}} for methods to filter and subset -##' \code{XCMSnExp} objects. -##' @seealso \code{\link{XCMSnExp}} for base class documentation. -##' @seealso \code{\link[MSnbase]{OnDiskMSnExp}} for the documentation of the -##' parent class. -##' -##' @author Johannes Rainer +#' @title XCMSnExp data manipulation methods inherited from MSnbase +#' +#' @description The methods listed on this page are \code{\link{XCMSnExp}} +#' methods inherited from its parent, the +#' \code{\link[MSnbase]{OnDiskMSnExp}} class from the \code{MSnbase} +#' package, that alter the raw data or are related to data subsetting. Thus +#' calling any of these methods causes all \code{xcms} pre-processing +#' results to be removed from the \code{\link{XCMSnExp}} object to ensure +#' its data integrity. +#' +#' The \code{[} method allows to subset a \code{\link{XCMSnExp}} object by +#' spectra. For more details and examples see the documentation for +#' \code{\link[MSnbase]{OnDiskMSnExp}}. +#' +#' @param x For \code{[}: an \code{\link{XCMSnExp}} object. +#' +#' @param i For \code{[}: \code{numeric} or \code{logical} vector specifying to +#' which spectra the data set should be reduced. +#' +#' @param j For \code{[}: not supported. +#' +#' @param drop For \code{[}: not supported. +#' +#' @return For all methods: a \code{XCMSnExp} object. +#' +#' @rdname XCMSnExp-inherited-methods +#' +#' @seealso \code{\link{XCMSnExp-filter}} for methods to filter and subset +#' \code{XCMSnExp} objects. +#' \code{\link{XCMSnExp}} for base class documentation. +#' \code{\link[MSnbase]{OnDiskMSnExp}} for the documentation of the +#' parent class. +#' +#' @author Johannes Rainer setMethod("[", signature(x = "XCMSnExp", i = "logicalOrNumeric", j = "missing", drop = "missing"), function(x, i, j, drop) { @@ -716,19 +772,19 @@ setMethod("[", signature(x = "XCMSnExp", i = "logicalOrNumeric", j = "missing", ## return(res) ## }) -##' @description \code{bin}: allows to \emph{bin} spectra. See -##' \code{\link[MSnbase]{bin}} documentation for more details and examples. -##' -##' @param object An \code{\link{XCMSnExp}} or \code{OnDiskMSnExp} object. -##' -##' @param binSize \code{numeric(1)} defining the size of a bin (in Dalton). -##' -##' @param msLevel. For \code{bin}, \code{clean}, \code{filterMsLevel}, -##' \code{removePeaks}: \code{numeric(1)} defining the MS level(s) -##' to which operations should be applied or to which the object should be -##' subsetted. -##' -##' @rdname XCMSnExp-inherited-methods +#' @description \code{bin}: allows to \emph{bin} spectra. See +#' \code{\link[MSnbase]{bin}} documentation for more details and examples. +#' +#' @param object An \code{\link{XCMSnExp}} or \code{OnDiskMSnExp} object. +#' +#' @param binSize \code{numeric(1)} defining the size of a bin (in Dalton). +#' +#' @param msLevel. For \code{bin}, \code{clean}, \code{filterMsLevel}, +#' \code{removePeaks}: \code{numeric(1)} defining the MS level(s) +#' to which operations should be applied or to which the object should be +#' subsetted. +#' +#' @rdname XCMSnExp-inherited-methods setMethod("bin", "XCMSnExp", function(object, binSize = 1L, msLevel.) { if (hasAdjustedRtime(object) | hasFeatures(object) | hasChromPeaks(object)) { @@ -742,17 +798,17 @@ setMethod("bin", "XCMSnExp", function(object, binSize = 1L, msLevel.) { callNextMethod() }) -##' @description \code{clean}: removes unused \code{0} intensity data -##' points. See \code{\link[MSnbase]{clean}} documentation for details and -##' examples. -##' -##' @param all For \code{clean}: \code{logical(1)}, if \code{TRUE} all zeros are -##' removed. -##' -##' @param verbose \code{logical(1)} whether progress information should be -##' displayed. -##' -##' @rdname XCMSnExp-inherited-methods +#' @description \code{clean}: removes unused \code{0} intensity data +#' points. See \code{\link[MSnbase]{clean}} documentation for details and +#' examples. +#' +#' @param all For \code{clean}: \code{logical(1)}, if \code{TRUE} all zeros are +#' removed. +#' +#' @param verbose \code{logical(1)} whether progress information should be +#' displayed. +#' +#' @rdname XCMSnExp-inherited-methods setMethod("clean", "XCMSnExp", function(object, all = FALSE, verbose = FALSE, msLevel.) { if (hasAdjustedRtime(object) | hasFeatures(object) | @@ -767,11 +823,12 @@ setMethod("clean", "XCMSnExp", function(object, all = FALSE, callNextMethod() }) -##' @description \code{filterMsLevel}: reduces the \code{\link{XCMSnExp}} -##' object to spectra of the specified MS level(s). See -##' \code{\link[MSnbase]{filterMsLevel}} documentation for details and examples. -##' -##' @rdname XCMSnExp-inherited-methods +#' @description \code{filterMsLevel}: reduces the \code{\link{XCMSnExp}} +#' object to spectra of the specified MS level(s). See +#' \code{\link[MSnbase]{filterMsLevel}} documentation for details and +#' examples. +#' +#' @rdname XCMSnExp-inherited-methods setMethod("filterMsLevel", "XCMSnExp", function(object, msLevel.) { if (hasAdjustedRtime(object) | hasFeatures(object) | hasChromPeaks(object)) { @@ -785,20 +842,20 @@ setMethod("filterMsLevel", "XCMSnExp", function(object, msLevel.) { callNextMethod() }) -##' @description \code{filterAcquisitionNum}: filters the -##' \code{\link{XCMSnExp}} object keeping only spectra with the provided -##' acquisition numbers. See \code{\link[MSnbase]{filterAcquisitionNum}} for -##' details and examples. -##' -##' @param n For \code{filterAcquisitionNum}: \code{integer} defining the -##' acquisition numbers of the spectra to which the data set should be -##' sub-setted. -##' -##' @param file For \code{filterAcquisitionNum}: -##' \code{integer} defining the file index within the object to subset the -##' object by file. -##' -##' @rdname XCMSnExp-inherited-methods +#' @description \code{filterAcquisitionNum}: filters the +#' \code{\link{XCMSnExp}} object keeping only spectra with the provided +#' acquisition numbers. See \code{\link[MSnbase]{filterAcquisitionNum}} for +#' details and examples. +#' +#' @param n For \code{filterAcquisitionNum}: \code{integer} defining the +#' acquisition numbers of the spectra to which the data set should be +#' sub-setted. +#' +#' @param file For \code{filterAcquisitionNum}: +#' \code{integer} defining the file index within the object to subset the +#' object by file. +#' +#' @rdname XCMSnExp-inherited-methods setMethod("filterAcquisitionNum", "XCMSnExp", function(object, n, file) { if (hasAdjustedRtime(object) | hasFeatures(object) | hasChromPeaks(object)) { @@ -812,92 +869,94 @@ setMethod("filterAcquisitionNum", "XCMSnExp", function(object, n, file) { callNextMethod() }) -##' @aliases XCMSnExp-filter -##' @title XCMSnExp filtering and subsetting -##' -##' @description The methods listed on this page allow to filter and subset -##' \code{\link{XCMSnExp}} objects. Most of them are inherited from the -##' \code{\link[MSnbase]{OnDiskMSnExp}} object and have been adapted for -##' \code{\link{XCMSnExp}} to enable subsetting also on the preprocessing -##' results. -##' -##' \code{filterFile}: allows to reduce the -##' \code{\link{XCMSnExp}} to data from only certain files. Identified -##' chromatographic peaks for these files are retained while all eventually -##' present features (peak grouping information) are dropped. By default also -##' adjusted retention times are removed. This can be overwritten by setting -##' \code{keepAdjustedRtime = TRUE}, but users should use this option with -##' caution. -##' -##' @note The \code{filterFile} method removes also process history steps not -##' related to the files to which the object should be sub-setted and updates -##' the \code{fileIndex} attribute accordingly. Also, the method does not allow -##' arbitrary ordering of the files or re-ordering of the files within the -##' object. -##' -##' @param object A \code{\link{XCMSnExp}} object. -##' -##' @param file For \code{filterFile}: \code{integer} defining the file index -##' within the object to subset the object by file or \code{character} specifying -##' the file names to sub set. The indices are expected to be increasingly -##' ordered, if not they are ordered internally. -##' -##' @param keepAdjustedRtime For \code{filterFile}: \code{logical(1)} defining -##' whether the adjusted retention times should be kept, even if features are -##' being removed (and the retention time correction being potentially performed -##' on these features). -##' -##' @return All methods return an \code{\link{XCMSnExp}} object. -##' -##' @author Johannes Rainer -##' -##' @seealso \code{\link{XCMSnExp}} for base class documentation. -##' -##' @rdname XCMSnExp-filter-methods -##' @examples -##' -##' ## Load some of the files from the faahKO package. -##' library(faahKO) -##' fs <- c(system.file('cdf/KO/ko15.CDF', package = "faahKO"), -##' system.file('cdf/KO/ko16.CDF', package = "faahKO"), -##' system.file('cdf/KO/ko18.CDF', package = "faahKO")) -##' ## Read the files -##' od <- readMSData2(fs) -##' -##' ## Perform peak detection on them using default matched filter settings. -##' mfp <- MatchedFilterParam() -##' xod <- findChromPeaks(od, param = mfp) -##' -##' ## Subset the dataset to the first and third file. -##' xod_sub <- filterFile(xod, file = c(1, 3)) -##' -##' ## The number of chromatographic peaks per file for the full object -##' table(chromPeaks(xod)[, "sample"]) -##' -##' ## The number of chromatographic peaks per file for the subset -##' table(chromPeaks(xod_sub)[, "sample"]) -##' -##' basename(fileNames(xod)) -##' basename(fileNames(xod_sub)) -##' -##' ## Filter on mz values; chromatographic peaks and features within the -##' ## mz range are retained (as well as adjusted retention times). -##' xod_sub <- filterMz(xod, mz = c(300, 400)) -##' head(chromPeaks(xod_sub)) -##' nrow(chromPeaks(xod_sub)) -##' nrow(chromPeaks(xod)) -##' -##' ## Filter on rt values. All chromatographic peaks and features within the -##' ## retention time range are retained. Filtering is performed by default on -##' ## adjusted retention times, if present. -##' xod_sub <- filterRt(xod, rt = c(2700, 2900)) -##' -##' range(rtime(xod_sub)) -##' head(chromPeaks(xod_sub)) -##' range(chromPeaks(xod_sub)[, "rt"]) -##' -##' nrow(chromPeaks(xod)) -##' nrow(chromPeaks(xod_sub)) +#' @aliases XCMSnExp-filter +#' +#' @title XCMSnExp filtering and subsetting +#' +#' @description The methods listed on this page allow to filter and subset +#' \code{\link{XCMSnExp}} objects. Most of them are inherited from the +#' \code{\link[MSnbase]{OnDiskMSnExp}} object and have been adapted for +#' \code{\link{XCMSnExp}} to enable subsetting also on the preprocessing +#' results. +#' +#' \code{filterFile}: allows to reduce the +#' \code{\link{XCMSnExp}} to data from only certain files. Identified +#' chromatographic peaks for these files are retained while all eventually +#' present features (peak grouping information) are dropped. By default also +#' adjusted retention times are removed. This can be overwritten by setting +#' \code{keepAdjustedRtime = TRUE}, but users should use this option with +#' caution. +#' +#' @note The \code{filterFile} method removes also process history steps not +#' related to the files to which the object should be sub-setted and updates +#' the \code{fileIndex} attribute accordingly. Also, the method does not +#' allow arbitrary ordering of the files or re-ordering of the files within +#' the object. +#' +#' @param object A \code{\link{XCMSnExp}} object. +#' +#' @param file For \code{filterFile}: \code{integer} defining the file index +#' within the object to subset the object by file or \code{character} +#' specifying the file names to sub set. The indices are expected to be +#' increasingly ordered, if not they are ordered internally. +#' +#' @param keepAdjustedRtime For \code{filterFile}: \code{logical(1)} defining +#' whether the adjusted retention times should be kept, even if features are +#' being removed (and the retention time correction being potentially +#' performed on these features). +#' +#' @return All methods return an \code{\link{XCMSnExp}} object. +#' +#' @author Johannes Rainer +#' +#' @seealso \code{\link{XCMSnExp}} for base class documentation. +#' +#' @rdname XCMSnExp-filter-methods +#' +#' @examples +#' +#' ## Load some of the files from the faahKO package. +#' library(faahKO) +#' fs <- c(system.file('cdf/KO/ko15.CDF', package = "faahKO"), +#' system.file('cdf/KO/ko16.CDF', package = "faahKO"), +#' system.file('cdf/KO/ko18.CDF', package = "faahKO")) +#' ## Read the files +#' od <- readMSData2(fs) +#' +#' ## Perform peak detection on them using default matched filter settings. +#' mfp <- MatchedFilterParam() +#' xod <- findChromPeaks(od, param = mfp) +#' +#' ## Subset the dataset to the first and third file. +#' xod_sub <- filterFile(xod, file = c(1, 3)) +#' +#' ## The number of chromatographic peaks per file for the full object +#' table(chromPeaks(xod)[, "sample"]) +#' +#' ## The number of chromatographic peaks per file for the subset +#' table(chromPeaks(xod_sub)[, "sample"]) +#' +#' basename(fileNames(xod)) +#' basename(fileNames(xod_sub)) +#' +#' ## Filter on mz values; chromatographic peaks and features within the +#' ## mz range are retained (as well as adjusted retention times). +#' xod_sub <- filterMz(xod, mz = c(300, 400)) +#' head(chromPeaks(xod_sub)) +#' nrow(chromPeaks(xod_sub)) +#' nrow(chromPeaks(xod)) +#' +#' ## Filter on rt values. All chromatographic peaks and features within the +#' ## retention time range are retained. Filtering is performed by default on +#' ## adjusted retention times, if present. +#' xod_sub <- filterRt(xod, rt = c(2700, 2900)) +#' +#' range(rtime(xod_sub)) +#' head(chromPeaks(xod_sub)) +#' range(chromPeaks(xod_sub)[, "rt"]) +#' +#' nrow(chromPeaks(xod)) +#' nrow(chromPeaks(xod_sub)) setMethod("filterFile", "XCMSnExp", function(object, file, keepAdjustedRtime = FALSE) { if (missing(file)) return(object) @@ -969,23 +1028,23 @@ setMethod("filterFile", "XCMSnExp", function(object, file, return(object) }) -##' @description \code{filterMz}: filters the data set based on the -##' provided mz value range. All chromatographic peaks and features (grouped -##' peaks) falling completely within the provided mz value range are retained -##' (if their minimal mz value is \code{>= mz[1]} and the maximal mz value -##' \code{<= mz[2]}. Adjusted retention times, if present, are not altered by -##' the filtering. -##' -##' @param mz For \code{filterMz}: \code{numeric(2)} defining the lower and upper -##' mz value for the filtering. -##' -##' @param msLevel. For \code{filterMz}, \code{filterRt}, \code{numeric(1)} -##' defining the MS level(s) to which operations should be applied or to which -##' the object should be subsetted. -##' -##' @param ... Optional additional arguments. -##' -##' @rdname XCMSnExp-filter-methods +#' @description \code{filterMz}: filters the data set based on the +#' provided mz value range. All chromatographic peaks and features (grouped +#' peaks) falling completely within the provided mz value range are retained +#' (if their minimal mz value is \code{>= mz[1]} and the maximal mz value +#' \code{<= mz[2]}. Adjusted retention times, if present, are not altered by +#' the filtering. +#' +#' @param mz For \code{filterMz}: \code{numeric(2)} defining the lower and upper +#' mz value for the filtering. +#' +#' @param msLevel. For \code{filterMz}, \code{filterRt}, \code{numeric(1)} +#' defining the MS level(s) to which operations should be applied or to +#' which the object should be subsetted. +#' +#' @param ... Optional additional arguments. +#' +#' @rdname XCMSnExp-filter-methods setMethod("filterMz", "XCMSnExp", function(object, mz, msLevel., ...) { if (missing(mz)) return(object) @@ -1006,28 +1065,28 @@ setMethod("filterMz", "XCMSnExp", function(object, mz, msLevel., ...) { return(object) }) -##' @description \code{filterRt}: filters the data set based on the -##' provided retention time range. All chromatographic peaks and features -##' (grouped peaks) the specified retention time window are retained (i.e. if -##' the retention time corresponding to the peak's apex is within the specified -##' rt range). If retention time correction has been performed, the method will -##' by default filter the object by adjusted retention times. -##' The argument \code{adjusted} allows to specify manually whether filtering -##' should be performed by raw or adjusted retention times. Filtering by -##' retention time does not drop any preprocessing results. -##' The method returns an empty object if no spectrum or feature is within the -##' specified retention time range. -##' -##' @param rt For \code{filterRt}: \code{numeric(2)} defining the retention time -##' window (lower and upper bound) for the filtering. -##' -##' @param adjusted For \code{filterRt}: \code{logical} indicating whether the -##' object should be filtered by original (\code{adjusted = FALSE}) or adjusted -##' retention times (\code{adjusted = TRUE}). -##' For \code{spectra}: whether the retention times in the individual -##' \code{Spectrum} objects should be the adjusted or raw retention times. -##' -##' @rdname XCMSnExp-filter-methods +#' @description \code{filterRt}: filters the data set based on the +#' provided retention time range. All chromatographic peaks and features +#' (grouped peaks) the specified retention time window are retained (i.e. if +#' the retention time corresponding to the peak's apex is within the +#' specified rt range). If retention time correction has been performed, +#' the method will by default filter the object by adjusted retention times. +#' The argument \code{adjusted} allows to specify manually whether filtering +#' should be performed by raw or adjusted retention times. Filtering by +#' retention time does not drop any preprocessing results. +#' The method returns an empty object if no spectrum or feature is within +#' the specified retention time range. +#' +#' @param rt For \code{filterRt}: \code{numeric(2)} defining the retention time +#' window (lower and upper bound) for the filtering. +#' +#' @param adjusted For \code{filterRt}: \code{logical} indicating whether the +#' object should be filtered by original (\code{adjusted = FALSE}) or +#' adjusted retention times (\code{adjusted = TRUE}). +#' For \code{spectra}: whether the retention times in the individual +#' \code{Spectrum} objects should be the adjusted or raw retention times. +#' +#' @rdname XCMSnExp-filter-methods setMethod("filterRt", "XCMSnExp", function(object, rt, msLevel., adjusted = hasAdjustedRtime(object)) { if (missing(rt)) @@ -1125,18 +1184,18 @@ setMethod("filterRt", "XCMSnExp", function(object, rt, msLevel., }) -##' The \code{normalize} method performs basic normalization of spectra -##' intensities. See \code{\link[MSnbase]{normalize}} documentation for details -##' and examples. -##' -##' @param method For \code{normalize}: \code{character(1)} specifying the -##' normalization method. See \code{\link[MSnbase]{normalize}} for details. -##' For \code{pickPeaks}: \code{character(1)} defining the method. See -##' \code{\link[MSnbase]{pickPeaks}} for options. For \code{smooth}: -##' \code{character(1)} defining the method. See \code{\link[MSnbase]{smooth}} -##' for options and details. -##' -##' @rdname XCMSnExp-inherited-methods +#' @description The \code{normalize} method performs basic normalization of +#' spectra intensities. See \code{\link[MSnbase]{normalize}} documentation +#' for details and examples. +#' +#' @param method For \code{normalize}: \code{character(1)} specifying the +#' normalization method. See \code{\link[MSnbase]{normalize}} for details. +#' For \code{pickPeaks}: \code{character(1)} defining the method. See +#' \code{\link[MSnbase]{pickPeaks}} for options. For \code{smooth}: +#' \code{character(1)} defining the method. See +#' \code{\link[MSnbase]{smooth}} for options and details. +#' +#' @rdname XCMSnExp-inherited-methods setMethod("normalize", "XCMSnExp", function(object, method = c("max", "sum"), ...) { if (hasAdjustedRtime(object) | hasFeatures(object) | @@ -1151,21 +1210,21 @@ setMethod("normalize", "XCMSnExp", function(object, method = c("max", "sum"), callNextMethod() }) -##' The \code{pickPeaks} method performs peak picking. See -##' \code{\link[MSnbase]{pickPeaks}} documentation for details and examples. -##' -##' @param halfWindowSize For \code{pickPeaks} and \code{smooth}: -##' \code{integer(1)} defining the window size for the peak picking. See -##' \code{\link[MSnbase]{pickPeaks}} and \code{\link[MSnbase]{smooth}} for -##' details and options. -##' -##' @param SNR For \code{pickPeaks}: \code{numeric(1)} defining the signal to -##' noise ratio to be considered. See \code{\link[MSnbase]{pickPeaks}} -##' documentation for details. -##' -##' @param ... Optional additional arguments. -##' -##' @rdname XCMSnExp-inherited-methods +#' @description The \code{pickPeaks} method performs peak picking. See +#' \code{\link[MSnbase]{pickPeaks}} documentation for details and examples. +#' +#' @param halfWindowSize For \code{pickPeaks} and \code{smooth}: +#' \code{integer(1)} defining the window size for the peak picking. See +#' \code{\link[MSnbase]{pickPeaks}} and \code{\link[MSnbase]{smooth}} for +#' details and options. +#' +#' @param SNR For \code{pickPeaks}: \code{numeric(1)} defining the signal to +#' noise ratio to be considered. See \code{\link[MSnbase]{pickPeaks}} +#' documentation for details. +#' +#' @param ... Optional additional arguments. +#' +#' @rdname XCMSnExp-inherited-methods setMethod("pickPeaks", "XCMSnExp", function(object, halfWindowSize = 3L, method = c("MAD", "SuperSmoother"), SNR = 0L, ...) { @@ -1181,17 +1240,18 @@ setMethod("pickPeaks", "XCMSnExp", function(object, halfWindowSize = 3L, callNextMethod() }) -##' The \code{removePeaks} method removes mass peaks (intensities) lower than a -##' threshold. Note that these peaks refer to \emph{mass} peaks, which are -##' different to the chromatographic peaks detected and analyzed in a -##' metabolomics experiment! See \code{\link[MSnbase]{removePeaks}} -##' documentation for details and examples. -##' -##' @param t For \code{removePeaks}: either a \code{numeric(1)} or \code{"min"} -##' defining the threshold (method) to be used. See -##' \code{\link[MSnbase]{removePeaks}} for details. -##' -##' @rdname XCMSnExp-inherited-methods +#' @description The \code{removePeaks} method removes mass peaks (intensities) +#' lower than a threshold. Note that these peaks refer to \emph{mass} +#' peaks, which are different to the chromatographic peaks detected and +#' analyzed in a metabolomics experiment! See +#' \code{\link[MSnbase]{removePeaks}} documentation for details and +#' examples. +#' +#' @param t For \code{removePeaks}: either a \code{numeric(1)} or \code{"min"} +#' defining the threshold (method) to be used. See +#' \code{\link[MSnbase]{removePeaks}} for details. +#' +#' @rdname XCMSnExp-inherited-methods setMethod("removePeaks", "XCMSnExp", function(object, t = "min", verbose = FALSE, msLevel.) { if (hasAdjustedRtime(object) | hasFeatures(object) | @@ -1206,10 +1266,10 @@ setMethod("removePeaks", "XCMSnExp", function(object, t = "min", verbose = FALSE callNextMethod() }) -##' The \code{smooth} method smooths spectra. See \code{\link[MSnbase]{smooth}} -##' documentation for details and examples. -##' -##' @rdname XCMSnExp-inherited-methods +#' @description The \code{smooth} method smooths spectra. See +#' \code{\link[MSnbase]{smooth}} documentation for details and examples. +#' +#' @rdname XCMSnExp-inherited-methods setMethod("smooth", "XCMSnExp", function(x, method = c("SavitzkyGolay", "MovingAverage"), halfWindowSize = 2L, verbose = FALSE, @@ -1226,43 +1286,45 @@ setMethod("smooth", "XCMSnExp", function(x, method = c("SavitzkyGolay", callNextMethod() }) -## @param from For \code{setAs} and \code{as}: an \code{XCMSnExp} object. -## @param to For \code{setAs} and \code{as}: \code{"xcmsSet"} -##' @title Data container storing xcms preprocessing results -##' -##' @aliases setAs -##' @rdname XCMSnExp-class -##' @name XCMSnExp-class +#' @title Data container storing xcms preprocessing results +#' +#' @aliases setAs +#' +#' @rdname XCMSnExp-class +#' +#' @name XCMSnExp-class setAs(from = "XCMSnExp", to = "xcmsSet", def = .XCMSnExp2xcmsSet) -##' @title Peak grouping/correspondence based on time dimension peak densities -##' -##' @description \code{groupChromPeaks,XCMSnExp,PeakDensityParam}: -##' performs correspondence (peak grouping within and across samples) within in -##' mz dimension overlapping slices of MS data based on the density distribution -##' of the identified chromatographic peaks in the slice along the time axis. -##' -##' @note Calling \code{groupChromPeaks} on an \code{XCMSnExp} object will cause -##' all eventually present previous correspondence results to be dropped. -##' -##' @param object For \code{groupChromPeaks}: an \code{\link{XCMSnExp}} object -##' containing the results from a previous peak detection analysis (see -##' \code{\link{findChromPeaks}}). -##' -##' For all other methods: a \code{PeakDensityParam} object. -##' -##' @param param A \code{PeakDensityParam} object containing all settings for -##' the peak grouping algorithm. -##' -##' @return For \code{groupChromPeaks}: a \code{\link{XCMSnExp}} object with the -##' results of the correspondence analysis. The definition of the resulting mz-rt -##' features can be accessed with the \code{\link{featureDefinitions}} method. -##' -##' @seealso \code{\link{XCMSnExp}} for the object containing the results of -##' the correspondence. -##' -##' @rdname groupChromPeaks-density +#' @title Peak grouping/correspondence based on time dimension peak densities +#' +#' @description \code{groupChromPeaks,XCMSnExp,PeakDensityParam}: +#' performs correspondence (peak grouping within and across samples) within +#' in mz dimension overlapping slices of MS data based on the density +#' distribution of the identified chromatographic peaks in the slice along +#' the time axis. +#' +#' @note Calling \code{groupChromPeaks} on an \code{XCMSnExp} object will cause +#' all eventually present previous correspondence results to be dropped. +#' +#' @param object For \code{groupChromPeaks}: an \code{\link{XCMSnExp}} object +#' containing the results from a previous peak detection analysis (see +#' \code{\link{findChromPeaks}}). +#' +#' For all other methods: a \code{PeakDensityParam} object. +#' +#' @param param A \code{PeakDensityParam} object containing all settings for +#' the peak grouping algorithm. +#' +#' @return For \code{groupChromPeaks}: a \code{\link{XCMSnExp}} object with the +#' results of the correspondence analysis. The definition of the resulting +#' mz-rt features can be accessed with the \code{\link{featureDefinitions}} +#' method. +#' +#' @seealso \code{\link{XCMSnExp}} for the object containing the results of +#' the correspondence. +#' +#' @rdname groupChromPeaks-density setMethod("groupChromPeaks", signature(object = "XCMSnExp", param = "PeakDensityParam"), function(object, param) { @@ -1308,32 +1370,32 @@ setMethod("groupChromPeaks", }) -##' @title Single-spectrum non-chromatography MS data peak grouping -##' -##' @description \code{groupChromPeaks,XCMSnExp,MzClustParam}: -##' performs high resolution peak grouping for single spectrum -##' metabolomics data. -##' -##' @note Calling \code{groupChromPeaks} on an \code{XCMSnExp} object will cause -##' all eventually present previous correspondence results to be dropped. -##' -##' @param object For \code{groupChromPeaks}: an \code{\link{XCMSnExp}} object -##' containing the results from a previous chromatographic peak detection -##' analysis (see \code{\link{findChromPeaks}}). -##' -##' For all other methods: a \code{MzClustParam} object. -##' -##' @param param A \code{MzClustParam} object containing all settings for -##' the peak grouping algorithm. -##' -##' @return For \code{groupChromPeaks}: a \code{\link{XCMSnExp}} object with the -##' results of the peak grouping step (i.e. the features). These can be accessed -##' with the \code{\link{featureDefinitions}} method. -##' -##' @seealso \code{\link{XCMSnExp}} for the object containing the results of -##' the peak grouping. -##' -##' @rdname groupChromPeaks-mzClust +#' @title Single-spectrum non-chromatography MS data peak grouping +#' +#' @description \code{groupChromPeaks,XCMSnExp,MzClustParam}: +#' performs high resolution peak grouping for single spectrum +#' metabolomics data. +#' +#' @note Calling \code{groupChromPeaks} on an \code{XCMSnExp} object will cause +#' all eventually present previous correspondence results to be dropped. +#' +#' @param object For \code{groupChromPeaks}: an \code{\link{XCMSnExp}} object +#' containing the results from a previous chromatographic peak detection +#' analysis (see \code{\link{findChromPeaks}}). +#' +#' For all other methods: a \code{MzClustParam} object. +#' +#' @param param A \code{MzClustParam} object containing all settings for +#' the peak grouping algorithm. +#' +#' @return For \code{groupChromPeaks}: a \code{\link{XCMSnExp}} object with the +#' results of the peak grouping step (i.e. the features). These can be +#' accessed with the \code{\link{featureDefinitions}} method. +#' +#' @seealso \code{\link{XCMSnExp}} for the object containing the results of +#' the peak grouping. +#' +#' @rdname groupChromPeaks-mzClust setMethod("groupChromPeaks", signature(object = "XCMSnExp", param = "MzClustParam"), function(object, param) { @@ -1384,32 +1446,33 @@ setMethod("groupChromPeaks", }) -##' @title Peak grouping/correspondence based on proximity in the mz-rt space -##' -##' @description \code{groupChromPeaks,XCMSnExp,NearestPeaksParam}: -##' performs peak grouping based on the proximity between chromatographic -##' peaks from different samples in the mz-rt range. -##' -##' @note Calling \code{groupChromPeaks} on an \code{XCMSnExp} object will cause -##' all eventually present previous alignment results to be dropped. -##' -##' @param object For \code{groupChromPeaks}: an \code{\link{XCMSnExp}} object -##' containing the results from a previous chromatographic peak detection -##' analysis (see \code{\link{findChromPeaks}}). -##' -##' For all other methods: a \code{NearestPeaksParam} object. -##' -##' @param param A \code{NearestPeaksParam} object containing all settings for -##' the peak grouping algorithm. -##' -##' @return For \code{groupChromPeaks}: a \code{\link{XCMSnExp}} object with the -##' results of the peak grouping/correspondence step (i.e. the mz-rt features). -##' These can be accessed with the \code{\link{featureDefinitions}} method. -##' -##' @seealso \code{\link{XCMSnExp}} for the object containing the results of -##' the peak grouping. -##' -##' @rdname groupChromPeaks-nearest +#' @title Peak grouping/correspondence based on proximity in the mz-rt space +#' +#' @description \code{groupChromPeaks,XCMSnExp,NearestPeaksParam}: +#' performs peak grouping based on the proximity between chromatographic +#' peaks from different samples in the mz-rt range. +#' +#' @note Calling \code{groupChromPeaks} on an \code{XCMSnExp} object will cause +#' all eventually present previous alignment results to be dropped. +#' +#' @param object For \code{groupChromPeaks}: an \code{\link{XCMSnExp}} object +#' containing the results from a previous chromatographic peak detection +#' analysis (see \code{\link{findChromPeaks}}). +#' +#' For all other methods: a \code{NearestPeaksParam} object. +#' +#' @param param A \code{NearestPeaksParam} object containing all settings for +#' the peak grouping algorithm. +#' +#' @return For \code{groupChromPeaks}: a \code{\link{XCMSnExp}} object with the +#' results of the peak grouping/correspondence step (i.e. the mz-rt +#' features). These can be accessed with the +#' \code{\link{featureDefinitions}} method. +#' +#' @seealso \code{\link{XCMSnExp}} for the object containing the results of +#' the peak grouping. +#' +#' @rdname groupChromPeaks-nearest setMethod("groupChromPeaks", signature(object = "XCMSnExp", param = "NearestPeaksParam"), function(object, param) { @@ -1453,42 +1516,43 @@ setMethod("groupChromPeaks", return(object) }) -##' @title Retention time correction based on alignment of house keeping peak -##' groups -##' -##' @description \code{adjustRtime,XCMSnExp,PeakGroupsParam}: -##' performs retention time correction based on the alignment of peak groups -##' (features) found in all/most samples. -##' -##' @note This method requires that a correspondence has been performed on the -##' data (see \code{\link{groupChromPeaks}}). Calling \code{adjustRtime} on an -##' \code{XCMSnExp} object will cause all peak grouping (correspondence) results -##' and any previous retention time adjustments to be dropped. -##' In some instances, the \code{adjustRtime,XCMSnExp,PeakGroupsParam} -##' re-adjusts adjusted retention times to ensure them being in the same order -##' than the raw (original) retention times. -##' -##' @param object For \code{adjustRtime}: an \code{\link{XCMSnExp}} object -##' containing the results from a previous chromatographic peak detection (see -##' \code{\link{findChromPeaks}}) and alignment analysis (see -##' \code{\link{groupChromPeaks}}). -##' -##' For all other methods: a \code{PeakGroupsParam} object. -##' -##' @param param A \code{PeakGroupsParam} object containing all settings for -##' the retention time correction method.. -##' -##' @return For \code{adjustRtime}: a \code{\link{XCMSnExp}} object with the -##' results of the retention time adjustment step. These can be accessed with the -##' \code{\link{adjustedRtime}} method. Retention time correction does also adjust -##' the retention time of the identified chromatographic peaks (accessed -##' \emph{via} \code{\link{chromPeaks}}. Note that retention time correction -##' drops all previous alignment results from the result object. -##' -##' @seealso \code{\link{XCMSnExp}} for the object containing the results of -##' the alignment. -##' -##' @rdname adjustRtime-peakGroups +#' @title Retention time correction based on alignment of house keeping peak +#' groups +#' +#' @description \code{adjustRtime,XCMSnExp,PeakGroupsParam}: +#' performs retention time correction based on the alignment of peak groups +#' (features) found in all/most samples. +#' +#' @note This method requires that a correspondence has been performed on the +#' data (see \code{\link{groupChromPeaks}}). Calling \code{adjustRtime} on +#' an \code{XCMSnExp} object will cause all peak grouping (correspondence) +#' results and any previous retention time adjustments to be dropped. +#' In some instances, the \code{adjustRtime,XCMSnExp,PeakGroupsParam} +#' re-adjusts adjusted retention times to ensure them being in the same +#' order than the raw (original) retention times. +#' +#' @param object For \code{adjustRtime}: an \code{\link{XCMSnExp}} object +#' containing the results from a previous chromatographic peak detection +#' (see \code{\link{findChromPeaks}}) and alignment analysis (see +#' \code{\link{groupChromPeaks}}). +#' +#' For all other methods: a \code{PeakGroupsParam} object. +#' +#' @param param A \code{PeakGroupsParam} object containing all settings for +#' the retention time correction method.. +#' +#' @return For \code{adjustRtime}: a \code{\link{XCMSnExp}} object with the +#' results of the retention time adjustment step. These can be accessed +#' with the \code{\link{adjustedRtime}} method. Retention time correction +#' does also adjust the retention time of the identified chromatographic +#' peaks (accessed \emph{via} \code{\link{chromPeaks}}. Note that retention +#' time correction drops all previous alignment results from the result +#' object. +#' +#' @seealso \code{\link{XCMSnExp}} for the object containing the results of +#' the alignment. +#' +#' @rdname adjustRtime-peakGroups setMethod("adjustRtime", signature(object = "XCMSnExp", param = "PeakGroupsParam"), function(object, param) { @@ -1543,43 +1607,45 @@ setMethod("adjustRtime", }) -##' @title Align retention times across samples using Obiwarp -##' -##' @description \code{adjustRtime,XCMSnExp,ObiwarpParam}: -##' performs retention time correction/alignment based on the total mz-rt data -##' using the \emph{obiwarp} method. -##' -##' @note Calling \code{adjustRtime} on an \code{XCMSnExp} object will cause -##' all peak grouping (correspondence) results and any previous retention time -##' adjustment results to be dropped. -##' -##' @param object For \code{adjustRtime}: an \code{\link{XCMSnExp}} object. -##' -##' For all other methods: a \code{ObiwarpParam} object. -##' -##' @param param A \code{ObiwarpParam} object containing all settings for -##' the alignment method. -##' -##' @return For \code{adjustRtime,XCMSnExp,ObiwarpParam}: a -##' \code{\link{XCMSnExp}} object with the results of the retention time -##' adjustment step. These can be accessed with the \code{\link{adjustedRtime}} -##' method. Retention time correction does also adjust the retention time of the -##' identified chromatographic peaks (accessed \emph{via} -##' \code{\link{chromPeaks}}. Note that retention time correction drops all -##' previous peak grouping results from the result object. -##' -##' For \code{adjustRtime,OnDiskMSnExp,ObiwarpParam}: a \code{numeric} with the -##' adjusted retention times per spectra (in the same order than \code{rtime}). -##' -##' @seealso \code{\link{XCMSnExp}} for the object containing the results of -##' the alignment. -##' -##' @references -##' John T. Prince and Edward M. Marcotte. "Chromatographic Alignment of -##' ESI-LC-MS Proteomic Data Sets by Ordered Bijective Interpolated Warping" -##' \emph{Anal. Chem.} 2006, 78 (17), 6140-6152. -##' -##' @rdname adjustRtime-obiwarp +#' @title Align retention times across samples using Obiwarp +#' +#' @description \code{adjustRtime,XCMSnExp,ObiwarpParam}: +#' performs retention time correction/alignment based on the total mz-rt +#' data using the \emph{obiwarp} method. +#' +#' @note Calling \code{adjustRtime} on an \code{XCMSnExp} object will cause +#' all peak grouping (correspondence) results and any previous retention +#' time adjustment results to be dropped. +#' +#' @param object For \code{adjustRtime}: an \code{\link{XCMSnExp}} object. +#' +#' For all other methods: a \code{ObiwarpParam} object. +#' +#' @param param A \code{ObiwarpParam} object containing all settings for +#' the alignment method. +#' +#' @return For \code{adjustRtime,XCMSnExp,ObiwarpParam}: a +#' \code{\link{XCMSnExp}} object with the results of the retention time +#' adjustment step. These can be accessed with the +#' \code{\link{adjustedRtime}} method. Retention time correction does also +#' adjust the retention time of the identified chromatographic peaks +#' (accessed \emph{via} \code{\link{chromPeaks}}. Note that retention time +#' correction drops all previous peak grouping results from the result +#' object. +#' +#' For \code{adjustRtime,OnDiskMSnExp,ObiwarpParam}: a \code{numeric} with +#' the adjusted retention times per spectra (in the same order than +#' \code{rtime}). +#' +#' @seealso \code{\link{XCMSnExp}} for the object containing the results of +#' the alignment. +#' +#' @references +#' John T. Prince and Edward M. Marcotte. "Chromatographic Alignment of +#' ESI-LC-MS Proteomic Data Sets by Ordered Bijective Interpolated Warping" +#' \emph{Anal. Chem.} 2006, 78 (17), 6140-6152. +#' +#' @rdname adjustRtime-obiwarp setMethod("adjustRtime", signature(object = "XCMSnExp", param = "ObiwarpParam"), function(object, param) { @@ -1605,7 +1671,7 @@ setMethod("adjustRtime", }) ## profMat for XCMSnExp -##' @rdname XCMSnExp-class +#' @rdname XCMSnExp-class setMethod("profMat", signature(object = "XCMSnExp"), function(object, method = "bin", step = 0.1, @@ -1623,64 +1689,70 @@ setMethod("profMat", signature(object = "XCMSnExp"), function(object, }) -##' @aliases featureValues -##' @title Accessing mz-rt feature data values -##' -##' @description \code{featureValues,XCMSnExp} : extract a \code{matrix} for -##' feature values with rows representing features and columns samples. -##' Parameter \code{value} allows to define which column from the -##' \code{\link{chromPeaks}} matrix should be returned. Multiple -##' chromatographic peaks from the same sample can be assigned to a feature. -##' Parameter \code{method} allows to specify the method to be used in such -##' cases to chose from which of the peaks the value should be returned. -##' -##' @note This method is equivalent to the \code{\link{groupval}} for -##' \code{xcmsSet} objects. -##' -##' @param object A \code{\link{XCMSnExp}} object providing the feature -##' definitions. -##' -##' @param method \code{character} specifying the method to resolve -##' multi-peak mappings within the same sample, i.e. to define the -##' \emph{representative} peak for a feature in samples where more than -##' one peak was assigned to the feature. If \code{"medret"}: select the -##' peak closest to the median retention time of the feature. -##' If \code{"maxint"}: select the peak yielding the largest signal. -##' -##' @param value \code{character} specifying the name of the column in -##' \code{chromPeaks(object)} that should be returned or \code{"index"} (the -##' default) to return the index of the peak in the -##' \code{chromPeaks(object)} matrix corresponding to the -##' \emph{representative} peak for the feature in the respective sample. -##' -##' @param intensity \code{character} specifying the name of the column in the -##' \code{chromPeaks(objects)} matrix containing the intensity value of the -##' peak that should be used for the conflict resolution if -##' \code{method = "maxint"}. -##' -##' @return For \code{featureValues}: a \code{matrix} with -##' feature values, columns representing samples, rows features. The order -##' of the features matches the order found in the -##' \code{featureDefinitions(object)} \code{DataFrame}. The rownames of the -##' \code{matrix} are the same than those of the \code{featureDefinitions} -##' \code{DataFrame}. \code{NA} is reported for features without -##' corresponding chromatographic peak in the respective sample(s). -##' -##' @author Johannes Rainer -##' -##' @seealso -##' \code{\link{XCMSnExp}} for information on the data object. -##' \code{\link{featureDefinitions}} to extract the \code{DataFrame} with the -##' feature definitions. -##' \code{\link{hasFeatures}} to evaluate whether the -##' \code{\link{XCMSnExp}} provides feature definitions. -##' \code{\link{groupval}} for the equivalent method on \code{xcmsSet} objects. -##' -##' @rdname XCMSnExp-peak-grouping-results +#' @aliases featureValues +#' +#' @title Accessing mz-rt feature data values +#' +#' @description \code{featureValues,XCMSnExp} : extract a \code{matrix} for +#' feature values with rows representing features and columns samples. +#' Parameter \code{value} allows to define which column from the +#' \code{\link{chromPeaks}} matrix should be returned. Multiple +#' chromatographic peaks from the same sample can be assigned to a feature. +#' Parameter \code{method} allows to specify the method to be used in such +#' cases to chose from which of the peaks the value should be returned. +#' +#' @note This method is equivalent to the \code{\link{groupval}} for +#' \code{xcmsSet} objects. +#' +#' @param object A \code{\link{XCMSnExp}} object providing the feature +#' definitions. +#' +#' @param method \code{character} specifying the method to resolve +#' multi-peak mappings within the same sample, i.e. to define the +#' \emph{representative} peak for a feature in samples where more than +#' one peak was assigned to the feature. If \code{"medret"}: select the +#' peak closest to the median retention time of the feature. +#' If \code{"maxint"}: select the peak yielding the largest signal. +#' +#' @param value \code{character} specifying the name of the column in +#' \code{chromPeaks(object)} that should be returned or \code{"index"} (the +#' default) to return the index of the peak in the +#' \code{chromPeaks(object)} matrix corresponding to the +#' \emph{representative} peak for the feature in the respective sample. +#' +#' @param intensity \code{character} specifying the name of the column in the +#' \code{chromPeaks(objects)} matrix containing the intensity value of the +#' peak that should be used for the conflict resolution if +#' \code{method = "maxint"}. +#' +#' @param filled \code{logical(1)} specifying whether values for filled-in +#' peaks should be returned or not. If \code{filled = FALSE}, an \code{NA} +#' is returned in the matrix for the respective peak. See +#' \code{\link{fillChromPeaks}} for details on peak filling. +#' +#' @return For \code{featureValues}: a \code{matrix} with +#' feature values, columns representing samples, rows features. The order +#' of the features matches the order found in the +#' \code{featureDefinitions(object)} \code{DataFrame}. The rownames of the +#' \code{matrix} are the same than those of the \code{featureDefinitions} +#' \code{DataFrame}. \code{NA} is reported for features without +#' corresponding chromatographic peak in the respective sample(s). +#' +#' @author Johannes Rainer +#' +#' @seealso +#' \code{\link{XCMSnExp}} for information on the data object. +#' \code{\link{featureDefinitions}} to extract the \code{DataFrame} with the +#' feature definitions. +#' \code{\link{hasFeatures}} to evaluate whether the +#' \code{\link{XCMSnExp}} provides feature definitions. +#' \code{\link{groupval}} for the equivalent method on \code{xcmsSet} objects. +#' +#' @rdname XCMSnExp-peak-grouping-results setMethod("featureValues", signature(object = "XCMSnExp"), function(object, method = c("medret", "maxint"), value = "index", - intensity = "into") { + intensity = "into", filled = TRUE) { ## Input argument checkings if (!hasFeatures(object)) stop("No peak groups present! Use 'groupChromPeaks' first.") @@ -1693,6 +1765,10 @@ setMethod("featureValues", ## Copy all of the objects to avoid costly S4 method calls - ## improves speed at the cost of higher memory demand. fts <- chromPeaks(object) + + ## issue #157: replace all values for filled-in peaks with NA + if (!filled) + fts[fts[, "is_filled"] == 1, ] <- NA grps <- featureDefinitions(object) ftIdx <- grps$peakidx ## Match columns @@ -1731,7 +1807,7 @@ setMethod("featureValues", rownames(vals) <- rownames(grps) vals }) -## ##' @rdname XCMSnExp-peak-grouping-results +## #' @rdname XCMSnExp-peak-grouping-results ## setMethod("groupval", ## signature(object = "XCMSnExp"), ## function(object, method = c("medret", "maxint"), value = "index", @@ -1742,61 +1818,66 @@ setMethod("featureValues", #' @aliases extractChromatograms +#' #' @title Extracting chromatograms #' #' @description \code{extractChromatograms}: the method allows to extract -#' chromatograms from \code{\link[MSnbase]{OnDiskMSnExp}} and -#' \code{\link{XCMSnExp}} objects. +#' chromatograms from \code{\link[MSnbase]{OnDiskMSnExp}} and +#' \code{\link{XCMSnExp}} objects. #' #' @details Arguments \code{rt} and \code{mz} allow to specify the MS -#' data slice from which the chromatogram should be extracted. The parameter -#' \code{aggregationSum} allows to specify the function to be used to aggregate -#' the intensities across the mz range for the same retention time. Setting -#' \code{aggregationFun = "sum"} would e.g. allow to calculate the \emph{total -#' ion chromatogram} (TIC), \code{aggregationFun = "max"} the \emph{base peak -#' chromatogram} (BPC). -#' -#' @note -#' \code{Chromatogram} objects extracted with \code{extractChromatogram} contain -#' \code{NA_real_} values if, for a given retention time, no valid measurement -#' was available for the provided mz range. -#' -#' For \code{\link{XCMSnExp}} objects, if adjusted retention times are -#' available, the \code{extractChromatograms} method will by default report and -#' use these (for the subsetting based on the provided parameter \code{rt}). This -#' can be overwritten with the parameter \code{adjustedRtime}. +#' data slice from which the chromatogram should be extracted. The +#' parameter \code{aggregationSum} allows to specify the function to be +#' used to aggregate the intensities across the mz range for the same +#' retention time. Setting \code{aggregationFun = "sum"} would e.g. allow +#' to calculate the \emph{total ion chromatogram} (TIC), +#' \code{aggregationFun = "max"} the \emph{base peak chromatogram} (BPC). +#' +#' @note \code{Chromatogram} objects extracted with \code{extractChromatogram} +#' contain \code{NA_real_} values if, for a given retention time, no valid +#' measurement was available for the provided mz range. +#' +#' For \code{\link{XCMSnExp}} objects, if adjusted retention times are +#' available, the \code{extractChromatograms} method will by default report +#' and use these (for the subsetting based on the provided parameter +#' \code{rt}). This can be overwritten with the parameter +#' \code{adjustedRtime}. #' #' @param object Either a \code{\link[MSnbase]{OnDiskMSnExp}} or -#' \code{\link{XCMSnExp}} object from which the chromatograms should be extracted. +#' \code{\link{XCMSnExp}} object from which the chromatograms should be +#' extracted. #' #' @param rt \code{numeric(2)} defining the lower and upper boundary for the -#' retention time range. If not specified, the full retention time range of the -#' original data will be used. It is also possible to submit a \code{numeric(1)} -#' in which case \code{range} is called on it to transform it to a -#' \code{numeric(2)}. +#' retention time range. If not specified, the full retention time range of +#' the original data will be used. It is also possible to submit a +#' \code{numeric(1)} in which case \code{range} is called on it to +#' transform it to a \code{numeric(2)}. #' #' @param mz \code{numeric(2)} defining the lower and upper mz value for the -#' MS data slice. If not specified, the chromatograms will be calculated on the -#' full mz range. It is also possible to submit a \code{numeric(1)} in which case -#' \code{range} is called on it to transform it to a \code{numeric(2)}. +#' MS data slice. If not specified, the chromatograms will be calculated on +#' the full mz range. It is also possible to submit a \code{numeric(1)} in +#' which case \code{range} is called on it to transform it to a +#' \code{numeric(2)}. #' #' @param adjustedRtime For \code{extractChromatograms,XCMSnExp}: whether the -#' adjusted (\code{adjustedRtime = TRUE}) or raw retention times -#' (\code{adjustedRtime = FALSE}) should be used for filtering and returned in -#' the resulting \code{\link{Chromatogram}} object. Adjusted retention times are -#' used by default if available. +#' adjusted (\code{adjustedRtime = TRUE}) or raw retention times +#' (\code{adjustedRtime = FALSE}) should be used for filtering and returned +#' in the resulting \code{\link{Chromatogram}} object. Adjusted retention +#' times are used by default if available. #' #' @param aggregationFun \code{character} specifying the function to be used to -#' aggregate intensity values across the mz value range for the same retention -#' time. Allowed values are \code{"sum"}, \code{"max"}, \code{"mean"} and -#' \code{"min"}. +#' aggregate intensity values across the mz value range for the same +#' retention time. Allowed values are \code{"sum"}, \code{"max"}, +#' \code{"mean"} and \code{"min"}. #' #' @author Johannes Rainer #' #' @seealso \code{\link{XCMSnExp}} for the data object. -#' \code{\link{Chromatogram}} for the object representing chromatographic data. +#' \code{\link{Chromatogram}} for the object representing chromatographic +#' data. #' #' @export +#' #' @rdname extractChromatograms-method #' #' @examples @@ -1827,12 +1908,14 @@ setMethod("extractChromatograms", adjusted = adjustedRtime)) }) -##' @rdname XCMSnExp-class -##' @param param A \code{\link{CentWaveParam}}, \code{\link{MatchedFilterParam}}, -##' \code{\link{MassifquantParam}}, \code{\link{MSWParam}} or -##' \code{\link{CentWavePredIsoParam}} object with the settings for the -##' chromatographic peak detection algorithm. -##' @inheritParams findChromPeaks-centWave +#' @rdname XCMSnExp-class +#' +#' @param param A \code{\link{CentWaveParam}}, \code{\link{MatchedFilterParam}}, +#' \code{\link{MassifquantParam}}, \code{\link{MSWParam}} or +#' \code{\link{CentWavePredIsoParam}} object with the settings for the +#' chromatographic peak detection algorithm. +#' +#' @inheritParams findChromPeaks-centWave setMethod("findChromPeaks", signature(object = "XCMSnExp", param = "ANY"), function(object, param, BPPARAM = bpparam(), return.type = "XCMSnExp") { @@ -1850,85 +1933,88 @@ setMethod("findChromPeaks", return(object) }) -## fillChromPeaks: #' @aliases fillChromPeaks +#' #' @title Integrate areas of missing peaks #' #' @description Integrate signal in the mz-rt area of a feature (chromatographic -#' peak group) for samples in which no chromatographic peak for this feature was -#' identified and add it to the \code{chromPeaks}. Such peaks will have a value -#' of \code{1} in the \code{"is_filled"} column of the \code{\link{chromPeaks}} -#' matrix of the object. +#' peak group) for samples in which no chromatographic peak for this +#' feature was identified and add it to the \code{chromPeaks}. Such peaks +#' will have a value of \code{1} in the \code{"is_filled"} column of the +#' \code{\link{chromPeaks}} matrix of the object. #' #' @details After correspondence (i.e. grouping of chromatographic peaks across -#' samples) there will always be features (peak groups) that do not include peaks -#' from every sample. The \code{fillChromPeaks} method defines intensity values -#' for such features in the missing samples by integrating the signal in the -#' mz-rt region of the feature. The mz-rt area is defined by the median mz and -#' rt start and end points of the other detected chromatographic peaks for a -#' given feature. +#' samples) there will always be features (peak groups) that do not include +#' peaks from every sample. The \code{fillChromPeaks} method defines +#' intensity values for such features in the missing samples by integrating +#' the signal in the mz-rt region of the feature. The mz-rt area is defined +#' by the median mz and rt start and end points of the other detected +#' chromatographic peaks for a given feature. #' -#' Adjusted retention times will be used if available. -#' -#' Based on the peak finding algorithm that was used to identify the -#' (chromatographic) peaks different internal functions are employed to guarantee -#' that the integrated peak signal matches as much as possible the peak signal -#' integration used during the peak detection. For peaks identified with the -#' \code{\link{matchedFilter}} method, signal integration is performed on the -#' \emph{profile matrix} generated with the same settings used also during peak -#' finding (using the same \code{bin} size for example). For direct injection -#' data and peaks identified with the \code{\link{MSW}} algorithm signal is -#' integrated only along the mz dimension. For all other methods the complete -#' (raw) signal within the area defined by \code{"mzmin"}, \code{"mzmax"}, -#' \code{"rtmin"} and \code{"rtmax"} is used. +#' Adjusted retention times will be used if available. +#' +#' Based on the peak finding algorithm that was used to identify the +#' (chromatographic) peaks different internal functions are employed to +#' guarantee that the integrated peak signal matches as much as possible +#' the peak signal integration used during the peak detection. For peaks +#' identified with the \code{\link{matchedFilter}} method, signal +#' integration is performed on the \emph{profile matrix} generated with +#' the same settings used also during peak finding (using the same +#' \code{bin} size for example). For direct injection data and peaks +#' identified with the \code{\link{MSW}} algorithm signal is integrated +#' only along the mz dimension. For all other methods the complete (raw) +#' signal within the area defined by \code{"mzmin"}, \code{"mzmax"}, +#' \code{"rtmin"} and \code{"rtmax"} is used. #' #' @note The reported \code{"mzmin"}, \code{"mzmax"}, \code{"rtmin"} and -#' \code{"rtmax"} for the filled peaks represents the actual MS area from which -#' the signal was integrated. -#' Note that no peak is filled in if no signal was present in a file/sample in -#' the respective mz-rt area. These samples will still show a \code{NA} in the -#' matrix returned by the \code{\link{featureValues}} method. This is in contrast -#' to the \code{\link{fillPeaks.chrom}} method that returned an \code{"into"} and -#' \code{"maxo"} of \code{0} for such peak areas. Growing the mz-rt area using -#' the \code{expandMz} and \code{expandRt} might help to reduce the number of -#' missing peak signals after filling. +#' \code{"rtmax"} for the filled peaks represents the actual MS area from +#' which the signal was integrated. +#' Note that no peak is filled in if no signal was present in a file/sample +#' in the respective mz-rt area. These samples will still show a \code{NA} +#' in the matrix returned by the \code{\link{featureValues}} method. This +#' is in contrast to the \code{\link{fillPeaks.chrom}} method that returned +#' an \code{"into"} and \code{"maxo"} of \code{0} for such peak areas. +#' Growing the mz-rt area using the \code{expandMz} and \code{expandRt} +#' might help to reduce the number of missing peak signals after filling. #' #' @param object \code{XCMSnExp} object with identified and grouped -#' chromatographic peaks. +#' chromatographic peaks. #' #' @param param A \code{FillChromPeaksParam} object with all settings. #' #' @param expandMz \code{numeric(1)} defining the value by which the mz width of -#' peaks should be expanded. Each peak is expanded in mz direction by -#' \code{expandMz *} their original mz width. A value of \code{0} means no -#' expansion, a value of \code{1} grows each peak by 1 * the mz width of the peak -#' resulting in peakswith twice their original size in mz direction (expansion -#' by half mz width to both sides). +#' peaks should be expanded. Each peak is expanded in mz direction by +#' \code{expandMz *} their original mz width. A value of \code{0} means no +#' expansion, a value of \code{1} grows each peak by 1 * the mz width of +#' the peak resulting in peakswith twice their original size in mz +#' direction (expansion by half mz width to both sides). #' #' @param expandRt \code{numeric(1)}, same as \code{expandRt} but for the -#' retention time width. +#' retention time width. #' #' @param ppm \code{numeric(1)} optionally specifying a \emph{ppm} by which the -#' mz width of the peak region should be expanded. For peaks with an mz width -#' smaller than \code{mean(c(mzmin, mzmax)) * ppm / 1e6}, the \code{mzmin} will -#' be replaced by -#' \code{mean(c(mzmin, mzmax)) - (mean(c(mzmin, mzmax)) * ppm / 2 / 1e6)} -#' and \code{mzmax} by -#' \code{mean(c(mzmin, mzmax)) + (mean(c(mzmin, mzmax)) * ppm / 2 / 1e6)}. This -#' is applied before eventually expanding the mz width using the \code{expandMz} -#' parameter. +#' mz width of the peak region should be expanded. For peaks with an mz +#' width smaller than \code{mean(c(mzmin, mzmax)) * ppm / 1e6}, the +#' \code{mzmin} will be replaced by +#' \code{mean(c(mzmin, mzmax)) - (mean(c(mzmin, mzmax)) * ppm / 2 / 1e6)} +#' and \code{mzmax} by +#' \code{mean(c(mzmin, mzmax)) + (mean(c(mzmin, mzmax)) * ppm / 2 / 1e6)}. +#' This is applied before eventually expanding the mz width using the +#' \code{expandMz} parameter. #' #' @param BPPARAM Parallel processing settings. #' #' @return A \code{\link{XCMSnExp}} object with previously missing -#' chromatographic peaks for features filled into its \code{chromPeaks} matrix. +#' chromatographic peaks for features filled into its \code{chromPeaks} +#' matrix. #' #' @rdname fillChromPeaks #' #' @author Johannes Rainer +#' #' @seealso \code{\link{groupChromPeaks}} for methods to perform the -#' correspondence. -#' \code{\link{dropFilledChromPeaks}} for the method to remove filled in peaks. +#' correspondence. +#' \code{\link{dropFilledChromPeaks}} for the method to remove filled in peaks. #' #' @examples #' @@ -2162,15 +2248,16 @@ setMethod( BPPARAM = BPPARAM) }) -##' @aliases dropFilledChromPeaks -##' -##' @description \code{dropFilledChromPeaks}: drops any filled-in chromatographic -##' peaks (filled in by the \code{\link{fillChromPeaks}} method) and all related -##' process history steps. -##' -##' @rdname XCMSnExp-class -##' @seealso \code{\link{fillChromPeaks}} for the method to fill-in eventually -##' missing chromatographic peaks for a feature in some samples. +#' @aliases dropFilledChromPeaks +#' +#' @description \code{dropFilledChromPeaks}: drops any filled-in chromatographic +#' peaks (filled in by the \code{\link{fillChromPeaks}} method) and all +#' related process history steps. +#' +#' @rdname XCMSnExp-class +#' +#' @seealso \code{\link{fillChromPeaks}} for the method to fill-in eventually +#' missing chromatographic peaks for a feature in some samples. setMethod("dropFilledChromPeaks", "XCMSnExp", function(object) { if (!.hasFilledPeaks(object)) return(object) diff --git a/R/methods-xcmsRaw.R b/R/methods-xcmsRaw.R index 5ec1c89c6..2280bc34d 100755 --- a/R/methods-xcmsRaw.R +++ b/R/methods-xcmsRaw.R @@ -1150,80 +1150,11 @@ setMethod("findPeaks", "xcmsRaw", function(object, method=getOption("BioC")$xcms invisible(do.call(method, list(object, ...))) }) -############################################################ -## getPeaks setMethod("getPeaks", "xcmsRaw", function(object, peakrange, step = 0.1) { - - profFun <- match.profFun(object) - if (all(c("mzmin","mzmax","rtmin","rtmax") %in% colnames(peakrange))) - peakrange <- peakrange[,c("mzmin","mzmax","rtmin","rtmax"),drop=FALSE] - stime <- object@scantime - -### Create EIC buffer - ## This is NOT calculated for the full file. - mrange <- range(peakrange[,1:2]) - mass <- seq(floor(mrange[1]/step)*step, ceiling(mrange[2]/step)*step, by = step) - bufsize <- min(100, length(mass)) - buf <- profFun(object@env$mz, object@env$intensity, object@scanindex, - bufsize, mass[1], mass[bufsize], TRUE, object@profparam) - bufidx <- integer(length(mass)) - idxrange <- c(1, bufsize) - bufidx[idxrange[1]:idxrange[2]] <- 1:bufsize - - cnames <- c("mz", "mzmin", "mzmax", "rt", "rtmin", "rtmax", "into", "maxo") - rmat <- matrix(nrow = nrow(peakrange), ncol = length(cnames)) - colnames(rmat) <- cnames - - for (i in order(peakrange[,1])) { - imz <- findRange(mass, c(peakrange[i,1]-.5*step, peakrange[i,2]+.5*step), TRUE) - iret <- findRange(stime, peakrange[i,3:4], TRUE) - -### Update EIC buffer if necessary - if (bufidx[imz[2]] == 0) { - bufidx[idxrange[1]:idxrange[2]] <- 0 - idxrange <- c(max(1, imz[1]), min(bufsize+imz[1]-1, length(mass))) - bufidx[idxrange[1]:idxrange[2]] <- 1:(diff(idxrange)+1) - buf <- profFun(object@env$mz, object@env$intensity, object@scanindex, - diff(idxrange)+1, mass[idxrange[1]], mass[idxrange[2]], - TRUE, object@profparam) - } - ## Extract the intensity matrix for the mz-rt range: rows are mz, cols - ## rt values. - ymat <- buf[bufidx[imz[1]:imz[2]],iret[1]:iret[2],drop=FALSE] - ## Define the maximum intensity, is one value per mz. - ymax <- colMax(ymat) - iymax <- which.max(ymax) - - ## The width in rt. - pwid <- diff(stime[iret])/diff(iret) - - ## Calculate sum across rt. For each mz we get one value. - rosm <- rowSums(ymat) - limz <- length(imz[1]:imz[2]) - if (length(rosm) != limz) { ## that happens for some reason - warning("weighted.mean : x and w must have the same length \n") - rosm <- rep(1, limz) ## fallback to mean - } - ## mean mz: - rmat[i,1] <- weighted.mean(mass[imz[1]:imz[2]], rosm) ## mz; its not the - ## position of the largest intensity! - if (is.nan(rmat[i,1]) || is.na(rmat[i,1])) ## R2.11 : weighted.mean() results in NA (not NaN) for zero weights - rmat[i,1] <- mean(peakrange[i,1:2]) - - rmat[i,2:3] <- peakrange[i,1:2] ## mzmin, mzmax - rmat[i,4] <- stime[iret[1]:iret[2]][iymax] ## rt - rmat[i,5:6] <- peakrange[i,3:4] ## rtmin, rtmax - - if (peakrange[i,3] < stime[1] || peakrange[i,4] > stime[length(stime)] || is.nan(pwid)) { - warning("getPeaks: Peak m/z:",peakrange[i,1],"-",peakrange[i,2], ", RT:",peakrange[i,3],"-",peakrange[i,4], - "is out of retention time range for this sample (",object@filepath,"), using zero intensity value.\n") - rmat[i,7:8] <- 0 - } else { - rmat[i,7] <- pwid*sum(ymax) ## into - rmat[i,8] <- ymax[iymax] ## maxo - } - } - invisible(rmat) + if (useOriginalCode()) + return(.getPeaks_orig(object, peakrange, step = step)) + else + return(.getPeaks_new(object, peakrange, step = step)) }) ############################################################ diff --git a/R/methods-xcmsSet.R b/R/methods-xcmsSet.R index e7d869e17..9d69e920e 100644 --- a/R/methods-xcmsSet.R +++ b/R/methods-xcmsSet.R @@ -1079,7 +1079,7 @@ setMethod("plotrt", "xcmsSet", function(object, col = NULL, ty = NULL, leg = TRU ############################################################ ## fillPeaks.chrom ## New version using BiocParallel instead of nSlaves and manual setup. -setMethod("fillPeaks.chrom", "xcmsSet", function(object, nSlaves = NULL, +setMethod("fillPeaks.chrom", "xcmsSet", function(object, nSlaves = 0, expand.mz = 1,expand.rt = 1, BPPARAM = bpparam()) { ## development mockup: @@ -1092,10 +1092,13 @@ setMethod("fillPeaks.chrom", "xcmsSet", function(object, nSlaves = NULL, attach(pkgEnv) } - if (!is.null(nSlaves)) - warning("Use of argument 'nSlaves' is deprecated!", - " Please use 'BPPARAM' instead.") - + if (!is.null(nSlaves)) { + if (nSlaves > 0) { + message("Use of argument 'nSlaves' is deprecated,", + " please use 'BPPARAM' instead.") + options(mc.cores = nSlaves) + } + } peakmat <- peaks(object) groupmat <- groups(object) if (length(groupmat) == 0) diff --git a/inst/NEWS b/inst/NEWS index b81a406ab..498b193d6 100644 --- a/inst/NEWS +++ b/inst/NEWS @@ -1,3 +1,16 @@ +CHANGES IN VERSION 1.51.11 +-------------------------- + +NEW FEATURES: +- Parameter "filled" for featureValues (issue #157). +- Parameters "rt" and "mz" in chromPeaks method allowing to extract + chromatographic peaks from the specified ranges (issue #156). + +BUG FIXES: +- Fixed possible memory problem in obiwarp (issue #159). +- Update getPeaks to use non-deprecated API (issue #163). + + CHANGES IN VERSION 1.51.10 -------------------------- diff --git a/inst/unitTests/runit.XCMSnExp.R b/inst/unitTests/runit.XCMSnExp.R index 74feffb32..e9e1fe1cb 100644 --- a/inst/unitTests/runit.XCMSnExp.R +++ b/inst/unitTests/runit.XCMSnExp.R @@ -142,6 +142,44 @@ test_XCMSnExp_class_accessors <- function() { tmp <- do.call(rbind, tmp) rownames(tmp) <- NULL checkEquals(tmp, chromPeaks(xod)) + ## chromPeaks with rt + all_pks <- chromPeaks(xod_x) + pks <- chromPeaks(xod_x, rt = c(2000, 2600), type = "within") + checkTrue(nrow(pks) < nrow(all_pks)) + checkTrue(all(pks[, "rtmin"] >= 2000 & pks[, "rtmax"] <= 2600)) + pks <- chromPeaks(xod_x, rt = c(2000, 2600), bySample = TRUE, + type = "within") + checkTrue(nrow(pks[[2]]) == 0) + pks <- chromPeaks(xod_x, rt = c(2000, 2600), type = "any") + checkTrue(all(pks[, "rtmax"] >= 2000 & pks[, "rtmin"] <= 2600)) + pks <- chromPeaks(xod_x, rt = c(2000, 2200)) + checkTrue(nrow(pks) == 0) + pks <- chromPeaks(xod_x, rt = c(2000, 2200), bySample = TRUE) + checkTrue(all(lengths(pks) == 0)) + ## chromPeaks with mz + pks <- chromPeaks(xod_x, mz = c(280, 281), type = "within") + checkTrue(all(pks[, "mzmin"] >= 280 & pks[, "mzmax"] <= 281)) + pks <- chromPeaks(xod_x, mz = c(280, 281), bySample = TRUE, type = "within") + checkTrue(nrow(pks[[1]]) == 0) + checkTrue(nrow(pks[[3]]) == 0) + checkTrue(nrow(pks[[2]]) == 1) + pks <- chromPeaks(xod_x, mz = c(280, 300), bySample = FALSE, type = "within") + checkTrue(all(pks[, "mzmin"] >= 280 & pks[, "mzmax"] <= 300)) + pks <- chromPeaks(xod_x, mz = c(280, 300), bySample = FALSE, type = "any") + checkTrue(all(pks[, "mzmax"] >= 280 & pks[, "mzmin"] <= 300)) + pks <- chromPeaks(xod_x, mz = c(200, 210), bySample = FALSE) + checkTrue(nrow(pks) == 0) + pks <- chromPeaks(xod_x, mz = c(200, 210), bySample = TRUE) + checkTrue(all(lengths(pks) == 0)) + ## chromPeaks with both + pks <- chromPeaks(xod_x, mz = c(280, 300), rt = c(3000, 3300), + type = "within") + checkTrue(all(pks[, "mzmin"] >= 280 & pks[, "mzmax"] <= 300)) + checkTrue(all(pks[, "rtmin"] >= 3000 & pks[, "rtmax"] <= 3300)) + pks <- chromPeaks(xod_x, mz = c(280, 300), rt = c(3000, 3300), + type = "any") + checkTrue(all(pks[, "mzmax"] >= 280 & pks[, "mzmin"] <= 300)) + checkTrue(all(pks[, "rtmax"] >= 3000 & pks[, "rtmin"] <= 3300)) ## Wrong assignments. pks <- xs_2@peaks pks[1, "sample"] <- 40 diff --git a/inst/unitTests/runit.fillChromPeaks.R b/inst/unitTests/runit.fillChromPeaks.R index c20ab5559..0a9527d28 100644 --- a/inst/unitTests/runit.fillChromPeaks.R +++ b/inst/unitTests/runit.fillChromPeaks.R @@ -6,6 +6,9 @@ test_fillChromPeaks <- function() { ph <- processHistory(res, type = xcms:::.PROCSTEP.PEAK.FILLING) checkTrue(length(ph) == 1) checkEquals(ph[[1]]@param, FillChromPeaksParam()) + ## Check parameter filled in featureValues (issue #157) + checkEquals(featureValues(res, filled = FALSE), featureValues(xod_xg)) + ## Check if the signal corresponds to what we expect for some peaks. fp <- chromPeaks(res) fp <- fp[fp[, "is_filled"] == 1, ] diff --git a/inst/unitTests/runit.fillPeaks.R b/inst/unitTests/runit.fillPeaks.R index 7d574b2b8..2c14b01bf 100644 --- a/inst/unitTests/runit.fillPeaks.R +++ b/inst/unitTests/runit.fillPeaks.R @@ -42,6 +42,87 @@ test.fillPeaksColumns <- function() { } +test.getPeaks_implementation <- function() { + ## Compare the old and new getPeaks implementations. + xs_m <- xcmsSet(faahko_3_files[1]) + + pks_range <- peaks(xs_m)[1:200, ] + ## Extend the range + pks_range[, "mzmin"] <- pks_range[, "mzmin"] - 0.05 + pks_range[, "mzmax"] <- pks_range[, "mzmax"] + 0.05 + suppressWarnings( + pks_o <- xcms:::.getPeaks_orig(faahko_xr_1, peakrange = pks_range) + ) + pks_n <- xcms:::.getPeaks_new(faahko_xr_1, peakrange = pks_range) + checkEquals(pks_o, pks_n) + + pks_tmp <- pks_o + ## Force it to use different step. + suppressWarnings( + pks_o <- xcms:::.getPeaks_orig(faahko_xr_1, peakrange = pks_range, step = 0.3) + ) + pks_n <- xcms:::.getPeaks_new(faahko_xr_1, peakrange = pks_range, step = 0.3) + checkEquals(pks_o, pks_n) + checkTrue(sum(pks_o[, "into"] != pks_tmp[, "into"]) > 0) + + ## Change profile generation settings. + tmp <- deepCopy(faahko_xr_1) + tmp@profmethod <- "binlin" + suppressWarnings( + pks_o <- xcms:::.getPeaks_orig(tmp, peakrange = pks_range, step = 0.2) + ) + pks_n <- xcms:::.getPeaks_new(tmp, peakrange = pks_range, step = 0.2) + ## Can not expect identical values because of differences in binlin + ## See issues #46 and #49. + checkTrue(cor(pks_o[, "into"], pks_n[, "into"]) > 0.999) + checkTrue(sum(pks_o[, "into"] != pks_tmp[, "into"]) > 0) + pks_tmp <- pks_o + + ## Change profile generation settings. + tmp@profmethod <- "binlinbase" + suppressWarnings( + pks_o <- xcms:::.getPeaks_orig(tmp, peakrange = pks_range, step = 0.2) + ) + pks_n <- xcms:::.getPeaks_new(tmp, peakrange = pks_range, step = 0.2) + checkEquals(pks_o, pks_n) + checkTrue(sum(pks_o[, "into"] != pks_tmp[, "into"]) > 0) + pks_tmp <- pks_o + + tmp@profmethod <- "intlin" + suppressWarnings( + pks_o <- xcms:::.getPeaks_orig(tmp, peakrange = pks_range, step = 0.2) + ) + pks_n <- xcms:::.getPeaks_new(tmp, peakrange = pks_range, step = 0.2) + checkEquals(pks_o, pks_n) + checkTrue(sum(pks_o[, "into"] != pks_tmp[, "into"]) > 0) + } + +## Compare the results we get when running the old and new fillPeaks. +test.fillPeaks_old_vs_new <- function() { + xsg <- group(faahko, minfrac = 1) + + register(SerialParam()) + res_n <- fillPeaks(xsg) + useOriginalCode(TRUE) + res_o <- fillPeaks(xsg) + useOriginalCode(FALSE) + pks_n <- peaks(res_n)[res_n@filled, ] + pks_o <- peaks(res_o)[res_o@filled, ] + checkTrue(cor(pks_o[pks_o[, "sample"] == 7, "into"], + pks_n[pks_n[, "sample"] == 7, "into"]) > 0.999) + ## plot(pks_n[, "into"], pks_o[, "into"]) + + profinfo(xsg) <- list(method = "binlin", step = 0.2) + res_n <- fillPeaks(xsg) + useOriginalCode(TRUE) + res_o <- fillPeaks(xsg) + useOriginalCode(FALSE) + pks_n <- peaks(res_n)[res_n@filled, ] + pks_o <- peaks(res_o)[res_o@filled, ] + checkTrue(cor(pks_o[pks_o[, "sample"] == 7, "into"], + pks_n[pks_n[, "sample"] == 7, "into"]) > 0.999) +} + ## testFilledFlagMSW <- function() { diff --git a/man/XCMSnExp-class.Rd b/man/XCMSnExp-class.Rd index c290eee52..7cdff0bfb 100644 --- a/man/XCMSnExp-class.Rd +++ b/man/XCMSnExp-class.Rd @@ -108,7 +108,8 @@ processHistoryTypes() \S4method{featureDefinitions}{XCMSnExp}(object) <- value -\S4method{chromPeaks}{XCMSnExp}(object, bySample = FALSE) +\S4method{chromPeaks}{XCMSnExp}(object, bySample = FALSE, rt = numeric(), + mz = numeric(), ppm = 10, type = "any") \S4method{chromPeaks}{XCMSnExp}(object) <- value @@ -191,16 +192,32 @@ specifying the index of the files/samples for which the \item{bySample}{logical(1) specifying whether results should be grouped by sample.} +\item{rt}{optional \code{numeric(2)} defining the retention time range for +which chromatographic peaks should be returned.} + +\item{mz}{optional \code{numeric(2)} defining the mz range for which +chromatographic peaks should be returned.} + +\item{ppm}{optional \code{numeric(1)} specifying the ppm by which the +\code{mz} range should be extended. For a value of \code{ppm = 10}, all +peaks within \code{mz[1] - ppm / 1e6} and \code{mz[2] + ppm / 1e6} are +returned.} + +\item{type}{For \code{processHistory}: restrict returned +\code{\link{ProcessHistory}} objects to analysis steps of a certain +type. Use the \code{processHistoryTypes} to list all supported values. +For \code{chromPeaks}: \code{character} specifying which peaks to return +if \code{rt} or \code{mz} are defined. For \code{type = "any"} all +chromatographic peaks that \emph{overlap} the range defined by the +\code{mz} or by the \code{rt}. For \code{type = "within"} only peaks +completely within the range(s) are returned.} + \item{adjusted}{logical(1) whether adjusted or raw (i.e. the original retention times reported in the files) should be returned.} \item{BPPARAM}{Parameter class for parallel processing. See \code{\link[BiocParallel]{bpparam}}.} -\item{type}{For \code{processHistory}: restrict returned -\code{\link{ProcessHistory}} objects to analysis steps of a certain type. Use -the \code{processHistoryTypes} to list all supported values.} - \item{keepAdjRtime}{For \code{dropFeatureDefinitions,XCMSnExp}: \code{logical(1)} defining whether eventually present retention time adjustment should not be dropped. By default dropping feature definitions @@ -210,8 +227,8 @@ drops retention time adjustment results too.} \code{numeric(1)} defining the number of peak grouping related process history steps to remove. By default \code{dropLastN = -1}, dropping the chromatographic peaks removes all process history steps related to peak -grouping. Setting e.g. \code{dropLastN = 1} will only remove the most recent -peak grouping related process history step.} +grouping. Setting e.g. \code{dropLastN = 1} will only remove the most +recent peak grouping related process history step.} \item{param}{A \code{\link{CentWaveParam}}, \code{\link{MatchedFilterParam}}, \code{\link{MassifquantParam}}, \code{\link{MSWParam}} or @@ -229,10 +246,10 @@ For \code{profMat}: a \code{list} with a the profile matrix help and information about the profile matrix. For \code{adjustedRtime}: if \code{bySample = FALSE} a \code{numeric} -vector with the adjusted retention for each spectrum of all files/samples -within the object. If \code{bySample = TRUE } a \code{list} (length equal to -the number of samples) with adjusted retention times grouped by sample. -Returns \code{NULL} if no adjusted retention times are present. + vector with the adjusted retention for each spectrum of all files/samples + within the object. If \code{bySample = TRUE } a \code{list} (length equal + to the number of samples) with adjusted retention times grouped by + sample. Returns \code{NULL} if no adjusted retention times are present. For \code{featureDefinitions}: a \code{DataFrame} with peak grouping information, each row corresponding to one mz-rt feature (grouped peaks @@ -245,49 +262,50 @@ For \code{featureDefinitions}: a \code{DataFrame} with peak grouping \code{chromPeaks} method that belong to that feature group. The method returns \code{NULL} if no feature definitions are present. -For \code{chromPeaks}: if \code{bySample = FALSE} a \code{matrix} with -at least the following columns: -\code{"mz"} (intensity-weighted mean of mz values of the peak across scans/ -retention times), -\code{"mzmin"} (minimal mz value), -\code{"mzmax"} (maximal mz value), -\code{"rt"} (retention time for the peak apex), -\code{"rtmin"} (minimal retention time), -\code{"rtmax"} (maximal retention time), -\code{"into"} (integrated, original, intensity of the peak), -\code{"maxo"} (maximum intentity of the peak), -\code{"sample"} (sample index in which the peak was identified) and -\code{"is_filled"} defining whether the chromatographic peak was identified -by the peak picking algorithm (\code{0}) or was added by the -\code{fillChromPeaks} method (\code{1}). -Depending on the employed peak detection algorithm and the -\code{verboseColumns} parameter of it additional columns might be returned. -For \code{bySample = TRUE} the chronatographic peaks are returned as a -\code{list} of matrices, each containing the chromatographic peaks of a -specific sample. For samples in which no peaks were detected a matrix -with 0 rows is returned. - -For \code{rtime}: if \code{bySample = FALSE} a numeric vector with the -retention times of each scan, if \code{bySample = TRUE} a \code{list} of -numeric vectors with the retention times per sample. +For \code{chromPeaks}: if \code{bySample = FALSE} a \code{matrix} + with at least the following columns: + \code{"mz"} (intensity-weighted mean of mz values of the peak across + scans/retention times), + \code{"mzmin"} (minimal mz value), + \code{"mzmax"} (maximal mz value), + \code{"rt"} (retention time for the peak apex), + \code{"rtmin"} (minimal retention time), + \code{"rtmax"} (maximal retention time), + \code{"into"} (integrated, original, intensity of the peak), + \code{"maxo"} (maximum intentity of the peak), + \code{"sample"} (sample index in which the peak was identified) and + \code{"is_filled"} defining whether the chromatographic peak was + identified by the peak picking algorithm (\code{0}) or was added by the + \code{fillChromPeaks} method (\code{1}). + Depending on the employed peak detection algorithm and the + \code{verboseColumns} parameter of it additional columns might be + returned. For \code{bySample = TRUE} the chronatographic peaks are + returned as a \code{list} of matrices, each containing the + chromatographic peaks of a specific sample. For samples in which no + peaks were detected a matrix with 0 rows is returned. + +For \code{rtime}: if \code{bySample = FALSE} a numeric vector with + the retention times of each scan, if \code{bySample = TRUE} a + \code{list} of numeric vectors with the retention times per sample. For \code{mz}: if \code{bySample = FALSE} a \code{list} with the mz -values (numeric vectors) of each scan. If \code{bySample = TRUE} a -\code{list} with the mz values per sample. + values (numeric vectors) of each scan. If \code{bySample = TRUE} a + \code{list} with the mz values per sample. For \code{intensity}: if \code{bySample = FALSE} a \code{list} with -the intensity values (numeric vectors) of each scan. If -\code{bySample = TRUE} a \code{list} with the intensity values per sample. + the intensity values (numeric vectors) of each scan. If + \code{bySample = TRUE} a \code{list} with the intensity values per + sample. For \code{spectra}: if \code{bySample = FALSE} a \code{list} with -\code{\link[MSnbase]{Spectrum}} objects. If \code{bySample = TRUE} the result -is grouped by sample, i.e. as a \code{list} of \code{lists}, each element in -the \emph{outer} \code{list} being the \code{list} of spectra of the specific -file. + \code{\link[MSnbase]{Spectrum}} objects. If \code{bySample = TRUE} the + result is grouped by sample, i.e. as a \code{list} of \code{lists}, each + element in the \emph{outer} \code{list} being the \code{list} of spectra + of the specific file. For \code{processHistory}: a \code{list} of -\code{\link{ProcessHistory}} objects providing the details of the individual -data processing steps that have been performed. + \code{\link{ProcessHistory}} objects providing the details of the + individual data processing steps that have been performed. } \description{ The \code{MsFeatureData} class is designed to encapsule all @@ -330,104 +348,111 @@ the maximum intensity measured for the specific scan and m/z values. See methods. \code{hasAdjustedRtime}: whether the object provides adjusted -retention times. + retention times. \code{hasFeatures}: whether the object contains correspondence -results (i.e. features). + results (i.e. features). \code{hasChromPeaks}: whether the object contains peak -detection results. + detection results. \code{adjustedRtime},\code{adjustedRtime<-}: -extract/set adjusted retention times. \code{adjustedRtime<-} should not be -called manually, it is called internally by the \code{\link{adjustRtime}} -methods. For \code{XCMSnExp} objects, \code{adjustedRtime<-} does also apply -the retention time adjustment to the chromatographic peaks in the object. -The \code{bySample} parameter allows to specify whether the adjusted -retention time should be grouped by sample (file). + extract/set adjusted retention times. \code{adjustedRtime<-} should not + be called manually, it is called internally by the + \code{\link{adjustRtime}} methods. For \code{XCMSnExp} objects, + \code{adjustedRtime<-} does also apply the retention time adjustment to + the chromatographic peaks in the object. The \code{bySample} parameter + allows to specify whether the adjusted retention time should be grouped + by sample (file). \code{featureDefinitions}, \code{featureDefinitions<-}: extract or set the correspondence results, i.e. the mz-rt features (peak groups). \code{chromPeaks}, \code{chromPeaks<-}: extract or set -the matrix containing the information on identified chromatographic peaks. -Parameter \code{bySample} allows to specify whether peaks should be -returned ungrouped (default \code{bySample = FALSE}) or grouped by sample ( -\code{bySample = TRUE}). The \code{chromPeaks<-} method for \code{XCMSnExp} -objects removes also all correspondence (peak grouping) and retention time -correction (alignment) results. -See description of the return value for details on the returned matrix. Users -usually don't have to use the \code{chromPeaks<-} method directly as detected -chromatographic peaks are added to the object by the -\code{\link{findChromPeaks}} method. + the matrix containing the information on identified chromatographic + peaks. Parameter \code{bySample} allows to specify whether peaks should + be returned ungrouped (default \code{bySample = FALSE}) or grouped by + sample (\code{bySample = TRUE}). The \code{chromPeaks<-} method for + \code{XCMSnExp} objects removes also all correspondence (peak grouping) + and retention time correction (alignment) results. The optional + arguments \code{rt}, \code{mz} and \code{ppm} allow to extract only + chromatographic peaks overlapping (if \code{type = "any"}) or completely + within (if \code{type = "within"}) the defined retention time and mz + ranges. + See description of the return value for details on the returned matrix. + Users usually don't have to use the \code{chromPeaks<-} method directly + as detected chromatographic peaks are added to the object by the + \code{\link{findChromPeaks}} method. \code{rtime}: extracts the retention time for each -scan. The \code{bySample} parameter allows to return the values grouped -by sample/file and \code{adjusted} whether adjusted or raw retention times -should be returned. By default the method returns adjusted retention times, -if they are available (i.e. if retention times were adjusted using the -\code{\link{adjustRtime}} method). + scan. The \code{bySample} parameter allows to return the values grouped + by sample/file and \code{adjusted} whether adjusted or raw retention + times should be returned. By default the method returns adjusted + retention times, if they are available (i.e. if retention times were + adjusted using the \code{\link{adjustRtime}} method). \code{mz}: extracts the mz values from each scan of -all files within an \code{XCMSnExp} object. These values are extracted from -the original data files and eventual processing steps are applied -\emph{on the fly}. Using the \code{bySample} parameter it is possible to -switch from the default grouping of mz values by spectrum/scan to a grouping -by sample/file. + all files within an \code{XCMSnExp} object. These values are extracted + from the original data files and eventual processing steps are applied + \emph{on the fly}. Using the \code{bySample} parameter it is possible to + switch from the default grouping of mz values by spectrum/scan to a + grouping by sample/file. \code{intensity}: extracts the intensity values from -each scan of all files within an \code{XCMSnExp} object. These values are -extracted from the original data files and eventual processing steps are -applied \emph{on the fly}. Using the \code{bySample} parameter it is possible -to switch from the default grouping of intensity values by spectrum/scan to -a grouping by sample/file. + each scan of all files within an \code{XCMSnExp} object. These values are + extracted from the original data files and eventual processing steps are + applied \emph{on the fly}. Using the \code{bySample} parameter it is + possible to switch from the default grouping of intensity values by + spectrum/scan to a grouping by sample/file. \code{spectra}: extracts the -\code{\link[MSnbase]{Spectrum}} objects containing all data from -\code{object}. The values are extracted from the original data files and -eventual processing steps are applied \emph{on the fly}. By setting -\code{bySample = TRUE}, the spectra are returned grouped by sample/file. If -the \code{XCMSnExp} object contains adjusted retention times, these are -returned by default in the \code{Spectrum} objects (can be overwritten -by setting \code{adjusted = FALSE}). + \code{\link[MSnbase]{Spectrum}} objects containing all data from + \code{object}. The values are extracted from the original data files and + eventual processing steps are applied \emph{on the fly}. By setting + \code{bySample = TRUE}, the spectra are returned grouped by sample/file. + If the \code{XCMSnExp} object contains adjusted retention times, these + are returned by default in the \code{Spectrum} objects (can be + overwritten by setting \code{adjusted = FALSE}). \code{processHistory}: returns a \code{list} with -\code{\link{ProcessHistory}} objects (or objects inheriting from this base -class) representing the individual processing steps that have been performed, -eventually along with their settings (\code{Param} parameter class). Optional -arguments \code{fileIndex} and \code{type} allow to restrict to process steps -of a certain type or performed on a certain file. + \code{\link{ProcessHistory}} objects (or objects inheriting from this + base class) representing the individual processing steps that have been + performed, eventually along with their settings (\code{Param} parameter + class). Optional arguments \code{fileIndex} and \code{type} allow to + restrict to process steps of a certain type or performed on a certain + file. \code{dropChromPeaks}: drops any identified chromatographic -peaks and returns the object without that information. Note that for -\code{XCMSnExp} objects the method drops all results from a correspondence -(peak grouping) or alignment (retention time adjustment) too. -For \code{XCMSnExp} objects the method drops also any related process -history steps. + peaks and returns the object without that information. Note that for + \code{XCMSnExp} objects the method drops all results from a + correspondence (peak grouping) or alignment (retention time adjustment) + too. For \code{XCMSnExp} objects the method drops also any related + process history steps. \code{dropFeatureDefinitions}: drops the results from a -correspondence (peak grouping) analysis, i.e. the definition of the mz-rt -features and returns the object without that information. Note that for -\code{XCMSnExp} objects the method will also drop retention time adjustment -results, if these were performed after the last peak grouping (i.e. which -base on the results from the peak grouping that are going to be removed). -For \code{XCMSnExp} objects also all related process history steps are -removed. Also eventually filled in peaks (by \code{\link{fillChromPeaks}}) -will be removed too. + correspondence (peak grouping) analysis, i.e. the definition of the mz-rt + features and returns the object without that information. Note that for + \code{XCMSnExp} objects the method will also drop retention time + adjustment results, if these were performed after the last peak grouping + (i.e. which base on the results from the peak grouping that are going to + be removed). + For \code{XCMSnExp} objects also all related process history steps are + removed. Also eventually filled in peaks (by \code{\link{fillChromPeaks}} + ) will be removed too. \code{dropAdjustedRtime}: drops any retention time -adjustment information and returns the object without adjusted retention -time. For \code{XCMSnExp} object this also reverts the retention times -reported for the chromatographic peaks in the peak matrix to the original, -raw, ones (after chromatographic peak detection). Note that for -\code{XCMSnExp} objects the method drops also all peak grouping results -if these were performed \emph{after} the retention time adjustment. -For \code{XCMSnExp} objects the method drops also any related process history -steps. + adjustment information and returns the object without adjusted retention + time. For \code{XCMSnExp} object this also reverts the retention times + reported for the chromatographic peaks in the peak matrix to the + original, raw, ones (after chromatographic peak detection). Note that + for \code{XCMSnExp} objects the method drops also all peak grouping + results if these were performed \emph{after} the retention time + adjustment. For \code{XCMSnExp} objects the method drops also any + related process history steps. \code{dropFilledChromPeaks}: drops any filled-in chromatographic -peaks (filled in by the \code{\link{fillChromPeaks}} method) and all related -process history steps. + peaks (filled in by the \code{\link{fillChromPeaks}} method) and all + related process history steps. } \section{Slots}{ @@ -528,7 +553,7 @@ head(peaks(xs)) \code{\link{adjustRtime}} for retention time adjustment methods. \code{\link{fillChromPeaks}} for the method to fill-in eventually -missing chromatographic peaks for a feature in some samples. + missing chromatographic peaks for a feature in some samples. } \author{ Johannes Rainer diff --git a/man/XCMSnExp-filter-methods.Rd b/man/XCMSnExp-filter-methods.Rd index 24b813162..7b0615136 100644 --- a/man/XCMSnExp-filter-methods.Rd +++ b/man/XCMSnExp-filter-methods.Rd @@ -19,21 +19,21 @@ \item{object}{A \code{\link{XCMSnExp}} object.} \item{file}{For \code{filterFile}: \code{integer} defining the file index -within the object to subset the object by file or \code{character} specifying -the file names to sub set. The indices are expected to be increasingly -ordered, if not they are ordered internally.} +within the object to subset the object by file or \code{character} +specifying the file names to sub set. The indices are expected to be +increasingly ordered, if not they are ordered internally.} \item{keepAdjustedRtime}{For \code{filterFile}: \code{logical(1)} defining whether the adjusted retention times should be kept, even if features are -being removed (and the retention time correction being potentially performed -on these features).} +being removed (and the retention time correction being potentially +performed on these features).} \item{mz}{For \code{filterMz}: \code{numeric(2)} defining the lower and upper mz value for the filtering.} \item{msLevel.}{For \code{filterMz}, \code{filterRt}, \code{numeric(1)} -defining the MS level(s) to which operations should be applied or to which -the object should be subsetted.} +defining the MS level(s) to which operations should be applied or to +which the object should be subsetted.} \item{...}{Optional additional arguments.} @@ -41,8 +41,8 @@ the object should be subsetted.} window (lower and upper bound) for the filtering.} \item{adjusted}{For \code{filterRt}: \code{logical} indicating whether the -object should be filtered by original (\code{adjusted = FALSE}) or adjusted -retention times (\code{adjusted = TRUE}). +object should be filtered by original (\code{adjusted = FALSE}) or +adjusted retention times (\code{adjusted = TRUE}). For \code{spectra}: whether the retention times in the individual \code{Spectrum} objects should be the adjusted or raw retention times.} } @@ -51,44 +51,44 @@ All methods return an \code{\link{XCMSnExp}} object. } \description{ The methods listed on this page allow to filter and subset -\code{\link{XCMSnExp}} objects. Most of them are inherited from the -\code{\link[MSnbase]{OnDiskMSnExp}} object and have been adapted for -\code{\link{XCMSnExp}} to enable subsetting also on the preprocessing -results. - -\code{filterFile}: allows to reduce the -\code{\link{XCMSnExp}} to data from only certain files. Identified -chromatographic peaks for these files are retained while all eventually -present features (peak grouping information) are dropped. By default also -adjusted retention times are removed. This can be overwritten by setting -\code{keepAdjustedRtime = TRUE}, but users should use this option with -caution. + \code{\link{XCMSnExp}} objects. Most of them are inherited from the + \code{\link[MSnbase]{OnDiskMSnExp}} object and have been adapted for + \code{\link{XCMSnExp}} to enable subsetting also on the preprocessing + results. + + \code{filterFile}: allows to reduce the + \code{\link{XCMSnExp}} to data from only certain files. Identified + chromatographic peaks for these files are retained while all eventually + present features (peak grouping information) are dropped. By default also + adjusted retention times are removed. This can be overwritten by setting + \code{keepAdjustedRtime = TRUE}, but users should use this option with + caution. \code{filterMz}: filters the data set based on the -provided mz value range. All chromatographic peaks and features (grouped -peaks) falling completely within the provided mz value range are retained -(if their minimal mz value is \code{>= mz[1]} and the maximal mz value -\code{<= mz[2]}. Adjusted retention times, if present, are not altered by -the filtering. + provided mz value range. All chromatographic peaks and features (grouped + peaks) falling completely within the provided mz value range are retained + (if their minimal mz value is \code{>= mz[1]} and the maximal mz value + \code{<= mz[2]}. Adjusted retention times, if present, are not altered by + the filtering. \code{filterRt}: filters the data set based on the -provided retention time range. All chromatographic peaks and features -(grouped peaks) the specified retention time window are retained (i.e. if -the retention time corresponding to the peak's apex is within the specified -rt range). If retention time correction has been performed, the method will -by default filter the object by adjusted retention times. -The argument \code{adjusted} allows to specify manually whether filtering -should be performed by raw or adjusted retention times. Filtering by -retention time does not drop any preprocessing results. -The method returns an empty object if no spectrum or feature is within the -specified retention time range. + provided retention time range. All chromatographic peaks and features + (grouped peaks) the specified retention time window are retained (i.e. if + the retention time corresponding to the peak's apex is within the + specified rt range). If retention time correction has been performed, + the method will by default filter the object by adjusted retention times. + The argument \code{adjusted} allows to specify manually whether filtering + should be performed by raw or adjusted retention times. Filtering by + retention time does not drop any preprocessing results. + The method returns an empty object if no spectrum or feature is within + the specified retention time range. } \note{ The \code{filterFile} method removes also process history steps not -related to the files to which the object should be sub-setted and updates -the \code{fileIndex} attribute accordingly. Also, the method does not allow -arbitrary ordering of the files or re-ordering of the files within the -object. + related to the files to which the object should be sub-setted and updates + the \code{fileIndex} attribute accordingly. Also, the method does not + allow arbitrary ordering of the files or re-ordering of the files within + the object. } \examples{ diff --git a/man/XCMSnExp-inherited-methods.Rd b/man/XCMSnExp-inherited-methods.Rd index ee833ed3a..9da8e200e 100644 --- a/man/XCMSnExp-inherited-methods.Rd +++ b/man/XCMSnExp-inherited-methods.Rd @@ -71,8 +71,8 @@ object by file.} normalization method. See \code{\link[MSnbase]{normalize}} for details. For \code{pickPeaks}: \code{character(1)} defining the method. See \code{\link[MSnbase]{pickPeaks}} for options. For \code{smooth}: -\code{character(1)} defining the method. See \code{\link[MSnbase]{smooth}} -for options and details.} +\code{character(1)} defining the method. See +\code{\link[MSnbase]{smooth}} for options and details.} \item{...}{Optional additional arguments.} @@ -94,56 +94,57 @@ For all methods: a \code{XCMSnExp} object. } \description{ The methods listed on this page are \code{\link{XCMSnExp}} -methods inherited from its parent, the \code{\link[MSnbase]{OnDiskMSnExp}} -class from the \code{MSnbase} package, that alter the raw data or are related -to data subsetting. Thus calling any of these methods causes all \code{xcms} -pre-processing results to be removed from the \code{\link{XCMSnExp}} object -to ensure its data integrity. + methods inherited from its parent, the + \code{\link[MSnbase]{OnDiskMSnExp}} class from the \code{MSnbase} + package, that alter the raw data or are related to data subsetting. Thus + calling any of these methods causes all \code{xcms} pre-processing + results to be removed from the \code{\link{XCMSnExp}} object to ensure + its data integrity. -The \code{[} method allows to subset a \code{\link{XCMSnExp}} object by -spectra. For more details and examples see the documentation for -\code{\link[MSnbase]{OnDiskMSnExp}}. + The \code{[} method allows to subset a \code{\link{XCMSnExp}} object by + spectra. For more details and examples see the documentation for + \code{\link[MSnbase]{OnDiskMSnExp}}. \code{bin}: allows to \emph{bin} spectra. See -\code{\link[MSnbase]{bin}} documentation for more details and examples. + \code{\link[MSnbase]{bin}} documentation for more details and examples. \code{clean}: removes unused \code{0} intensity data -points. See \code{\link[MSnbase]{clean}} documentation for details and -examples. + points. See \code{\link[MSnbase]{clean}} documentation for details and + examples. \code{filterMsLevel}: reduces the \code{\link{XCMSnExp}} -object to spectra of the specified MS level(s). See -\code{\link[MSnbase]{filterMsLevel}} documentation for details and examples. + object to spectra of the specified MS level(s). See + \code{\link[MSnbase]{filterMsLevel}} documentation for details and + examples. \code{filterAcquisitionNum}: filters the -\code{\link{XCMSnExp}} object keeping only spectra with the provided -acquisition numbers. See \code{\link[MSnbase]{filterAcquisitionNum}} for -details and examples. + \code{\link{XCMSnExp}} object keeping only spectra with the provided + acquisition numbers. See \code{\link[MSnbase]{filterAcquisitionNum}} for + details and examples. -The \code{normalize} method performs basic normalization of spectra -intensities. See \code{\link[MSnbase]{normalize}} documentation for details -and examples. +The \code{normalize} method performs basic normalization of + spectra intensities. See \code{\link[MSnbase]{normalize}} documentation + for details and examples. The \code{pickPeaks} method performs peak picking. See -\code{\link[MSnbase]{pickPeaks}} documentation for details and examples. + \code{\link[MSnbase]{pickPeaks}} documentation for details and examples. -The \code{removePeaks} method removes mass peaks (intensities) lower than a -threshold. Note that these peaks refer to \emph{mass} peaks, which are -different to the chromatographic peaks detected and analyzed in a -metabolomics experiment! See \code{\link[MSnbase]{removePeaks}} -documentation for details and examples. +The \code{removePeaks} method removes mass peaks (intensities) + lower than a threshold. Note that these peaks refer to \emph{mass} + peaks, which are different to the chromatographic peaks detected and + analyzed in a metabolomics experiment! See + \code{\link[MSnbase]{removePeaks}} documentation for details and + examples. -The \code{smooth} method smooths spectra. See \code{\link[MSnbase]{smooth}} -documentation for details and examples. +The \code{smooth} method smooths spectra. See + \code{\link[MSnbase]{smooth}} documentation for details and examples. } \seealso{ \code{\link{XCMSnExp-filter}} for methods to filter and subset -\code{XCMSnExp} objects. - -\code{\link{XCMSnExp}} for base class documentation. - -\code{\link[MSnbase]{OnDiskMSnExp}} for the documentation of the -parent class. + \code{XCMSnExp} objects. + \code{\link{XCMSnExp}} for base class documentation. + \code{\link[MSnbase]{OnDiskMSnExp}} for the documentation of the + parent class. } \author{ Johannes Rainer diff --git a/man/XCMSnExp-peak-grouping-results.Rd b/man/XCMSnExp-peak-grouping-results.Rd index 8b05357e6..fcbce04e6 100644 --- a/man/XCMSnExp-peak-grouping-results.Rd +++ b/man/XCMSnExp-peak-grouping-results.Rd @@ -7,7 +7,7 @@ \title{Accessing mz-rt feature data values} \usage{ \S4method{featureValues}{XCMSnExp}(object, method = c("medret", "maxint"), - value = "index", intensity = "into") + value = "index", intensity = "into", filled = TRUE) } \arguments{ \item{object}{A \code{\link{XCMSnExp}} object providing the feature @@ -30,6 +30,11 @@ default) to return the index of the peak in the \code{chromPeaks(objects)} matrix containing the intensity value of the peak that should be used for the conflict resolution if \code{method = "maxint"}.} + +\item{filled}{\code{logical(1)} specifying whether values for filled-in +peaks should be returned or not. If \code{filled = FALSE}, an \code{NA} +is returned in the matrix for the respective peak. See +\code{\link{fillChromPeaks}} for details on peak filling.} } \value{ For \code{featureValues}: a \code{matrix} with diff --git a/man/adjustRtime-obiwarp.Rd b/man/adjustRtime-obiwarp.Rd index 562c37862..375b69ad2 100644 --- a/man/adjustRtime-obiwarp.Rd +++ b/man/adjustRtime-obiwarp.Rd @@ -146,7 +146,7 @@ alignment (for local alignment only).} \item{object}{For \code{adjustRtime}: an \code{\link{XCMSnExp}} object. -For all other methods: a \code{ObiwarpParam} object.} + For all other methods: a \code{ObiwarpParam} object.} \item{param}{A \code{ObiwarpParam} object containing all settings for the alignment method.} @@ -159,15 +159,17 @@ The \code{ObiwarpParam} function returns a specified for obiwarp retention time adjustment and alignment. For \code{adjustRtime,XCMSnExp,ObiwarpParam}: a -\code{\link{XCMSnExp}} object with the results of the retention time -adjustment step. These can be accessed with the \code{\link{adjustedRtime}} -method. Retention time correction does also adjust the retention time of the -identified chromatographic peaks (accessed \emph{via} -\code{\link{chromPeaks}}. Note that retention time correction drops all -previous peak grouping results from the result object. - -For \code{adjustRtime,OnDiskMSnExp,ObiwarpParam}: a \code{numeric} with the -adjusted retention times per spectra (in the same order than \code{rtime}). + \code{\link{XCMSnExp}} object with the results of the retention time + adjustment step. These can be accessed with the + \code{\link{adjustedRtime}} method. Retention time correction does also + adjust the retention time of the identified chromatographic peaks + (accessed \emph{via} \code{\link{chromPeaks}}. Note that retention time + correction drops all previous peak grouping results from the result + object. + + For \code{adjustRtime,OnDiskMSnExp,ObiwarpParam}: a \code{numeric} with + the adjusted retention times per spectra (in the same order than + \code{rtime}). } \description{ This method performs retention time adjustment using the @@ -183,38 +185,38 @@ The \code{ObiwarpParam} class allows to specify all \code{ObiwarpParam} constructor. \code{binSize},\code{binSize<-}: getter and setter -for the \code{binSize} slot of the object. + for the \code{binSize} slot of the object. \code{centerSample},\code{centerSample<-}: getter and setter -for the \code{centerSample} slot of the object. + for the \code{centerSample} slot of the object. \code{response},\code{response<-}: getter and setter -for the \code{response} slot of the object. + for the \code{response} slot of the object. \code{distFun},\code{distFun<-}: getter and setter -for the \code{distFun} slot of the object. + for the \code{distFun} slot of the object. \code{gapInit},\code{gapInit<-}: getter and setter -for the \code{gapInit} slot of the object. + for the \code{gapInit} slot of the object. \code{gapExtend},\code{gapExtend<-}: getter and setter -for the \code{gapExtend} slot of the object. + for the \code{gapExtend} slot of the object. \code{factorDiag},\code{factorDiag<-}: getter and setter -for the \code{factorDiag} slot of the object. + for the \code{factorDiag} slot of the object. \code{factorGap},\code{factorGap<-}: getter and setter -for the \code{factorGap} slot of the object. + for the \code{factorGap} slot of the object. \code{localAlignment},\code{localAlignment<-}: getter and setter -for the \code{localAlignment} slot of the object. + for the \code{localAlignment} slot of the object. \code{initPenalty},\code{initPenalty<-}: getter and setter -for the \code{initPenalty} slot of the object. + for the \code{initPenalty} slot of the object. \code{adjustRtime,XCMSnExp,ObiwarpParam}: -performs retention time correction/alignment based on the total mz-rt data -using the \emph{obiwarp} method. + performs retention time correction/alignment based on the total mz-rt + data using the \emph{obiwarp} method. } \section{Slots}{ @@ -231,8 +233,8 @@ These methods and classes are part of the updated and modernized algorithm can be passed with a \code{ObiwarpParam} object. Calling \code{adjustRtime} on an \code{XCMSnExp} object will cause -all peak grouping (correspondence) results and any previous retention time -adjustment results to be dropped. + all peak grouping (correspondence) results and any previous retention + time adjustment results to be dropped. } \examples{ library(faahKO) @@ -286,7 +288,7 @@ ESI-LC-MS Proteomic Data Sets by Ordered Bijective Interpolated Warping" \code{\link{plotAdjustedRtime}} for visualization of alignment results. \code{\link{XCMSnExp}} for the object containing the results of -the alignment. + the alignment. Other retention time correction methods: \code{\link{adjustRtime-peakGroups}}, \code{\link{adjustRtime}} diff --git a/man/adjustRtime-peakGroups.Rd b/man/adjustRtime-peakGroups.Rd index 1eba6bd10..27492dd68 100644 --- a/man/adjustRtime-peakGroups.Rd +++ b/man/adjustRtime-peakGroups.Rd @@ -102,11 +102,11 @@ represents a sample, each row a feature/peak group. Such a matrix is for example returned by the \code{\link{adjustRtimePeakGroups}} method.} \item{object}{For \code{adjustRtime}: an \code{\link{XCMSnExp}} object -containing the results from a previous chromatographic peak detection (see -\code{\link{findChromPeaks}}) and alignment analysis (see -\code{\link{groupChromPeaks}}). + containing the results from a previous chromatographic peak detection + (see \code{\link{findChromPeaks}}) and alignment analysis (see + \code{\link{groupChromPeaks}}). -For all other methods: a \code{PeakGroupsParam} object.} + For all other methods: a \code{PeakGroupsParam} object.} \item{param}{A \code{PeakGroupsParam} object containing all settings for the retention time correction method..} @@ -126,11 +126,12 @@ For \code{adjustRtimePeakGroups}: a \code{matrix}, rows being by the median retention time across columns. For \code{adjustRtime}: a \code{\link{XCMSnExp}} object with the -results of the retention time adjustment step. These can be accessed with the -\code{\link{adjustedRtime}} method. Retention time correction does also adjust -the retention time of the identified chromatographic peaks (accessed -\emph{via} \code{\link{chromPeaks}}. Note that retention time correction -drops all previous alignment results from the result object. + results of the retention time adjustment step. These can be accessed + with the \code{\link{adjustedRtime}} method. Retention time correction + does also adjust the retention time of the identified chromatographic + peaks (accessed \emph{via} \code{\link{chromPeaks}}. Note that retention + time correction drops all previous alignment results from the result + object. } \description{ This method performs retention time adjustment based on the @@ -152,26 +153,26 @@ The \code{PeakGroupsParam} class allows to specify all selected for alignment/retention time correction. \code{minFraction},\code{minFraction<-}: getter and setter -for the \code{minFraction} slot of the object. + for the \code{minFraction} slot of the object. \code{extraPeaks},\code{extraPeaks<-}: getter and setter -for the \code{extraPeaks} slot of the object. + for the \code{extraPeaks} slot of the object. \code{smooth},\code{smooth<-}: getter and setter -for the \code{smooth} slot of the object. + for the \code{smooth} slot of the object. \code{span},\code{span<-}: getter and setter -for the \code{span} slot of the object. + for the \code{span} slot of the object. \code{family},\code{family<-}: getter and setter -for the \code{family} slot of the object. + for the \code{family} slot of the object. \code{peakGroupsMatrix},\code{peakGroupsMatrix<-}: getter and setter for the \code{peakGroupsMatrix} slot of the object. \code{adjustRtime,XCMSnExp,PeakGroupsParam}: -performs retention time correction based on the alignment of peak groups -(features) found in all/most samples. + performs retention time correction based on the alignment of peak groups + (features) found in all/most samples. } \section{Slots}{ @@ -197,12 +198,12 @@ These methods and classes are part of the updated and modernized sample alignment, but after a correspondence (peak grouping). This method requires that a correspondence has been performed on the -data (see \code{\link{groupChromPeaks}}). Calling \code{adjustRtime} on an -\code{XCMSnExp} object will cause all peak grouping (correspondence) results -and any previous retention time adjustments to be dropped. -In some instances, the \code{adjustRtime,XCMSnExp,PeakGroupsParam} -re-adjusts adjusted retention times to ensure them being in the same order -than the raw (original) retention times. + data (see \code{\link{groupChromPeaks}}). Calling \code{adjustRtime} on + an \code{XCMSnExp} object will cause all peak grouping (correspondence) + results and any previous retention time adjustments to be dropped. + In some instances, the \code{adjustRtime,XCMSnExp,PeakGroupsParam} + re-adjusts adjusted retention times to ensure them being in the same + order than the raw (original) retention times. } \examples{ ############################## @@ -281,7 +282,7 @@ The \code{\link{do_adjustRtime_peakGroups}} core \code{\link{plotAdjustedRtime}} for visualization of alignment results. \code{\link{XCMSnExp}} for the object containing the results of -the alignment. + the alignment. Other retention time correction methods: \code{\link{adjustRtime-obiwarp}}, \code{\link{adjustRtime}} diff --git a/man/extractChromatograms-method.Rd b/man/extractChromatograms-method.Rd index 1bfd6b916..e7cc1f047 100644 --- a/man/extractChromatograms-method.Rd +++ b/man/extractChromatograms-method.Rd @@ -15,53 +15,56 @@ } \arguments{ \item{object}{Either a \code{\link[MSnbase]{OnDiskMSnExp}} or -\code{\link{XCMSnExp}} object from which the chromatograms should be extracted.} +\code{\link{XCMSnExp}} object from which the chromatograms should be +extracted.} \item{rt}{\code{numeric(2)} defining the lower and upper boundary for the -retention time range. If not specified, the full retention time range of the -original data will be used. It is also possible to submit a \code{numeric(1)} -in which case \code{range} is called on it to transform it to a -\code{numeric(2)}.} +retention time range. If not specified, the full retention time range of +the original data will be used. It is also possible to submit a +\code{numeric(1)} in which case \code{range} is called on it to +transform it to a \code{numeric(2)}.} \item{mz}{\code{numeric(2)} defining the lower and upper mz value for the -MS data slice. If not specified, the chromatograms will be calculated on the -full mz range. It is also possible to submit a \code{numeric(1)} in which case -\code{range} is called on it to transform it to a \code{numeric(2)}.} +MS data slice. If not specified, the chromatograms will be calculated on +the full mz range. It is also possible to submit a \code{numeric(1)} in +which case \code{range} is called on it to transform it to a +\code{numeric(2)}.} \item{aggregationFun}{\code{character} specifying the function to be used to -aggregate intensity values across the mz value range for the same retention -time. Allowed values are \code{"sum"}, \code{"max"}, \code{"mean"} and -\code{"min"}.} +aggregate intensity values across the mz value range for the same +retention time. Allowed values are \code{"sum"}, \code{"max"}, +\code{"mean"} and \code{"min"}.} \item{adjustedRtime}{For \code{extractChromatograms,XCMSnExp}: whether the adjusted (\code{adjustedRtime = TRUE}) or raw retention times -(\code{adjustedRtime = FALSE}) should be used for filtering and returned in -the resulting \code{\link{Chromatogram}} object. Adjusted retention times are -used by default if available.} +(\code{adjustedRtime = FALSE}) should be used for filtering and returned +in the resulting \code{\link{Chromatogram}} object. Adjusted retention +times are used by default if available.} } \description{ \code{extractChromatograms}: the method allows to extract -chromatograms from \code{\link[MSnbase]{OnDiskMSnExp}} and -\code{\link{XCMSnExp}} objects. + chromatograms from \code{\link[MSnbase]{OnDiskMSnExp}} and + \code{\link{XCMSnExp}} objects. } \details{ Arguments \code{rt} and \code{mz} allow to specify the MS -data slice from which the chromatogram should be extracted. The parameter -\code{aggregationSum} allows to specify the function to be used to aggregate -the intensities across the mz range for the same retention time. Setting -\code{aggregationFun = "sum"} would e.g. allow to calculate the \emph{total -ion chromatogram} (TIC), \code{aggregationFun = "max"} the \emph{base peak -chromatogram} (BPC). + data slice from which the chromatogram should be extracted. The + parameter \code{aggregationSum} allows to specify the function to be + used to aggregate the intensities across the mz range for the same + retention time. Setting \code{aggregationFun = "sum"} would e.g. allow + to calculate the \emph{total ion chromatogram} (TIC), + \code{aggregationFun = "max"} the \emph{base peak chromatogram} (BPC). } \note{ -\code{Chromatogram} objects extracted with \code{extractChromatogram} contain -\code{NA_real_} values if, for a given retention time, no valid measurement -was available for the provided mz range. +\code{Chromatogram} objects extracted with \code{extractChromatogram} + contain \code{NA_real_} values if, for a given retention time, no valid + measurement was available for the provided mz range. -For \code{\link{XCMSnExp}} objects, if adjusted retention times are -available, the \code{extractChromatograms} method will by default report and -use these (for the subsetting based on the provided parameter \code{rt}). This -can be overwritten with the parameter \code{adjustedRtime}. + For \code{\link{XCMSnExp}} objects, if adjusted retention times are + available, the \code{extractChromatograms} method will by default report + and use these (for the subsetting based on the provided parameter + \code{rt}). This can be overwritten with the parameter + \code{adjustedRtime}. } \examples{ ## Read some files from the faahKO package. @@ -85,7 +88,8 @@ for(i in c(1, 3)) { } \seealso{ \code{\link{XCMSnExp}} for the data object. -\code{\link{Chromatogram}} for the object representing chromatographic data. + \code{\link{Chromatogram}} for the object representing chromatographic + data. } \author{ Johannes Rainer diff --git a/man/fillChromPeaks.Rd b/man/fillChromPeaks.Rd index b4d6d133c..6299d1b08 100644 --- a/man/fillChromPeaks.Rd +++ b/man/fillChromPeaks.Rd @@ -47,22 +47,22 @@ FillChromPeaksParam(expandMz = 0, expandRt = 0, ppm = 0) \item{expandMz}{\code{numeric(1)} defining the value by which the mz width of peaks should be expanded. Each peak is expanded in mz direction by \code{expandMz *} their original mz width. A value of \code{0} means no -expansion, a value of \code{1} grows each peak by 1 * the mz width of the peak -resulting in peakswith twice their original size in mz direction (expansion -by half mz width to both sides).} +expansion, a value of \code{1} grows each peak by 1 * the mz width of +the peak resulting in peakswith twice their original size in mz +direction (expansion by half mz width to both sides).} \item{expandRt}{\code{numeric(1)}, same as \code{expandRt} but for the retention time width.} \item{ppm}{\code{numeric(1)} optionally specifying a \emph{ppm} by which the -mz width of the peak region should be expanded. For peaks with an mz width -smaller than \code{mean(c(mzmin, mzmax)) * ppm / 1e6}, the \code{mzmin} will -be replaced by +mz width of the peak region should be expanded. For peaks with an mz +width smaller than \code{mean(c(mzmin, mzmax)) * ppm / 1e6}, the +\code{mzmin} will be replaced by \code{mean(c(mzmin, mzmax)) - (mean(c(mzmin, mzmax)) * ppm / 2 / 1e6)} and \code{mzmax} by -\code{mean(c(mzmin, mzmax)) + (mean(c(mzmin, mzmax)) * ppm / 2 / 1e6)}. This -is applied before eventually expanding the mz width using the \code{expandMz} -parameter.} +\code{mean(c(mzmin, mzmax)) + (mean(c(mzmin, mzmax)) * ppm / 2 / 1e6)}. +This is applied before eventually expanding the mz width using the +\code{expandMz} parameter.} \item{object}{\code{XCMSnExp} object with identified and grouped chromatographic peaks.} @@ -78,49 +78,51 @@ The \code{FillChromPeaksParam} function returns a \code{FillChromPeaksParam} object. A \code{\link{XCMSnExp}} object with previously missing -chromatographic peaks for features filled into its \code{chromPeaks} matrix. + chromatographic peaks for features filled into its \code{chromPeaks} + matrix. } \description{ The \code{FillChromPeaksParam} object encapsules all settings for the signal integration for missing peaks. \code{expandMz},\code{expandMz<-}: getter and setter -for the \code{expandMz} slot of the object. + for the \code{expandMz} slot of the object. \code{expandRt},\code{expandRt<-}: getter and setter -for the \code{expandRt} slot of the object. + for the \code{expandRt} slot of the object. \code{ppm},\code{ppm<-}: getter and setter -for the \code{ppm} slot of the object. + for the \code{ppm} slot of the object. Integrate signal in the mz-rt area of a feature (chromatographic -peak group) for samples in which no chromatographic peak for this feature was -identified and add it to the \code{chromPeaks}. Such peaks will have a value -of \code{1} in the \code{"is_filled"} column of the \code{\link{chromPeaks}} -matrix of the object. + peak group) for samples in which no chromatographic peak for this + feature was identified and add it to the \code{chromPeaks}. Such peaks + will have a value of \code{1} in the \code{"is_filled"} column of the + \code{\link{chromPeaks}} matrix of the object. } \details{ After correspondence (i.e. grouping of chromatographic peaks across -samples) there will always be features (peak groups) that do not include peaks -from every sample. The \code{fillChromPeaks} method defines intensity values -for such features in the missing samples by integrating the signal in the -mz-rt region of the feature. The mz-rt area is defined by the median mz and -rt start and end points of the other detected chromatographic peaks for a -given feature. - -Adjusted retention times will be used if available. - -Based on the peak finding algorithm that was used to identify the -(chromatographic) peaks different internal functions are employed to guarantee -that the integrated peak signal matches as much as possible the peak signal -integration used during the peak detection. For peaks identified with the -\code{\link{matchedFilter}} method, signal integration is performed on the -\emph{profile matrix} generated with the same settings used also during peak -finding (using the same \code{bin} size for example). For direct injection -data and peaks identified with the \code{\link{MSW}} algorithm signal is -integrated only along the mz dimension. For all other methods the complete -(raw) signal within the area defined by \code{"mzmin"}, \code{"mzmax"}, -\code{"rtmin"} and \code{"rtmax"} is used. + samples) there will always be features (peak groups) that do not include + peaks from every sample. The \code{fillChromPeaks} method defines + intensity values for such features in the missing samples by integrating + the signal in the mz-rt region of the feature. The mz-rt area is defined + by the median mz and rt start and end points of the other detected + chromatographic peaks for a given feature. + + Adjusted retention times will be used if available. + + Based on the peak finding algorithm that was used to identify the + (chromatographic) peaks different internal functions are employed to + guarantee that the integrated peak signal matches as much as possible + the peak signal integration used during the peak detection. For peaks + identified with the \code{\link{matchedFilter}} method, signal + integration is performed on the \emph{profile matrix} generated with + the same settings used also during peak finding (using the same + \code{bin} size for example). For direct injection data and peaks + identified with the \code{\link{MSW}} algorithm signal is integrated + only along the mz dimension. For all other methods the complete (raw) + signal within the area defined by \code{"mzmin"}, \code{"mzmax"}, + \code{"rtmin"} and \code{"rtmax"} is used. } \section{Slots}{ @@ -130,15 +132,15 @@ integrated only along the mz dimension. For all other methods the complete \note{ The reported \code{"mzmin"}, \code{"mzmax"}, \code{"rtmin"} and -\code{"rtmax"} for the filled peaks represents the actual MS area from which -the signal was integrated. -Note that no peak is filled in if no signal was present in a file/sample in -the respective mz-rt area. These samples will still show a \code{NA} in the -matrix returned by the \code{\link{featureValues}} method. This is in contrast -to the \code{\link{fillPeaks.chrom}} method that returned an \code{"into"} and -\code{"maxo"} of \code{0} for such peak areas. Growing the mz-rt area using -the \code{expandMz} and \code{expandRt} might help to reduce the number of -missing peak signals after filling. + \code{"rtmax"} for the filled peaks represents the actual MS area from + which the signal was integrated. + Note that no peak is filled in if no signal was present in a file/sample + in the respective mz-rt area. These samples will still show a \code{NA} + in the matrix returned by the \code{\link{featureValues}} method. This + is in contrast to the \code{\link{fillPeaks.chrom}} method that returned + an \code{"into"} and \code{"maxo"} of \code{0} for such peak areas. + Growing the mz-rt area using the \code{expandMz} and \code{expandRt} + might help to reduce the number of missing peak signals after filling. } \examples{ @@ -199,8 +201,8 @@ sum(is.na(featureValues(res))) } \seealso{ \code{\link{groupChromPeaks}} for methods to perform the -correspondence. -\code{\link{dropFilledChromPeaks}} for the method to remove filled in peaks. + correspondence. + \code{\link{dropFilledChromPeaks}} for the method to remove filled in peaks. } \author{ Johannes Rainer diff --git a/man/fillPeaks.chrom-methods.Rd b/man/fillPeaks.chrom-methods.Rd index 6ae615dd1..76d7ac4c9 100644 --- a/man/fillPeaks.chrom-methods.Rd +++ b/man/fillPeaks.chrom-methods.Rd @@ -12,19 +12,27 @@ \section{Methods}{ \describe{ \item{object = "xcmsSet"}{ - \code{fillPeaks.chrom(object, nSlaves=0,expand.mz=1,expand.rt=1)} + \code{fillPeaks.chrom(object, nSlaves=0,expand.mz=1,expand.rt=1, + BPPARAM = bpparam())} } }} \arguments{ \item{object}{the \code{xcmsSet} object} - \item{nSlaves}{number of slaves/cores to be used for parallel peak filling. + \item{nSlaves}{(DEPRECATED): number of slaves/cores to be used for + parallel peak filling. MPI is used if installed, otherwise the snow package is employed for multicore support. If none of the two packages is available it uses the parallel package for parallel processing on multiple CPUs of the - current machine.} + current machine. Users are advised to use the \code{BPPARAM} + parameter instead.} \item{expand.mz}{Expansion factor for the m/z range used for integration.} - \item{expand.rt}{Expansion factor for the rentention time range used for integration.} + \item{expand.rt}{Expansion factor for the rentention time range used + for integration.} + \item{BPPARAM}{allows to define a specific parallel processing setup + for the current task (see \code{\link[BiocParallel]{bpparam}} from the + \code{BiocParallel} package help more information). The default uses + the globally defined parallel setup.} } \details{ After peak grouping, there will always be peak groups that do not diff --git a/man/findChromPeaks-centWave.Rd b/man/findChromPeaks-centWave.Rd index 936d4e81b..9a9bacfb1 100644 --- a/man/findChromPeaks-centWave.Rd +++ b/man/findChromPeaks-centWave.Rd @@ -238,43 +238,43 @@ data and load the spectra data (mz and intensity values) on the fly from the original files applying also all eventual data manipulations. \code{ppm},\code{ppm<-}: getter and setter for the \code{ppm} -slot of the object. + slot of the object. \code{peakwidth},\code{peakwidth<-}: getter and setter for the -\code{peakwidth} slot of the object. + \code{peakwidth} slot of the object. \code{snthresh},\code{snthresh<-}: getter and setter for the -\code{snthresh} slot of the object. + \code{snthresh} slot of the object. \code{prefilter},\code{prefilter<-}: getter and setter for the -\code{prefilter} slot of the object. + \code{prefilter} slot of the object. \code{mzCenterFun},\code{mzCenterFun<-}: getter and setter for the -\code{mzCenterFun} slot of the object. + \code{mzCenterFun} slot of the object. \code{integrate},\code{integrate<-}: getter and setter for the -\code{integrate} slot of the object. + \code{integrate} slot of the object. \code{mzdiff},\code{mzdiff<-}: getter and setter for the -\code{mzdiff} slot of the object. + \code{mzdiff} slot of the object. \code{fitgauss},\code{fitgauss<-}: getter and setter for the -\code{fitgauss} slot of the object. + \code{fitgauss} slot of the object. \code{noise},\code{noise<-}: getter and setter for the -\code{noise} slot of the object. + \code{noise} slot of the object. \code{verboseColumns},\code{verboseColumns<-}: getter and -setter for the \code{verboseColumns} slot of the object. + setter for the \code{verboseColumns} slot of the object. \code{roiList},\code{roiList<-}: getter and setter for the -\code{roiList} slot of the object. + \code{roiList} slot of the object. \code{fistBaselineCheck},\code{firstBaselineCheck<-}: getter -and setter for the \code{firstBaselineCheck} slot of the object. + and setter for the \code{firstBaselineCheck} slot of the object. \code{roiScales},\code{roiScales<-}: getter and setter for the -\code{roiScales} slot of the object. + \code{roiScales} slot of the object. } \details{ The centWave algorithm is most suitable for high resolution diff --git a/man/findChromPeaks-centWaveWithPredIsoROIs.Rd b/man/findChromPeaks-centWaveWithPredIsoROIs.Rd index 5707df29e..a86b35f24 100644 --- a/man/findChromPeaks-centWaveWithPredIsoROIs.Rd +++ b/man/findChromPeaks-centWaveWithPredIsoROIs.Rd @@ -200,19 +200,19 @@ data and load the spectra data (mz and intensity values) on the fly from the original files applying also all eventual data manipulations. \code{snthreshIsoROIs},\code{snthreshIsoROIs<-}: getter and -setter for the \code{snthreshIsoROIs} slot of the object. + setter for the \code{snthreshIsoROIs} slot of the object. \code{maxCharge},\code{maxCharge<-}: getter and -setter for the \code{maxCharge} slot of the object. + setter for the \code{maxCharge} slot of the object. \code{maxIso},\code{maxIso<-}: getter and -setter for the \code{maxIso} slot of the object. + setter for the \code{maxIso} slot of the object. \code{mzIntervalExtension},\code{mzIntervalExtension<-}: getter -and setter for the \code{mzIntervalExtension} slot of the object. + and setter for the \code{mzIntervalExtension} slot of the object. \code{polarity},\code{polarity<-}: getter and -setter for the \code{polarity} slot of the object. + setter for the \code{polarity} slot of the object. } \details{ See \code{\link{centWave}} for details on the centWave method. diff --git a/man/findChromPeaks-massifquant.Rd b/man/findChromPeaks-massifquant.Rd index 87ab2e109..ee03f4bd2 100644 --- a/man/findChromPeaks-massifquant.Rd +++ b/man/findChromPeaks-massifquant.Rd @@ -266,49 +266,49 @@ data and load the spectra data (mz and intensity values) on the fly from the original files applying also all eventual data manipulations. \code{ppm},\code{ppm<-}: getter and setter for the \code{ppm} -slot of the object. + slot of the object. \code{peakwidth},\code{peakwidth<-}: getter and setter for the -\code{peakwidth} slot of the object. + \code{peakwidth} slot of the object. \code{snthresh},\code{snthresh<-}: getter and setter for the -\code{snthresh} slot of the object. + \code{snthresh} slot of the object. \code{prefilter},\code{prefilter<-}: getter and setter for the -\code{prefilter} slot of the object. + \code{prefilter} slot of the object. \code{mzCenterFun},\code{mzCenterFun<-}: getter and setter for the -\code{mzCenterFun} slot of the object. + \code{mzCenterFun} slot of the object. \code{integrate},\code{integrate<-}: getter and setter for the -\code{integrate} slot of the object. + \code{integrate} slot of the object. \code{mzdiff},\code{mzdiff<-}: getter and setter for the -\code{mzdiff} slot of the object. + \code{mzdiff} slot of the object. \code{fitgauss},\code{fitgauss<-}: getter and setter for the -\code{fitgauss} slot of the object. + \code{fitgauss} slot of the object. \code{noise},\code{noise<-}: getter and setter for the -\code{noise} slot of the object. + \code{noise} slot of the object. \code{verboseColumns},\code{verboseColumns<-}: getter and -setter for the \code{verboseColumns} slot of the object. + setter for the \code{verboseColumns} slot of the object. \code{criticalValue},\code{criticalValue<-}: getter and -setter for the \code{criticalValue} slot of the object. + setter for the \code{criticalValue} slot of the object. \code{consecMissedLimit},\code{consecMissedLimit<-}: getter and -setter for the \code{consecMissedLimit} slot of the object. + setter for the \code{consecMissedLimit} slot of the object. \code{unions},\code{unions<-}: getter and -setter for the \code{unions} slot of the object. + setter for the \code{unions} slot of the object. \code{checkBack},\code{checkBack<-}: getter and -setter for the \code{checkBack} slot of the object. + setter for the \code{checkBack} slot of the object. \code{withWave},\code{withWave<-}: getter and -setter for the \code{withWave} slot of the object. + setter for the \code{withWave} slot of the object. } \details{ This algorithm's performance has been tested rigorously diff --git a/man/findChromPeaks-matchedFilter.Rd b/man/findChromPeaks-matchedFilter.Rd index de17b0f0a..9bac5e9ef 100644 --- a/man/findChromPeaks-matchedFilter.Rd +++ b/man/findChromPeaks-matchedFilter.Rd @@ -206,37 +206,37 @@ data and load the spectra data (mz and intensity values) on the fly from the original files applying also all eventual data manipulations. \code{binSize},\code{binSize<-}: getter and setter for the -\code{binSize} slot of the object. + \code{binSize} slot of the object. \code{impute},\code{impute<-}: getter and setter for the -\code{impute} slot of the object. + \code{impute} slot of the object. \code{baseValue},\code{baseValue<-}: getter and setter for the -\code{baseValue} slot of the object. + \code{baseValue} slot of the object. \code{distance},\code{distance<-}: getter and setter for the -\code{distance} slot of the object. + \code{distance} slot of the object. \code{fwhm},\code{fwhm<-}: getter and setter for the -\code{fwhm} slot of the object. + \code{fwhm} slot of the object. \code{sigma},\code{sigma<-}: getter and setter for the -\code{sigma} slot of the object. + \code{sigma} slot of the object. \code{max},\code{max<-}: getter and setter for the -\code{max} slot of the object. + \code{max} slot of the object. \code{snthresh},\code{snthresh<-}: getter and setter for the -\code{snthresh} slot of the object. + \code{snthresh} slot of the object. \code{steps},\code{steps<-}: getter and setter for the -\code{steps} slot of the object. + \code{steps} slot of the object. \code{mzdiff},\code{mzdiff<-}: getter and setter for the -\code{mzdiff} slot of the object. + \code{mzdiff} slot of the object. \code{index},\code{index<-}: getter and setter for the -\code{index} slot of the object. + \code{index} slot of the object. } \details{ The intensities are binned by the provided m/z values within each diff --git a/man/findPeaks-MSW.Rd b/man/findPeaks-MSW.Rd index 223d87cc9..a992c2dba 100644 --- a/man/findPeaks-MSW.Rd +++ b/man/findPeaks-MSW.Rd @@ -192,41 +192,41 @@ data and load the spectra data (mz and intensity values) on the fly from the original files applying also all eventual data manipulations. \code{snthresh},\code{snthresh<-}: getter and setter for the -\code{snthresh} slot of the object. + \code{snthresh} slot of the object. \code{verboseColumns},\code{verboseColumns<-}: getter and setter -for the \code{verboseColumns} slot of the object. + for the \code{verboseColumns} slot of the object. \code{scales},\code{scales<-}: getter and setter for the -\code{scales} slot of the object. + \code{scales} slot of the object. \code{nearbyPeak},\code{nearbyPeak<-}: getter and setter for the -\code{nearbyPeak} slot of the object. + \code{nearbyPeak} slot of the object. \code{peakScaleRange},\code{peakScaleRange<-}: getter and setter -for the \code{peakScaleRange} slot of the object. + for the \code{peakScaleRange} slot of the object. \code{ampTh},\code{ampTh<-}: getter and setter for the -\code{ampTh} slot of the object. + \code{ampTh} slot of the object. \code{minNoiseLevel},\code{minNoiseLevel<-}: getter and setter -for the \code{minNoiseLevel} slot of the object. + for the \code{minNoiseLevel} slot of the object. \code{ridgeLength},\code{ridgeLength<-}: getter and setter for -the \code{ridgeLength} slot of the object. + the \code{ridgeLength} slot of the object. \code{peakThr},\code{peakThr<-}: getter and setter for the -\code{peakThr} slot of the object. + \code{peakThr} slot of the object. \code{tuneIn},\code{tuneIn<-}: getter and setter for the -\code{tuneIn} slot of the object. + \code{tuneIn} slot of the object. \code{addParams},\code{addParams<-}: getter and setter for the -\code{addParams} slot of the object. This slot stores optional additional -parameters to be passed to the -\code{\link[MassSpecWavelet]{identifyMajorPeaks}} and -\code{\link[MassSpecWavelet]{sav.gol}} functions from the -\code{MassSpecWavelet} package. + \code{addParams} slot of the object. This slot stores optional additional + parameters to be passed to the + \code{\link[MassSpecWavelet]{identifyMajorPeaks}} and + \code{\link[MassSpecWavelet]{sav.gol}} functions from the + \code{MassSpecWavelet} package. } \details{ This is a wrapper for the peak picker in Bioconductor's diff --git a/man/groupChromPeaks-density.Rd b/man/groupChromPeaks-density.Rd index ba2fd8641..bf13d6532 100644 --- a/man/groupChromPeaks-density.Rd +++ b/man/groupChromPeaks-density.Rd @@ -87,10 +87,10 @@ in mz dimension.} to be identified in a single mz slice.} \item{object}{For \code{groupChromPeaks}: an \code{\link{XCMSnExp}} object -containing the results from a previous peak detection analysis (see -\code{\link{findChromPeaks}}). + containing the results from a previous peak detection analysis (see + \code{\link{findChromPeaks}}). -For all other methods: a \code{PeakDensityParam} object.} + For all other methods: a \code{PeakDensityParam} object.} \item{value}{The value for the slot.} @@ -103,8 +103,9 @@ The \code{PeakDensityParam} function returns a specified for chromatographic peak alignment based on peak densities. For \code{groupChromPeaks}: a \code{\link{XCMSnExp}} object with the -results of the correspondence analysis. The definition of the resulting mz-rt -features can be accessed with the \code{\link{featureDefinitions}} method. + results of the correspondence analysis. The definition of the resulting + mz-rt features can be accessed with the \code{\link{featureDefinitions}} + method. } \description{ This method performs performs correspondence (chromatographic @@ -119,27 +120,28 @@ The \code{PeakDensityParam} class allows to specify all constructor. \code{sampleGroups},\code{sampleGroups<-}: getter and setter -for the \code{sampleGroups} slot of the object. + for the \code{sampleGroups} slot of the object. \code{bw},\code{bw<-}: getter and setter for the \code{bw} slot -of the object. + of the object. \code{minFraction},\code{minFraction<-}: getter and setter for -the \code{minFraction} slot of the object. + the \code{minFraction} slot of the object. \code{minSamples},\code{minSamples<-}: getter and setter for the -\code{minSamples} slot of the object. + \code{minSamples} slot of the object. \code{binSize},\code{binSize<-}: getter and setter for the -\code{binSize} slot of the object. + \code{binSize} slot of the object. \code{maxFeatures},\code{maxFeatures<-}: getter and setter for -the \code{maxFeatures} slot of the object. + the \code{maxFeatures} slot of the object. \code{groupChromPeaks,XCMSnExp,PeakDensityParam}: -performs correspondence (peak grouping within and across samples) within in -mz dimension overlapping slices of MS data based on the density distribution -of the identified chromatographic peaks in the slice along the time axis. + performs correspondence (peak grouping within and across samples) within + in mz dimension overlapping slices of MS data based on the density + distribution of the identified chromatographic peaks in the slice along + the time axis. } \section{Slots}{ @@ -156,7 +158,7 @@ These methods and classes are part of the updated and modernized can be passed with a \code{PeakDensityParam} object. Calling \code{groupChromPeaks} on an \code{XCMSnExp} object will cause -all eventually present previous correspondence results to be dropped. + all eventually present previous correspondence results to be dropped. } \examples{ @@ -217,7 +219,7 @@ The \code{\link{do_groupChromPeaks_density}} core features (i.e. the peak grouping results). \code{\link{XCMSnExp}} for the object containing the results of -the correspondence. + the correspondence. Other peak grouping methods: \code{\link{groupChromPeaks-mzClust}}, \code{\link{groupChromPeaks-nearest}}, diff --git a/man/groupChromPeaks-mzClust.Rd b/man/groupChromPeaks-mzClust.Rd index 80f8df7c2..69ae1f38d 100644 --- a/man/groupChromPeaks-mzClust.Rd +++ b/man/groupChromPeaks-mzClust.Rd @@ -69,10 +69,10 @@ least one sample group in which the peaks have to be detected to be considered a peak group (feature).} \item{object}{For \code{groupChromPeaks}: an \code{\link{XCMSnExp}} object -containing the results from a previous chromatographic peak detection -analysis (see \code{\link{findChromPeaks}}). + containing the results from a previous chromatographic peak detection + analysis (see \code{\link{findChromPeaks}}). -For all other methods: a \code{MzClustParam} object.} + For all other methods: a \code{MzClustParam} object.} \item{value}{The value for the slot.} @@ -85,8 +85,8 @@ The \code{MzClustParam} function returns a specified for high resolution single spectra peak alignment. For \code{groupChromPeaks}: a \code{\link{XCMSnExp}} object with the -results of the peak grouping step (i.e. the features). These can be accessed -with the \code{\link{featureDefinitions}} method. + results of the peak grouping step (i.e. the features). These can be + accessed with the \code{\link{featureDefinitions}} method. } \description{ This method performs high resolution correspondence for single @@ -97,23 +97,23 @@ The \code{MzClustParam} class allows to specify all Instances should be created with the \code{MzClustParam} constructor. \code{sampleGroups},\code{sampleGroups<-}: getter and setter -for the \code{sampleGroups} slot of the object. + for the \code{sampleGroups} slot of the object. \code{ppm},\code{ppm<-}: getter and setter for the \code{ppm} -slot of the object. + slot of the object. \code{absMz},\code{absMz<-}: getter and setter for the -\code{absMz} slot of the object. + \code{absMz} slot of the object. \code{minFraction},\code{minFraction<-}: getter and setter for -the \code{minFraction} slot of the object. + the \code{minFraction} slot of the object. \code{minSamples},\code{minSamples<-}: getter and setter for the -\code{minSamples} slot of the object. + \code{minSamples} slot of the object. \code{groupChromPeaks,XCMSnExp,MzClustParam}: -performs high resolution peak grouping for single spectrum -metabolomics data. + performs high resolution peak grouping for single spectrum + metabolomics data. } \section{Slots}{ @@ -130,7 +130,7 @@ These methods and classes are part of the updated and modernized can be passed with a \code{MzClustParam} object. Calling \code{groupChromPeaks} on an \code{XCMSnExp} object will cause -all eventually present previous correspondence results to be dropped. + all eventually present previous correspondence results to be dropped. } \examples{ @@ -170,7 +170,7 @@ The \code{\link{do_groupPeaks_mzClust}} core API function and grouping results (i.e. the features). \code{\link{XCMSnExp}} for the object containing the results of -the peak grouping. + the peak grouping. Other peak grouping methods: \code{\link{groupChromPeaks-density}}, \code{\link{groupChromPeaks-nearest}}, diff --git a/man/groupChromPeaks-nearest.Rd b/man/groupChromPeaks-nearest.Rd index 85bc8051e..9af5b51ce 100644 --- a/man/groupChromPeaks-nearest.Rd +++ b/man/groupChromPeaks-nearest.Rd @@ -70,10 +70,10 @@ two peaks.} to check.} \item{object}{For \code{groupChromPeaks}: an \code{\link{XCMSnExp}} object -containing the results from a previous chromatographic peak detection -analysis (see \code{\link{findChromPeaks}}). + containing the results from a previous chromatographic peak detection + analysis (see \code{\link{findChromPeaks}}). -For all other methods: a \code{NearestPeaksParam} object.} + For all other methods: a \code{NearestPeaksParam} object.} \item{value}{The value for the slot.} @@ -86,8 +86,9 @@ The \code{NearestPeaksParam} function returns a specified for peak alignment based on peak proximity. For \code{groupChromPeaks}: a \code{\link{XCMSnExp}} object with the -results of the peak grouping/correspondence step (i.e. the mz-rt features). -These can be accessed with the \code{\link{featureDefinitions}} method. + results of the peak grouping/correspondence step (i.e. the mz-rt + features). These can be accessed with the + \code{\link{featureDefinitions}} method. } \description{ This method is inspired by the grouping algorithm of mzMine @@ -104,23 +105,23 @@ The \code{NearestPeaksParam} class allows to specify all Instances should be created with the \code{NearestPeaksParam} constructor. \code{sampleGroups},\code{sampleGroups<-}: getter and setter -for the \code{sampleGroups} slot of the object. + for the \code{sampleGroups} slot of the object. \code{mzVsRtBalance},\code{mzVsRtBalance<-}: getter and setter -for the \code{mzVsRtBalance} slot of the object. + for the \code{mzVsRtBalance} slot of the object. \code{absMz},\code{absMz<-}: getter and setter for the -\code{absMz} slot of the object. + \code{absMz} slot of the object. \code{absRt},\code{absRt<-}: getter and setter for the -\code{absRt} slot of the object. + \code{absRt} slot of the object. \code{kNN},\code{kNN<-}: getter and setter for the -\code{kNN} slot of the object. + \code{kNN} slot of the object. \code{groupChromPeaks,XCMSnExp,NearestPeaksParam}: -performs peak grouping based on the proximity between chromatographic -peaks from different samples in the mz-rt range. + performs peak grouping based on the proximity between chromatographic + peaks from different samples in the mz-rt range. } \section{Slots}{ @@ -137,7 +138,7 @@ These methods and classes are part of the updated and modernized can be passed with a \code{NearestPeaksParam} object. Calling \code{groupChromPeaks} on an \code{XCMSnExp} object will cause -all eventually present previous alignment results to be dropped. + all eventually present previous alignment results to be dropped. } \examples{ @@ -194,7 +195,7 @@ The \code{\link{do_groupChromPeaks_nearest}} core peak grouping results (i.e. the features). \code{\link{XCMSnExp}} for the object containing the results of -the peak grouping. + the peak grouping. Other peak grouping methods: \code{\link{groupChromPeaks-density}}, \code{\link{groupChromPeaks-mzClust}}, diff --git a/src/xcms_obiwarp.cpp b/src/xcms_obiwarp.cpp index 844586783..998db09dd 100644 --- a/src/xcms_obiwarp.cpp +++ b/src/xcms_obiwarp.cpp @@ -39,7 +39,7 @@ extern "C" SEXP R_set_from_xcms(SEXP valscantime, SEXP scantime, SEXP mzrange, S double *pscantime2, *pmz2, *pintensity2; SEXP corrected; - valscantime = coerceVector(valscantime, INTSXP); + PROTECT(valscantime = coerceVector(valscantime, INTSXP)); mzrange = coerceVector(mzrange, INTSXP); pvalscantime = INTEGER(valscantime)[0]; pmzrange = INTEGER(mzrange)[0]; @@ -47,7 +47,7 @@ extern "C" SEXP R_set_from_xcms(SEXP valscantime, SEXP scantime, SEXP mzrange, S pmz = REAL(mz); pintensity = REAL(intensity); - valscantime2 = coerceVector(valscantime2, INTSXP); + PROTECT(valscantime2 = coerceVector(valscantime2, INTSXP)); mzrange2 = coerceVector(mzrange2, INTSXP); pvalscantime2 = INTEGER(valscantime2)[0]; pmzrange2 = INTEGER(mzrange2)[0]; @@ -125,7 +125,7 @@ extern "C" SEXP R_set_from_xcms(SEXP valscantime, SEXP scantime, SEXP mzrange, S REAL(corrected)[i] = lmat2.tm()->back()[i]; } - UNPROTECT(1); + UNPROTECT(3); return corrected; diff --git a/vignettes/new_functionality.Rmd b/vignettes/new_functionality.Rmd index 5633dee99..0383cc15c 100644 --- a/vignettes/new_functionality.Rmd +++ b/vignettes/new_functionality.Rmd @@ -30,6 +30,7 @@ in the `xcms` package introduced during the update to version *3*. ```{r message = FALSE, warning = FALSE} library(xcms) library(RColorBrewer) +register(SerialParam()) ``` @@ -191,6 +192,56 @@ boxplot(ints, varwidth = TRUE, col = sample_colors[pData(xod)$sample_group], ylab = expression(log[2]~intensity), main = "Peak intensities") ``` +After peak detection it might be advisable to evaluate whether the peak +detection identified e.g. compounds known to be present in the +sample. Facilitating access to the raw data has thus been one of the major aims +for the updated user interface. + +Next we extract the chromatogram for the rt-mz region corresponding to one +detected chromatographic peak increasing the region in rt dimension by +/- 60 +seconds. In addition we extract also all chromatographic peaks in that region by +passing the same `mz` and `rt` parameters to the `chromPeaks` method. + +```{r faahKO-chromPeaks-extractChroms, warning = FALSE} +rtr <- chromPeaks(xod)[68, c("rtmin", "rtmax")] +## Increase the range: +rtr[1] <- rtr[1] - 60 +rtr[2] <- rtr[2] + 60 +mzr <- chromPeaks(xod)[68, c("mzmin", "mzmax")] + +chrs <- extractChromatograms(xod, rt = rtr, mz = mzr) + +## In addition we get all peaks detected in the same region +pks <- chromPeaks(xod, rt = rtr, mz = mzr) +``` + +Next we plot the extracted chromatogram for the data and highlight in addition +the identified peaks. + +```{r faahKO-extracted-chrom-with-peaks, message = FALSE, fig.cap = "Extracted ion chromatogram for one of the identified peaks. Each line represents the signal measured in one sample. The rectangles indicate the margins of the identified chromatographic peak in the respective sample.", fig.align = "center", fig.width = 8, fig.height = 8} +## Define the limits on x- and y-dimension +xl <- range(lapply(chrs, rtime), na.rm = TRUE) +yl <- range(lapply(chrs, intensity), na.rm = TRUE) +plot(3, 3, pch = NA, main = paste(format(mzr, digits = 6), collapse = "-"), + xlab = "rt", ylab = "intensity", xlim = xl, ylim = yl) +## Plot the chromatogram per sample +for (i in 1:length(chrs)) { + points(rtime(chrs[[i]]), intensity(chrs[[i]]), type = "l", + col = sample_colors[pData(xod)$sample_group[i]]) +} +## Highlight the identified chromatographic peaks. +for (i in 1:nrow(pks)) { + rect(xleft = pks[i, "rtmin"], xright = pks[i, "rtmax"], ybottom = 0, + ytop = pks[i, "maxo"], + border = paste0(sample_colors[pData(xod)$sample_group][pks[i, "sample"]], 60)) +} +``` + +Note that the `extractChromatograms` does return an `NA` value if in a certain scan +(i.e. for a specific retention time) no signal was measured in the respective mz +range. This is reflected by the lines not being drawn as continuous lines in the +plot above. + Next we align the samples using the *obiwarp* method [@Prince:2006jj]. This method does not require, in contrast to other alignment/retention time correction methods, any identified peaks and could thus also be applied to an @@ -248,6 +299,41 @@ The 3rd sample was used as *center* sample against which all other samples were aligned to, hence its adjusted retention times are identical to the raw retention times. +We are again plotting the extracted ion chromatogram for the selected peaks from +above to evaluate the impact of the alignment. + +```{r faahKO-extracted-chrom-with-peaks-aligned, echo = FALSE, message = FALSE, fig.cap = "Extracted ion chromatogram for one of the identified peaks after alignment.", fig.align = "center", fig.width = 8, fig.height = 8} +rtr <- chromPeaks(xod)[68, c("rtmin", "rtmax")] +## Increase the range: +rtr[1] <- rtr[1] - 60 +rtr[2] <- rtr[2] + 60 +mzr <- chromPeaks(xod)[68, c("mzmin", "mzmax")] + +chrs <- extractChromatograms(xod, rt = rtr, mz = mzr) + +## In addition we get all peaks detected in the same region +pks <- chromPeaks(xod, rt = rtr, mz = mzr) + +## Define the limits on x- and y-dimension +xl <- range(lapply(chrs, rtime), na.rm = TRUE) +yl <- range(lapply(chrs, intensity), na.rm = TRUE) +plot(3, 3, pch = NA, main = paste(format(mzr, digits = 6), collapse = "-"), + xlab = "rt", ylab = "intensity", xlim = xl, ylim = yl) +## Plot the chromatogram per sample +for (i in 1:length(chrs)) { + points(rtime(chrs[[i]]), intensity(chrs[[i]]), type = "l", + col = sample_colors[pData(xod)$sample_group[i]]) +} +## Highlight the identified chromatographic peaks. +for (i in 1:nrow(pks)) { + rect(xleft = pks[i, "rtmin"], xright = pks[i, "rtmax"], ybottom = 0, + ytop = pks[i, "maxo"], + border = paste0(sample_colors[pData(xod)$sample_group][pks[i, "sample"]], 60)) +} +``` + +After alignment, the peaks are nicely overlapping. + Next we group identified chromatographic peaks across samples. We use the *peak density* method [@Smith:2006ic] specifying that a chromatographic peak have to be present in at least 1/3 of the samples within each group to be combined to diff --git a/vignettes/new_functionality.org b/vignettes/new_functionality.org index e83beb949..e9df02811 100644 --- a/vignettes/new_functionality.org +++ b/vignettes/new_functionality.org @@ -42,6 +42,7 @@ in the =xcms= package introduced during the update to version /3/. #+BEGIN_SRC R :ravel message = FALSE, warning = FALSE library(xcms) library(RColorBrewer) + register(SerialParam()) #+END_SRC ** Modernized user interface @@ -212,6 +213,59 @@ plot the signal distribution of the identified peaks per sample. ylab = expression(log[2]~intensity), main = "Peak intensities") #+END_SRC +After peak detection it might be advisable to evaluate whether the peak +detection identified e.g. compounds known to be present in the +sample. Facilitating access to the raw data has thus been one of the major aims +for the updated user interface. + +Next we extract the chromatogram for the rt-mz region corresponding to one +detected chromatographic peak increasing the region in rt dimension by +/- 60 +seconds. In addition we extract also all chromatographic peaks in that region by +passing the same =mz= and =rt= parameters to the =chromPeaks= method. + +#+NAME: faahKO-chromPeaks-extractChroms +#+BEGIN_SRC R :ravel warning = FALSE + rtr <- chromPeaks(xod)[68, c("rtmin", "rtmax")] + ## Increase the range: + rtr[1] <- rtr[1] - 60 + rtr[2] <- rtr[2] + 60 + mzr <- chromPeaks(xod)[68, c("mzmin", "mzmax")] + + chrs <- extractChromatograms(xod, rt = rtr, mz = mzr) + + ## In addition we get all peaks detected in the same region + pks <- chromPeaks(xod, rt = rtr, mz = mzr) +#+END_SRC + +Next we plot the extracted chromatogram for the data and highlight in addition +the identified peaks. + +#+NAME: faahKO-extracted-chrom-with-peaks +#+BEGIN_SRC R :ravel message = FALSE, fig.cap = "Extracted ion chromatogram for one of the identified peaks. Each line represents the signal measured in one sample. The rectangles indicate the margins of the identified chromatographic peak in the respective sample.", fig.align = "center", fig.width = 8, fig.height = 8 + ## Define the limits on x- and y-dimension + xl <- range(lapply(chrs, rtime), na.rm = TRUE) + yl <- range(lapply(chrs, intensity), na.rm = TRUE) + plot(3, 3, pch = NA, main = paste(format(mzr, digits = 6), collapse = "-"), + xlab = "rt", ylab = "intensity", xlim = xl, ylim = yl) + ## Plot the chromatogram per sample + for (i in 1:length(chrs)) { + points(rtime(chrs[[i]]), intensity(chrs[[i]]), type = "l", + col = sample_colors[pData(xod)$sample_group[i]]) + } + ## Highlight the identified chromatographic peaks. + for (i in 1:nrow(pks)) { + rect(xleft = pks[i, "rtmin"], xright = pks[i, "rtmax"], ybottom = 0, + ytop = pks[i, "maxo"], + border = paste0(sample_colors[pData(xod)$sample_group][pks[i, "sample"]], 60)) + } + +#+END_SRC + +Note that the =extractChromatograms= does return an =NA= value if in a certain scan +(i.e. for a specific retention time) no signal was measured in the respective mz +range. This is reflected by the lines not being drawn as continuous lines in the +plot above. + Next we align the samples using the /obiwarp/ method \cite{Prince:2006jj}. This method does not require, in contrast to other alignment/retention time correction methods, any identified peaks and could thus also be applied to an @@ -272,6 +326,43 @@ The 3rd sample was used as /center/ sample against which all other samples were aligned to, hence its adjusted retention times are identical to the raw retention times. +We are again plotting the extracted ion chromatogram for the selected peaks from +above to evaluate the impact of the alignment. + +#+NAME: faahKO-extracted-chrom-with-peaks-aligned +#+BEGIN_SRC R :ravel echo = FALSE, message = FALSE, fig.cap = "Extracted ion chromatogram for one of the identified peaks after alignment.", fig.align = "center", fig.width = 8, fig.height = 8 + rtr <- chromPeaks(xod)[68, c("rtmin", "rtmax")] + ## Increase the range: + rtr[1] <- rtr[1] - 60 + rtr[2] <- rtr[2] + 60 + mzr <- chromPeaks(xod)[68, c("mzmin", "mzmax")] + + chrs <- extractChromatograms(xod, rt = rtr, mz = mzr) + + ## In addition we get all peaks detected in the same region + pks <- chromPeaks(xod, rt = rtr, mz = mzr) + + ## Define the limits on x- and y-dimension + xl <- range(lapply(chrs, rtime), na.rm = TRUE) + yl <- range(lapply(chrs, intensity), na.rm = TRUE) + plot(3, 3, pch = NA, main = paste(format(mzr, digits = 6), collapse = "-"), + xlab = "rt", ylab = "intensity", xlim = xl, ylim = yl) + ## Plot the chromatogram per sample + for (i in 1:length(chrs)) { + points(rtime(chrs[[i]]), intensity(chrs[[i]]), type = "l", + col = sample_colors[pData(xod)$sample_group[i]]) + } + ## Highlight the identified chromatographic peaks. + for (i in 1:nrow(pks)) { + rect(xleft = pks[i, "rtmin"], xright = pks[i, "rtmax"], ybottom = 0, + ytop = pks[i, "maxo"], + border = paste0(sample_colors[pData(xod)$sample_group][pks[i, "sample"]], 60)) + } + +#+END_SRC + +After alignment, the peaks are nicely overlapping. + Next we group identified chromatographic peaks across samples. We use the /peak density/ method \cite{Smith:2006ic} specifying that a chromatographic peak have to be present in at least 1/3 of the samples within each group to be combined to