writeMetadata.Rd
This function is simply a wrapper to write the metadata associated with a collection of mass spectra into a file in either the R or csv format.
writeMetadata(x, filename = "Metadata", format = c("R", "csv"), ...)
Metadata in any sensible data format, preferably matrix
or data.frame
.
A character string specifying a name for the destination file (filename extension not required).
One of R (default .RData
file) or text (comma-separated .csv
file).
Other arguments.
It uses either save
or write.table
to store the metadata. Check these functions for adequate data formats.
No return value, file in selected format created on destination folder.
# Load example data
data(spectra) # list of MassSpectra class objects
data(type) # metadata
# Some pre-processing
sc.spectra <- screenSpectra(spectra, meta = type)
spectra <- sc.spectra$fspectra # filtered spectra
type <- sc.spectra$fmeta # filtered metadata
spectra <- transformIntensity(spectra, method = "sqrt")
spectra <- wavSmoothing(spectra)
spectra <- removeBaseline(spectra)
peaks <- detectPeaks(spectra)
peaks <- alignPeaks(peaks, minFreq = 0.8)
# Intensity matrix
int <- intensityMatrix(peaks)
# Save resulting data in R format (to a temporary location as an example)
# \donttest{
writeIntensity(int, filename = file.path(tempdir(),"MyintMatrix"))
writeMetadata(type, filename = file.path(tempdir(),"MyMetadata"))
# }
# Save resulting data in csv format (to a temporary location as an example)
# \donttest{
writeIntensity(int, filename = file.path(tempdir(),"MyintMatrix"),
format = "csv")
writeMetadata(type, filename = file.path(tempdir(),"MyMetadata"),
format = "csv")
# }