Skip to main content
Recent Posts
XCMS / Re: replacement for getEIC in XCMS3
Last post by johannes.rainer -
For now you can use the function below (just copy-paste into R). I will add it also to xcms and update the vignette to describe your use case.

Code: [Select]
featureChromatograms <- function(x, expandRt = 0, aggregationFun = "max",
                                 ...) {
    if (!hasFeatures(x))
        stop("No feature definitions present. Please run first 'groupChromPeaks'")
    pks <- chromPeaks(x)
    mat <-, lapply(featureDefinitions(x)$peakidx, function(z) {
        pks_current <- pks[z, , drop = FALSE]
        c(range(pks_current[, c("rtmin", "rtmax")]),
          range(pks_current[, c("mzmin", "mzmax")]))
    colnames(mat) <- c("rtmin", "rtmax", "mzmin", "mzmax")
    chromatogram(x, rt = mat[, 1:2], mz = mat[, 3:4],
                 aggregationFun = aggregationFun, ...)

This function takes an XCMSnExp object, extracts chromatograms for each feature and returns it as an Chromatograms object. The Chromatograms arranges the XIC in a two-dimensional matrix, columns being the individual samples. Each row contains the XIC for one feature. It is thus straight forward to plot the data for one specific feature. The example code below illustrates it on the famous faahko data set:

Code: [Select]
faahko_3_files <- c(system.file('cdf/KO/ko15.CDF', package = "faahKO"),
                    system.file('cdf/KO/ko16.CDF', package = "faahKO"),
                    system.file('cdf/KO/ko18.CDF', package = "faahKO"))

## Do a quick and dirty preprocessing
od <- readMSData(faahko_3_files, mode = "onDisk")
od <- findChromPeaks(od, param = CentWaveParam(peakwidth = c(30, 80),
        noise = 1000))
od <- adjustRtime(od, param = ObiwarpParam(binSize = 0.6))
od <- groupChromPeaks(od,
        param = PeakDensityParam(minFraction = 0.8, sampleGroups = rep(1, 3)))

## Extract ion chromatograms for each feature (need to post the code above or use xcms version > 3.3.4
chrs <- featureChromatograms(od)

## Extract also XICs without adjusted retention times
chrs_raw <- featureChromatograms(od, adjustedRtime = FALSE)

## Plot the XIC for the first feature using different colors for each file
par(mfrow = c(1, 2))
plot(chrs[1, ], col = c("red", "green", "blue"))
plot(chrs_raw[1, ], col = c("red", "green", "blue"))

In your use case you could simply make then a for loop over nrow(chrs) to plot the data for each feature.

Note: you could also use the highlightChromPeaks function to indicate the identified peaks in the individual XICs:

Code: [Select]
plot(chrs[1, ], col = c("red", "green", "blue"))
highlightChromPeaks(od, rt = range(lapply(chrs[1, ], rtime)), mz = range(lapply(chrs[1, ], mz)),
    border = c("red", "green", "blue"))

Hope that helps.
cheers, jo
Job opportunities / Postdoctoral position in Computational Metabolomics
Last post by johannes.rainer -
Eurac Research is looking for a

Postdoctoral researcher in Computational Metabolomics
The Institute for Biomedicine is seeking a highly motivated researcher to join the Computational Metabolomics team.

The Institute for Biomedicine is home to an international and interdisciplinary team of scientists, students and support staff, integrated in an excellent network of international and national partners. Living and working in Bozen/Bolzano allows you to experience a unique combination of alpine and Mediterranean culture right at the heart of one of the most exciting mountain regions in Europe.

The Institute for Biomedicine is running the Cooperative Health Research in South Tyrol (CHRIS) study, a population-based study on cardiometabolic and neurological health of 13,000 general population subjects [Pattaro et al 2015] that excels with a high participation rate from complete families. From this population study, targeted (Biocrates p180) and LC-MS-based untargeted metabolomics data are available for 7,500 and 5,000 individuals, respectively. The Computational Metabolomics group focuses, besides contributing to the xcms and MSnbase Bioconductor packages for untargeted metabolomics and mass spectrometry data processing, on the analysis of these and other metabolomics data sets generated at the Institute. The successful candidate will perform metabolomics data analyses, contribute to software development and is expected to write scientific articles.

· Analyze large scale targeted and untargeted metabolomics data sets.
· Investigate metabolic profiles in relation to family structure within a population study-based data set.
· Identify metabolic profiles related to health, lifestyle and nutrition.
· Integration of metabolomics and genotype data.
· In silico annotation and identification of features identified by LC-MS experiments.
· Implement and extend software for the analysis of untargeted metabolomics data.
· Present results and/or software at international conferences.
· Write scientific articles.
· PhD or equivalent experience in computational biology, bioinformatics, metabolomics or a related field.
· Experience in the analysis of LC-MS-based metabolomics data sets.
· Proficient R-software usage. Software development skills are beneficial.
· Good communication skills; fluent in the English language.
· Team-working ability.
We offer:
· A one-year full-time position with the possibility of extension.
· A collaborative work environment with multidisciplinary teams of experts form different fields of biomedical research.
· Access to cutting-edge data and computational resources.
· Attractive living and working conditions.
How to apply:
Interested candidates should submit their application (CV, cover letter, reference contacts and further relevant documents) within 31.12.2018 via Email to  stating “Researcher in Computational Metabolomics” as subject:
Eurac Research
Institute for Biomedicine
Via Galvani 31 – 39100 Bolzano
Email:  -
Tel: +39 0471 055 500 / Fax: + 39 0471 055 599

Information about the Institute is available at:

For further information please contact Johannes Rainer (

Please attach, after reading the privacy policy in compliance with the EU Regulation No. 2016/679 (GDPR) and the national legislation, the following consent to your personal record: 'I have read the privacy policy under and hereby authorize Eurac Research to use my personal data in accordance to EU Regulation No. 2016/679 and national legislation.' We inform you that we will not be allowed to consider any application without this compliancy declaration.

Please add the following consent if it is of interest to you: “I hereby explicitly authorize Eurac Research to store my personal data for the purpose of being contacted for potential future job openings”.
XCMS - FAQ / Re: xcms does not execute
Last post by johannes.rainer -
Eventually there is something strange going on with the parallel processing. Please add the following line right after you load the xcms package and retry:


with that you disable parallel processing - if it runs without parallel processing we can think of a way to fix parallel processing.

cheers, jo
XCMS / Re: export XCMS2 fragments
Last post by johannes.rainer -
We're actually currently implementing some potentially interesting stuff. In the next version you'll have a featureSpectra and chromPeakSpectra function that returns MS2 spectra related to a feature or chromatographic peak.

stay tuned.
XCMS / Re: replacement for getEIC in XCMS3
Last post by johannes.rainer -
Dear Krista,

I realized that that's something apparently missing in xcms version 3 at present. I will think of a solution and post it. Thanks for the feedback.

cheers, jo
XCMS / Re: replacement for getEIC in XCMS3
Last post by CoreyG -
Hi Krista,

I'm getting used to XCMS3, but I hope I can help you anyway.

You might be getting unstuck due to differences in XCMSnExp and xcmsSet classes. Using the 'as' function, you can convert an XCMSnExp object to an xcmsSet object.

I think all of your code will work if you replace the first line with:
xs.fill <- as(xgF,"xcmsSet")

Please let me (and everyone else) know if this works for you :)
R packages for metabolomics / R course for metabolomics
Last post by biosiva -
I am interested to learn R. Could anyone suggest a best R course for metabolomics available online?

Also i would be interested to know if there is a mass spectral interpretation course available online?

XCMS / replacement for getEIC in XCMS3
Last post by krista -
I am in the process of updating to use XCMS3. So far, I like XCMS3 and most of the transition to XCMS3 has been easy in terms of how to set peak picking, retention time correction, and defining correspondence across a set of files (the old 'grouping'). However, one thing I miss is the ability to plot all of our mzRT features into a PDF that we could use to assess how well our parameters were working. I find multiple examples to extract a pre-determined mz / RT combination in the vignettes provided with XCMS3. Therefore, if I know the mz and retention time for a single peak, I can easily plot it. However, what I cannot figure out is out to get all the peaks across my set of samples.

I used to use the code listed below. In the example, xgF is the data after peak picking, group, retention time correction, and fillPeaks.

Any thoughts?

xs.fill <- xgF
xeic.raw <- getEIC(xs.fill, rt = "raw", groupidx= 1:nrow(xs.fill@groups))
xeic.corrected <- getEIC(xs.fill, rt = "corrected", groupidx= 1:nrow(xs.fill@groups))

#colorList should be as long as the number of possible levels in the dataset...
colorList <- c("deepskyblue","magenta","forestgreen","darkorchid","firebrick", "gold")

#plot first feature from diffreport (not sorted after pval!!)
cairo_pdf(file = fName_peaksPicked,onefile=TRUE)
for (i in 1:nrow(xs.fill@groups)){
  #for (i in 1:5){
  par(mfrow= c(2,1))
  #rt row data
  plot(xeic.raw, xs.fill,groupidx=i,col=colorList)
  #rt corrected data
  plot(xeic.corrected, xs.fill,groupidx=i,col=colorList)

My sessionInfo()
R version 3.5.1 (2018-07-02)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

Matrix products: default

[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

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

other attached packages:
[1] CAMERA_1.36.0 xcms_3.2.0 MSnbase_2.6.4 ProtGenerics_1.12.0 mzR_2.14.0
[6] Rcpp_0.12.19 BiocParallel_1.14.2 Biobase_2.40.0 BiocGenerics_0.26.0

loaded via a namespace (and not attached):
 [1] lattice_0.20-35 snow_0.4-3 digest_0.6.18 foreach_1.4.4
 [5] plyr_1.8.4 backports_1.1.2 acepack_1.4.1 mzID_1.18.0
 [9] stats4_3.5.1 ggplot2_3.0.0 BiocInstaller_1.30.0 pillar_1.3.0
[13] zlibbioc_1.26.0 rlang_0.2.2 lazyeval_0.2.1 rstudioapi_0.8
[17] data.table_1.11.8 S4Vectors_0.18.3 rpart_4.1-13 Matrix_1.2-14
[21] checkmate_1.8.5 preprocessCore_1.42.0 splines_3.5.1 stringr_1.3.1
[25] foreign_0.8-71 htmlwidgets_1.3 igraph_1.2.2 munsell_0.5.0
[29] compiler_3.5.1 pkgconfig_2.0.2 base64enc_0.1-3 multtest_2.36.0
[33] pcaMethods_1.72.0 htmltools_0.3.6 nnet_7.3-12 tibble_1.4.2
[37] gridExtra_2.3 htmlTable_1.12 RANN_2.6 Hmisc_4.1-1
[41] IRanges_2.14.12 codetools_0.2-15 XML_3.98-1.16 crayon_1.3.4
[45] MASS_7.3-50 grid_3.5.1 MassSpecWavelet_1.46.0 RBGL_1.56.0
[49] gtable_0.2.0 affy_1.58.0 magrittr_1.5 scales_1.0.0
[53] graph_1.58.2 stringi_1.2.4 impute_1.54.0 affyio_1.50.0
[57] doParallel_1.0.14 limma_3.36.5 latticeExtra_0.6-28 Formula_1.2-3
[61] RColorBrewer_1.1-2 iterators_1.0.10 tools_3.5.1 survival_2.42-6
[65] yaml_2.2.0 colorspace_1.3-2 cluster_2.0.7-1 vsn_3.48.1
[69] MALDIquant_1.18 knitr_1.20

Job opportunities / Postdoctoral Fellow in Mass Spectrometry-based Metabolomics
Last post by eppsd -
Post: Postdoctoral Fellow in Mass Spectrometry-based Metabolomics
Department: IU Bloomington Public & Environmental Affairs

Full text:

Position Summary:
We are recruiting a postdoctoral fellow in Mass Spectrometry-based Metabolomics at Indiana University Bloomington to participate in an exciting, new collaborative project called PhyloTox, which seeks to identify the evolutionary origins of molecular toxicity pathways. Using transcriptomics and metabolomics data collected from a group of model species/cells exposed to a carefully selected suite of chemicals, biological insights will be drawn from the perturbation of entire genetic and biochemical networks via chemical ablation. The ultimate goal of the project is to develop a novel precision environmental health program to help solve the enormous environmental health crisis caused by environmental pollution.

For this position, we seek a postdoctoral fellow in Mass Spectrometry Metabolomics to focus on the application of metabolic phenotyping across a six model organisms/cell lines, applying primarily non-targeted LC-MS strategies. The post-holder will perform sample preparation applying manual and robotic approaches, LC-MS instrument maintenance and operation to acquire highly reproducible data in a high-throughput laboratory, and metabolite identification. They will contribute to study design and analytical method development in cutting edge, biomedical computational and statistical analysis.

The project involves working with several PIs and laboratories and, thus, collaborative skills and results-oriented project management are required. The position is localized at Indiana University Bloomington in the School of Public and Environmental Affairs, Department of Chemistry, Department of Environmental Health, and Department of Intelligent Systems Engineering. The position also includes a unique training opportunity under the guidance of Prof Mark Viant in the world class metabolomics facility of the University of Birmingham, UK ( This position will either be assigned to the Department of Chemistry or the School of Public and Environmental Affairs, whichever is the best fit for the successful candidate.

Questions regarding the position or application process can be directed to: Drs. Joseph Shaw ( or Stephen Jacobson (

To apply: Interested candidates should review the application requirements and submit their application online: The application should consist of a cover letter stating your accomplishments and interest in the project’s research, curriculum vitae, and letters of support from at least two references. Review of applications will begin immediately and continue until the position is filled. Applications received by November 15, 2018 will receive full consideration.