~ubuntu-branches/ubuntu/utopic/r-bioc-affy/utopic-proposed

« back to all changes in this revision

Viewing changes to R/read.affybatch.R

  • Committer: Package Import Robot
  • Author(s): Andreas Tille
  • Date: 2014-06-08 14:24:15 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20140608142415-cdpkgnsvgan8qhzr
Tags: 1.42.2-1
* New upstream version
* Add citation
* Add autopkgtest

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
## Dec 12, 2006 - added checkCelFiles() to ensure all filenames are celfiles so unintended
26
26
##                arguments don't get passed in via ...
27
27
## Apr 19, 2013 - JWM: added warning and error messages for Gene ST and Exon ST arrays
 
28
## Sept 26, 2013 - naked .Call() to affyio replaced
28
29
##
29
30
#############################################################
30
31
 
79
80
      warning(paste0("\n\nThe affy package can process data from the Gene ST 1.x series of arrays,\n",
80
81
                    "but you should consider using either the oligo or xps packages, which are specifically\n",
81
82
                     "designed for these arrays.\n\n"), call. = FALSE)
82
 
  if(length(grep("gene2[01]st|ex[1-2][0-1]st", cleancdfname(ref.cdfName))) == 1)
 
83
  if(length(grep("gene2[01]st|ex[1-2][0-1]st|hta20", cleancdfname(ref.cdfName))) == 1)
83
84
      stop(paste0("\n\nThe affy package is not designed for this array type.\n",
84
 
                   "Please use either the oligo or xps package.\n\n"), .call = FALSE)
 
85
                   "Please use either the oligo or xps package.\n\n"), call. = FALSE)
85
86
              
86
87
 
87
88
  scandates <-
108
109
  ## Change sampleNames to be consistent with row.names of phenoData
109
110
  ## object
110
111
 
111
 
  exprs <- .Call("read_abatch",filenames, rm.mask,
 
112
  exprs <-  affyio::read_abatch(filenames, rm.mask,
112
113
               rm.outliers, rm.extra, ref.cdfName,
113
 
               dim.intensity[c(1,2)],verbose, PACKAGE="affyio")
 
114
               dim.intensity[c(1,2)],verbose)
114
115
  colnames(exprs) <- samplenames
115
116
  
116
117
  #### this is where the code changes from the original read.affybatch.
130
131
  } else {
131
132
    return(new("AffyBatch",
132
133
               exprs  = exprs,
133
 
               se.exprs = .Call("read_abatch_stddev",filenames, rm.mask,
134
 
                 rm.outliers, rm.extra, ref.cdfName,
135
 
                 dim.intensity,verbose, PACKAGE="affyio"),
 
134
               se.exprs =  affyio::read_abatch_stddev(filenames, rm.mask,
 
135
               rm.outliers, rm.extra, ref.cdfName,
 
136
               dim.intensity[c(1,2)],verbose),
136
137
               cdfName    = cdfname,   ##cel@cdfName,
137
138
               phenoData  = phenoData,
138
139
               nrow       = dim.intensity[2],##["Rows"],
231
232
    }
232
233
  }
233
234
 
 
235
  chkSn <- function(filenames, samplenames){
 
236
      fntest <- sub("^/?([^/]*/)*", "", filenames)
 
237
      if(all(fntest %in% samplenames)){
 
238
          filenames <<- filenames[match(samplenames, fntest)]
 
239
      } else {
 
240
          warning(paste0("Mismatched phenoData and celfile names!\n\n",
 
241
                         "Please note that the row.names of your phenoData ",
 
242
                         "object should be identical to what you get from ",
 
243
                         "list.celfiles()!\nOtherwise you are responsible for ",
 
244
                         "ensuring that the ordering of your phenoData object ",
 
245
                         "conforms to the ordering of the celfiles as they are ",
 
246
                         "read into the AffyBatch!\nIf not, errors may ",
 
247
                         "result from using the phenoData for subsetting or ",
 
248
                         "creating linear models, etc.\n\n"),
 
249
                  call. = FALSE)
 
250
      }
 
251
  }
 
252
  
234
253
  if(is.character(phenoData)) { 
235
254
    ## if character, read file 
236
255
    if(length(phenoData)!=1) stop(sprintf("'phenoData' must be of length 1, but is %d.", length(phenoData)))
237
256
    phenoData <- read.AnnotatedDataFrame(filename=phenoData)
238
257
    sampleNames <- sampleNames(phenoData)
 
258
    chkSn(filenames, sampleNames)
239
259
  } else if(is.data.frame(phenoData)) {
240
260
    ## if data.frame, coerce
241
261
    phenoData <-  as(phenoData, "AnnotatedDataFrame")
 
262
    sampleNames <- sampleNames(phenoData)
 
263
    chkSn(filenames, sampleNames)
242
264
  } else if(is.null(phenoData)) {
243
265
    phenoData <- new("AnnotatedDataFrame",
244
266
                     data = data.frame(sample=seq_along(sampleNames),