"SVDpipeline" <-
function(compendium,tform=TRUE,qtile=FALSE,impute=TRUE,GCenter=TRUE,GScale=TRUE,ACenter=FALSE,AScale=FALSE,svd=TRUE,nv=0)

# This code take a compendium (matrix) of microarray data and progresses
# through the analysis pipeline to end in an SVD of the data

# Modified by daigle 3/8/08

{
  if(tform) {
    compendium[compendium <= 0] <- NA
    compendium <- log2(compendium)
    gc()
  }
  if(qtile) {
    compendium <- normalizeBetweenArrays(compendium,method="quantile")
    gc()
  }
  if(impute) {
    require(impute,quietly=TRUE)
    compendium <- impute.knn(compendium,maxp=nrow(compendium))[[1]]
    gc()
  }
  if(GCenter || GScale) {
    compendium <- t(scale(t(compendium),center=GCenter,scale=GScale))
    gc()
  }
  if(ACenter || AScale) {
    compendium <- scale(compendium,center=ACenter,scale=AScale)
    gc()
  }
  if(svd) {
    compendium <- svd(compendium,nv=nv)
    gc()
  }
  
  return(compendium)
}