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

Spectra to/from MSnExp #370

Closed
lgatto opened this issue Oct 21, 2018 · 6 comments
Closed

Spectra to/from MSnExp #370

lgatto opened this issue Oct 21, 2018 · 6 comments

Comments

@lgatto
Copy link
Owner

lgatto commented Oct 21, 2018

I am wondering if we wouldn't need methods to coerce MSnExp objects to/from Spectra objects. One example I am going to implement soon, after combining spectra (see #366), is that these new data will need to be quantified and serialised to mzML.

@jotsetung @sgibb - what do you think?

@jorainer
Copy link
Collaborator

I'd like to keep the Spectra agnostic of where it comes from (e.g. mzML or a database). Wouldn't be a combineSpectra,MSnExp what you're looking for? You combine the spectra (get an MSnExp back), call quantify on that and you then save the MSnExp with the writeMSData back to mzML.

Getting a Spectra from an MSnExp is rather simple: Spectra(spectra(<MSnExp>)).

@sgibb
Copy link
Collaborator

sgibb commented Oct 21, 2018

Sorry, but Spectra(spectra(<MSnExp>)) is awkward. I would prefer that there are some as(<MSnExp>, "Spectra")/as(<Spectra>, "MSnExp") and Spectra(<MSnExp>)/MSnExp(<Spectra>) functions. May we should discuss whether spectra(<MSnExp>) should return a Spectra object. Converting it to a simple list via as.list(spectra(<MSnExp>)) is easy even for inexperienced users.

@jorainer
Copy link
Collaborator

I know that Spectra(spectra is awkward. For me spectra returning a Spectra is the cleanest solution (possibly in addition with an as(<MSnExp>, "Spectra").

@jorainer
Copy link
Collaborator

hm, my previous comment disappeared...

@sgibb, I know, Spectra(spectra is awkward, but that's presently the way how you can convert an MSnExp to a Spectra. I would opt for spectra returing a Spectra. The question is what to do with the fData, pass that as mcols to the Spectra? For OnDiskMSnExp that can result in quite a heavy Spectra object. Also, should spectra be identical to as(<MSnExp>, "Spectra")? My feeling is that it might be better to return with spectra a Spectra without all feature data to keep that more lightweight, and to use as(<MSnExp>, "Spectra") to pass along also all feature data as mcols. On the other hand it might be more intuitive to have also spectra return a Spectra with feature data as metadata columns.

@lgatto
Copy link
Owner Author

lgatto commented Oct 24, 2018

The as(from, to) syntax is general across many object types, and hence I think it would be nice to have as(<MSnExp>, "Spectra") and as(<Spectra>, "MSnExp"), as it does exactly what's on the tin. And similarly, having as(<Spectra>, "list") would to get a plain list. I am ok with redundancy and also having constructors Spectra(<MSnExp>) and MSnExp(<Spectra>).

As for mcols, yes, it always gets passed along to/from fData.

jorainer added a commit that referenced this issue Nov 7, 2018
- Add filterMsLevel,Spectra method.
- Add coerce,Spectra,MSnExp method (issue #370).
- Add related unit tests and documentation.
@jorainer
Copy link
Collaborator

jorainer commented Nov 7, 2018

I've added the related conversion methods in #378

@lgatto lgatto closed this as completed Jan 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants