rformassspectrometry / Spectra

Low level infrastructure to handle MS spectra
https://rformassspectrometry.github.io/Spectra/
37 stars 25 forks source link

Make sure comparison with empty spectra yields N/A #130

Closed sneumann closed 3 years ago

sneumann commented 4 years ago

Hi, @michaelwitting found that comparison with an empty spectrum hangs. Instead it should return N/A. Stay tuned for details and test case. Yours, Steffen

jorainer commented 4 years ago

This is strange. I can not reproduce:

sps2 <- Spectra()
res <- compareSpectra(sps2)
res
<0 x 0 matrix>

and if one of the two Spectra is not empty (in this case having length 20):

res <- compareSpectra(sps, sps2)
res     
 [1,]
 [2,]
 [3,]
 [4,]
 [5,]
 [6,]
 [7,]
 [8,]
 [9,]
[10,]
[11,]
[12,]
[13,]
[14,]
[15,]
[16,]
[17,]
[18,]
[19,]
[20,]
michaelwitting commented 4 years ago

I created the spectra via a DataFrame, because I want to fill some gaps in a Spectra object. I set mz and intensity to NA instead of having it empty. That caused the problem. If I use an empty list its fine!

jorainer commented 4 years ago

Thanks for the clarification. A simple example would help too. In general, NA_real_ intensity values should be supported but NA_real_ m/z values not.

jorainer commented 3 years ago

Closing this issue now - feel free to re-open if needed.