Skip to content

Commit

Permalink
Fixing missing or outdated documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Michele Stravs committed Apr 26, 2023
1 parent b64975c commit 284d385
Show file tree
Hide file tree
Showing 29 changed files with 284 additions and 22 deletions.
44 changes: 42 additions & 2 deletions R/SpectrumMethods.R
Original file line number Diff line number Diff line change
Expand Up @@ -228,21 +228,38 @@ setMethod("normalize", c("RmbSpectrum2List"), function(object, ...)
})



#' Add a mass shift to a spectrum
#'
#' @param e1 a `MSnbase::Spectrum` object
#' @param e2 a numeric mass shift
#'
setMethod("+", c("Spectrum", "numeric"), function(e1, e2)
{
e1@mz <- e1@mz + e2
return(e1)
})



#' Add a negative mass shift to a spectrum
#'
#' @param e1 a `MSnbase::Spectrum` object
#' @param e2 a numeric mass shift
#'
setMethod("-", c("Spectrum", "numeric"), function(e1, e2)
{
e1@mz <- e1@mz - e2
return(e1)
})

#' Add a mass shift to a list of spectra
#'
#' Shifts both `parent` and `children` spectra of the `RmbSpectraSet` by the
#' same mass.
#'
#' @param e1 a `RmbSpectraSet` object containing zero or more `children` spectra
#' and a `parent` spectrum
#' @param e2 a numeric mass shift
#'
setMethod("+", c("RmbSpectraSet", "ANY"), function(e1, e2)
{
e1@parent <- e1@parent + e2
Expand All @@ -251,6 +268,15 @@ setMethod("+", c("RmbSpectraSet", "ANY"), function(e1, e2)
e1
})

#' Add a negative mass shift to a list of spectra
#'
#' Shifts both `parent` and `children` spectra of the `RmbSpectraSet` by the
#' same mass.
#'
#' @param e1 a `RmbSpectraSet` object containing zero or more `children` spectra
#' and a `parent` spectrum
#' @param e2 a numeric mass shift
#'
setMethod("-", c("RmbSpectraSet", "ANY"), function(e1, e2)
{
e1@parent <- e1@parent - e2
Expand All @@ -260,6 +286,13 @@ setMethod("-", c("RmbSpectraSet", "ANY"), function(e1, e2)
})


#' Add a mass shift to a list of spectra
#'
#' Shifts all spectra in a `RmbSpectrum2List` by the same mass
#'
#' @param e1 a `RmbSpectrum2List` object containing zero or more `RmbSpectrum2` spectra
#' @param e2 a numeric mass shift
#'
setMethod("+", c("RmbSpectrum2List", "ANY"), function(e1, e2)
{
for(n in seq_len(length(e1)))
Expand All @@ -268,6 +301,13 @@ setMethod("+", c("RmbSpectrum2List", "ANY"), function(e1, e2)
})


#' Add a negative mass shift to a list of spectra
#'
#' Shifts all spectra in a `RmbSpectrum2List` by the same mass
#'
#' @param e1 a `RmbSpectrum2List` object containing zero or more `RmbSpectrum2` spectra
#' @param e2 a numeric mass shift
#'
setMethod("-", c("RmbSpectrum2List", "ANY"), function(e1, e2)
{
for(n in seq_len(length(e1)))
Expand Down
3 changes: 3 additions & 0 deletions R/buildRecord.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
#' @param mbdata list
#' The information data block for the record header, as stored in
#' \code{mbdata_relisted} after loading an infolist.
#' @param analyticalInfo A list containing information for the `AC$` section of
#' a MassBank record, with elements `ai, ac_lc, ac_ms` for general, LC and MS
#' info respectively.
#' @param additionalPeaks data.frame
#' If present, a table with additional peaks to add into the spectra.
#' As loaded with \code{\link{addPeaks}}.
Expand Down
13 changes: 13 additions & 0 deletions R/createMassBank.R
Original file line number Diff line number Diff line change
Expand Up @@ -1488,12 +1488,25 @@ annotator.default <- function(annotation, formulaTag)
#' @export
setGeneric("toMassbank", function(o, ...) standardGeneric("toMassbank"))


#' Convert spectra from a `RmbSpectraSet` object to MassBank records
#'
#' @param addAnnotation `logical`, whether to add peak annotations (putative formulas) to the record.
#'
#' @returns A list of character vectors with the MassBank records
#'
#' @export
setMethod("toMassbank", "RmbSpectraSet", function(o, addAnnotation = getOption("RMassBank")$add_annotation)
{
lapply(o@children, function(s) toMassbank(s, addAnnotation))
})

#' Convert a `RmbSpectrum2` object to a MassBank record
#'
#' @param addAnnotation `logical`, whether to add peak annotations (putative formulas) to the record.
#'
#' @returns A character vector with the MassBank record
#'
#' @export
setMethod("toMassbank", "RmbSpectrum2", function(o, addAnnotation = getOption("RMassBank")$add_annotation)
{
Expand Down
8 changes: 5 additions & 3 deletions R/leMsMs.r
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ archiveResults <- function(w, fileName, settings = getOption("RMassBank"))
#' used to extract peaks. MassBank will read existing records,
#' so that e.g. a recalibration can be performed, and "peaklist"
#' just requires a CSV with two columns and the column header "mz", "int".
#' @param filetable If including step 1 (data extraction), a `filetable` argument
#' to be passed to \code{\link{msmsRead}}.
#' @param findPeaksArgs A list of arguments that will be handed to the xcms-method findPeaks via do.call
#' @param plots A parameter that determines whether the spectra should be plotted or not (This parameter is only used for the xcms-method)
#' @param precursorscan.cf Whether to fill precursor scans. To be used with files which for
Expand Down Expand Up @@ -1292,7 +1294,7 @@ setMethod("cleanElnoise", c("RmbSpectraSet", noise="numeric", width="numeric"),
#' sp@@good <- c(TRUE, TRUE, TRUE, FALSE, FALSE)
#' sp@@precursorMz <- 600
#' sp_checked <- problematicPeaks(sp)
#' stopifnot(sum(getData(sp_checked)$problematicPeaks) == 2))
#' stopifnot(sum(getData(sp_checked)$problematicPeaks) == 2)
#' @export
problematicPeaks <- function(sp)
{
Expand Down Expand Up @@ -1330,7 +1332,6 @@ problematicPeaks <- function(sp)
#' Generates a list of intense unmatched peaks for further review (the "failpeak list") and exports it if the archive name is given.
#'
#' @param w \code{msmsWorkspace} to analyze.
#' @param mode Processing mode (pH etc)
#' @param archivename Base name of the archive to write to (for "abc" the exported failpeaks list will be "abc_Failpeaks.csv").
#' if the compoundlist is complete, "tentative", if at least a formula is present or "unknown"
#' if the only know thing is the m/z
Expand Down Expand Up @@ -1764,6 +1765,7 @@ filterPeakSatellites <- function(peaks, filterSettings = getOption("RMassBank")$
#' @param progressbar The progress bar callback to use. Only needed for specialized
#' applications. Cf. the documentation of \code{\link{progressBarHook}} for usage.
#' @param filterSettings Settings for filtering data. Refer to\code{\link{analyzeMsMs}} for settings.
#' @param mode for `reanalyzeFailpeak`, the `mode` (adduct) of the analyzed spectrum.
#' @return The aggregate data frame extended by the columns:
#' #' \item{reanalyzed.???}{If reanalysis (step 7) has already been processed: matching values from the reanalyzed peaks}
#' \item{matchedReanalysis}{Whether reanalysis has matched (\code{TRUE}), not matched(\code{FALSE}) or has not been conducted for the peak(\code{NA}).}
Expand Down Expand Up @@ -2150,7 +2152,7 @@ filterMultiplicity <- function(w, archivename=NA, mode="pH", recalcBest = TRUE,
#' to the \code{spec$peaksMatched} table. However, only minimal information needed for
#' recalibration is returned.
#'
#' @usage recalibrate.addMS1data(spec,mode="pH", recalibrateMS1Window =
#' @usage recalibrate.addMS1data(spec, recalibrateMS1Window =
#' getOption("RMassBank")$recalibrateMS1Window)
#' @param spec A \code{msmsWorkspace} or \code{RmbSpectraSetList} containing spectra for which MS1 "peaks" should be "constructed".
#' @param recalibrateMS1Window Window width to look for MS1 peaks to recalibrate (in ppm).
Expand Down
29 changes: 16 additions & 13 deletions R/leMsmsRaw.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,6 @@ NULL # This is required so that roxygen knows where the first manpage starts
#'
#' @note \code{findMsMs.direct} is deactivated
#'
## # @usage findMsMsHR(fileName, cpdID, mode="pH",confirmMode =0, useRtLimit = TRUE,
## # ppmFine = getOption("RMassBank")$findMsMsRawSettings$ppmFine,
## # mzCoarse = getOption("RMassBank")$findMsMsRawSettings$mzCoarse,
## # fillPrecursorScan = getOption("RMassBank")$findMsMsRawSettings$fillPrecursorScan,
## # rtMargin = getOption("RMassBank")$rtMargin,
## # deprofile = getOption("RMassBank")$deprofile,
## # headerCache = NULL,
## # peaksCache = NULL)
## #
## # findMsMsHR.mass(msRaw, mz, limit.coarse, limit.fine, rtLimits = NA, maxCount = NA,
## # headerCache = NULL, fillPrecursorScan = FALSE,
## # deprofile = getOption("RMassBank")$deprofile, peaksCache = NULL, cpdID = NA)
#'
#'
#' @aliases findMsMsHR.mass findMsMsHR
Expand Down Expand Up @@ -85,6 +73,10 @@ NULL # This is required so that roxygen knows where the first manpage starts
#' used (cf. \code{\link{deprofile}})
#' @param diaWindows A data frame with columns \code{precursorMz}, \code{mzMin}, \code{mzMax} which specifies the precursor and
#' window size of each window for DIA acquisition.
#' @param enforcePolarity If TRUE, scans are filtered for the given `mode`'s polarity when
#' finding the target spectrum.
#' @param polarity If set (for ?findMsMsHR.mass), scans are filtered for the given `mode`'s polarity when
#' finding the target spectrum.
#' @return An \code{RmbSpectraSet} (for \code{findMsMsHR}). Contains parent MS1 spectrum (\code{@@parent}), a block of dependent MS2 spectra ((\code{@@children})
#' and some metadata (\code{id},\code{mz},\code{name},\code{mode} in which the spectrum was acquired.
#'
Expand All @@ -106,7 +98,9 @@ NULL # This is required so that roxygen knows where the first manpage starts
#' @author Michael A. Stravs, Eawag <michael.stravs@@eawag.ch>
#' @seealso findEIC
#' @export
findMsMsHR <- function(fileName = NULL, msRaw = NULL, cpdID, mode="pH",confirmMode =0, useRtLimit = TRUE,
findMsMsHR <- function(
fileName = NULL, msRaw = NULL, cpdID, mode="pH",
confirmMode = 0, useRtLimit = TRUE,
ppmFine = getOption("RMassBank")$findMsMsRawSettings$ppmFine,
mzCoarse = getOption("RMassBank")$findMsMsRawSettings$mzCoarse,
fillPrecursorScan = getOption("RMassBank")$findMsMsRawSettings$fillPrecursorScan,
Expand Down Expand Up @@ -969,6 +963,15 @@ read.msp <- function(file){
#' freshly from \code{msRaw} for every compound.
#' @param peaksCache If present, the complete output of \code{mzR::peaks(msRaw)}. This speeds up the lookup
#' if multiple compounds should be searched in the same file.
#' @param polarity If a value is given, scans are filtered to this polarity before EIC
#' extraction. Valid values are 1 for positive, 0 for negative (according to mzR), or a RMassBank
#' `mode` (e.g. `pH, pM, mH...`) from which the polarity can be derived.
#' @param msLevel Which MS level to target for EIC extraction. By default this is 1; level 2
#' can be used to extract the EIC of fragments for a specific precursor or to extract EICs
#' from DIA data.
#' @param precursor Which precursor to target for EIC extraction. If `NULL`, the scans are not
#' filtered by precursor. Use this only for `msLevel != 1`. If a `precursor` filter is set for
#' `msLevel == 1`, all scans will be filtered out.
#' @param floatingRecalibration
#' A fitting function that \code{predict()}s a mass shift based on the retention time. Can be used
#' if a lockmass calibration is known (however you have to build the calibration yourself.)
Expand Down
21 changes: 21 additions & 0 deletions R/log_wrapper.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ NULL
#' Pass arguments to logger::log_info using custom RMassBank-logging settings
#'
#' The logging file to be used can be specified by the user in the \code{logging_file} field of \code{settings.ini}
#'
#' @param ... The log message, as for `logger::log_...` functions
#'
#' @seealso logger::log_info
#' @author pstahlhofen
#' @export
Expand All @@ -14,6 +17,9 @@ rmb_log_info <- function(...) {
#' Pass arguments to logger::log_trace using custom RMassBank-logging settings
#'
#' The logging file to be used can be specified by the user in the \code{logging_file} field of \code{settings.ini}
#'
#' @param ... The log message, as for `logger::log_...` functions
#'
#' @seealso logger::log_trace
#' @author pstahlhofen
#' @export
Expand All @@ -24,6 +30,9 @@ rmb_log_trace <- function(...) {
#' Pass arguments to logger::log_debug using custom RMassBank-logging settings
#'
#' The logging file to be used can be specified by the user in the \code{logging_file} field of \code{settings.ini}
#'
#' @param ... The log message, as for `logger::log_...` functions
#'
#' @seealso logger::log_debug
#' @author pstahlhofen
#' @export
Expand All @@ -34,6 +43,9 @@ rmb_log_debug <- function(...) {
#' Pass arguments to logger::log_warn using custom RMassBank-logging settings
#'
#' The logging file to be used can be specified by the user in the \code{logging_file} field of \code{settings.ini}
#'
#' @param ... The log message, as for `logger::log_...` functions
#'
#' @seealso logger::log_warn
#' @author pstahlhofen
#' @export
Expand All @@ -44,6 +56,9 @@ rmb_log_warn <- function(...) {
#' Pass arguments to logger::log_success using custom RMassBank-logging settings
#'
#' The logging file to be used can be specified by the user in the \code{logging_file} field of \code{settings.ini}
#'
#' @param ... The log message, as for `logger::log_...` functions
#'
#' @seealso logger::log_success
#' @author pstahlhofen
#' @export
Expand All @@ -54,6 +69,9 @@ rmb_log_success <- function(...) {
#' Pass arguments to logger::log_error using custom RMassBank-logging settings
#'
#' The logging file to be used can be specified by the user in the \code{logging_file} field of \code{settings.ini}
#'
#' @param ... The log message, as for `logger::log_...` functions
#'
#' @seealso logger::log_error
#' @author pstahlhofen
#' @export
Expand All @@ -64,6 +82,9 @@ rmb_log_error <- function(...) {
#' Pass arguments to logger::log_fatal using custom RMassBank-logging settings
#'
#' The logging file to be used can be specified by the user in the \code{logging_file} field of \code{settings.ini}
#'
#' @param ... The log message, as for `logger::log_...` functions
#'
#' @seealso logger::log_fatal
#' @author pstahlhofen
#' @export
Expand Down
18 changes: 18 additions & 0 deletions man/RmbSpectraSet-ANY-method.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions man/RmbSpectrum2List-ANY-method.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions man/Spectrum-numeric-method.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions man/buildRecord.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions man/findEIC.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions man/findMsMsHR.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 284d385

Please sign in to comment.