Search
Question: Extract whether list element is MS1 or MS2 from mzR::peaks() output
0
8 months ago by
jspmccain10
jspmccain10 wrote:

I'm working the R package mzR for extracting raw data from a mzMXL file. I'd like to examine the distribution of ion intensities from MS1 only, is there a way to differentiate the MS1 scans from MS2 scans via the *peaks()* function?

Right now I'm just filtering the elements of the list by the range of *m/z* within each element, but I'm wondering if there is a simpler way.

Any tips are greatly appreciated, and thanks for such a well-documented package!

modified 8 months ago by Laurent Gatto980 • written 8 months ago by jspmccain10
1
8 months ago by
Laurent Gatto980
United Kingdom
Laurent Gatto980 wrote:

I would suggest you give the MSnbase package a go and load your data as an MSnExp object:

x <- readMSData("raw.mzML", mode = "onDisk")


If you want only MS1 data, you can either filter your data

x1 <- filterMsLevel(x, 1)


or directly load MS1 data only

x1 <- readMSData("raw.mzML", msLevel = 1, mode = "onDisk")


This would also work with multiple files and come with many additional features.

2
8 months ago by
Germany
Sebastian Gibb80 wrote:

You have to access the header information (?header) first. Subsequently you could subset peaks() (second argument, which is unfortunately missing in the Usage section of the manual page but present in the Details. (I opened an issue on github: https://github.com/sneumann/mzR/issues/134)):

library("mzR")

f <- openMSfile("yourfile.mzML")

idxMs1 <- which(h\$msLevel == 1L)

if (length(idxMs1)) {
ms1Peaks <- peaks(f, idxMs1)
}

close(f)