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
Easier way to import (spectra) data from an experiment #32
Comments
Yes, indeed, that would be useful. Why not use the |
The problem with that is (IMO) that passing a pre-loaded sps <- Spectra(fls)
mse <- MsExperiment(sps, sampleData = pd) that would then pre-fill the slots with the spectra and the sample data, but then an additional Importing the data using file names and the sample data (like with the |
Of course, I understand, but why no adding the logic of linking in the constructor. That same logic could be applied if the object is constructed from spectra or chromatograms (probably not relevant for quantitative data). Otherwise, we'll need to have a |
That's why I didn't put it in the OK, a solution for having all in the sps <- Spectra(pd$dataOrigin)
mse <- MsExperiment(spectra = sps, sampleData = pd) requiring that |
Or, let's start with the simplest solution, which is the one you suggested first. Once it has matured and been tested, that function could simply be called from within the constructor when both |
Or what about this: MsExperiment <- function(spectra, sampleData, ...) {
if (is.character(spectra)) {
if (!nrow(sampleData))
sampleData <- data.frame(spectraOrigin = spectra)
if (!any(colnames(sampleData) == "spectraOrigin") && nrow(sampleData) == length(spectra))
sampleData$spectraOrigin <- spectra
spectra <- Spectra(spectra, ...)
}
x <- MsExperiment()
x@spectra <- spectra
x@sampleData <- sampleData
if (any(colnames(sampleData) == "spectraOrigin"))
linkSampleData(x, with = "sampleData.spectraOrigin = spectra.dataOrigin")
x
} this would be a combination of both variants... if a |
I don't like to overload the meaning of the In general I think we should follow your first thought and @lgatto's suggestion to provide a new function and if it has matured it could be called by the constructor, or? |
Agree - let's not overdo it now. The problem with Anyway, I'll make a PR for a new simple import function as you suggest. |
The problem still persists in Do we need
|
Hm, I would prefer a |
feat: add readMsExperiment (issue #32)
The current way to create a
MsExperiment
and adding data to it is IMHO a bit cumbersome. In most of my use cases (e.g. in a typicalxcms
-based analysis workflow) I have a set of mzML files and adata.frame
with sample annotations. Importing that data in the current way involves many code of lines with the possibility of mistakes or misunderstandings (especially for the linking between samples and spectra). I think it would be nice (especially also for the less experienced user) to provide a simple import functions like the one below:I currently have that function in
xcms
but maybe we could add that directly toMsExperiment
. @lgatto @sgibb any opinion on that?The text was updated successfully, but these errors were encountered: