Skip to main content
Topic: How does "step" influence the result of getEIC? (Read 5689 times) previous topic - next topic

How does "step" influence the result of getEIC?

Hey there,

I am playing around with getEIC on xcmsRaw objects and do not really understand the step parameter.

In the beginning I ignored this parameter completely and let it set to its default (0.1). But then I realized that although I provided mz ranges with a width of about 10-35 ppm, getEIC extracted mass traces within a much broader range. So I lowered the step parameter to 0.0001. However, now I get again strange results as indicated by the three ion chromatograms:

[attachment=2:3tprx2vu]eic1.png[/attachment:3tprx2vu][attachment=1:3tprx2vu]eic2.png[/attachment:3tprx2vu][attachment=0:3tprx2vu]eic3.png[/attachment:3tprx2vu]

So my question is, what happend to the second and third EIC (30ppm/35ppm, step = 0.0001) and why? To which value should I set the step size? Would be something like 0.1*(mzmax - mzmin) a robust value?

Many thanks
Isam

[attachment deleted by admin]

Re: How does "step" influence the result of getEIC?

Reply #1
Isam,

The reason that your 2nd & 3rd trace don't look like a peak is due to the m/z shifting between scans. When we normally refer to a peak there is a certain allowance for the m/z. If you have an FT-ICR and it's well tuned then your step could probably be closer to what your 3rd EIC is set to. So now on to the ppm difference and the step. When xcms makes and EIC it calls up the raw data from the file and reads it in as an xcmsRaw object. This object has a binned matrix of the data. The step parameter refers directly to this binning size. So if you over bin then there is nothing around to bin and of course under binning (large bin size) would mean that you lose detail. Once the bin matrix is made you can choose an m/z range of this binned matrix (you've chosen in ppm I assume by your own function?). Does that make sense?

As for selection of this parameter something like you specified would probably make sense as long as the mzmin & mzmax that you're talking about is from a single file, ie from a single run of 'findPeaks'.

As always let me know how you get on and if this made sense. Always a lot easier to explain in person than in text.

Cheers,

Paul
~~
H. Paul Benton
Scripps Research Institute
If you have an error with XCMS Online please send me the JOBID and submit an error via the XCMS Online contact page

Re: How does "step" influence the result of getEIC?

Reply #2
Hey Paul,

many thanks for the explanations. Actually you're right:
Quote
...would probably make sense as long as the mzmin & mzmax that you're talking about is from a single file, ie from a single run of 'findPeaks'.
I should have mentioned, that I am calling `getEIC` directly on a single chromatogram with the sole purpose to access ion traces of targeted compounds. I am not even calling `findPeaks`. My data are acquired by a qTOF with scan-to-scan accuracy around 35ppm.

I understand the need for binning when performing profile generation, although I do not really understand why this is necessary when trying to access ion traces on the raw data. And in case of over binning I would have expected that all bins within the given mz-range are collapsed, which is obviously not the case. I circumvent this now with this solution (which is not vectorized yet and could be improved by using `data.table` instead of `data.frame`):

Code: [Select]
getIonTrace <- function( obj, mz, ppm, rtRange ) {
  # get table mz, intensity, scantime
  scanTime <- rep( obj@scantime, times = diff(  c( obj@scanindex, length( obj@env$mz ) ) ) )
  eic <- data.frame( intensity = obj@env$intensity, mz = obj@env$mz, scantime = scanTime ) 
 
  # filter RT
  if( !missing( rtRange ) ) {
    eic <- eic[ eic$scantime >= rtRange[1] & eic$scantime <= rtRange[2], ]
  }
 
  # filter mz
  mzRange <- c( mz * (1 - 1E-6 * ppm) , mz * (1 + 1E-6 * ppm) )
  eic <- eic[ eic$mz >= mzRange[1] & eic$mz <= mzRange[2], ]
 
  # sum intensities of signals within single scans
  eic <- aggregate( intensity ~ scantime, eic, sum )
  return(eic)
}
eic <- getIonTrace( xcmsRaw( filename="test.mzdata.xml"  ) , mz = 378.0977, ppm = 35 )
plot( intensity ~ scantime, eic )

As a follow-up question, which has nothing to do with `getEIC`: Does the step parameter influence the peak or ROI detection in `xcmsSet( files, method = "centWave", ... )`? I thought that no profMethod is applied when calling xcmsSet with centWave, but today I understood that every xcmsRaw is subject to binning. So, what would be a good parameter for our qTOF data, if the step parameter makes a difference?

Many thanks,
Isam

Re: How does "step" influence the result of getEIC?

Reply #3
Quote
Does the step parameter influence the peak or ROI detection in `xcmsSet( files, method = "centWave", ... )`?

No, centWave does not make use of a profile matrix, it uses the raw data directly.

Also, you can use rawEIC() if you want to extract EICs from the raw without binning/the profile matrix.

Ralf

Re: How does "step" influence the result of getEIC?

Reply #4
Just to follow up on Ralf's answer. While calling xcmsRaw directly will always bin by default, you can call xcmsRaw with step=0. This will stop the binning for the profile matrix. This is exactly what the xcmsSet method does when calling centWave.

the rawEIC that ralf mentions is a very function. However, if you still decide to go with getEIC then I would probably go with something around 0.01.

Paul
~~
H. Paul Benton
Scripps Research Institute
If you have an error with XCMS Online please send me the JOBID and submit an error via the XCMS Online contact page

Re: How does "step" influence the result of getEIC?

Reply #5
omg :-/

I was not aware of `rawEIC`. Many thanks to both of you for pointing me to that and for the detailed explanations concerning centWave.

Isam