inst/examples/reduce_to_xcms.R

# reduce an chromatoplots object to its xcms root object
setGeneric('.reduce', function(object,...) standardGeneric('.reduce'))

setMethod('.reduce', 'cpSample', function(object){
  out <- new('xcmsRaw')
  sapply(slotNames('xcmsRaw'), FUN = function(x){
   slot(out, x) <- slot(object, x)
   assign('out', out, envir = parent.env(environment()))
  })
  return(out)
})

setMethod('.reduce', 'cpExperiment', function(object){
  out <- new('xcmsSet')
  sapply(slotNames('xcmsSet'), FUN = function(x){
    slot(out, x) <- slot(object, x)
    assign('out', out, envir = parent.env(environment()))
  })
})

setMethod('.reduce', 'cpPeaks', function(object){
  out <- new('xcmsPeaks')
  sapply(slotNAmes('xcmsPeaks'), FUN = function(x){
    slot(out, x) <- slot(object, x)
    assign('out', out, envir = parent.env(environment()))
  })
  return(out)
})
mariev/chromatoplotsgui documentation built on May 21, 2019, 11:46 a.m.