inst/examples/qplotChrom.r

setGeneric('qplotChrom', function(object,...) standardGeneric('qplotChrom'))

setMethod('qplotChrom', 'xcmsRaw', function(object, 
                                              base = FALSE, 
                                              ident = FALSE,
                                              fitgauss = FALSE, 
                                              vline = numeric(0), ...) {
  if(is.null(object@env$profile)){
    stop('profstep must be > 0')
  }
  sel <- profRange(object, ...)
  if (base) {
    title = paste("Base Peak Chromatogram: ", sel$masslab, sep = "")
    pts <- data.frame(x = object@scantime[sel$scanidx],
                 y = colMax(object@env$profile[sel$massidx,sel$scanidx,drop=FALSE]))
  }  else {

    title = paste("Averaged Ion Chromatogram: ", sel$masslab, sep = "")
    pts <- data.frame(x = object@scantime[sel$scanidx],
                 y = colMeans(object@env$profile[sel$massidx,sel$scanidx,drop=FALSE]))
  }
  print(qscatter(pts, x = x, y = y, main = title, xlab="Seconds", ylab="Intensity"))
  if (length(vline))
  
  if (fitgauss) {
    fit <- nls(y ~ SSgauss(x, mu, sigma, h), data.frame(x = pts[,1], y = pts[,2]))
    return(fit)
  }
  

  invisible(pts)
})
mariev/chromatoplotsgui documentation built on May 21, 2019, 11:46 a.m.