Question: Difference between methods getEIC and rawEIC for xcmsRaw classes
0
4.5 years ago by
Johannes Rainer1.5k
Italy
Johannes Rainer1.5k wrote:

Dear all!

I am a little puzzled by the two methods for xcmsRaw classes to extract ion chromatograms, namely the rawEIC and the getEIC methods. I am most likely mistaken, but I was expecting the function to return comparable data (which they don't do, see code below). The difference is also not explained by the fact that rawEIC returns the sum of all signals across the m/z range, and the getEIC (likely) not (I checked for the max signal across the m/z range, but that does also not fit).

I appreciate any help or suggestion on this!

thanks, jo

library(xcms)
cdfpath <- system.file("cdf", package="faahKO")
cdffiles <- list.files(cdfpath, recursive=TRUE, full.names=TRUE)
xraw <- xcmsRaw(cdffiles[1], profmethod="bin", profstep=0.1)
## define the mz and rtrange
mzrange <- xraw@mzrange
rtrange <- range(xraw@scantim)
## now getting the raw EIC
reic <- rawEIC(xraw, mzrange=mzrange, rtrange=rtrange)
par(mfrow=c(1, 2))
plot(xraw@scantime[reic$scan], reic$intensity, type="l", main="TIC")
## now using the getEIC...
mzrange.m <- matrix(mzrange, nrow=1)
colnames(mzrange.m) <- c("mzmin", "mzmax")
rtrange.m <- matrix(rtrange, nrow=1)
geic <- getEIC(xraw, mzrange=mzrange.m, rtrange=rtrange.m)
plot(geic)

My session info:

> sessionInfo()
R version 3.2.0 (2015-04-16)
Platform: x86_64-apple-darwin14.3.0/x86_64 (64-bit)
Running under: OS X 10.10.3 (Yosemite)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] parallel  stats     graphics  grDevices utils     datasets  methods
[8] base

other attached packages:
[1] xcms_1.45.2         ProtGenerics_1.0.0  mzR_2.2.0
[4] Rcpp_0.11.5         ascii_2.1           RColorBrewer_1.1-2
[7] Biobase_2.28.0      BiocGenerics_0.14.0

loaded via a namespace (and not attached):
[1] compiler_3.2.0   tools_3.2.0      codetools_0.2-11 grid_3.2.0
[5] lattice_0.20-31
metabolomics xcms • 1.4k views
modified 4.5 years ago • written 4.5 years ago by Johannes Rainer1.5k
Answer: Difference between methods getEIC and rawEIC for xcmsRaw classes
0
4.5 years ago by
Copenhagen, Denmark
Thomas Lin Pedersen70 wrote:

From the xcms documentation:

"(rawEIC) Generate extracted ion chromatogram for m/z values of interest. The raw data is used in contrast to getEIC which uses data from the profile matrix."

rawEIC ignores any binning done and reads the raw data, while getEIC is based on the binned data...

best Thomas

thanks! didn't read careful enough ;)

Unfortunately, that does however not explain the difference! I calculated the eic on the profile matrix too, but the results are different (using the code/objects from the original message):

par(mfrow=c(1,2))
## the EIC from the getEIC:
plot(geic)
## and the EIC calculated from the profile matrix (same settings, i.e. step=0.1)
plot(xraw@scantime, apply(xraw@env$profile, MARGIN=2, max), type="l") ## that's not the same, the following however is! plot(geic) plot(xraw@scantime, apply(xraw@env$profile[1:100, ], MARGIN=2, max), type="l")

Apparently (evaluating also the code in xcmsRaw.R) the function extracts only the first 100 bins (rows) in the profile matrix, so does not consider the full m/z range... I'll evaluate the code again but at present I'm afraid that's a bug :(

Answer: Difference between methods getEIC and rawEIC for xcmsRaw classes
0
4.5 years ago by
Johannes Rainer1.5k
Italy
Johannes Rainer1.5k wrote:

Summarizing:

getEIC uses the profile matrix to calculate the chromatogram (returning the maximal signal within the specified m/z range for each RT).

However, after checking and evaluating the code, I come to the conclusion that the getEIC method was only intended to extract chromatograms for a restricted, small m/z range. If the m/z range is larger than 100 the method just returns the max signal across the first 100 bins in m/z range.

To me it would make more sense to keep the getEIC method more generic and to allow also extraction of the base peak chromatogram (i.e. most intense signal for each RT across all m/z). I've rewritten the method and submitted a pull request to the xcms github repository.

cheers, jo

UPDATE (2015-05-07)

It's now in the xcms development branch (version 1.45.3), however, at present only as an option. By setting

BioC <- getOption("BioC")
BioC$xcms$getEIC.method <- "getEICNew"
options(BioC=BioC)

the new getEIC method will be used. In later releases of the package the new implementation might become default.

cheers, jo