Skip to main content
Topic: Using an internal standard for retcor (Read 4298 times) previous topic - next topic

Using an internal standard for retcor

(GCMS) Looking to implement a preprocessing step before retcor(). 

After significant manual investigation of a large set of chromatograms, it is clear that the best single retention time correction is to remove overall drift using the  RT of an internal standard. After that, the remaining RT jiggle is quite small, but we still want to correct for it. 

Without using the internal standard for drift correction, retcor() works remarkably well, but occasionally it reaches too far, introducing spuriously large rt shifts.

So I'd like to try a simple drift correction before calling retcor().
Has anyone done this? Is it misguided?

It looks like this can be implemented by hand in the following way (do any of the other parts of the xcmsSet class need to be fixed?):
xset <- xcmsSet(fList)
# manually shift the third file by 7.25 seconds
rtShift <- 7.25
cgramNum <- 3

Many thanks to the xcms community for this fabulous tool!
xset@rt[["corrected]][cgramNum ] <- lapply(xset@rt[["corrected]][cgramNum ] , function(x) x-rtShift)
xset@peaks[cgramNum ,"rt"] <- xset@peaks[cgramNum ,"rt"]-rtShift
xset@peaks[cgramNum ,"rt"] <- xset@peaks[cgramNum ,"rt"]-rtShift
xset@peaks[cgramNum ,"rtmin"] <- xset@peaks[cgramNum ,"rtmin"]-rtShift
xset@peaks[cgramNum ,"rtmax"] <- xset@peaks[cgramNum ,"rtmax"]-rtShift