Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import methods #746

Closed
wants to merge 18 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: xcms
Version: 4.3.1
Version: 4.3.2
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,
Expand Down Expand Up @@ -60,10 +60,10 @@ Imports:
S4Vectors,
IRanges,
SummarizedExperiment,
MsCoreUtils (>= 1.15.5),
MsCoreUtils (>= 1.15.7),
MsFeatures,
MsExperiment (>= 1.5.4),
Spectra (>= 1.13.7),
Spectra (>= 1.15.3),
progress,
jsonlite,
RColorBrewer,
Expand Down
20 changes: 13 additions & 7 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -52,7 +52,7 @@ importFrom("stats", "aov", "approx", "convolve", "cor", "deriv3",
"rnorm", "runif", "dbeta", "resid")
importFrom("utils", "flush.console", "head", "object.size",
"packageVersion", "read.csv", "tail", "write.csv",
"write.table", "capture.output", "data")
"write.table", "capture.output", "data", "read.table")

importFrom("MassSpecWavelet", "peakDetectionCWT", "tuneInPeakInfo")

Expand Down Expand Up @@ -254,7 +254,8 @@ export(
"loadXcmsData",
"matchLamasChromPeaks",
"summarizeLamaMatch",
"matchedRtimes"
"matchedRtimes",
"XcmsExperiment"
)

## New analysis methods
Expand Down Expand Up @@ -558,15 +559,17 @@ importMethodsFrom("Spectra", "uniqueMsLevels")
importMethodsFrom("Spectra", "selectSpectraVariables")
importMethodsFrom("Spectra", "setBackend")
importMethodsFrom("Spectra", "dataOrigin")
importMethodsFrom("Spectra", "dataStorage")
importMethodsFrom("Spectra", "dataStorage", "dataStorage<-")
importMethodsFrom("Spectra", "spectraVariables")
importMethodsFrom("Spectra", "rtime<-")
importMethodsFrom("Spectra", "ionCount")
importMethodsFrom("Spectra", "precursorMz")
importMethodsFrom("Spectra", "$")
importMethodsFrom("Spectra", "uniqueMsLevels")
importMethodsFrom("Spectra", "backendBpparam")
importFrom("Spectra", "MsBackendMemory")
importFrom("Spectra", "MsBackendMemory", "dataStorageBasePath",
"dataStorageBasePath<-", "processingChunkSize",
"dropNaSpectraVariables", "MsBackendMzR", "filterEmptySpectra")

## MsExperiment things
importClassesFrom("MsExperiment", "MsExperiment")
Expand All @@ -590,12 +593,15 @@ exportMethods("filterMzRange")
exportMethods("fromFile")
exportMethods("fileNames")

## saving xcms objects things
## saving/loading xcms objects things
importFrom("jsonlite", "serializeJSON", "write_json", "unserializeJSON",
"read_json")
importFrom("stats", "setNames")
importFrom("MsCoreUtils", "between")
export("RDataParam")
export("PlainTextParam")
exportMethods("storeResults")
exportMethods("storeResults", "loadResults")


## filtering features things
importFrom("MetaboCoreUtils", "rowRsd", "rowDratio", "rowPercentMissing",
Expand Down
6 changes: 5 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# xcms 4.3

## Changes in version 4.3.2

- Addition of generic function `loadResults()`and method for import using
`RDataParam` and `PlaintTextParam`.

## Changes in version 4.3.1

- Support excluding samples or sample groups from defining features with
Expand All @@ -8,7 +13,6 @@
- Fix in `dropFeatureDefinitions()` that was not correctly removing additional
metadata from gap-filled chromatographic peaks.


# xcms 4.1

## Changes in version 4.1.14
Expand Down
60 changes: 60 additions & 0 deletions R/AllGenerics.R
Original file line number Diff line number Diff line change
Expand Up @@ -1486,6 +1486,66 @@ setGeneric("kNN<-", function(object, value) standardGeneric("kNN<-"))

## L
setGeneric("levelplot", function(x, data, ...) standardGeneric("levelplot"))
#' @title Import various file format as XcmsExperiment object
#'
#' @description
#'
#' The `loadResults` function allows to import and create an `XcmsExperiment`
#' object from a file. Multiple formats for importing are available and can be
#' defined by the `param` argument.
#'
#' Supported `param` objects are:
#'
#' - [`RDataParam`]: Import an `MsExperiment` or `XcmsExperiment` object from
#' an .RData file.
#'
#' - [`PlainTextParam`]: Import an `MsExperiment` or `XcmsExperiment` object
#' from a folder of text files.
#'
#' - `MzTabParam`: Load a MzTab-m file (to be defined).
#'
#' For specific examples, see the help pages of the individual parameter classes
#' listed above.
#'
#' @param object Define the class of the object to be imported. It can be one
#' of the following classes: [`XcmsExperiment()`], [`MsExperiment()`] for now,
#' more class will be supported in the future.
#'
#' @param param The parameter object selecting and configuring the format for
#' saving. It can be one of the following classes: [`RDataParam`],
#' [`PlainTextParam`], or `MzTabParam`.
#'
#' @param ... Optional parameters.
#'
#' @note
#' The same `param` object can be used to import as it was used for export with
#' the `storeResults()` function.
#'
#' @name loadResults
#'
#' @author Philippine Louail
#'
#' @examples
#' ## Load a test data set with detected peaks
#' faahko_sub <- loadXcmsData("faahko_sub2")
#'
#' ## Save as RData
#' param <- RDataParam(fileName = "example_xcms_object")
#' storeResults(object = faahko_sub, param = param)
#'
#' ## Load this saved dataset
#' xcmse <- loadResults(object = XcmsExperiment(),param = param)
#'
#' ## Save as a collection of plain text files
#' pth = file.path(tempdir(), "test")
#' param <- PlainTextParam(path = pth)
#' storeResults(object = faahko_sub, param = param)
#'
#' ## Load this saved dataset
#' faahko_load <- loadResults(object= XcmsExperiment(), param = param)
#'
#' @md
setGeneric("loadResults", function(object, param,...) standardGeneric("loadResults"))
setGeneric("localAlignment", function(object) standardGeneric("localAlignment"))
setGeneric("localAlignment<-", function(object, value) standardGeneric("localAlignment<-"))
setGeneric("loadRaw", function(object, ...) standardGeneric("loadRaw"))
Expand Down
Loading
Loading