sneumann / mzR

This is the git repository matching the Bioconductor package mzR: parser for netCDF, mzXML, mzData and mzML files (mass spectrometry data)
42 stars 26 forks source link

What does `scans` argument to peaks query? #187

Open glormph opened 5 years ago

glormph commented 5 years ago

I'm pretty much a mzR newbie (so this is probably a question and not a bug) but one of our lab's scripts uses the peaks function. I have created some testdata by filtering "quality" MS2 scans from an mzML, and this broke the peaks functionality:

Index whichScan out of bounds [1 ... 191]

My question is, am I correct in assuming that the scans argument actually fetches a scan by some sort of index? My scan numbers in the mzML files go way higher than 191.

lgatto commented 5 years ago

From the message above, it looks like your file contains 191 scans, and the peaks function retrieves them by their index. For example peaks(x, 1) gets you a matrix of M/Z and intensities. If you use peaks(x) or peaks(x, 1:10) you get a list of matrices.

I would suggest you look into using the MSnExp object from MSnbase. It uses the code from mzR but with a much richer and nicer interface.

higsch commented 5 years ago

I think the question is, which parameter field peaks uses. Is it

glormph commented 5 years ago

Thank you! That is correct. I'm apparently getting the scan numbers from MSGF+ output, but figured out how to do it now in MSnbase :)

lgatto commented 5 years ago

The scan index is extracted directly from the underlying file (generally mzML), i.e. option 2 in @mtstahl's list above.

glormph commented 5 years ago

Maybe it is extracted from the file, but not directly from this element:

<spectrum index="0" id="controllerType=0 controllerNumber=1 scan=4702" defaultArrayLength="310">

which I think gets scan index 1. My R skills are pretty bad but I'm guessing something with its counting starting at 1?

higsch commented 5 years ago

@glormph So this would speak for option 1 in my list above. ;)