Skip to content
Snippets Groups Projects
Commit bc06fbff authored by Michele Stravs's avatar Michele Stravs
Browse files

EIC and MSMS search using cached peaks tables

parent 0f054488
No related branches found
No related tags found
No related merge requests found
......@@ -127,9 +127,18 @@ findMsMsHR <- function(fileName, cpdID, mode="pH",confirmMode =0, useRtLimit = T
#' @export
findMsMsHR.mass <- function(msRaw, mz, limit.coarse, limit.fine, rtLimits = NA, maxCount = NA,
headerCache = NULL, fillPrecursorScan = FALSE,
deprofile = getOption("RMassBank")$deprofile)
deprofile = getOption("RMassBank")$deprofile, peaksCache = NULL)
{
eic <- findEIC(msRaw, mz, limit.fine, rtLimits)
eic <- findEIC(msRaw, mz, limit.fine, rtLimits, headerCache=headerCache,
peaksCache=peaksCache)
# if(!is.na(rtLimits))
# {
# eic <- subset(eic, rt >= rtLimits[[1]] & rt <= rtLimits[[2]])
......@@ -413,7 +422,8 @@ findMsMsHRperxcms.direct <- function(fileName, cpdID, mode="pH", findPeaksArgs =
#' @author Michael A. Stravs, Eawag <michael.stravs@@eawag.ch>
#' @seealso findMsMsHR
#' @export
findEIC <- function(msRaw, mz, limit = NULL, rtLimit = NA, headerCache = NULL, floatingRecalibration = NULL)
findEIC <- function(msRaw, mz, limit = NULL, rtLimit = NA, headerCache = NULL, floatingRecalibration = NULL,
peaksCache = NULL)
{
# calculate mz upper and lower limits for "integration"
if(all(c("mzMin", "mzMax") %in% names(mz)))
......@@ -425,6 +435,12 @@ findEIC <- function(msRaw, mz, limit = NULL, rtLimit = NA, headerCache = NULL, f
headerData <- as.data.frame(headerCache)
else
headerData <- as.data.frame(header(msRaw))
# Add row numbering because I'm not sure if seqNum or acquisitionNum correspond to anything really
if(nrow(headerData) > 0)
headerData$rowNum <- 1:nrow(headerData)
else
headerData$rowNum <- integer(0)
# If RT limit is already given, retrieve only candidates in the first place,
# since this makes everything much faster.
if(all(!is.na(rtLimit)))
......@@ -434,7 +450,11 @@ findEIC <- function(msRaw, mz, limit = NULL, rtLimit = NA, headerCache = NULL, f
,]
else
headerMS1 <- headerData[headerData$msLevel == 1,]
pks <- mzR::peaks(msRaw, headerMS1$seqNum)
if(is.null(peaksCache))
pks <- mzR::peaks(msRaw, headerMS1$seqNum)
else
pks <- peaksCache[headerData$rowNum]
# Sum intensities in the given mass window for each scan
if(is.null(floatingRecalibration))
{
......@@ -448,7 +468,7 @@ findEIC <- function(msRaw, mz, limit = NULL, rtLimit = NA, headerCache = NULL, f
}
intensity <- unlist(lapply(1:nrow(headerMS1), function(row)
{
peaktable <- mzR::peaks(msRaw, headerMS1[row,"acquisitionNum"])
peaktable <- pks[[row]]
sum(peaktable[
which((peaktable[,1] >= headerMS1[row,"mzMin"]) & (peaktable[,1] <= headerMS1[row,"mzMax"])),
2])
......@@ -457,6 +477,12 @@ findEIC <- function(msRaw, mz, limit = NULL, rtLimit = NA, headerCache = NULL, f
return(data.frame(rt = headerMS1$retentionTime, intensity=intensity, scan=headerMS1$acquisitionNum))
}
makePeaksCache <- function(msRaw, headerCache)
{
mzR::peaks(msRaw, headerCache$seqNum)
}
#' Conversion of XCMS-pseudospectra into RMassBank-spectra
#'
#' Converts a pseudospectrum extracted from XCMS using CAMERA into the msmsWorkspace(at)specs-format that RMassBank uses
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment