Skip to content

plot chromatograms - Stacking EICs #612

Closed
@CarlBrunius

Description

@CarlBrunius

Hi guys,
When examining multiple EIC for a particular feature, I find it hard to visualize more than a rather low number of samples. In lots of conventional software, there is frequently an option of stacking multiple spectra in the y axis by adding a pseudo-offset between subsequent injections.

Let's say I've identified a feature of interest and want to confirm that the peak looks good. I'd do something like this:

fd <- featureDefinitions(xdata)

# let's say you're interested in features close to mz=201.113 and rt=222.95
target_mz <- 193.131
target_rt <- 258.7440
whichFt <- which(abs(fd$mzmed - target_mz) < 0.001 & abs(fd$rtmed - target_rt) < 3)
ft1 <- fd[whichFt,]

# Plot feature peaks
par(mfrow = c(2, 1))
feature_chroms <- featureChromatograms(xdata, features = whichFt, expandRt = 20, adjustedRtime = F)
plot(feature_chroms, peakType = 'rectangle', peakBg = NA)
feature_chroms <- featureChromatograms(xdata, features = whichFt, expandRt = 20, adjustedRtime = T)
plot(feature_chroms, peakType = 'rectangle', peakBg = NA)

image
In this particular example, the peaks look really good. In fact, it looks like the retention adjustment is even making RTs more dissimilar in this particular region :)

But if I'm in a more crowded region with not too good retention time adjustment, or potentially in a region with a lot of isomers, peaks may be a little all over the place. It would be awesome to see them stacked to get a better overview of peaks in the individual injections.

Moreover, the options for expanding mz and rt with custom ranges would be awesome also for feature peaks.

To customize a bit more I tried to do this:

# Extract the chromatographic peak numbers corresponding to your Feature of Interest (FoI)
ft1_peaks <- ft1$peakidx[[1]]

# Extract all chromatographic peaks
cp <- chromPeaks(xdata)

# Restrict chromatographic peaks to the FoI
cp1 <- cp[ft1_peaks,]

# Extract chromatograms
mzr <- target_mz + c(-0.005, 0.005)
rtr <- target_rt + c(-40, 40)
par(mfrow = c(2, 1))
chr <- chromatogram(xdata, mz = mzr, rt = rtr, adjustedRtime = F)
plot(chr, peakType = 'rectangle', peakBg = NA)
chr <- chromatogram(xdata, mz = mzr, rt = rtr, adjustedRtime = T)
plot(chr, peakType = 'rectangle', peakBg = NA)

image

This figure is a bit more tweakable, but I don't get how I could restrict peak boundaries to cp1 only: Let's say there are multiple peaks in the region, where several don't "survive" correspondence. Or I don't want to be visually disturbed by other features in trying to assess the quality of this particular feature. Or RT adjustment is a bit dodgy and I just want the plot to be as clean as possible.

In such cases, i'd like to confirm which were the peaks belonging to a specific feature - and only those - are with rectangles or polygons or whatever. I.e. no other nearby peaks. This would help me to get hands-on quality assessment of the integration and retention adjustment exclusively of the peaks belonging to a specific feature.

Sorry if anything was unclear and thanks for any help / tips you could give me!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions