Logical indicating whether spectra already smoothed or not. Default is
'FALSE'. Used to initialise "MSnProcess" object
in processingData slot.
centroided
Logical indicating whether spectra are centroided or not. Default is
'TRUE'. Used to initialise "MSnProcess" object
in processingData slot.
cache
Numeric indicating caching level. Default is 1. Under development.
verbose
verbosity flag.
Details
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.
Value
An instance of
Author(s)
Guangchuang Yu <guangchuangyu@gmail.com> and Laurent Gatto <lg390@cam.ac.uk>
See Also
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.
Examples
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
file <- dir(system.file(package="MSnbase",dir="extdata"),
full.name=TRUE,
pattern="test.mgf")
(x <- readMgfData(file))
x[[2]]
precursorMz(x[[2]])
precursorIntensity(x[[2]])
precursorMz(x[[1]])
precursorIntensity(x[[1]]) ## was not in test.mgf
scanIndex(x)
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(MSnbase)
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, xtabs
The following objects are masked from 'package:base':
Filter, Find, Map, Position, Reduce, anyDuplicated, append,
as.data.frame, cbind, colnames, do.call, duplicated, eval, evalq,
get, grep, grepl, intersect, is.unsorted, lapply, lengths, mapply,
match, mget, order, paste, pmax, pmax.int, pmin, pmin.int, rank,
rbind, rownames, sapply, setdiff, sort, table, tapply, union,
unique, unsplit
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: BiocParallel
Loading required package: ProtGenerics
This is MSnbase version 1.20.7
Read '?MSnbase' and references therein for information
about the package and how to get started.
Attaching package: 'MSnbase'
The following object is masked from 'package:stats':
smooth
The following object is masked from 'package:base':
trimws
> png(filename="/home/ddbj/snapshot/RGM3/R_BC/result/MSnbase/readMgfData.Rd_%03d_medium.png", width=480, height=480)
> ### Name: readMgfData
> ### Title: Import mgf files as 'MSnExp' instances.
> ### Aliases: readMgfData
> ### Keywords: file
>
> ### ** Examples
>
> data(itraqdata)
> writeMgfData(itraqdata, con="itraqdata.mgf", COM="MSnbase itraqdata")
| | | 0% | |= | 2% | |=== | 4% | |==== | 5% | |===== | 7% | |====== | 9% | |======== | 11% | |========= | 13% | |========== | 15% | |=========== | 16% | |============= | 18% | |============== | 20% | |=============== | 22% | |================= | 24% | |================== | 25% | |=================== | 27% | |==================== | 29% | |====================== | 31% | |======================= | 33% | |======================== | 35% | |========================= | 36% | |=========================== | 38% | |============================ | 40% | |============================= | 42% | |=============================== | 44% | |================================ | 45% | |================================= | 47% | |================================== | 49% | |==================================== | 51% | |===================================== | 53% | |====================================== | 55% | |======================================= | 56% | |========================================= | 58% | |========================================== | 60% | |=========================================== | 62% | |============================================= | 64% | |============================================== | 65% | |=============================================== | 67% | |================================================ | 69% | |================================================== | 71% | |=================================================== | 73% | |==================================================== | 75% | |===================================================== | 76% | |======================================================= | 78% | |======================================================== | 80% | |========================================================= | 82% | |=========================================================== | 84% | |============================================================ | 85% | |============================================================= | 87% | |============================================================== | 89% | |================================================================ | 91% | |================================================================= | 93% | |================================================================== | 95% | |=================================================================== | 96% | |===================================================================== | 98% | |======================================================================| 100%
> itraqdata2 <- readMgfData("itraqdata.mgf")
Scanning itraqdata.mgf ...
| | | 0% | |= | 2% | |=== | 4% | |==== | 5% | |===== | 7% | |====== | 9% | |======== | 11% | |========= | 13% | |========== | 15% | |=========== | 16% | |============= | 18% | |============== | 20% | |=============== | 22% | |================= | 24% | |================== | 25% | |=================== | 27% | |==================== | 29% | |====================== | 31% | |======================= | 33% | |======================== | 35% | |========================= | 36% | |=========================== | 38% | |============================ | 40% | |============================= | 42% | |=============================== | 44% | |================================ | 45% | |================================= | 47% | |================================== | 49% | |==================================== | 51% | |===================================== | 53% | |====================================== | 55% | |======================================= | 56% | |========================================= | 58% | |========================================== | 60% | |=========================================== | 62% | |============================================= | 64% | |============================================== | 65% | |=============================================== | 67% | |================================================ | 69% | |================================================== | 71% | |=================================================== | 73% | |==================================================== | 75% | |===================================================== | 76% | |======================================================= | 78% | |======================================================== | 80% | |========================================================= | 82% | |=========================================================== | 84% | |============================================================ | 85% | |============================================================= | 87% | |============================================================== | 89% | |================================================================ | 91% | |================================================================= | 93% | |================================================================== | 95% | |=================================================================== | 96% | |===================================================================== | 98% | |======================================================================| 100%
> ## 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 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] 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)
[1] TRUE
> ## is TRUE
> all.equal(as.data.frame(itraqdata2[[1]]),as.data.frame(itraqdata[[1]]))
[1] TRUE
> ## is TRUE
> all.equal(as.data.frame(itraqdata2[[3]]),as.data.frame(itraqdata[[11]]))
[1] TRUE
> ## is TRUE
> file <- dir(system.file(package="MSnbase",dir="extdata"),
+ full.name=TRUE,
+ pattern="test.mgf")
> (x <- readMgfData(file))
Scanning /home/ddbj/local/lib64/R/library/MSnbase/extdata/test.mgf ...
| | | 0% | |======================= | 33% | |=============================================== | 67% | |======================================================================| 100%
Object of class "MSnExp"
Object size in memory: 0.04 Mb
- - - Spectra data - - -
MS level(s): 2
Number of MS1 acquisitions: 1
Number of MSn scans: 3
Number of precursor ions: 3
3 unique MZs
Precursor MZ's: 780.84 - 816.34
MSn M/Z range: 101.07 1406.58
MSn retention times: 17:8 - 18:47 minutes
- - - Processing information - - -
Data loaded: Wed Jul 6 01:09:59 2016
MSnbase version: 1.20.7
- - - 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)'
> x[[2]]
Object of class "Spectrum2"
Precursor: 787.8283
Retention time: 18:37
Charge: 2
MSn level: 2
Peaks count: 21
Total ion count: 124558.3
> precursorMz(x[[2]])
PEPMASSMZ
787.8283
> precursorIntensity(x[[2]])
PEPMASSINT
880650.4
> precursorMz(x[[1]])
PEPMASSMZ
816.3383
> precursorIntensity(x[[1]]) ## was not in test.mgf
PEPMASSINT
0
> scanIndex(x)
X1 X2 X3
2162 2406 2432
>
>
>
>
>
> dev.off()
null device
1
>