diff --git a/R/XcmsExperiment-functions.R b/R/XcmsExperiment-functions.R index 931bcdb7..fdbed26e 100644 --- a/R/XcmsExperiment-functions.R +++ b/R/XcmsExperiment-functions.R @@ -793,7 +793,8 @@ "largest_bpi"), msLevel = 2L, expandRt = 0, expandMz = 0, ppm = 0, skipFilled = FALSE, - peaks = integer(), BPPARAM = bpparam()) { + peaks = integer(), peaksInfo = c("rt", "mz"), + BPPARAM = bpparam()) { method <- match.arg(method) pks <- .chromPeaks(x)[, c("mz", "mzmin", "mzmax", "rt", "rtmin", "rtmax", "maxo", "sample")] @@ -830,6 +831,7 @@ ids <- rep(rownames(pk), lengths(idx)) res <- sp[unlist(idx)] res$peak_id <- ids + res2@backend@spectraData <- cbind(res2@backend@spectraData, info) res }, MoreArgs = list(msLevel = msLevel, method = method), diff --git a/R/XcmsExperiment.R b/R/XcmsExperiment.R index a094a716..6a222aec 100644 --- a/R/XcmsExperiment.R +++ b/R/XcmsExperiment.R @@ -515,6 +515,10 @@ #' indicating the identified chromatographic peaks. Only a single color #' is supported. Defaults to `peakCol = "#ff000060". #' +#' @param peaksInfo For `chromPeakSpectra`: `character` vector of additional +#' information from `chromPeaks()` to be added to the spectra object. The +#' columns names will be appended with "peaks_". +#' #' @param ppm For `chromPeaks` and `featureDefinitions`: optional `numeric(1)` #' specifying the ppm by which the m/z range (defined by `mz` should be #' extended. For a value of `ppm = 10`, all peaks within `mz[1] - ppm / 1e6` @@ -1228,7 +1232,7 @@ setMethod( function(object, method = c("all", "closest_rt", "closest_mz", "largest_tic", "largest_bpi"), msLevel = 2L, expandRt = 0, expandMz = 0, ppm = 0, - skipFilled = FALSE, peaks = character(), + skipFilled = FALSE, peaks = character(), peaksInfo = c("rt", "mz") return.type = c("Spectra", "List"), BPPARAM = bpparam()) { if (hasAdjustedRtime(object)) object <- applyAdjustedRtime(object) @@ -1244,7 +1248,7 @@ setMethod( else pkidx <- integer() res <- .mse_spectra_for_peaks(object, method, msLevel, expandRt, expandMz, ppm, skipFilled, pkidx, - BPPARAM) + peaksInfo, BPPARAM) if (!length(pkidx)) peaks <- rownames(.chromPeaks(object)) else peaks <- rownames(.chromPeaks(object))[pkidx]