The readMgf
function imports the data from a file in MGF format reading
all specified fields and returning the data as a DataFrame()
.
For very large MGF files the readMgfSplit
function might be used instead.
In contrast to the readMgf
functions, readMgfSplit
reads only nlines
lines from an MGF file at once reducing thus the memory demand (at the cost
of a lower performance, compared to readMgf
).
Usage
readMgf(
f,
msLevel = 2L,
mapping = spectraVariableMapping(MsBackendMgf()),
...,
BPPARAM = SerialParam()
)
readMgfSplit(
f,
msLevel = 2L,
mapping = spectraVariableMapping(MsBackendMgf()),
nlines = 1e+05,
BPPARAM = SerialParam(),
...
)
Arguments
- f
character(1)
with the path to an mgf file.- msLevel
numeric(1)
with the MS level. Default is 2.- mapping
named
character
vector to rename mgf fields to spectra variables.- ...
Additional parameters, currently ignored.
- BPPARAM
parallel processing setup that should be used. Only the parsing of the imported MGF file is performed in parallel.
- nlines
for
readMgfSplit
:integer(1)
with the number of lines that should be imported and parsed in each iteration.
Value
A DataFrame
with each row containing the data from one spectrum
in the MGF file. m/z and intensity values are available in columns "mz"
and "intensity"
in a list representation.
Examples
fls <- dir(system.file("extdata", package = "MsBackendMgf"),
full.names = TRUE, pattern = "mgf$")[1L]
readMgf(fls)
#> DataFrame with 3 rows and 10 columns
#> TITLE precursorMz precursorCharge rtime acquisitionNum
#> <character> <numeric> <integer> <numeric> <integer>
#> 1 File193 Spectrum1719.. 816.338 2 1028 2162
#> 2 File193 Spectrum1944.. 787.828 2 1117 2406
#> 3 File193 Spectrum1968.. 780.840 2 1127 2432
#> precursorIntensity mz intensity
#> <numeric> <NumericList> <NumericList>
#> 1 NA 102.055,103.005,103.035,... 753.738,385.376,315.441,...
#> 2 880650 101.071,102.055,103.002,... 1228.93,1424.66,1550.90,...
#> 3 1265631 102.056,103.000,115.051,... 1340.44,1714.76,1938.82,...
#> dataOrigin msLevel
#> <character> <integer>
#> 1 /__w/_temp/Library/M.. 2
#> 2 /__w/_temp/Library/M.. 2
#> 3 /__w/_temp/Library/M.. 2