diff --git a/DESCRIPTION b/DESCRIPTION index e700676d..ae152de7 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: xcms -Version: 4.3.0 +Version: 4.3.1 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, @@ -60,7 +60,7 @@ Imports: S4Vectors, IRanges, SummarizedExperiment, - MsCoreUtils (>= 1.15.5), + MsCoreUtils (>= 1.16.0), MsFeatures, MsExperiment (>= 1.5.4), Spectra (>= 1.13.7), diff --git a/NAMESPACE b/NAMESPACE index e732edbc..d039123b 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -33,7 +33,7 @@ importFrom("SummarizedExperiment", "rowData") importFrom("SummarizedExperiment", "rowData<-") importFrom("SummarizedExperiment", "assay") importFrom("MsCoreUtils", "rbindFill", "closest", "i2index", "sumi", "between", - "maxi", "breaks_ppm", "force_sorted") + "maxi", "breaks_ppm", "force_sorted", "common_path") importFrom("RColorBrewer", "brewer.pal") importFrom("graphics", "image", "boxplot", "matplot", "rect", "axis", diff --git a/NEWS.md b/NEWS.md index 6d0da0e0..4e8a9cc0 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,9 @@ -# xcms 4.1 +# xcms 4.3 + +## Changes in version 4.3.1 + +- Addition of generic function `loadResults()`and method for import using + `RDataParam` and `PlaintTextParam`. ## Changes in version 4.1.14 diff --git a/R/AllGenerics.R b/R/AllGenerics.R index 38673af7..888892d4 100644 --- a/R/AllGenerics.R +++ b/R/AllGenerics.R @@ -1523,7 +1523,7 @@ setGeneric("levelplot", function(x, data, ...) standardGeneric("levelplot")) #' #' ## Save as a collection of plain text files #' pth = file.path(tempdir(), "test") -#' param <- PlainTextParam(path = pth) +#' param <- PlainTextParam(path = pth, spectraExport = TRUE) #' storeResults(object = faahko_sub, param = param) #' #' ## Load this saved dataset diff --git a/R/PlainTextParam.R b/R/PlainTextParam.R index cc6bd05c..5545860f 100644 --- a/R/PlainTextParam.R +++ b/R/PlainTextParam.R @@ -56,6 +56,14 @@ #' `storeResults`. If the folder already exists, previous exports in that #' folder might get overwritten. #' +#' If the `spectraExport` parameter is set to `TRUE`, the spectra data will be +#' exported/imported. The import should be done in a file system similar to the +#' one used for the export. The `spectraFilePath` parameter can be used to +#' define the absolute path where the spectra files should be imported from +#' when loading the object. The default will be set using the common file path +#' of all the spectra files when exporting. If the `spectraExport` parameter is +#' set to `FALSE`, the spectra data will not be exported/imported. +#' #' @param path for `PlainTextParam` `character(1)`, defining where the files #' are going to be stored/ should be loaded from. The default will be #' `tempdir()`. @@ -109,7 +117,7 @@ #' #' ## Define param #' pth = file.path(tempdir(), "test") -#' param <- PlainTextParam(path = pth) +#' param <- PlainTextParam(path = pth, spectraExport = TRUE) #' #' ## Save as a collection of plain text files #' storeResults(object = faahko_sub, param = param) diff --git a/man/PlainTextParam.Rd b/man/PlainTextParam.Rd index 38b9ff26..e98c47f5 100644 --- a/man/PlainTextParam.Rd +++ b/man/PlainTextParam.Rd @@ -94,6 +94,14 @@ generic functions `storeResults()` and `loadResults()`. The folder defined in the `path` parameter will be created by calling `storeResults`. If the folder already exists, previous exports in that folder might get overwritten. + +If the `spectraExport` parameter is set to `TRUE`, the spectra data will be +exported/imported. The import should be done in a file system similar to the +one used for the export. The `spectraFilePath` parameter can be used to +define the absolute path where the spectra files should be imported from +when loading the object. The default will be set using the common file path +of all the spectra files when exporting. If the `spectraExport` parameter is +set to `FALSE`, the spectra data will not be exported/imported. } \examples{ ## Load test data set of class `MsExperiment` @@ -118,7 +126,7 @@ faahko_sub <- loadXcmsData("faahko_sub2") ## Define param pth = file.path(tempdir(), "test") -param <- PlainTextParam(path = pth) +param <- PlainTextParam(path = pth, spectraExport = TRUE) ## Save as a collection of plain text files storeResults(object = faahko_sub, param = param) diff --git a/man/loadResults.Rd b/man/loadResults.Rd index 7cb8666e..8e6e897a 100644 --- a/man/loadResults.Rd +++ b/man/loadResults.Rd @@ -46,7 +46,7 @@ xcmse <- loadResults(param = param) ## Save as a collection of plain text files pth = file.path(tempdir(), "test") -param <- PlainTextParam(path = pth) +param <- PlainTextParam(path = pth, spectraExport = TRUE) storeResults(object = faahko_sub, param = param) ## Load this saved dataset diff --git a/tests/testthat/test_PlainTextParam.R b/tests/testthat/test_PlainTextParam.R index b62444ae..f4c7c635 100644 --- a/tests/testthat/test_PlainTextParam.R +++ b/tests/testthat/test_PlainTextParam.R @@ -45,7 +45,7 @@ test_that("loadResults, PlainTextParam works", { storeResults(mse, param = param) load_mse <- loadResults(param) expect_true(inherits(load_mse, "MsExperiment")) - expect_equal(mse, load_mse) # does nto work but make sense because no spectra data. other checks ? + expect_equal(mse, load_mse) # does nto work but make sense because no spectra data. ideas for other checks ? expect_equal(sampleData(mse), sampleData(load_mse)) #with spectra ? param <- PlainTextParam(path = pth, spectraExport = TRUE) @@ -61,12 +61,15 @@ test_that("loadResults, PlainTextParam works", { storeResults(xmse_full, param = param) load_xmse <- loadResults(param) expect_true(inherits(load_xmse, "XcmsExperiment")) - expect_equal(xmse_full, load_xmse) - expect_equal(processHistory(xmse_full), processHistory(load_xmse)) + expect_equal(xmse_full, load_xmse) # also fail probably because of spectra missing + expect_equal(processHistory(xmse_full), processHistory(load_xmse)) #fail why ? expect_equal(xmse_full@featureDefinitions, load_xmse@featureDefinitions) expect_equal(adjustedRtime(xmse_full), adjustedRtime(load_xmse)) param <- PlainTextParam(path = pth, spectraExport = TRUE) storeResults(xmse_full, param = param) + load_xmse <- loadResults(param) + expect_equal(xmse_full, load_xmse) + # not sure how to check for `spectraFilePath` })