lgatto / MSnbase

Base Classes and Functions for Mass Spectrometry and Proteomics
http://lgatto.github.io/MSnbase/
123 stars 50 forks source link

Error in retention time vector generated by MSmap #558

Closed Lasseeli closed 6 months ago

Lasseeli commented 2 years ago

Hi,

This is specific to the function MSmap, and I wonder if I have come across a bug (or more likely I've made some mistake...).

First I open my sample: ms.sample <- openMSfile(dir[36]) hd.sample <- header(ms.sample)

I select MS1 and from 0 to 10 minutes (which is longer than the retention time of the sample which is 8 minutes, or 480 seconds). ms1.sample <- which(hd.sample$msLevel == 1) rtsel.sample <- hd.sample$retentionTime[ms1.sample] / 60 > 0 & hd.sample$retentionTime[ms1.sample] / 60 < 10

I check what the max retention time and number of observations are in my data: max(hd.sample$retentionTime, na.rm=T) #479s length(hd.sample$retentionTime) # 7010 max(hd.sample$retentionTime[ms1.sample], na.rm=T) #479s length(hd.sample$retentionTime[ms1.sample]) #1121

So I interpret this as: once I filter out MS2 and other scans, I am left with 1121 scans for MS1, that span 479 seconds. So far so good.

I generate my MSmap M.sample <- MSmap(ms.sample, ms1.sample[rtsel.sample], 537.3, 537.6, .01, hd, zeroIsNA = TRUE)

When I check this: max(M.sample@rt) #376.538 length(M.sample@rt) #1121

I get 376.538 instead, so it looks like I have lost almost 100 seconds, even though I seem not to have lost any observations?

Hopefully I have made a simple mistake somewhere, but I have exhausted my limited coding abilities to check this... Any thoughts would be greatly appreciated!

I assume I have not actually lost any data, but that the retention axis has been incorrectly labelled, seeing as i still have the same amount of scans (1121)?

Kind regards, Lasse

lgatto commented 1 year ago

It would be easier for me to have your test file to track this.