Code Monkey home page Code Monkey logo

Comments (3)

Pascallio avatar Pascallio commented on September 27, 2024

I dove a little bit deeper into the code and it's likely an indexing issue. I've extracted the values that go into getEIC in order to extract the result from the function. Using the variables from the previous code gives us the following plot (black = original chromatogram, red = EIC chromatogram):

scanindex <- 1:length(rts) - 1
mzrange <- c(1, 1)
sr <- c(1, length(rts))

eic <- .Call("getEIC", mzs, intensities, as.integer(scanindex), as.double(mzrange),
             as.integer(sr), as.integer(length(scanindex)),
             PACKAGE = "xcms"
)

plot(intensities, type = "l", ylim = c(0, 2e5))
lines(eic$intensity, col = "red")

image

It seems that the getEIC function adds the previous scan intensity to the current scan intensity. A one-liner using dplyr confirms this:

points(intensities + dplyr::lag(intensities, n = 1), col = "green")

image

I haven't found the solution yet, but it's either in the loop in getScanEIC, or in the lowerBound or upperBound functions:

xcms/src/mzROI.c

Lines 440 to 447 in db80f2c

int idx1b = lowerBound(from, pmz, idx1-1, idx2-idx1);
int idx2b = upperBound(to, pmz, idx1b, idx2-idx1b);
for (idx=idx1b;idx <= idx2b; idx++)
{
double mzval = pmz[idx-1];
if ((mzval <= to) && (mzval >= from)) sum += pintensity[idx-1];
}

from xcms.

sneumann avatar sneumann commented on September 27, 2024

Hi, thanks for the report, we should turn this into a unit test once we've figured exactly what's going on.
Yours, Steffeb

from xcms.

Pascallio avatar Pascallio commented on September 27, 2024

Thanks Steffen,

Interestingly, this issue does not occur in the S4 method findChromPeaks. It specifically occurs in the do_* version of the method.

# Load library
library(xcms)

# Select MRM mzML from msdata package
data <- readSRMData(system.file("proteomics", "MRM-standmix-5.mzML.gz", package = "msdata"))

# Use 0.1 - 1 due to RT being in minutes
data <- findChromPeaks(data[5, ], CentWaveParam(peakwidth = c(0.1, 1)))
chromPeaks(data)

Returns the top peak with the correct maxo of 61141.1367

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.