From 7d169e4e36cf1b5c399721bc32f9616da2b5d3f9 Mon Sep 17 00:00:00 2001 From: jorainer Date: Fri, 22 Sep 2023 13:54:04 +0200 Subject: [PATCH] docs: add comment and documentation --- R/MsBackend.R | 6 +++++- R/MsBackendDataFrame.R | 2 ++ man/MsBackend.Rd | 6 +++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/R/MsBackend.R b/R/MsBackend.R index ae21e74c..79970a57 100644 --- a/R/MsBackend.R +++ b/R/MsBackend.R @@ -561,7 +561,11 @@ #' `data`. The second parameter `peaksVariables` allows to define which columns #' in `data` contain *peak variables* such as the m/z and intensity values of #' individual peaks per spectrum. The default for this parameter is -#' `peaksVariables = c("mz", "intensity")`. +#' `peaksVariables = c("mz", "intensity")`. Note that it is not supported to +#' provide either `"mz"` or `"intensity"`, if provided, both need to be +#' present in the data frame. Alternatively, the function also supports a data +#' frame without m/z and intensity values, in which case a `Spectra` without +#' mass peaks is created. #' #' Suggested columns of this `DataFrame` are: #' diff --git a/R/MsBackendDataFrame.R b/R/MsBackendDataFrame.R index 4d2b71fb..424e64da 100644 --- a/R/MsBackendDataFrame.R +++ b/R/MsBackendDataFrame.R @@ -62,6 +62,8 @@ setMethod("backendInitialize", signature = "MsBackendDataFrame", if (!is(data, "DataFrame")) stop("'data' has to be a 'DataFrame'") peaksVariables <- intersect(peaksVariables, colnames(data)) + ## support either no m/z or intensity values provided, or both + ## have to be specified. if (sum(c("mz", "intensity") %in% peaksVariables) == 1L) stop("Both \"mz\" and \"intensity\" peak variables ", "need to be provided.") diff --git a/man/MsBackend.Rd b/man/MsBackend.Rd index c473147e..3d6a1ba5 100644 --- a/man/MsBackend.Rd +++ b/man/MsBackend.Rd @@ -779,7 +779,11 @@ subsequently initialized with the \code{backendInitialize} method, taking a \code{data}. The second parameter \code{peaksVariables} allows to define which columns in \code{data} contain \emph{peak variables} such as the m/z and intensity values of individual peaks per spectrum. The default for this parameter is -\code{peaksVariables = c("mz", "intensity")}. +\code{peaksVariables = c("mz", "intensity")}. Note that it is not supported to +provide either \code{"mz"} or \code{"intensity"}, if provided, both need to be +present in the data frame. Alternatively, the function also supports a data +frame without m/z and intensity values, in which case a \code{Spectra} without +mass peaks is created. Suggested columns of this \code{DataFrame} are: \itemize{