Code Monkey home page Code Monkey logo

Comments (2)

jorainer avatar jorainer commented on June 8, 2024

Writing unit tests comparing the results from matchedFilter with and without iterative buffering I stumbled across another problem from the iterative buffering concept:

  • In each profBin call the bin size is calculated anew and, due to rounding errors (imprecision of floating point numbers), this will result in slightly different bin sizes in repetitive calls. Under certain conditions this can affect the binning and even result in presumably wrong results (such as in the example below for step = 0.2).
library(xcms)
f <- system.file('cdf/KO/ko15.CDF', package = "faahKO")
xr <- xcmsRaw(f)
mz <- xr@env$mz
int <- xr@env$intensity
scantime <- xr@scantime
scanindex <- xr@scanindex
valsPerSpect <- diff(c(scanindex, length(mz)))
step <- 0.2
## Run the feature detection using iterations.
A <- xcms:::do_detectFeatures_matchedFilter(mz, int, scantime, valsPerSpect, step = step)
## Run the feature detection without iterations.
B <- xcms:::do_detectFeatures_matchedFilter_no_iter(mz, int, scantime, valsPerSpect, step = step)
all.equal(A, B)
[1] "Mean relative difference: 0.7609699"

## If we run the implementation using binYonX with iteration.
C <- xcms:::do_detectFeatures_matchedFilter_binYonX_iter(mz, int, scantime, valsPerSpect, step = step)
all.equal(B, C)
[1] TRUE

## Or binYonX without iteration
D <- xcms:::do_detectFeatures_matchedFilter_binYonX_no_iter(mz, int, scantime, valsPerSpect, step = step)
all.equal(B, D)
[1] TRUE

The *_matchedFilter_binYonX_iter implementation calculates the breaks defining the bins once and re-uses them in each iteration thus avoiding the above described problem.

The conclusion from this is that the iterative buffering adds to data insecurity and potentially leads to a wrong binning result. I thus strongly suggest that we change this in the new code for xcms3.

from xcms.

jorainer avatar jorainer commented on June 8, 2024

Closing because we changed the default to use the new code in version > 1.51.1.

from xcms.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.