From c862f7c1689cecc84702c09a30dfde58bb08ff4b Mon Sep 17 00:00:00 2001 From: Philippine Louail Date: Thu, 1 Feb 2024 15:45:48 +0100 Subject: [PATCH 1/9] MztabParam --- DESCRIPTION | 3 +- NAMESPACE | 1 + R/AllGenerics.R | 14 +- R/MzTabParam.R | 406 +++++++++++++++++++++++++++++++ inst/NEWS | 8 +- man/MzTabParam.Rd | 99 ++++++++ man/PlainTextParam.Rd | 3 +- man/RDataParam.Rd | 3 +- man/storeResults.Rd | 14 +- tests/testthat/test_MzTabParam.R | 95 ++++++++ 10 files changed, 638 insertions(+), 8 deletions(-) create mode 100644 R/MzTabParam.R create mode 100644 man/MzTabParam.Rd create mode 100644 tests/testthat/test_MzTabParam.R diff --git a/DESCRIPTION b/DESCRIPTION index 005b55868..60a014ecf 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: xcms -Version: 4.1.7 +Version: 4.1.8 Title: LC-MS and GC-MS Data Analysis Description: Framework for processing and visualization of chromatographically separated and single-spectra mass spectral data. Imports from AIA/ANDI NetCDF, @@ -97,6 +97,7 @@ Collate: 'MPI.R' 'MsExperiment-functions.R' 'MsExperiment.R' + 'MzTabParam.R' 'PlainTextParam.R' 'RDataParam.R' 'XcmsExperiment-functions.R' diff --git a/NAMESPACE b/NAMESPACE index aa3563bf3..e0d862fcd 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -596,6 +596,7 @@ importFrom("jsonlite", "serializeJSON", "write_json", "unserializeJSON", "read_json") export("RDataParam") export("PlainTextParam") +export("MzTabParam") exportMethods("storeResults") ## filtering features things diff --git a/R/AllGenerics.R b/R/AllGenerics.R index b9cd7618f..465064e8d 100644 --- a/R/AllGenerics.R +++ b/R/AllGenerics.R @@ -2024,7 +2024,8 @@ setGeneric("stitch.netCDF.new", function(object, lockMass) standardGeneric("stit #' - [`PlainTextParam`]: Store `MsExperiment` and `XcmsExperiment` objects as a #' folder of plain text files, folder path defined in the `path` argument. #' -#' - `MzTabMParam`: Save in MzTab format (to be defined). +#' - [`MzTabMParam`]: Save an `XcmsExperiment` object as a .mztabm format. file +#' path defined in the `path` argument. #' #' For specific examples, see the help pages of the individual parameter classes #' listed above. @@ -2034,7 +2035,7 @@ setGeneric("stitch.netCDF.new", function(object, lockMass) standardGeneric("stit #' #' @param param The parameter object selecting and configuring the format for #' saving. It can be one of the following classes: [`RDataParam`], -#' [`PlainTextParam`], or `MzTabMParam`. +#' [`PlainTextParam`], or [`MzTabMParam`]. #' #' @param ... Optional parameters. #' @@ -2059,6 +2060,15 @@ setGeneric("stitch.netCDF.new", function(object, lockMass) standardGeneric("stit #' ## Save as a collection of plain text files #' storeResults(object = faahko_sub, param = param) #' +#' ## Define param +#' param <- MzTabParam(studyId = "test", +#' polarity = "positive", +#' sampleDataColumn = "sample_type" +#' path = "test/path/") +#' +#' ## Save as a .mzTabm file +#' storeResults(object = faahko_sub, param = param) +#' #' @md setGeneric("storeResults", function(object, param, ...) standardGeneric("storeResults")) setGeneric("subset<-", function(object, value) standardGeneric("subset<-")) diff --git a/R/MzTabParam.R b/R/MzTabParam.R new file mode 100644 index 000000000..756ae2d8a --- /dev/null +++ b/R/MzTabParam.R @@ -0,0 +1,406 @@ +#' @title Store contents of an `XcmsExperiment` objects as a .mztabm file +#' +#' @name MzTabParam +#' +#' @export +#' +#' @family xcms result export formats. +#' +#' @description +#' The `MzTabParam` class and method enable users to save an `XcmsExperiment` +#' object as a mzTabm format. Mainly the metadata (MTD) and Small molecule +#' feature (SMF) tables will represent the `XcmsExperiment`. The small molecule +#' summary section (SML) will be filled with `null` values as no annotation and +#' identification of compound is performed in `xcms`. +#' +#' This `param` class and method are part of the possible dispatch of the +#' generic function `storeResults`. The file will be created by calling +#' `storeResults`. If the file already exists, it will get overwritten. +#' +#' @param studyId `character` Will be both the `filename` of the object saved in +#' .mztabm format and the `mzTab-ID` in the file. +#' +#' @param polarity `character` Describes the polarity of the experiment. Two +#' inputs are possible, "positive" (default) or "negative". +#' +#' @param sampleDataColumn `character` strings corresponding to the column name(s) +#' of the `sampleData()` of the `XcmsExperiment` object with the different +#' *variables* of the experiment, for example it could be *"phenotype"*, +#' *"sample_type"*, etc... +#' +#' @param path `character(1)` Define where the file is going to be stored. The +#' default will be `tempdir()`. +#' +#' @param optionalFeatureColumns Optional columns from `featureDefinitions` +#' that should be exported too. For example it could be *"peakidx*, +#' *"npeaks"*, etc... +#' +#' @param dots `list` Correspond to any optional parameters to be passed +#' to the `featureValues` function. (e.g. parameters `method` or `value`). +#' +#' @inheritParams storeResults +#' +#' @return for `MzTabParam`: a `MzTabParam` class. `storeResults` does +#' not return anything but saves the object as a .mztabm file. +#' +#' @note +#' This function was build so that the output fit the recommendation of mztab-m +#' file format. These can be found here: +#' http://hupo-psi.github.io/mzTab/2_0-metabolomics-release/mzTab_format_specification_2_0-M_release.html +#' +#' @references +#' +#' Hoffmann N, Rein J, Sachsenberg T, Hartler J, Haug K, Mayer G, Alka O, +#' Dayalan S, Pearce JTM, Rocca-Serra P, Qi D, Eisenacher M, Perez-Riverol Y, +#' Vizcaíno JA, Salek RM, Neumann S, Jones AR. mzTab-M: A Data Standard for +#' Sharing Quantitative Results in Mass Spectrometry Metabolomics. Anal Chem. +#' 2019 Mar 5;91(5):3302-3310. doi: 10.1021/acs.analchem.8b04310. Epub 2019 Feb +#' 13. PMID: 30688441; PMCID: PMC6660005. +#' +#' @author Philippine Louail, Johannes Rainer +#' +#' @examples +#' ## Load a test data set with detected peaks, of class `XcmsExperiment` +#' test_xcms <- loadXcmsData() +#' +#' ## Define param +#' param <- MzTabParam(studyId = "test", +#' polarity = "positive", +#' sampleDataColumn = "sample_type") +#' +#' ## Save as a .mzTabm file +#' storeResults(test_xcms, param) +#' +NULL + +#' @noRd +setClass("MzTabParam", + slots = c(studyId = "character", + polarity = "character", + sampleDataColumn = "character", + path = "character", + optionalFeatureColumns = "character", + dots = "list" + ), + contains = "Param", + prototype = prototype( + studyId = character(), + polarity = character(), + sampleDataColumn = character(), + path = character(), + optionalFeatureColumns = character(), + dots = list() + ), + validity = function(object) { + msg <- NULL + if(length(object@studyId) != 1) + msg <- c("'studyId' has to be a character string of length 1") + if(length(object@polarity) != 1) + msg <- c(msg, "'polarity' has to be a character string of length 1") + if(length(object@sampleDataColumn) == 0) + msg <- c(msg, "'sampleDataColumn' cannot be empty") + if (length(object@path) != 1) + msg <- c(msg, "'path' has to be a character string of length 1") + msg + }) + +#' @rdname MzTabParam +#' +#' @export +MzTabParam <- function(studyId = character(), + polarity = c("positive", "negative"), + sampleDataColumn = character(), + path = tempdir(), + optionalFeatureColumns = character(), ...) { + polarity <- match.arg(polarity) + new("MzTabParam", studyId = studyId, polarity = polarity, + sampleDataColumn = sampleDataColumn, path = path, + optionalFeatureColumns = optionalFeatureColumns, dots = list(...)) +} + +#' @rdname MzTabParam +setMethod("storeResults", + signature(object = "XcmsExperiment", + param = "MzTabParam"), + function(object, param){ + if(!param@sampleDataColumn %in% colnames(sampleData(object))) + stop("'sampleDataColumn' has to correspond to column names", + "of the sampleData() table") + if(length(param@optionalFeatureColumns) != 0) + if(!param@optionalFeatureColumns %in% colnames(featureDefinitions(object))) + stop("'optionalFeatureColumns' have to correspond to", + "column names of the featureDefinitions() table") + + var_list <- unique(.mztab_study_variables(sampleData(object), + param@sampleDataColumn)) + fl <- file.path(param@path, paste0(param@studyId, ".mztab")) + if (file.exists(fl)) { + warning("File ", basename(fl), " already exists. ", + "Will overwrite.") + file.remove(fl) + } + con <- file(fl, open = "at") + on.exit(close(con)) + + mtd <- .mztab_metadata(object, study_id = param@studyId, + polarity = param@polarity, + col_phenotype = param@sampleDataColumn) + .mztab_export(mtd, con) + writeLines("", con) + + sml <- .mztab_small_molecule_summary(n_sample = length(object), + var_list = var_list) + .mztab_export(sml, con) + writeLines("", con) + + smf <- do.call(.mztab_small_molecule_feature, + c(list(object = object, + opt_columns = param@optionalFeatureColumns), + param@dots)) + .mztab_export(smf, con) + }) + + +### Helper functions + +#' @description +#' +#' Create the metadata `matrix` (MTD). Use the .MTD static object as a basis. +#' +#' @noRd +.mztab_metadata <- function(object, study_id, polarity, col_phenotype) { + n_sample <- length(object) + seq_sample <- seq_len(n_sample) + base <- .MTD + base[base == "replace_id"] <- study_id + msrun <- cbind( + name = paste0("ms_run[", seq_sample, "]-location"), + value = unlist(fileNames(object)), + order = .prefix_zero(seq_sample) + ) + if (polarity == "positive") { + pol <- cbind( + name = paste0("ms_run[", seq_sample, "]-scan_polarity[1]"), + value = "[MS, MS:1000130, positive scan, ]", + order = .prefix_zero(seq_sample)) + } else { + pol <- cbind( + name = paste0("ms_run[", seq_sample, "]-scan_polarity[1]"), + value = "[MS, MS:1000129, negative scan, ]", + order = .prefix_zero(seq_sample)) + } + msrun <- rbind(msrun, pol) + msrun <- msrun[order(msrun[, "order"]), c("name", "value")] + + assay <- cbind( + name = paste("assay", seq_sample), + value = paste0("assay[", seq_sample, "]"), + order = .prefix_zero(seq_sample) + ) + assay_ref <- cbind( + name = paste0("assay[", seq_sample, "]-ms_run_ref"), + value = paste0("ms_run[", seq_sample, "]"), + order = .prefix_zero(seq_sample) + ) + assay <- rbind(assay, assay_ref) + assay <- assay[order(assay[, "order"]), c("name", "value")] + + var <- .mztab_study_variable_entries(sampleData(object), col_phenotype) + + mtd <- rbind( + base[1:4, ], + msrun, + assay, + var, + base[5:nrow(base), ] + ) + cbind(id = "MTD", mtd) +} + +#' @description +#' +#' Create the *empty* small molecule summary (SML) `matrix`. +#' Use the .SML static object as a basis +#' +#' @noRd +#' +#' @examples +#' +#' .mztab_small_molecule_summary(5, c(1, 2, 3)) +.mztab_small_molecule_summary <- function(n_sample, var_list) { + sml <- c(.SML, paste0("abundance_assay[", seq_len(n_sample) ,"]"), + paste0("abundance_study_variable[", + seq_len(length(var_list)) ,"]"), + paste0("abundance_variation_study_variable[", + seq_len(length(var_list)) ,"]")) + rbind(sml, c("SML", "1", rep("null", length(sml) - 2L))) +} + +#' @description +#' +#' Create the small molecule feature (SMF) `matrix` One row is one feature +#' defined in xcms. Use the .SMF static object. +#' object as a basis. +#' +#' @noRd +#' +#' @param object `XcmsExperiment`. +#' +#' @param opt_columns `character` defining optional columns in +#' `featureDefinitions` that should be exported too. +#' +#' @param ... optional parameters for the `featureValues` call. +.mztab_small_molecule_feature <- function(object, opt_columns = character(), + ...) { + fts <- featureDefinitions(object) + smf <- matrix(data = "null", ncol = length(.SMF), nrow = nrow(fts), + dimnames = list(character(), .SMF)) + smf[, "SFH"] <- "SMF" + smf[, "SMF_ID"] <- seq_len(nrow(fts)) + smf[, "exp_mass_to_charge"] <- as.character(fts$mzmed, digits = 18) + smf[, "retention_time_in_seconds"] <- as.character(fts$rtmed, digits = 15) + smf[, "retention_time_in_seconds_start"] <- as.character(fts$rtmin, + digits = 15) + smf[, "retention_time_in_seconds_end"] <- as.character(fts$rtmax, + digits = 15) + + fvals <- featureValues(object, ...) + colnames(fvals) <- paste0("abundance_assay[", seq_len(ncol(fvals)), "]") + fvals <- apply(fvals, 2L, as.character, digits = 15) + fvals[is.na(fvals)] <- "null" + + smf <- cbind(smf, fvals) + + if (length(opt_columns)) { + tmp <- do.call( + cbind, lapply(opt_columns, + function(z) { + if (z == "peakidx") { + vapply(fts[, z], paste0, character(1), + collapse = "| ") + } else as.character(fts[, z], digits = 15) + })) + colnames(tmp) <- paste0("opt_", opt_columns) + smf <- cbind(smf, tmp) + } + smf <- rbind(colnames(smf), smf) + unname(smf) +} + +#' @description +#' +#' Define the `character` vector with all study variables. +#' +#' @param x `data.frame` with sample annotations +#' +#' @param variable `character` with the column name(s) containing the study +#' variables. +#' +#' @return `character` with the study variables, being a concatenation of +#' the column name `"|"` and the value of the variable. +#' +#' @noRd +#' +#' @examples +#' +#' x <- data.frame(sex = c("male", "female", "female", "male", "male"), +#' group = c("case", "case", "control", "case", "control")) +#' +#' .mztab_study_variables(x, variable = c("sex", "group")) +#' +#' .mztab_study_variables(x, "sex") +.mztab_study_variables <- function(x = data.frame(), variable = character(), + sep = ":") { + do.call(cbind, lapply(variable, function(z) paste0(z, sep, x[, z]))) +} + +#' @description +#' +#' Create a `matrix` with the *study_variable* metadata content based. +#' +#' @param x `data.frame` representing the `sampleData` of the `MsExperiment`. +#' +#' @param variable `character` defining the columns in `x` containing the +#' sample variables. +#' +#' @return `character` `matrix` (two columns) with the result. +#' +#' @noRd +#' +#' @examples +#' +#' .mztab_study_variable_entries(x, "sex") +#' +#' .mztab_study_variable_entries(x, c("group", "sex")) +.mztab_study_variable_entries <- function(x, variable, sep = "| ") { + svar <- .mztab_study_variables(x, variable) + unique_svar <- unique(as.vector(svar)) + res <- matrix(character(), ncol = 2, nrow = 0, + dimnames = list(character(), c("name", "value"))) + for (i in seq_along(unique_svar)) { + idx <- which(svar == unique_svar[i], arr.ind = TRUE) + res <- rbind( + res, + matrix(ncol = 2, + c(paste0("study_variable[", i, "]"), + paste0("study_variable[", i, "]-assay_refs"), + paste0(unique_svar[i]), + paste0("assay[", idx[, "row"], "]", collapse = sep) + ))) + } + res +} + +#' @noRd +.prefix_zero <- function(x) { + sprintf(paste0("%0", ceiling(log10(max(x) + 1)), "d"), x) +} + +#' @noRd +.mztab_export <- function(x, con) { + x <- apply(x, 1L, paste0, collapse = "\t") + writeLines(x, con) +} + +### Static objects +.MTD <- cbind( + name = c("mzTab-version", + "mzTab-ID", + "software[1]", + "quantification_method", + "cv[1]-label", + "cv[1]-full_name", + "cv[1]-version", + "cv[1]-uri", + "database[1]", + "database[1]-prefix", + "database[1]-version", + "database[1]-uri", + "small_molecule-quantification_unit", + "small_molecule_feature-quantification_unit", + "id_confidence_measure[1]"), + value = c("2.0.0-M", + "replace_id", + "[MS, MS:4711, xcms, 3.1.1]", + "[MS, MS:1001834, LC-MS label-free quantitation analysis]", + "MS", + "PSI-MS controlled vocabulary", + "4.1.138", + "https://raw.githubusercontent.com/HUPO-PSI/psi-ms-CV/master/psi-ms.obo", + "[,, \"no database\", null ]", + "null", + "Unknown", + "null", + "null", + "[MS, MS:1001841, LC-MS feature volume, ]", + "null")) + +.SML <- c("SMH", "SML_ID","SMF_ID_REFS", "database_identifier", + "chemical_formula", "smiles", "inchi", "chemical_name", + "uri", "theoretical_neutral_mass", "adduct_ions", "reliability", + "best_id_confidence_measure", "best_id_confidence_value") + +.SMF <- c("SFH", "SMF_ID","SME_ID_REFS", "SME_ID_REF_ambiguity_code", + "adduct_ion", "isotopomer", "exp_mass_to_charge", "charge", + "retention_time_in_seconds", "retention_time_in_seconds_start", + "retention_time_in_seconds_end") diff --git a/inst/NEWS b/inst/NEWS index 5fc15922b..6d84b4881 100644 --- a/inst/NEWS +++ b/inst/NEWS @@ -1,3 +1,9 @@ +Changes in version 4.1.8 +---------------------- + +- Add a `param =` to generic function `storeResults`: `MzTabParam` to save + an `XcmsExperiment` object as .mztabm file type. + Changes in version 4.1.7 ---------------------- @@ -56,7 +62,7 @@ Changes in version 4.1.2 ---------------------- - Add a `param =` to generic function `storeResults`: `PlainTextParam` to save - an `XcmsExperiment` or `MsExperiment` object as colleciton of plain text + an `XcmsExperiment` or `MsExperiment` object as collection of plain text files. Changes in version 4.1.1 diff --git a/man/MzTabParam.Rd b/man/MzTabParam.Rd new file mode 100644 index 000000000..f142657c5 --- /dev/null +++ b/man/MzTabParam.Rd @@ -0,0 +1,99 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/MzTabParam.R +\name{MzTabParam} +\alias{MzTabParam} +\alias{storeResults,XcmsExperiment,MzTabParam-method} +\title{Store contents of an `XcmsExperiment` objects as a .mztabm file} +\usage{ +MzTabParam( + studyId = character(), + polarity = c("positive", "negative"), + sampleDataColumn = character(), + path = tempdir(), + optionalFeatureColumns = character(), + ... +) + +\S4method{storeResults}{XcmsExperiment,MzTabParam}(object, param) +} +\arguments{ +\item{studyId}{`character` Will be both the `filename` of the object saved in +.mztabm format and the `mzTab-ID` in the file.} + +\item{polarity}{`character` Describes the polarity of the experiment. Two +inputs are possible, "positive" (default) or "negative".} + +\item{sampleDataColumn}{`character` strings corresponding to the column name(s) +of the `sampleData()` of the `XcmsExperiment` object with the different +*variables* of the experiment, for example it could be *"phenotype"*, +*"sample_type"*, etc...} + +\item{path}{`character(1)` Define where the file is going to be stored. The +default will be `tempdir()`.} + +\item{optionalFeatureColumns}{Optional columns from `featureDefinitions` +that should be exported too. For example it could be *"peakidx*, +*"npeaks"*, etc...} + +\item{...}{Optional parameters.} + +\item{object}{\code{MsExperiment} or \code{XcmsExperiment} The data object that needs +to be saved.} + +\item{param}{The parameter object selecting and configuring the format for +saving. It can be one of the following classes: \code{\link{RDataParam}}, +\code{\link{PlainTextParam}}, or \code{\link{MzTabMParam}}.} + +\item{dots}{`list` Correspond to any optional parameters to be passed +to the `featureValues` function. (e.g. parameters `method` or `value`).} +} +\value{ +for `MzTabParam`: a `MzTabParam` class. `storeResults` does +not return anything but saves the object as a .mztabm file. +} +\description{ +The `MzTabParam` class and method enable users to save an `XcmsExperiment` +object as a mzTabm format. Mainly the metadata (MTD) and Small molecule +feature (SMF) tables will represent the `XcmsExperiment`. The small molecule +summary section (SML) will be filled with `null` values as no annotation and +identification of compound is performed in `xcms`. + +This `param` class and method are part of the possible dispatch of the +generic function `storeResults`. The file will be created by calling +`storeResults`. If the file already exists, it will get overwritten. +} +\note{ +This function was build so that the output fit the recommendation of mztab-m +file format. These can be found here: +http://hupo-psi.github.io/mzTab/2_0-metabolomics-release/mzTab_format_specification_2_0-M_release.html +} +\examples{ +## Load a test data set with detected peaks, of class `XcmsExperiment` +test_xcms <- loadXcmsData() + +## Define param +param <- MzTabParam(studyId = "test", + polarity = "positive", + sampleDataColumn = "sample_type") + +## Save as a .mzTabm file +storeResults(test_xcms, param) + +} +\references{ +Hoffmann N, Rein J, Sachsenberg T, Hartler J, Haug K, Mayer G, Alka O, +Dayalan S, Pearce JTM, Rocca-Serra P, Qi D, Eisenacher M, Perez-Riverol Y, +Vizcaíno JA, Salek RM, Neumann S, Jones AR. mzTab-M: A Data Standard for +Sharing Quantitative Results in Mass Spectrometry Metabolomics. Anal Chem. +2019 Mar 5;91(5):3302-3310. doi: 10.1021/acs.analchem.8b04310. Epub 2019 Feb +13. PMID: 30688441; PMCID: PMC6660005. +} +\seealso{ +Other xcms result export formats.: +\code{\link{PlainTextParam}}, +\code{\link{RDataParam}} +} +\author{ +Philippine Louail, Johannes Rainer +} +\concept{xcms result export formats.} diff --git a/man/PlainTextParam.Rd b/man/PlainTextParam.Rd index 8bd806486..46f094294 100644 --- a/man/PlainTextParam.Rd +++ b/man/PlainTextParam.Rd @@ -22,7 +22,7 @@ to be saved.} \item{param}{The parameter object selecting and configuring the format for saving. It can be one of the following classes: \code{\link{RDataParam}}, -\code{\link{PlainTextParam}}, or \code{MzTabMParam}.} +\code{\link{PlainTextParam}}, or \code{\link{MzTabMParam}}.} } \value{ for `PlainTextParam`: a `PlainTextParam` class. `storeResults` does @@ -106,6 +106,7 @@ storeResults(object = faahko_sub, param = param) } \seealso{ Other xcms result export formats.: +\code{\link{MzTabParam}}, \code{\link{RDataParam}} } \author{ diff --git a/man/RDataParam.Rd b/man/RDataParam.Rd index 617c3dc93..7da2d9dd1 100644 --- a/man/RDataParam.Rd +++ b/man/RDataParam.Rd @@ -18,7 +18,7 @@ to be saved.} \item{param}{The parameter object selecting and configuring the format for saving. It can be one of the following classes: \code{\link{RDataParam}}, -\code{\link{PlainTextParam}}, or \code{MzTabMParam}.} +\code{\link{PlainTextParam}}, or \code{\link{MzTabMParam}}.} } \value{ for `RDataParam`: a `RDataParam` class. `storeResults` does not @@ -44,6 +44,7 @@ storeResults(object = faahko_sub, param = param) } \seealso{ Other xcms result export formats.: +\code{\link{MzTabParam}}, \code{\link{PlainTextParam}} } \author{ diff --git a/man/storeResults.Rd b/man/storeResults.Rd index a72a4c8cd..d435e30c3 100644 --- a/man/storeResults.Rd +++ b/man/storeResults.Rd @@ -12,7 +12,7 @@ to be saved.} \item{param}{The parameter object selecting and configuring the format for saving. It can be one of the following classes: \code{\link{RDataParam}}, -\code{\link{PlainTextParam}}, or \code{MzTabMParam}.} +\code{\link{PlainTextParam}}, or \code{\link{MzTabMParam}}.} \item{...}{Optional parameters.} } @@ -27,7 +27,8 @@ Supported \code{param} objects are: specified in the \code{fileName} argument. \item \code{\link{PlainTextParam}}: Store \code{MsExperiment} and \code{XcmsExperiment} objects as a folder of plain text files, folder path defined in the \code{path} argument. -\item \code{MzTabMParam}: Save in MzTab format (to be defined). +\item \code{\link{MzTabMParam}}: Save an \code{XcmsExperiment} object as a .mztabm format. file +path defined in the \code{path} argument. } For specific examples, see the help pages of the individual parameter classes @@ -50,6 +51,15 @@ param <- PlainTextParam(path = "test/path/") ## Save as a collection of plain text files storeResults(object = faahko_sub, param = param) +## Define param +param <- MzTabParam(studyId = "test", + polarity = "positive", + sampleDataColumn = "sample_type" + path = "test/path/") + +## Save as a .mzTabm file +storeResults(object = faahko_sub, param = param) + } \author{ Philippine Louail diff --git a/tests/testthat/test_MzTabParam.R b/tests/testthat/test_MzTabParam.R new file mode 100644 index 000000000..372f34dc8 --- /dev/null +++ b/tests/testthat/test_MzTabParam.R @@ -0,0 +1,95 @@ +faahko <- loadXcmsData("faahko_sub2") +faahko <- groupChromPeaks( + faahko, PeakDensityParam(sampleGroups = rep(1, length(faahko)))) + +xmse_full <- loadXcmsData() + +test_that(".mztab_metadata works", { + mtd <- .mztab_metadata(xmse_full, study_id = "test", polarity = "negative", + col_phenotype = "sample_type") + + expect_false(all(mtd != "test")) + expect_true(is.matrix(mtd)) + expect_true(is.character(mtd)) + expect_equal(mtd[, "id"], rep("MTD", nrow(mtd))) + expect_equal(ncol(mtd), 3) + expect_equal(length(grep("assay ", mtd[, 2])), length(xmse_full)) + expect_equal(length(grep("negative ", mtd[, 3])), length(xmse_full)) +}) + +test_that(".mztab_small_molecule_feature works", { + a <- .mztab_small_molecule_feature(faahko) + expect_true(is.matrix(a)) + expect_true(is.character(a)) + expect_equal(a[1, 1], "SFH") + expect_equal(nrow(a), nrow(featureDefinitions(faahko)) + 1) + expect_equal(length(grep("abundance_assay", a[1, ])), length(faahko)) + + b <- .mztab_small_molecule_feature( + faahko, opt_columns = c("peakidx", "ms_level"), + method = "sum", value = "maxo") + expect_equal(nrow(a), nrow(b)) + expect_true(ncol(b) > ncol(a)) + expect_true(any(b[1, ] == "opt_peakidx")) + expect_true(any(b[1, ] == "opt_ms_level")) + ## Check that optional parameters are correctly passed + a2 <- a[2:nrow(a), a[1, ] == "abundance_assay[2]"] + a2[a2 == "null"] <- NA + a2 <- as.numeric(a2) + b2 <- b[2:nrow(b), b[1, ] == "abundance_assay[2]"] + b2[b2 == "null"] <- NA + b2 <- as.numeric(b2) + expect_equal(is.na(a2), is.na(b2)) + expect_true(all(a2[!is.na(a2)] != b2[!is.na(b2)])) + ## Check that we don't loose information through import/export + expect_equal(a2, unname(featureValues(faahko)[, 2])) + expect_equal(b2, unname(featureValues( + faahko, method = "sum", value = "maxo")[, 2])) +}) + +test_that(".mztab_study_variables works", { + x <- data.frame(a = 1:3, b = c(1, 1, 2)) + res <- .mztab_study_variables(x, variable = "a") + expect_true(is.character(res)) + expect_true(is.matrix(res)) + expect_true(ncol(res) == 1L) + expect_equal(res[, 1L], c("a:1", "a:2", "a:3")) + + res <- .mztab_study_variables(x, variable = c("a", "b")) + expect_true(is.character(res)) + expect_true(is.matrix(res)) + expect_true(ncol(res) == 2L) + expect_equal(res[, 1L], c("a:1", "a:2", "a:3")) + expect_equal(res[, 2L], c("b:1", "b:1", "b:2")) +}) + +test_that(".mztab_study_variable_entries works", { + x <- data.frame(a = 1:3, b = c(1, 1, 2)) + res <- .mztab_study_variable_entries(x, variable = "a") + expect_true(is.character(res)) + expect_true(is.matrix(res)) + expect_true(ncol(res) == 2L) + expect_equal(unname(res[1, 1]), "study_variable[1]") + expect_equal(unname(res[2, 1]), "study_variable[1]-assay_refs") + expect_equal(unname(res[1, 2]), "a:1") + expect_equal(unname(res[2, 2]), "assay[1]") + + res2 <- .mztab_study_variable_entries(x, variable = c("a", "b")) + expect_true(length(res2) > length(res)) +}) + +test_that("storeResults,MzTabParam works", { + d <- tempdir() + p <- MzTabParam(studyId = "test_study", path = d, + sampleDataColumn = "sample_index", + optionalFeatureColumns = "peakidx") + storeResults(faahko, p) + expect_true(file.exists(file.path(d, "test_study.mztab"))) + res <- readLines(file.path(d, "test_study.mztab")) + expect_true(length(res) > 0L) + expect_true(length(grep("^MTD", res)) > 0) + expect_true(length(grep("^SML", res)) > 0) + expect_true(length(grep("^SMF", res)) > 0) + ## Check for empty lines + expect_true(length(grep(c("^MTD|SML|SMF"), res, invert = TRUE)) == 2) +}) From 8dd469bd433b554fb6159c0e547f16a12871e7c9 Mon Sep 17 00:00:00 2001 From: Philippine Louail Date: Fri, 2 Feb 2024 09:50:14 +0100 Subject: [PATCH 2/9] fixes --- R/AllGenerics.R | 11 +++++++---- R/MzTabParam.R | 6 +++--- man/MzTabParam.Rd | 16 ++++++++++------ man/PlainTextParam.Rd | 2 +- man/RDataParam.Rd | 2 +- man/storeResults.Rd | 11 +++++++---- 6 files changed, 29 insertions(+), 19 deletions(-) diff --git a/R/AllGenerics.R b/R/AllGenerics.R index 465064e8d..3cea0d758 100644 --- a/R/AllGenerics.R +++ b/R/AllGenerics.R @@ -2024,7 +2024,7 @@ setGeneric("stitch.netCDF.new", function(object, lockMass) standardGeneric("stit #' - [`PlainTextParam`]: Store `MsExperiment` and `XcmsExperiment` objects as a #' folder of plain text files, folder path defined in the `path` argument. #' -#' - [`MzTabMParam`]: Save an `XcmsExperiment` object as a .mztabm format. file +#' - [`MzTabParam`]: Save an `XcmsExperiment` object as a .mztabm format. file #' path defined in the `path` argument. #' #' For specific examples, see the help pages of the individual parameter classes @@ -2035,7 +2035,7 @@ setGeneric("stitch.netCDF.new", function(object, lockMass) standardGeneric("stit #' #' @param param The parameter object selecting and configuring the format for #' saving. It can be one of the following classes: [`RDataParam`], -#' [`PlainTextParam`], or [`MzTabMParam`]. +#' [`PlainTextParam`], or [`MzTabParam`]. #' #' @param ... Optional parameters. #' @@ -2060,14 +2060,17 @@ setGeneric("stitch.netCDF.new", function(object, lockMass) standardGeneric("stit #' ## Save as a collection of plain text files #' storeResults(object = faahko_sub, param = param) #' +#' ## Get XcmsExperiment object with defined metadata +#' test_xcms <- loadXcmsData() +#' #' ## Define param #' param <- MzTabParam(studyId = "test", #' polarity = "positive", -#' sampleDataColumn = "sample_type" +#' sampleDataColumn = "sample_type", #' path = "test/path/") #' #' ## Save as a .mzTabm file -#' storeResults(object = faahko_sub, param = param) +#' storeResults(object = test_xcms, param = param) #' #' @md setGeneric("storeResults", function(object, param, ...) standardGeneric("storeResults")) diff --git a/R/MzTabParam.R b/R/MzTabParam.R index 756ae2d8a..8563e4407 100644 --- a/R/MzTabParam.R +++ b/R/MzTabParam.R @@ -35,7 +35,7 @@ #' that should be exported too. For example it could be *"peakidx*, #' *"npeaks"*, etc... #' -#' @param dots `list` Correspond to any optional parameters to be passed +#' @slot dots `list` Correspond to any optional parameters to be passed #' to the `featureValues` function. (e.g. parameters `method` or `value`). #' #' @inheritParams storeResults @@ -46,13 +46,13 @@ #' @note #' This function was build so that the output fit the recommendation of mztab-m #' file format. These can be found here: -#' http://hupo-psi.github.io/mzTab/2_0-metabolomics-release/mzTab_format_specification_2_0-M_release.html +#' (http://hupo-psi.github.io/mzTab/2_0-metabolomics-release/mzTab_format_specification_2_0-M_release.html) #' #' @references #' #' Hoffmann N, Rein J, Sachsenberg T, Hartler J, Haug K, Mayer G, Alka O, #' Dayalan S, Pearce JTM, Rocca-Serra P, Qi D, Eisenacher M, Perez-Riverol Y, -#' Vizcaíno JA, Salek RM, Neumann S, Jones AR. mzTab-M: A Data Standard for +#' Vizcaino JA, Salek RM, Neumann S, Jones AR. mzTab-M: A Data Standard for #' Sharing Quantitative Results in Mass Spectrometry Metabolomics. Anal Chem. #' 2019 Mar 5;91(5):3302-3310. doi: 10.1021/acs.analchem.8b04310. Epub 2019 Feb #' 13. PMID: 30688441; PMCID: PMC6660005. diff --git a/man/MzTabParam.Rd b/man/MzTabParam.Rd index f142657c5..9c0591332 100644 --- a/man/MzTabParam.Rd +++ b/man/MzTabParam.Rd @@ -42,10 +42,7 @@ to be saved.} \item{param}{The parameter object selecting and configuring the format for saving. It can be one of the following classes: \code{\link{RDataParam}}, -\code{\link{PlainTextParam}}, or \code{\link{MzTabMParam}}.} - -\item{dots}{`list` Correspond to any optional parameters to be passed -to the `featureValues` function. (e.g. parameters `method` or `value`).} +\code{\link{PlainTextParam}}, or \code{\link{MzTabParam}}.} } \value{ for `MzTabParam`: a `MzTabParam` class. `storeResults` does @@ -62,10 +59,17 @@ This `param` class and method are part of the possible dispatch of the generic function `storeResults`. The file will be created by calling `storeResults`. If the file already exists, it will get overwritten. } +\section{Slots}{ + +\describe{ +\item{\code{dots}}{`list` Correspond to any optional parameters to be passed +to the `featureValues` function. (e.g. parameters `method` or `value`).} +}} + \note{ This function was build so that the output fit the recommendation of mztab-m file format. These can be found here: -http://hupo-psi.github.io/mzTab/2_0-metabolomics-release/mzTab_format_specification_2_0-M_release.html +(http://hupo-psi.github.io/mzTab/2_0-metabolomics-release/mzTab_format_specification_2_0-M_release.html) } \examples{ ## Load a test data set with detected peaks, of class `XcmsExperiment` @@ -83,7 +87,7 @@ storeResults(test_xcms, param) \references{ Hoffmann N, Rein J, Sachsenberg T, Hartler J, Haug K, Mayer G, Alka O, Dayalan S, Pearce JTM, Rocca-Serra P, Qi D, Eisenacher M, Perez-Riverol Y, -Vizcaíno JA, Salek RM, Neumann S, Jones AR. mzTab-M: A Data Standard for +Vizcaino JA, Salek RM, Neumann S, Jones AR. mzTab-M: A Data Standard for Sharing Quantitative Results in Mass Spectrometry Metabolomics. Anal Chem. 2019 Mar 5;91(5):3302-3310. doi: 10.1021/acs.analchem.8b04310. Epub 2019 Feb 13. PMID: 30688441; PMCID: PMC6660005. diff --git a/man/PlainTextParam.Rd b/man/PlainTextParam.Rd index 46f094294..69c50266b 100644 --- a/man/PlainTextParam.Rd +++ b/man/PlainTextParam.Rd @@ -22,7 +22,7 @@ to be saved.} \item{param}{The parameter object selecting and configuring the format for saving. It can be one of the following classes: \code{\link{RDataParam}}, -\code{\link{PlainTextParam}}, or \code{\link{MzTabMParam}}.} +\code{\link{PlainTextParam}}, or \code{\link{MzTabParam}}.} } \value{ for `PlainTextParam`: a `PlainTextParam` class. `storeResults` does diff --git a/man/RDataParam.Rd b/man/RDataParam.Rd index 7da2d9dd1..ce2536f1e 100644 --- a/man/RDataParam.Rd +++ b/man/RDataParam.Rd @@ -18,7 +18,7 @@ to be saved.} \item{param}{The parameter object selecting and configuring the format for saving. It can be one of the following classes: \code{\link{RDataParam}}, -\code{\link{PlainTextParam}}, or \code{\link{MzTabMParam}}.} +\code{\link{PlainTextParam}}, or \code{\link{MzTabParam}}.} } \value{ for `RDataParam`: a `RDataParam` class. `storeResults` does not diff --git a/man/storeResults.Rd b/man/storeResults.Rd index d435e30c3..c4da3169d 100644 --- a/man/storeResults.Rd +++ b/man/storeResults.Rd @@ -12,7 +12,7 @@ to be saved.} \item{param}{The parameter object selecting and configuring the format for saving. It can be one of the following classes: \code{\link{RDataParam}}, -\code{\link{PlainTextParam}}, or \code{\link{MzTabMParam}}.} +\code{\link{PlainTextParam}}, or \code{\link{MzTabParam}}.} \item{...}{Optional parameters.} } @@ -27,7 +27,7 @@ Supported \code{param} objects are: specified in the \code{fileName} argument. \item \code{\link{PlainTextParam}}: Store \code{MsExperiment} and \code{XcmsExperiment} objects as a folder of plain text files, folder path defined in the \code{path} argument. -\item \code{\link{MzTabMParam}}: Save an \code{XcmsExperiment} object as a .mztabm format. file +\item \code{\link{MzTabParam}}: Save an \code{XcmsExperiment} object as a .mztabm format. file path defined in the \code{path} argument. } @@ -51,14 +51,17 @@ param <- PlainTextParam(path = "test/path/") ## Save as a collection of plain text files storeResults(object = faahko_sub, param = param) +## Get XcmsExperiment object with defined metadata +test_xcms <- loadXcmsData() + ## Define param param <- MzTabParam(studyId = "test", polarity = "positive", - sampleDataColumn = "sample_type" + sampleDataColumn = "sample_type", path = "test/path/") ## Save as a .mzTabm file -storeResults(object = faahko_sub, param = param) +storeResults(object = test_xcms, param = param) } \author{ From a45ff100881c7c781bd1b4d0cdddacab00dab4e2 Mon Sep 17 00:00:00 2001 From: Philippine Louail Date: Thu, 18 Jul 2024 10:43:18 +0200 Subject: [PATCH 3/9] Update MzTabParam.R --- R/MzTabParam.R | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/R/MzTabParam.R b/R/MzTabParam.R index 8563e4407..0b80eafc0 100644 --- a/R/MzTabParam.R +++ b/R/MzTabParam.R @@ -175,7 +175,7 @@ setMethod("storeResults", base[base == "replace_id"] <- study_id msrun <- cbind( name = paste0("ms_run[", seq_sample, "]-location"), - value = unlist(fileNames(object)), + value = paste0("file:///", unlist(gsub(" ", "",fileNames(object)))), order = .prefix_zero(seq_sample) ) if (polarity == "positive") { @@ -193,8 +193,8 @@ setMethod("storeResults", msrun <- msrun[order(msrun[, "order"]), c("name", "value")] assay <- cbind( - name = paste("assay", seq_sample), - value = paste0("assay[", seq_sample, "]"), + name = paste0("assay[", seq_sample, "]"), + value = paste(seq_sample, "assay"), order = .prefix_zero(seq_sample) ) assay_ref <- cbind( @@ -214,7 +214,9 @@ setMethod("storeResults", var, base[5:nrow(base), ] ) - cbind(id = "MTD", mtd) + mtd <- cbind(id = "MTD", mtd) + + gsub("\\\\", "/", mtd) } #' @description @@ -241,7 +243,7 @@ setMethod("storeResults", #' Create the small molecule feature (SMF) `matrix` One row is one feature #' defined in xcms. Use the .SMF static object. #' object as a basis. -#' +#'read #' @noRd #' #' @param object `XcmsExperiment`. @@ -343,8 +345,10 @@ setMethod("storeResults", res, matrix(ncol = 2, c(paste0("study_variable[", i, "]"), + paste0("study_variable[", i, "]-description"), paste0("study_variable[", i, "]-assay_refs"), paste0(unique_svar[i]), + paste0("Sample in column ", unique_svar[i]), #either this or paste0("assay[", idx[, "row"], "]", collapse = sep) ))) } @@ -363,6 +367,7 @@ setMethod("storeResults", } ### Static objects + .MTD <- cbind( name = c("mzTab-version", "mzTab-ID", @@ -372,28 +377,32 @@ setMethod("storeResults", "cv[1]-full_name", "cv[1]-version", "cv[1]-uri", + "cv[2]-label", + "cv[2]-full_name", + "cv[2]-version", + "cv[2]-uri", "database[1]", "database[1]-prefix", "database[1]-version", "database[1]-uri", - "small_molecule-quantification_unit", - "small_molecule_feature-quantification_unit", - "id_confidence_measure[1]"), + "small_molecule_feature-quantification_unit"), value = c("2.0.0-M", "replace_id", - "[MS, MS:4711, xcms, 3.1.1]", - "[MS, MS:1001834, LC-MS label-free quantitation analysis]", + "[MS, MS:1001582, XCMS, 3.1.1]", + "[MS, MS:1001834, LC-MS label-free quantitation analysis, ]", "MS", "PSI-MS controlled vocabulary", "4.1.138", "https://raw.githubusercontent.com/HUPO-PSI/psi-ms-CV/master/psi-ms.obo", + "PRIDE", + "PRIDE PRoteomics IDEntifications (PRIDE) database controlled vocabulary", + "16:10:2023 11:38", + "https://www.ebi.ac.uk/ols/ontologies/pride", "[,, \"no database\", null ]", "null", "Unknown", "null", - "null", - "[MS, MS:1001841, LC-MS feature volume, ]", - "null")) + "[PRIDE, PRIDE:0000330, Arbitrary quantification unit, ]")) .SML <- c("SMH", "SML_ID","SMF_ID_REFS", "database_identifier", "chemical_formula", "smiles", "inchi", "chemical_name", @@ -404,3 +413,4 @@ setMethod("storeResults", "adduct_ion", "isotopomer", "exp_mass_to_charge", "charge", "retention_time_in_seconds", "retention_time_in_seconds_start", "retention_time_in_seconds_end") + From c403cd6b29fe141c640034e8c85723d7b8abce19 Mon Sep 17 00:00:00 2001 From: Philippine Louail <127301965+philouail@users.noreply.github.com> Date: Tue, 1 Oct 2024 21:54:40 +0200 Subject: [PATCH 4/9] small_update to matchLamaChromPeaks() output --- R/XcmsExperiment.R | 2 +- R/do_adjustRtime-functions.R | 7 +- tests/testthat/test_MzTabParam.R | 95 ------------------- .../testthat/test_do_adjustRtime-functions.R | 11 ++- 4 files changed, 13 insertions(+), 102 deletions(-) delete mode 100644 tests/testthat/test_MzTabParam.R diff --git a/R/XcmsExperiment.R b/R/XcmsExperiment.R index db3efa05f..a094a7163 100644 --- a/R/XcmsExperiment.R +++ b/R/XcmsExperiment.R @@ -1391,7 +1391,7 @@ setMethod( rt_adj <- bpmapply(rtMap, rt_raw, idx, FUN = function(x, y, i, param) { if (nrow(x) >= 10) { # too strict ? Gam always throws error when less than that and loess does not work that well either. .adjust_rt_model(y, method = param@method, - rt_map = x, span = param@span, + rt_map = x[, c("ref","obs")], span = param@span, resid_ratio = param@outlierTolerance, zero_weight = param@zeroWeight, bs = param@bs) diff --git a/R/do_adjustRtime-functions.R b/R/do_adjustRtime-functions.R index c45b0940a..1fe5282cb 100644 --- a/R/do_adjustRtime-functions.R +++ b/R/do_adjustRtime-functions.R @@ -788,7 +788,9 @@ NULL #' #' @return a `data.frame` with columns `"ref"` and `"obs"` with the retention #' times of the pairs of matched peaks. This `data.frame` can be used -#' in `.adjust_rt_model`'s parameter `rt_raw`. +#' in `.adjust_rt_model`'s parameter `rt_raw`. The column `chromPeaksId` +#' contains the rownames of the `obs_peaks` matrix. This can be used to +#' identify the peaks that were matched. #' #' @author Johannes Rainer, Philippine Louail #' @@ -804,7 +806,8 @@ NULL dups <- idx[duplicated(idx[, 2L]), 2L] idx <- idx[!idx[, 2L] %in% dups, , drop = FALSE] data.frame(ref = ref_anchors[idx[, 2L], 2L], - obs = obs_peaks[idx[, 1L], 2L]) + obs = obs_peaks[idx[, 1L], 2L], + chromPeaksId = rownames(obs_peaks[idx[, 1L], ,drop = FALSE])) } #' @description diff --git a/tests/testthat/test_MzTabParam.R b/tests/testthat/test_MzTabParam.R deleted file mode 100644 index 372f34dc8..000000000 --- a/tests/testthat/test_MzTabParam.R +++ /dev/null @@ -1,95 +0,0 @@ -faahko <- loadXcmsData("faahko_sub2") -faahko <- groupChromPeaks( - faahko, PeakDensityParam(sampleGroups = rep(1, length(faahko)))) - -xmse_full <- loadXcmsData() - -test_that(".mztab_metadata works", { - mtd <- .mztab_metadata(xmse_full, study_id = "test", polarity = "negative", - col_phenotype = "sample_type") - - expect_false(all(mtd != "test")) - expect_true(is.matrix(mtd)) - expect_true(is.character(mtd)) - expect_equal(mtd[, "id"], rep("MTD", nrow(mtd))) - expect_equal(ncol(mtd), 3) - expect_equal(length(grep("assay ", mtd[, 2])), length(xmse_full)) - expect_equal(length(grep("negative ", mtd[, 3])), length(xmse_full)) -}) - -test_that(".mztab_small_molecule_feature works", { - a <- .mztab_small_molecule_feature(faahko) - expect_true(is.matrix(a)) - expect_true(is.character(a)) - expect_equal(a[1, 1], "SFH") - expect_equal(nrow(a), nrow(featureDefinitions(faahko)) + 1) - expect_equal(length(grep("abundance_assay", a[1, ])), length(faahko)) - - b <- .mztab_small_molecule_feature( - faahko, opt_columns = c("peakidx", "ms_level"), - method = "sum", value = "maxo") - expect_equal(nrow(a), nrow(b)) - expect_true(ncol(b) > ncol(a)) - expect_true(any(b[1, ] == "opt_peakidx")) - expect_true(any(b[1, ] == "opt_ms_level")) - ## Check that optional parameters are correctly passed - a2 <- a[2:nrow(a), a[1, ] == "abundance_assay[2]"] - a2[a2 == "null"] <- NA - a2 <- as.numeric(a2) - b2 <- b[2:nrow(b), b[1, ] == "abundance_assay[2]"] - b2[b2 == "null"] <- NA - b2 <- as.numeric(b2) - expect_equal(is.na(a2), is.na(b2)) - expect_true(all(a2[!is.na(a2)] != b2[!is.na(b2)])) - ## Check that we don't loose information through import/export - expect_equal(a2, unname(featureValues(faahko)[, 2])) - expect_equal(b2, unname(featureValues( - faahko, method = "sum", value = "maxo")[, 2])) -}) - -test_that(".mztab_study_variables works", { - x <- data.frame(a = 1:3, b = c(1, 1, 2)) - res <- .mztab_study_variables(x, variable = "a") - expect_true(is.character(res)) - expect_true(is.matrix(res)) - expect_true(ncol(res) == 1L) - expect_equal(res[, 1L], c("a:1", "a:2", "a:3")) - - res <- .mztab_study_variables(x, variable = c("a", "b")) - expect_true(is.character(res)) - expect_true(is.matrix(res)) - expect_true(ncol(res) == 2L) - expect_equal(res[, 1L], c("a:1", "a:2", "a:3")) - expect_equal(res[, 2L], c("b:1", "b:1", "b:2")) -}) - -test_that(".mztab_study_variable_entries works", { - x <- data.frame(a = 1:3, b = c(1, 1, 2)) - res <- .mztab_study_variable_entries(x, variable = "a") - expect_true(is.character(res)) - expect_true(is.matrix(res)) - expect_true(ncol(res) == 2L) - expect_equal(unname(res[1, 1]), "study_variable[1]") - expect_equal(unname(res[2, 1]), "study_variable[1]-assay_refs") - expect_equal(unname(res[1, 2]), "a:1") - expect_equal(unname(res[2, 2]), "assay[1]") - - res2 <- .mztab_study_variable_entries(x, variable = c("a", "b")) - expect_true(length(res2) > length(res)) -}) - -test_that("storeResults,MzTabParam works", { - d <- tempdir() - p <- MzTabParam(studyId = "test_study", path = d, - sampleDataColumn = "sample_index", - optionalFeatureColumns = "peakidx") - storeResults(faahko, p) - expect_true(file.exists(file.path(d, "test_study.mztab"))) - res <- readLines(file.path(d, "test_study.mztab")) - expect_true(length(res) > 0L) - expect_true(length(grep("^MTD", res)) > 0) - expect_true(length(grep("^SML", res)) > 0) - expect_true(length(grep("^SMF", res)) > 0) - ## Check for empty lines - expect_true(length(grep(c("^MTD|SML|SMF"), res, invert = TRUE)) == 2) -}) diff --git a/tests/testthat/test_do_adjustRtime-functions.R b/tests/testthat/test_do_adjustRtime-functions.R index 1f90ec845..2d36e1014 100644 --- a/tests/testthat/test_do_adjustRtime-functions.R +++ b/tests/testthat/test_do_adjustRtime-functions.R @@ -293,13 +293,16 @@ test_that(".match_reference_anchors works", { rt = c(100, 150.1, 190, 190, 190, 192)) b <- cbind(mz = c(200.2, 232, 233.1, 234), rt = c(150, 190.4, 193, 240)) + rownames(a) <- rep("a", nrow(a)) + rownames(b) <- rep("b", nrow(b)) res <- .match_reference_anchors(a, b) expect_true(is.data.frame(res)) - expect_equal(colnames(res), c("ref", "obs")) + expect_equal(colnames(res), c("ref", "obs", "chromPeaksId")) expect_true(nrow(res) == 1L) expect_equal(res$ref, 193.0) expect_equal(res$obs, 190.0) + expect_equal(res$chromPeaksId, "a") ## no matches: res <- .match_reference_anchors(a, b, tolerance = 0, toleranceRt = 0) @@ -311,7 +314,7 @@ test_that(".match_reference_anchors works", { ## rows 5 and 6 from `a` match row 3 from `b` res <- .match_reference_anchors(a, b, tolerance = 0.1, toleranceRt = 52) expect_true(is.data.frame(res)) - expect_equal(colnames(res), c("ref", "obs")) + expect_equal(colnames(res),c("ref", "obs", "chromPeaksId")) expect_equal(res$ref, 190.4) expect_equal(res$obs, 190.0) @@ -320,7 +323,7 @@ test_that(".match_reference_anchors works", { ## `b` and should thus not be reported. res <- .match_reference_anchors(a, b, tolerance = 0.1, toleranceRt = 5) expect_true(is.data.frame(res)) - expect_equal(colnames(res), c("ref", "obs")) + expect_equal(colnames(res), c("ref", "obs", "chromPeaksId")) expect_equal(res$ref, c(150, 190.4)) expect_equal(res$obs, c(150.1, 190.0)) @@ -328,7 +331,7 @@ test_that(".match_reference_anchors works", { ## with row 3 in `b`. res <- .match_reference_anchors(a, b, tolerance = 0.1, toleranceRt = 2) expect_true(is.data.frame(res)) - expect_equal(colnames(res), c("ref", "obs")) + expect_equal(colnames(res), c("ref", "obs", "chromPeaksId")) expect_equal(res$ref, c(150, 190.4, 193.0)) expect_equal(res$obs, c(150.1, 190.0, 192.0)) }) From 89f17f0fc6c7410beb64d186752d5d2da1d9d659 Mon Sep 17 00:00:00 2001 From: Philippine Louail <127301965+philouail@users.noreply.github.com> Date: Tue, 1 Oct 2024 22:07:27 +0200 Subject: [PATCH 5/9] removing MztabParam --- R/MzTabParam.R | 416 ---------------------------------------------- man/MzTabParam.Rd | 103 ------------ 2 files changed, 519 deletions(-) delete mode 100644 R/MzTabParam.R delete mode 100644 man/MzTabParam.Rd diff --git a/R/MzTabParam.R b/R/MzTabParam.R deleted file mode 100644 index 0b80eafc0..000000000 --- a/R/MzTabParam.R +++ /dev/null @@ -1,416 +0,0 @@ -#' @title Store contents of an `XcmsExperiment` objects as a .mztabm file -#' -#' @name MzTabParam -#' -#' @export -#' -#' @family xcms result export formats. -#' -#' @description -#' The `MzTabParam` class and method enable users to save an `XcmsExperiment` -#' object as a mzTabm format. Mainly the metadata (MTD) and Small molecule -#' feature (SMF) tables will represent the `XcmsExperiment`. The small molecule -#' summary section (SML) will be filled with `null` values as no annotation and -#' identification of compound is performed in `xcms`. -#' -#' This `param` class and method are part of the possible dispatch of the -#' generic function `storeResults`. The file will be created by calling -#' `storeResults`. If the file already exists, it will get overwritten. -#' -#' @param studyId `character` Will be both the `filename` of the object saved in -#' .mztabm format and the `mzTab-ID` in the file. -#' -#' @param polarity `character` Describes the polarity of the experiment. Two -#' inputs are possible, "positive" (default) or "negative". -#' -#' @param sampleDataColumn `character` strings corresponding to the column name(s) -#' of the `sampleData()` of the `XcmsExperiment` object with the different -#' *variables* of the experiment, for example it could be *"phenotype"*, -#' *"sample_type"*, etc... -#' -#' @param path `character(1)` Define where the file is going to be stored. The -#' default will be `tempdir()`. -#' -#' @param optionalFeatureColumns Optional columns from `featureDefinitions` -#' that should be exported too. For example it could be *"peakidx*, -#' *"npeaks"*, etc... -#' -#' @slot dots `list` Correspond to any optional parameters to be passed -#' to the `featureValues` function. (e.g. parameters `method` or `value`). -#' -#' @inheritParams storeResults -#' -#' @return for `MzTabParam`: a `MzTabParam` class. `storeResults` does -#' not return anything but saves the object as a .mztabm file. -#' -#' @note -#' This function was build so that the output fit the recommendation of mztab-m -#' file format. These can be found here: -#' (http://hupo-psi.github.io/mzTab/2_0-metabolomics-release/mzTab_format_specification_2_0-M_release.html) -#' -#' @references -#' -#' Hoffmann N, Rein J, Sachsenberg T, Hartler J, Haug K, Mayer G, Alka O, -#' Dayalan S, Pearce JTM, Rocca-Serra P, Qi D, Eisenacher M, Perez-Riverol Y, -#' Vizcaino JA, Salek RM, Neumann S, Jones AR. mzTab-M: A Data Standard for -#' Sharing Quantitative Results in Mass Spectrometry Metabolomics. Anal Chem. -#' 2019 Mar 5;91(5):3302-3310. doi: 10.1021/acs.analchem.8b04310. Epub 2019 Feb -#' 13. PMID: 30688441; PMCID: PMC6660005. -#' -#' @author Philippine Louail, Johannes Rainer -#' -#' @examples -#' ## Load a test data set with detected peaks, of class `XcmsExperiment` -#' test_xcms <- loadXcmsData() -#' -#' ## Define param -#' param <- MzTabParam(studyId = "test", -#' polarity = "positive", -#' sampleDataColumn = "sample_type") -#' -#' ## Save as a .mzTabm file -#' storeResults(test_xcms, param) -#' -NULL - -#' @noRd -setClass("MzTabParam", - slots = c(studyId = "character", - polarity = "character", - sampleDataColumn = "character", - path = "character", - optionalFeatureColumns = "character", - dots = "list" - ), - contains = "Param", - prototype = prototype( - studyId = character(), - polarity = character(), - sampleDataColumn = character(), - path = character(), - optionalFeatureColumns = character(), - dots = list() - ), - validity = function(object) { - msg <- NULL - if(length(object@studyId) != 1) - msg <- c("'studyId' has to be a character string of length 1") - if(length(object@polarity) != 1) - msg <- c(msg, "'polarity' has to be a character string of length 1") - if(length(object@sampleDataColumn) == 0) - msg <- c(msg, "'sampleDataColumn' cannot be empty") - if (length(object@path) != 1) - msg <- c(msg, "'path' has to be a character string of length 1") - msg - }) - -#' @rdname MzTabParam -#' -#' @export -MzTabParam <- function(studyId = character(), - polarity = c("positive", "negative"), - sampleDataColumn = character(), - path = tempdir(), - optionalFeatureColumns = character(), ...) { - polarity <- match.arg(polarity) - new("MzTabParam", studyId = studyId, polarity = polarity, - sampleDataColumn = sampleDataColumn, path = path, - optionalFeatureColumns = optionalFeatureColumns, dots = list(...)) -} - -#' @rdname MzTabParam -setMethod("storeResults", - signature(object = "XcmsExperiment", - param = "MzTabParam"), - function(object, param){ - if(!param@sampleDataColumn %in% colnames(sampleData(object))) - stop("'sampleDataColumn' has to correspond to column names", - "of the sampleData() table") - if(length(param@optionalFeatureColumns) != 0) - if(!param@optionalFeatureColumns %in% colnames(featureDefinitions(object))) - stop("'optionalFeatureColumns' have to correspond to", - "column names of the featureDefinitions() table") - - var_list <- unique(.mztab_study_variables(sampleData(object), - param@sampleDataColumn)) - fl <- file.path(param@path, paste0(param@studyId, ".mztab")) - if (file.exists(fl)) { - warning("File ", basename(fl), " already exists. ", - "Will overwrite.") - file.remove(fl) - } - con <- file(fl, open = "at") - on.exit(close(con)) - - mtd <- .mztab_metadata(object, study_id = param@studyId, - polarity = param@polarity, - col_phenotype = param@sampleDataColumn) - .mztab_export(mtd, con) - writeLines("", con) - - sml <- .mztab_small_molecule_summary(n_sample = length(object), - var_list = var_list) - .mztab_export(sml, con) - writeLines("", con) - - smf <- do.call(.mztab_small_molecule_feature, - c(list(object = object, - opt_columns = param@optionalFeatureColumns), - param@dots)) - .mztab_export(smf, con) - }) - - -### Helper functions - -#' @description -#' -#' Create the metadata `matrix` (MTD). Use the .MTD static object as a basis. -#' -#' @noRd -.mztab_metadata <- function(object, study_id, polarity, col_phenotype) { - n_sample <- length(object) - seq_sample <- seq_len(n_sample) - base <- .MTD - base[base == "replace_id"] <- study_id - msrun <- cbind( - name = paste0("ms_run[", seq_sample, "]-location"), - value = paste0("file:///", unlist(gsub(" ", "",fileNames(object)))), - order = .prefix_zero(seq_sample) - ) - if (polarity == "positive") { - pol <- cbind( - name = paste0("ms_run[", seq_sample, "]-scan_polarity[1]"), - value = "[MS, MS:1000130, positive scan, ]", - order = .prefix_zero(seq_sample)) - } else { - pol <- cbind( - name = paste0("ms_run[", seq_sample, "]-scan_polarity[1]"), - value = "[MS, MS:1000129, negative scan, ]", - order = .prefix_zero(seq_sample)) - } - msrun <- rbind(msrun, pol) - msrun <- msrun[order(msrun[, "order"]), c("name", "value")] - - assay <- cbind( - name = paste0("assay[", seq_sample, "]"), - value = paste(seq_sample, "assay"), - order = .prefix_zero(seq_sample) - ) - assay_ref <- cbind( - name = paste0("assay[", seq_sample, "]-ms_run_ref"), - value = paste0("ms_run[", seq_sample, "]"), - order = .prefix_zero(seq_sample) - ) - assay <- rbind(assay, assay_ref) - assay <- assay[order(assay[, "order"]), c("name", "value")] - - var <- .mztab_study_variable_entries(sampleData(object), col_phenotype) - - mtd <- rbind( - base[1:4, ], - msrun, - assay, - var, - base[5:nrow(base), ] - ) - mtd <- cbind(id = "MTD", mtd) - - gsub("\\\\", "/", mtd) -} - -#' @description -#' -#' Create the *empty* small molecule summary (SML) `matrix`. -#' Use the .SML static object as a basis -#' -#' @noRd -#' -#' @examples -#' -#' .mztab_small_molecule_summary(5, c(1, 2, 3)) -.mztab_small_molecule_summary <- function(n_sample, var_list) { - sml <- c(.SML, paste0("abundance_assay[", seq_len(n_sample) ,"]"), - paste0("abundance_study_variable[", - seq_len(length(var_list)) ,"]"), - paste0("abundance_variation_study_variable[", - seq_len(length(var_list)) ,"]")) - rbind(sml, c("SML", "1", rep("null", length(sml) - 2L))) -} - -#' @description -#' -#' Create the small molecule feature (SMF) `matrix` One row is one feature -#' defined in xcms. Use the .SMF static object. -#' object as a basis. -#'read -#' @noRd -#' -#' @param object `XcmsExperiment`. -#' -#' @param opt_columns `character` defining optional columns in -#' `featureDefinitions` that should be exported too. -#' -#' @param ... optional parameters for the `featureValues` call. -.mztab_small_molecule_feature <- function(object, opt_columns = character(), - ...) { - fts <- featureDefinitions(object) - smf <- matrix(data = "null", ncol = length(.SMF), nrow = nrow(fts), - dimnames = list(character(), .SMF)) - smf[, "SFH"] <- "SMF" - smf[, "SMF_ID"] <- seq_len(nrow(fts)) - smf[, "exp_mass_to_charge"] <- as.character(fts$mzmed, digits = 18) - smf[, "retention_time_in_seconds"] <- as.character(fts$rtmed, digits = 15) - smf[, "retention_time_in_seconds_start"] <- as.character(fts$rtmin, - digits = 15) - smf[, "retention_time_in_seconds_end"] <- as.character(fts$rtmax, - digits = 15) - - fvals <- featureValues(object, ...) - colnames(fvals) <- paste0("abundance_assay[", seq_len(ncol(fvals)), "]") - fvals <- apply(fvals, 2L, as.character, digits = 15) - fvals[is.na(fvals)] <- "null" - - smf <- cbind(smf, fvals) - - if (length(opt_columns)) { - tmp <- do.call( - cbind, lapply(opt_columns, - function(z) { - if (z == "peakidx") { - vapply(fts[, z], paste0, character(1), - collapse = "| ") - } else as.character(fts[, z], digits = 15) - })) - colnames(tmp) <- paste0("opt_", opt_columns) - smf <- cbind(smf, tmp) - } - smf <- rbind(colnames(smf), smf) - unname(smf) -} - -#' @description -#' -#' Define the `character` vector with all study variables. -#' -#' @param x `data.frame` with sample annotations -#' -#' @param variable `character` with the column name(s) containing the study -#' variables. -#' -#' @return `character` with the study variables, being a concatenation of -#' the column name `"|"` and the value of the variable. -#' -#' @noRd -#' -#' @examples -#' -#' x <- data.frame(sex = c("male", "female", "female", "male", "male"), -#' group = c("case", "case", "control", "case", "control")) -#' -#' .mztab_study_variables(x, variable = c("sex", "group")) -#' -#' .mztab_study_variables(x, "sex") -.mztab_study_variables <- function(x = data.frame(), variable = character(), - sep = ":") { - do.call(cbind, lapply(variable, function(z) paste0(z, sep, x[, z]))) -} - -#' @description -#' -#' Create a `matrix` with the *study_variable* metadata content based. -#' -#' @param x `data.frame` representing the `sampleData` of the `MsExperiment`. -#' -#' @param variable `character` defining the columns in `x` containing the -#' sample variables. -#' -#' @return `character` `matrix` (two columns) with the result. -#' -#' @noRd -#' -#' @examples -#' -#' .mztab_study_variable_entries(x, "sex") -#' -#' .mztab_study_variable_entries(x, c("group", "sex")) -.mztab_study_variable_entries <- function(x, variable, sep = "| ") { - svar <- .mztab_study_variables(x, variable) - unique_svar <- unique(as.vector(svar)) - res <- matrix(character(), ncol = 2, nrow = 0, - dimnames = list(character(), c("name", "value"))) - for (i in seq_along(unique_svar)) { - idx <- which(svar == unique_svar[i], arr.ind = TRUE) - res <- rbind( - res, - matrix(ncol = 2, - c(paste0("study_variable[", i, "]"), - paste0("study_variable[", i, "]-description"), - paste0("study_variable[", i, "]-assay_refs"), - paste0(unique_svar[i]), - paste0("Sample in column ", unique_svar[i]), #either this or - paste0("assay[", idx[, "row"], "]", collapse = sep) - ))) - } - res -} - -#' @noRd -.prefix_zero <- function(x) { - sprintf(paste0("%0", ceiling(log10(max(x) + 1)), "d"), x) -} - -#' @noRd -.mztab_export <- function(x, con) { - x <- apply(x, 1L, paste0, collapse = "\t") - writeLines(x, con) -} - -### Static objects - -.MTD <- cbind( - name = c("mzTab-version", - "mzTab-ID", - "software[1]", - "quantification_method", - "cv[1]-label", - "cv[1]-full_name", - "cv[1]-version", - "cv[1]-uri", - "cv[2]-label", - "cv[2]-full_name", - "cv[2]-version", - "cv[2]-uri", - "database[1]", - "database[1]-prefix", - "database[1]-version", - "database[1]-uri", - "small_molecule_feature-quantification_unit"), - value = c("2.0.0-M", - "replace_id", - "[MS, MS:1001582, XCMS, 3.1.1]", - "[MS, MS:1001834, LC-MS label-free quantitation analysis, ]", - "MS", - "PSI-MS controlled vocabulary", - "4.1.138", - "https://raw.githubusercontent.com/HUPO-PSI/psi-ms-CV/master/psi-ms.obo", - "PRIDE", - "PRIDE PRoteomics IDEntifications (PRIDE) database controlled vocabulary", - "16:10:2023 11:38", - "https://www.ebi.ac.uk/ols/ontologies/pride", - "[,, \"no database\", null ]", - "null", - "Unknown", - "null", - "[PRIDE, PRIDE:0000330, Arbitrary quantification unit, ]")) - -.SML <- c("SMH", "SML_ID","SMF_ID_REFS", "database_identifier", - "chemical_formula", "smiles", "inchi", "chemical_name", - "uri", "theoretical_neutral_mass", "adduct_ions", "reliability", - "best_id_confidence_measure", "best_id_confidence_value") - -.SMF <- c("SFH", "SMF_ID","SME_ID_REFS", "SME_ID_REF_ambiguity_code", - "adduct_ion", "isotopomer", "exp_mass_to_charge", "charge", - "retention_time_in_seconds", "retention_time_in_seconds_start", - "retention_time_in_seconds_end") - diff --git a/man/MzTabParam.Rd b/man/MzTabParam.Rd deleted file mode 100644 index 9c0591332..000000000 --- a/man/MzTabParam.Rd +++ /dev/null @@ -1,103 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/MzTabParam.R -\name{MzTabParam} -\alias{MzTabParam} -\alias{storeResults,XcmsExperiment,MzTabParam-method} -\title{Store contents of an `XcmsExperiment` objects as a .mztabm file} -\usage{ -MzTabParam( - studyId = character(), - polarity = c("positive", "negative"), - sampleDataColumn = character(), - path = tempdir(), - optionalFeatureColumns = character(), - ... -) - -\S4method{storeResults}{XcmsExperiment,MzTabParam}(object, param) -} -\arguments{ -\item{studyId}{`character` Will be both the `filename` of the object saved in -.mztabm format and the `mzTab-ID` in the file.} - -\item{polarity}{`character` Describes the polarity of the experiment. Two -inputs are possible, "positive" (default) or "negative".} - -\item{sampleDataColumn}{`character` strings corresponding to the column name(s) -of the `sampleData()` of the `XcmsExperiment` object with the different -*variables* of the experiment, for example it could be *"phenotype"*, -*"sample_type"*, etc...} - -\item{path}{`character(1)` Define where the file is going to be stored. The -default will be `tempdir()`.} - -\item{optionalFeatureColumns}{Optional columns from `featureDefinitions` -that should be exported too. For example it could be *"peakidx*, -*"npeaks"*, etc...} - -\item{...}{Optional parameters.} - -\item{object}{\code{MsExperiment} or \code{XcmsExperiment} The data object that needs -to be saved.} - -\item{param}{The parameter object selecting and configuring the format for -saving. It can be one of the following classes: \code{\link{RDataParam}}, -\code{\link{PlainTextParam}}, or \code{\link{MzTabParam}}.} -} -\value{ -for `MzTabParam`: a `MzTabParam` class. `storeResults` does -not return anything but saves the object as a .mztabm file. -} -\description{ -The `MzTabParam` class and method enable users to save an `XcmsExperiment` -object as a mzTabm format. Mainly the metadata (MTD) and Small molecule -feature (SMF) tables will represent the `XcmsExperiment`. The small molecule -summary section (SML) will be filled with `null` values as no annotation and -identification of compound is performed in `xcms`. - -This `param` class and method are part of the possible dispatch of the -generic function `storeResults`. The file will be created by calling -`storeResults`. If the file already exists, it will get overwritten. -} -\section{Slots}{ - -\describe{ -\item{\code{dots}}{`list` Correspond to any optional parameters to be passed -to the `featureValues` function. (e.g. parameters `method` or `value`).} -}} - -\note{ -This function was build so that the output fit the recommendation of mztab-m -file format. These can be found here: -(http://hupo-psi.github.io/mzTab/2_0-metabolomics-release/mzTab_format_specification_2_0-M_release.html) -} -\examples{ -## Load a test data set with detected peaks, of class `XcmsExperiment` -test_xcms <- loadXcmsData() - -## Define param -param <- MzTabParam(studyId = "test", - polarity = "positive", - sampleDataColumn = "sample_type") - -## Save as a .mzTabm file -storeResults(test_xcms, param) - -} -\references{ -Hoffmann N, Rein J, Sachsenberg T, Hartler J, Haug K, Mayer G, Alka O, -Dayalan S, Pearce JTM, Rocca-Serra P, Qi D, Eisenacher M, Perez-Riverol Y, -Vizcaino JA, Salek RM, Neumann S, Jones AR. mzTab-M: A Data Standard for -Sharing Quantitative Results in Mass Spectrometry Metabolomics. Anal Chem. -2019 Mar 5;91(5):3302-3310. doi: 10.1021/acs.analchem.8b04310. Epub 2019 Feb -13. PMID: 30688441; PMCID: PMC6660005. -} -\seealso{ -Other xcms result export formats.: -\code{\link{PlainTextParam}}, -\code{\link{RDataParam}} -} -\author{ -Philippine Louail, Johannes Rainer -} -\concept{xcms result export formats.} From c55523c3a9d00697b555f97b650cf32b7b595aee Mon Sep 17 00:00:00 2001 From: Philippine Louail <127301965+philouail@users.noreply.github.com> Date: Wed, 2 Oct 2024 10:05:59 +0200 Subject: [PATCH 6/9] Update check-bioc.yml --- .github/workflows/check-bioc.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check-bioc.yml b/.github/workflows/check-bioc.yml index 8af610887..7da178a3a 100644 --- a/.github/workflows/check-bioc.yml +++ b/.github/workflows/check-bioc.yml @@ -222,7 +222,7 @@ jobs: rcmdcheck::rcmdcheck( args = c("--no-build-vignettes", "--no-manual", "--timings"), build_args = c("--no-manual", "--no-resave-data"), - error_on = "warning", + error_on = "error", check_dir = "check" ) shell: Rscript {0} From 9cd1ebd9776f0818896ef72755e5615e6e48c445 Mon Sep 17 00:00:00 2001 From: Philippine Louail <127301965+philouail@users.noreply.github.com> Date: Thu, 3 Oct 2024 09:22:00 +0200 Subject: [PATCH 7/9] bump version --- DESCRIPTION | 2 +- NEWS.md | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index a9c46263e..6fd200747 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: xcms -Version: 4.3.3 +Version: 4.3.4 Title: LC-MS and GC-MS Data Analysis Description: Framework for processing and visualization of chromatographically separated and single-spectra mass spectral data. Imports from AIA/ANDI NetCDF, diff --git a/NEWS.md b/NEWS.md index 1a47aa96e..536bc58e5 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,14 @@ # xcms 4.3 +## Changes in version 4.3.4 + +- Small update to the `matchLamaChromPeaks()` function to get the chromPeaksId + of the chromPeaks matched with Lamas. +- Small fix to the .yml file for the github actions, so they do not crash on + warnings. + + + ## Changes in version 4.3.3 - Fix issue #755: `chromatogram()` with `msLevel = 2` fails to extract From 324bb462699b123fbec2398f7e9ee05b332c2e7f Mon Sep 17 00:00:00 2001 From: J Wokaty Date: Tue, 29 Oct 2024 09:24:25 -0400 Subject: [PATCH 8/9] bump x.y.z version to even y prior to creation of RELEASE_3_20 branch --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index a9c46263e..685a54874 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: xcms -Version: 4.3.3 +Version: 4.4.0 Title: LC-MS and GC-MS Data Analysis Description: Framework for processing and visualization of chromatographically separated and single-spectra mass spectral data. Imports from AIA/ANDI NetCDF, From 3c1702c2cc34b5fa05386b7bcedbbe7360cbe757 Mon Sep 17 00:00:00 2001 From: J Wokaty Date: Tue, 29 Oct 2024 09:24:25 -0400 Subject: [PATCH 9/9] bump x.y.z version to odd y following creation of RELEASE_3_20 branch --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 685a54874..154df8389 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: xcms -Version: 4.4.0 +Version: 4.5.0 Title: LC-MS and GC-MS Data Analysis Description: Framework for processing and visualization of chromatographically separated and single-spectra mass spectral data. Imports from AIA/ANDI NetCDF,