R/mas5.R

#==============================================================================#
# mas5.R: 
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# mas5: MAS5 preprocessing
#==============================================================================#

"mas5" <-
function(xps.data,
         filename   = character(0),
         filedir    = getwd(),
         tmpdir     = "",
         normalize  = FALSE,
         sc         = 500,
         option     = "transcript",
         exonlevel  = "",
         update     = FALSE,
         xps.scheme = NULL,
         add.data   = TRUE,
         verbose    = TRUE)
{
   ## check for valid normalize
   if (!is.logical(normalize)) {
      stop(paste(sQuote("normalize"), "must be TRUE or FALSE"));
   }#if

   ## check for valid update
   if (!is.logical(update)) {
      stop(paste(sQuote("update"), "must be TRUE or FALSE"));
   }#if

   if (update == TRUE) {
      tmpname  <- filename;
   } else {
      tmpname  <- paste(filename, "_tbw", sep="");
   }#if

   ## new class containing MAS5 preprocessed data
   if (is(xps.data, "DataTreeSet")) {
      set <- xpsMAS5(xps.data,
                     filename   = tmpname,
                     filedir    = filedir,
                     tmpdir     = tmpdir,
                     option     = option,
                     exonlevel  = exonlevel,
                     xps.scheme = xps.scheme,
                     add.data   = add.data,
                     verbose    = verbose);
   } else {
      stop(paste(sQuote("xps.data"), "is not a class", sQuote("DataTreeSet")));
   }#if

   ## normalize MAS5 data using trimmed mean
   if (normalize) {
      ## check for valid sc
      if (!is.numeric(sc)) {
         stop(paste("parameter", sQuote("sc"), "must be numeric"));
      }#if

      if (update == TRUE) {
         tmpname  <- rootFile(set);
         filename <- basename(tmpname);
         filedir  <- dirname(tmpname);
      }#if

      ## new class containing scaled MAS5 data
      set <- xpsNormalize(set,
                          filename  = filename,
                          filedir   = filedir,
                          tmpdir    = tmpdir,
                          update    = update,
                          select    = "separate",
                          method    = "mean",
                          option    = paste(option, "all", sep=":"),
                          logbase   = "0",
                          exonlevel = exonlevel,
                          refindex  = 1,
                          refmethod = "mean",
                          params    = c(0.02, sc),
                          add.data  = add.data,
                          verbose   = verbose);
   }#if

   return(set);
}#mas5

Try the xps package in your browser

Any scripts or data that you put into this service are public.

xps documentation built on Nov. 1, 2018, 2:29 a.m.