Hi,
I'm having trouble with extracting individual MS spectrum from my metadata based on precursor ion m/z.
rawdata <- readMSData("file.mzXML", msLevel = 2, mode = "onDisk")
I'm aware that I can assess individual MS spectrum objects by using index, like rawdata[[1]]
. But I was trying to get the index I want based on retention time or m/z of precursor ion. For example, my rawdata[[1]]
looks like this:
> rawdata[[1]]
Object of class "Spectrum2"
Precursor: 808.5253
Retention time: 0:8
Charge: 2
MSn level: 2
Peaks count: 462
Total ion count: 1423873
For retention time, this worked:
head(rtime(rawdata)) #got exact retention time
> which(rtime(rawdata)==7.81947)
F1.S00029
1
But when I do the same for precursor ion m/z, I don't get an index as an answer.
> which(precursorMz(rawdata)==808.5253)
named integer(0)
Why doesn't this work for precursor ion m/z? Is there any way to extract the index (and eventually the corresponding MS spectrum) based on precursor ion m/z?
Yes that was the problem,
which(round(precursorMz(rawdata),4)==808.5253)
gave me the index I wanted, thanks!Yes that was the problem,
which(round(precursorMz(rawdata),4)==808.5253)
gave me the index I wanted, thanks!