kuwisdelu / Cardinal

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

intensityData(object) <- value, peakData(object) <- value methods are broken #14

Closed bentyeh closed 6 months ago

bentyeh commented 4 years ago

The setter method intensityData(object) <- value seems to be broken. I first noticed this on a real dataset I was working with and have reproduced the error below using a simulated dataset.

Minimum reproducible example

library(Cardinal)
set.seed(2020)
mse <- Cardinal::simulateImage(preset = 1, npeaks = 10, nruns = 1, baseline=1)
mse <- as(mse, "MSProcessedImagingExperiment")
Cardinal::intensityData(mse) <- Cardinal::intensityData(mse)

Error message

Error in h(simpleError(msg, call)) : 
  error in evaluating the argument 'i' in selecting a method for function '[[<-': argument "i" is missing, with no default

Looking at the source code for intensityData(), it seems like the bug might be in matter::atomdata() or Cardinal::iData(). [source code]

setReplaceMethod("intensityData", "MSProcessedImagingExperiment",
    function(object, ..., value) {
        atomdata(iData(object))[["values"]] <- value
        if ( validObject(object) )
            object
    })
bentyeh commented 4 years ago

The same error is thrown with the Cardinal::peakData() method:

Cardinal::peakData(mse) <- Cardinal::peakData(mse)