Read/import MS spectra data of an experiment from the respective (raw)
data files into an MsExperiment()
object. Files provided with the
spectraFiles
parameter are imported as a Spectra
object and each
file is automatically linked to rows (samples) of a sampleData
data frame (if provided).
Usage
readMsExperiment(spectraFiles = character(), sampleData = data.frame(), ...)
Arguments
- spectraFiles
character
with the (absolute) file names of the MS data files that should be imported as aSpectra()
object.- sampleData
data.frame
orDataFrame
with the sample annotations. Each row is expected to contain annotations for one file (sample). The order of the data frame's rows is expected to match the order of the provided files (with parameterspectraFiles
).- ...
additional parameters for the
Spectra()
call to import the data.
Examples
## Define the files of the experiment to import
fls <- c(system.file("microtofq/MM14.mzML", package = "msdata"),
system.file("microtofq/MM8.mzML", package = "msdata"))
## Define a data frame with some sample annotations
ann <- data.frame(
injection_index = 1:2,
sample_id = c("MM14", "MM8"))
## Import the data
library(MsExperiment)
mse <- readMsExperiment(spectraFiles = fls, ann)
mse
#> Object of class MsExperiment
#> Spectra: MS1 (310)
#> Experiment data: 2 sample(s)
#> Sample data links:
#> - spectra: 2 sample(s) to 310 element(s).
## Access the spectra data
spectra(mse)
#> MSn data (Spectra) with 310 spectra in a MsBackendMzR backend:
#> msLevel rtime scanIndex
#> <integer> <numeric> <integer>
#> 1 1 270.334 1
#> 2 1 270.671 2
#> 3 1 271.007 3
#> 4 1 271.343 4
#> 5 1 271.680 5
#> ... ... ... ...
#> 306 1 65.4360 194
#> 307 1 65.7720 195
#> 308 1 66.1092 196
#> 309 1 66.4458 197
#> 310 1 66.7818 198
#> ... 33 more variables/columns.
#>
#> file(s):
#> MM14.mzML
#> MM8.mzML
## Access the sample annotations
sampleData(mse)
#> DataFrame with 2 rows and 3 columns
#> injection_index sample_id spectraOrigin
#> <integer> <character> <character>
#> 1 1 MM14 /__w/_temp...
#> 2 2 MM8 /__w/_temp...
## Import the data reading all MS spectra directly into memory
mse <- readMsExperiment(spectraFiles = fls, ann,
backend = Spectra::MsBackendMemory())
mse
#> Object of class MsExperiment
#> Spectra: MS1 (310)
#> Experiment data: 2 sample(s)
#> Sample data links:
#> - spectra: 2 sample(s) to 310 element(s).