kuwisdelu / Cardinal

Mass spectrometry imaging toolbox
http://www.cardinalmsi.org
Artistic License 2.0
42 stars 14 forks source link

Possible bug: feature.groups remain unchanged when no features in range in image() function #25

Closed YonghuiDong closed 6 months ago

YonghuiDong commented 1 year ago

Dear Cardinal developer,

When plotting MS images, the image function will recenter the m/z values if the user entered values ± a mass tolerance fall out of a specific range .

It could be misleading sometime because the generated MS images can be very different from the "real images" of the user entered m/z values.

I check the code from image2-MSImagingExperiment.R function that feature.groups will record this new m/z value. This is a great idea, as it would enable users to see the actual m/z values that were used to create the images.

https://github.com/kuwisdelu/Cardinal/blob/16af1e373916e428fabeada5d6707201b4ae3f65/R/image2-MSImagingExperiment.R#LL28C5-L38C7

However, when I tried with image() function, it seems that the feature.groups only records the user's initially entered m/z values, even if those values fall outside the specified range.

Here is my demo code:

set.seed(1)
x <- simulateImage(preset=2, npeaks=10, dim=c(10,10))
p <- image(x, mz = 1044.7588, plusminus = 0.0001)
Warning message:
no features in range; re-centering m/z 1044.7588 to 1044.76880921352
p$fids
             .feature.groups
X770 m/z = 1044.7588 ± 0.0001

Is this a bug? is it possible to show the real m/z value in the MSI image in case it falls out of the range?

Thanks a lot.

Dong