Skip to main content
Topic: Normalise to Fresh weight (Read 4444 times) previous topic - next topic

Normalise to Fresh weight

Problem: Your samples may contain different amounts of freshweight, so you want to correct the peak intensities accordingly. The following snippet will take a vector of the same length as your number of samples, and apply the correction factor to each peak in the xcmsSet:

Code corrected for full pipeline processing - (thank you Axel) viewtopic.php?t=286&p=839#p839
Code: [Select]
cdfpath <- system.file("cdf", package = "faahKO")
cdffiles <- list.files(cdfpath, recursive = TRUE,full=T)
faahko <- xcmsSet(cdffiles)
faahko <- group(faahko)
faahko <- retcor(faahko, p="m", f="s")
Finish xcms processing before correcting. The next step, the diffreport will use the corrected numbers for the statistical analysis and for the box plots, if you have multiple classes. Also remember that the EICs are not corrected as they are generated directly from the original data files themselves.

Start the correction
Code: [Select]
#samples: 20    21     22       23     …              example sample names
fw <-    c(99.0, 94.3, 101.3, 83.4, …)        #example fresh weights (mg)

#first part of factors, for detected peaks
factors1 <- rep(100/fw, times=table(peaks(xset13)[,"sample"]))
#second part of factors, for filled peaks
factors2<-rep(100/fw, times=table(peaks(xset14)[nrorigpeaks:nrtotalpeaks,"sample"]))
#combine factors
factors<-c(factors1, factors2)

#weight correct
intensitycolumns <- c("into", "intb", "maxo")
xset14@peaks[,intensitycolumns] <- xset14@peaks[,intensitycolumns] * factors

old code
Code: [Select]
xs <- faahko
## Example Freshweights
fw <- c(1.3, 0.6, 0.5, 0.6, 0.4, 2.4, 0.5, 0.8, 0.4, 0.7, 0.9, 0.9)
## Calculate correction factor for each peak
factors <- rep(1/fw, times=table(peaks(xs)[,"sample"]))
## Apply to peak intensities
intensitycolumns <- c("into", "intf", "maxo", "maxf")
xs@peaks[,intensitycolumns] <- xs@peaks[,intensitycolumns] * factors
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