diff --git a/DESCRIPTION b/DESCRIPTION index 8cd1d156ea91576f440dc3d6771cfe69712c3637..5f46eca1efab0e58a02c93982a074acc7f381d49 100755 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: RMassBank Type: Package Title: Workflow to process tandem MS files and build MassBank records -Version: 1.99.6 +Version: 1.99.7 Authors@R: c( person(given = "RMassBank at Eawag", email = "massbank@eawag.ch", role=c("cre")), diff --git a/R/alternateAnalyze.R b/R/alternateAnalyze.R index a3c75bbaa3e9a0c05aaf431064771ac1a5212199..c708634b66a65d8701ced4c6626d3d042e4b70dc 100644 --- a/R/alternateAnalyze.R +++ b/R/alternateAnalyze.R @@ -296,8 +296,8 @@ analyzeMsMs.formula.optimized <- function(msmsPeaks, mode="pH", detail=FALSE, ru # Circumvent bug in rcdk: correct the mass for the charge first, then calculate uncharged formulae # finally back-correct calculated masses for the charge mass.calc <- mass + mode.charge * .emass - peakformula <- tryCatch(generate.formula(mass.calc, ppm(mass.calc, ppmlimit, p=TRUE), - limits, charge=0), error=function(e) NA) + peakformula <- tryCatch(suppressWarnings(generate.formula(mass.calc, ppm(mass.calc, ppmlimit, p=TRUE), + limits, charge=0)), error=function(e) NA) #peakformula <- tryCatch( # generate.formula(mass, # ppm(mass, ppmlimit, p=TRUE), @@ -327,8 +327,8 @@ analyzeMsMs.formula.optimized <- function(msmsPeaks, mode="pH", detail=FALSE, ru # Circumvent bug in rcdk: correct the mass for the charge first, then calculate uncharged formulae # finally back-correct calculated masses for the charge mass.calc <- mass + mode.charge * .emass - peakformula <- tryCatch(generate.formula(mass.calc, ppm(mass.calc, ppmlimit, p=TRUE), - limits, charge=0), error=function(e) NA) + peakformula <- tryCatch(suppressWarnings(generate.formula(mass.calc, ppm(mass.calc, ppmlimit, p=TRUE), + limits, charge=0)), error=function(e) NA) #peakformula <- tryCatch( # generate.formula(mass, # ppm(mass, ppmlimit, p=TRUE), @@ -380,7 +380,7 @@ analyzeMsMs.formula.optimized <- function(msmsPeaks, mode="pH", detail=FALSE, ru childPeaksInt <- merge(childPeaks, shot, by.x = "mzFound", by.y = mzColname, all.x = TRUE, all.y = FALSE ) # find the best ppm value - bestPpm <- aggregate(childPeaksInt$dppm, list(childPeaksInt$mzFound), + bestPpm <- aggregate(as.data.frame(childPeaksInt$dppm), list(childPeaksInt$mzFound), function(dppm) dppm[[which.min(abs(dppm))]]) colnames(bestPpm) <- c("mzFound", "dppmBest") childPeaksInt <- merge(childPeaksInt, bestPpm, by="mzFound", all.x=TRUE) diff --git a/R/leMsMs.r b/R/leMsMs.r index 74e5c04efd09bbc1404935c119a874698dc82236..9e85bccf5629b42c2a5e488135aac7bda79d53cc 100755 --- a/R/leMsMs.r +++ b/R/leMsMs.r @@ -460,7 +460,6 @@ analyzeMsMs.formula <- function(msmsPeaks, mode="pH", detail=FALSE, run="prelimi # MolgenMsMs parentSpectrum <- msmsPeaks@parent - # On each spectrum the following function analyzeTandemShot will be applied. # It takes the raw peaks matrix as argument (mz, int) and processes the spectrum by @@ -508,7 +507,6 @@ analyzeMsMs.formula <- function(msmsPeaks, mode="pH", detail=FALSE, run="prelimi # this was done for the MOLGEN MSMS type analysis, is not necessary anymore now (23.1.15 MST) # shot[,mzColname] <- round(shot[,mzColname], 5) - # here follows the Rcdk analysis #------------------------------------ parentPeaks <- data.frame(mzFound=msmsPeaks@mz, @@ -574,8 +572,8 @@ analyzeMsMs.formula <- function(msmsPeaks, mode="pH", detail=FALSE, run="prelimi # finally back-correct calculated masses for the charge mass <- shot.row[["mz"]] mass.calc <- mass + mode.charge * .emass - peakformula <- tryCatch(generate.formula(mass.calc, ppm(mass.calc, ppmlimit, p=TRUE), - limits, charge=0), error=function(e) NA) + peakformula <- tryCatch(suppressWarnings(generate.formula(mass.calc, ppm(mass.calc, ppmlimit, p=TRUE), + limits, charge=0)), error=function(e) NA) #peakformula <- tryCatch( # generate.formula(mass, # ppm(mass, ppmlimit, p=TRUE), @@ -650,9 +648,9 @@ analyzeMsMs.formula <- function(msmsPeaks, mode="pH", detail=FALSE, run="prelimi child@ok <- FALSE return(child) } - +#browser() # find the best ppm value - bestPpm <- aggregate(childPeaks[!is.na(childPeaks$dppm),"dppm"], + bestPpm <- aggregate(as.data.frame(childPeaks[!is.na(childPeaks$dppm),"dppm"]), list(childPeaks[!is.na(childPeaks$dppm),"row"]), function(dppm) dppm[[which.min(abs(dppm))]]) colnames(bestPpm) <- c("row", "dppmBest") @@ -1107,7 +1105,7 @@ problematicPeaks <- function(peaks_unmatched, peaks_matched, mode="pH") if(nrow(peaks_matched) == 0){ assIntMax <- data.frame(list(integer(0),integer(0),integer(0))) } else{ - assIntMax <- as.data.frame(aggregate(peaks_matched$intensity, + assIntMax <- as.data.frame(aggregate(as.data.frame(peaks_matched$intensity), by=list(peaks_matched$cpdID, peaks_matched$scan), max)) } colnames(assIntMax) <- c("cpdID", "scan", "aMax") @@ -1336,6 +1334,8 @@ makeRecalibration <- function(w, mode, plotRecalibration <- function(w, recalibrateBy = getOption("RMassBank")$recalibrateBy) { spec <- w@aggregated + if(!is.null(w@parent)) + spec <- w@parent@aggregated rcdata <- data.frame(mzFound = w@rc$x, recalfield = w@rc$y) ms1data <- data.frame(mzFound = w@rc.ms1$x, recalfield = w@rc.ms1$y) @@ -1718,8 +1718,8 @@ reanalyzeFailpeak <- function(custom_additions, mass, cpdID, counter, pb = NULL, #print(parent_formula) limits <- to.limits.rcdk(parent_formula) - peakformula <- tryCatch(generate.formula(mass, ppm(mass, ppmlimit, p=TRUE), - limits, charge=mode.charge), error=function(e) NA) + peakformula <- tryCatch(suppressWarnings(generate.formula(mass, ppm(mass, ppmlimit, p=TRUE), + limits, charge=mode.charge)), error=function(e) NA) # was a formula found? If not, return empty result if(!is.list(peakformula)) return(as.data.frame( @@ -1834,7 +1834,8 @@ filterPeaksMultiplicity <- function(peaks, formulacol, recalcBest = TRUE) else { # calculate duplicity info - multInfo <- aggregate(peaks$scan, list(peaks$cpdID, peaks[,formulacol]), FUN=length) + multInfo <- aggregate(as.data.frame(peaks$scan), + list(peaks$cpdID, peaks[,formulacol]), FUN=length) # just for comparison: # nform <- unique(paste(pks$cpdID,pks$formula)) @@ -1877,7 +1878,7 @@ filterPeaksMultiplicity <- function(peaks, formulacol, recalcBest = TRUE) # prioritize duplicate peaks # get unique peaks with their maximum-multiplicity formula attached - best_mult <- aggregate(peaks$formulaMultiplicity, + best_mult <- aggregate(as.data.frame(peaks$formulaMultiplicity), list(peaks$cpdID, peaks$scan, peaks$mzFound), max) colnames(best_mult) <- c("cpdID", "scan", "mzFound", "bestMultiplicity") @@ -1887,7 +1888,7 @@ filterPeaksMultiplicity <- function(peaks, formulacol, recalcBest = TRUE) # now we also have to recalculate dppmBest since the "old best" may have been # dropped. peaks$dppmBest <- NULL - bestPpm <- aggregate(peaks$dppm, + bestPpm <- aggregate(as.data.frame(peaks$dppm), list(peaks$cpdID, peaks$scan, peaks$mzFound), function(dppm) dppm[[which.min(abs(dppm))]]) colnames(bestPpm) <- c("cpdID", "scan", "mzFound", "dppmBest") @@ -1899,7 +1900,7 @@ filterPeaksMultiplicity <- function(peaks, formulacol, recalcBest = TRUE) pks_best$formulaMultiplicity <- NULL pks_best$bestMultiplicity <- NULL - multInfo_best <- aggregate(pks_best$scan, + multInfo_best <- aggregate(as.data.frame(pks_best$scan), list(pks_best$cpdID, pks_best[,formulacol]), FUN=length) colnames(multInfo_best) <- c("cpdID", formulacol, "formulaMultiplicity")