Skip to main content
Topic: peak group detected with `peakDensityParam` but not listed in feature matrix (Read 218 times) previous topic - next topic

peak group detected with `peakDensityParam` but not listed in feature matrix

I used the code below on my data, and I detect the following peak group (see screenshot of peaks). However, when I export the feature details, this feature group is not listed (see screenshot of filtered feature definitions). The closest feature group detected is well outside of the retention time window of the peaks plotted. Any help or explanation would be greatly appreciated.

rtr_1 <- c(155, 175)
mzr <- c(153.05351119538767, 153.05504173815234)
gparam <- PeakDensityParam(sampleGroups=fgroups,
                            minFraction = 1/nrow(filegroups),
                            bw = 3,
                            binSize = .025,
                            maxFeatures = 100)
chr <- chromatogram(xset5, rt = rtr_1 , mz = mzr)
plot(chr)#, col = paste0(cols, 80))
highlightChromPeaks(xset5, rt = rtr_1, mz = mzr)
par(mar = c(4.5, 4.5, 1, 0))
plotChromPeakDensity(xset5, mz = mzr, param = gparam, xlim = rtr_1)


Re: peak group detected with `peakDensityParam` but not listed in feature matrix

Reply #1
Hi cpataki,

You can look at the peak table with the following command:
Quote
chromPeaks(xset5,rt=rtr_1,mz=mzr,type='all',msLevel=1L)

Both highlightChromPeaks and plotChromPeakDensity use this to find the peaks inside the ranges you specify.

What you should know, however, is that plotChromPeakDensity doesn't plot 'features'. It plots the density of the peaks found (see above) using the parameters you gave it (gparam). So, it is possible that 'groupChromPeaks' is including additional nearby (mz or rt) peaks, so that the median rt and mz are outside the range you specify in mzr and rtr_1.

So I would start by increasing the mzr range and trying to look again.

Cheers,
Corey

Re: peak group detected with `peakDensityParam` but not listed in feature matrix

Reply #2
Thank you so much for the clarification, CoreyG. You were right - peak grouping was lumping those peaks in with other peaks, which widened the mz window of that feature.

Thank you again!

Re: peak group detected with `peakDensityParam` but not listed in feature matrix

Reply #3
Glad you got it working, cpataki.

For future reference/readers, you can find the feature that contains your peaks through a brute force approach, such as:
Code: [Select]
## Save peak and feature definitions
Pks<-chromPeaks(xdata)
fDef<-featureDefinitions(xdata)

## Get peaks that you want to find in a feature
specificPeaks<-chromPeaks(xdata,rt=rtr_1,mz=mzr,type='all',msLevel=1L)

## Identify the row number of each peak from Pks
rows<-which(row.names(Pks)%in%row.names(specificPeaks))

## Search each feature definition peak list and identify the feature/s that contain every peak from above
fDef_row<-which(sapply(fDef$peakidx,function(x) all(rows%in%x)))

## Show the identified feature/s
fDef[fDef_row,]

Re: peak group detected with `peakDensityParam` but not listed in feature matrix

Reply #4
Thank you for the reference.

As a follow up, I have a very hard time separating these peaks and I'm hoping you can shed some light on what I could do differently.

My problem:
The peaks getting grouped together have an m/z range of: 153.03701335740, 153.054790674362 --> which is much larger than the 10ppm tolerance that is acceptable in our system to group peaks together. The peaks in that m/z range overlap quite a bit in the 8second window that is defined for that feature, so I can see how xcms could be grouping them together. However, I need the peaks in that feature to be separated into two groups. one group having the mz range: 153.037 - 153.053 and the other group at: 153.0535 - 153.055

I'm using PeakDensityParam and `groupChromPeaks(xset, param=gparam)` to group peaks, and I've tried a range of values for bw, binsize, and maxFeatures with no success. Am I on the right path? Is there anything else you suggest?

 

Re: peak group detected with `peakDensityParam` but not listed in feature matrix

Reply #5
Hi cpataki,

My understanding of 'groupChromPeaks' is that is first generates of sequence of overlapping mass windows:
Code: [Select]
mass <- seq(peaks[1, "mz"], peaks[nrow(peaks), "mz"] + binSize, by = binSize / 2)
Then, it finds which peaks fall in each window and performs density based grouping on them (which is based on 'bw').

So, if you know that your instrument has very high accuracy/precision, you can reduce binsize to a smaller number. This should ensure peaks with relatively different masses aren't grouped together.
Thereafter, you can reduce 'bw' to fine tune based on RT.

You could get a rough visualization of the mass groupings with some basic plotting:
Code: [Select]
mz<-c(153.03,153.06)
rtr_1<-c(155, 175)
binSize<-0.01

## Get peaks that you want to find in a feature
specificPeaks<-chromPeaks(xdata,rt=rtr_1,mz=mzr)

## Plot the peak locations
plot(specificPeaks[,"rt"],specificPeaks[,"mz"])

## Create approximate grouping windows (not the values that 'groupChromPeaks' will generate)
mass<-seq(min(specificPeaks[, "mz"]), max(specificPeaks[, "mz"]) + binSize, by = binSize / 2)
abline(h=mass,col=rep(c('red','green')))
## Note these are overlapping windows. So look at groupings between the coloured lines