Description Usage Arguments Details Value Author(s) See Also Examples
View source: R/readWriteMgfData.R
Reads a mgf file and generates an "MSnExp"
object.
1 2 | readMgfData(filename, pdata = NULL, centroided = TRUE, smoothed = FALSE,
verbose = isMSnbaseVerbose(), cache = 1)
|
filename |
character vector with file name to be read. |
pdata |
an object of class |
smoothed |
|
centroided |
|
cache |
Numeric indicating caching level. Default is 1. Under development. |
verbose |
verbosity flag. |
Note that when reading an mgf file, the original order of the spectra
is lost. Thus, if the data was originally written to mgf from an
MSnExp object using writeMgfData, although the feature
names will be identical, the spectra are not as a result of the
reordering. See example below.
An instance of
Guangchuang Yu <guangchuangyu@gmail.com> and Laurent Gatto <lg390@cam.ac.uk>
writeMgfData method to write the content of
"Spectrum" or "MSnExp"
objects to mgf files. Raw data files can also be read with the
readMSData function.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | data(itraqdata)
writeMgfData(itraqdata, con="itraqdata.mgf", COM="MSnbase itraqdata")
itraqdata2 <- readMgfData("itraqdata.mgf")
## note that the order of the spectra is altered
## and precision of some values (precursorMz for instance)
match(signif(precursorMz(itraqdata2),4),signif(precursorMz(itraqdata),4))
## [1] 1 10 11 12 13 14 15 16 17 18 ...
## ... but all the precursors are there
all.equal(sort(precursorMz(itraqdata2)),
sort(precursorMz(itraqdata)),
check.attributes=FALSE,
tolerance=10e-5)
## is TRUE
all.equal(as.data.frame(itraqdata2[[1]]),as.data.frame(itraqdata[[1]]))
## is TRUE
all.equal(as.data.frame(itraqdata2[[3]]),as.data.frame(itraqdata[[11]]))
## is TRUE
f <- dir(system.file(package="MSnbase",dir="extdata"),
full.name=TRUE,
pattern="test.mgf")
(x <- readMgfData(f))
x[[2]]
precursorMz(x[[2]])
precursorIntensity(x[[2]])
precursorMz(x[[1]])
precursorIntensity(x[[1]]) ## was not in test.mgf
scanIndex(x)
|
Loading required package: BiocGenerics
Loading required package: parallel
Attaching package: ‘BiocGenerics’
The following objects are masked from ‘package:parallel’:
clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
clusterExport, clusterMap, parApply, parCapply, parLapply,
parLapplyLB, parRapply, parSapply, parSapplyLB
The following objects are masked from ‘package:stats’:
IQR, mad, sd, var, xtabs
The following objects are masked from ‘package:base’:
anyDuplicated, append, as.data.frame, basename, cbind, colnames,
dirname, do.call, duplicated, eval, evalq, Filter, Find, get, grep,
grepl, intersect, is.unsorted, lapply, Map, mapply, match, mget,
order, paste, pmax, pmax.int, pmin, pmin.int, Position, rank,
rbind, Reduce, rownames, sapply, setdiff, sort, table, tapply,
union, unique, unsplit, which.max, which.min
Loading required package: Biobase
Welcome to Bioconductor
Vignettes contain introductory material; view with
'browseVignettes()'. To cite Bioconductor, see
'citation("Biobase")', and for packages 'citation("pkgname")'.
Loading required package: mzR
Loading required package: Rcpp
Loading required package: S4Vectors
Loading required package: stats4
Attaching package: ‘S4Vectors’
The following object is masked from ‘package:base’:
expand.grid
Loading required package: ProtGenerics
Attaching package: ‘ProtGenerics’
The following object is masked from ‘package:stats’:
smooth
This is MSnbase version 2.16.0
Visit https://lgatto.github.io/MSnbase/ to get started.
Attaching package: ‘MSnbase’
The following object is masked from ‘package:base’:
trimws
[1] 1 10 11 12 13 14 15 16 17 18 19 2 20 21 22 23 24 25 26 27 28 29 3 30 31
[26] 32 33 34 35 36 37 38 39 4 40 41 42 43 44 45 46 47 48 49 5 50 51 52 53 54
[51] 55 6 7 8 9
[1] TRUE
[1] TRUE
[1] TRUE
MSn experiment data ("MSnExp")
Object size in memory: 0.01 Mb
- - - Spectra data - - -
MS level(s): 2
Number of spectra: 3
MSn retention times: 17:8 - 18:47 minutes
- - - Processing information - - -
Data loaded: Wed Dec 9 12:37:11 2020
MSnbase version: 2.16.0
- - - Meta data - - -
phenoData
rowNames: 1
varLabels: sampleNames fileNumbers
varMetadata: labelDescription
Loaded from:
test.mgf
protocolData: none
featureData
featureNames: X1 X2 X3
fvarLabels: TITLE PEPMASS ... SCANS (5 total)
fvarMetadata: labelDescription
experimentData: use 'experimentData(object)'
Object of class "Spectrum2"
Precursor: 787.8283
Retention time: 18:37
Charge: 2
MSn level: 2
Peaks count: 21
Total ion count: 124558.3
[1] 787.8283
[1] 880650.4
[1] 816.3383
[1] 0
X1 X2 X3
2162 2406 2432
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.