Ways to export the spectra object (S4 method object) to a dataframe?
Hi Johannes,
Since I am working on several dozens of MS2 spectra, rather than one cysteine, I need to try to export the information stored in the spectra objects or .mgf files to a data frame (and thus can be exported as csv). I am not familiar with S4 method object so I am still struggling to find a way to handle that?
I know I can manually access individual SpectraVariables and write a loop for it. But I think there must be some more clever ways to do that.
Please let me know your suggestions! Always appreciate it!
Best regards, Minghao Gong
I just saw this: https://bioconductor.org/packages/devel/bioc/vignettes/Spectra/inst/doc/Spectra.html#34_Data_manipulations. I saw you updated on May 19th. Is this the newest version?
Thanks very much for the beautiful vignette!
To get all spectra variables (except m/z and intensity values) you can use spectraData(sps) - if I'm not wrong you could even call spectraData(sps, columns = c(spectraVariables(sps), "mz", "intensity")) to get everything. The returned data is a DataFrame, to convert that to a data.frame simply do df <- as(DF, "data.frame") (DF being a DataFrame).
And yes, that vignette is the most recent - and it is the same as in the current release version (Bioconductor release 3.13). We did not add any new functionality to the developmental version, so at the moment there is no difference in using the Spectra version from the release and devel branch.