Skip to content

Commit

Permalink
add chromPeaks information to the Spectra output of chromPeakSpectra
Browse files Browse the repository at this point in the history
  • Loading branch information
philouail committed Nov 20, 2024
1 parent 7c9e7d3 commit cd7e00c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion R/XcmsExperiment-functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down Expand Up @@ -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),
Expand Down
8 changes: 6 additions & 2 deletions R/XcmsExperiment.R
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down Expand Up @@ -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)
Expand All @@ -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]
Expand Down

0 comments on commit cd7e00c

Please sign in to comment.