Browse code

merge local changes with dan's changes on bioc

git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/crlmm@72708 bc3139a8-67e5-0310-9ffc-ced21a209358

Rob Scharp authored on 20/01/2013 18:31:47
Showing10 changed files

... ...
@@ -1,19 +1,19 @@
1 1
 Package: crlmm
2 2
 Type: Package
3 3
 Title: Genotype Calling (CRLMM) and Copy Number Analysis tool for Affymetrix SNP 5.0 and 6.0 and Illumina arrays.
4
-Version: 1.17.12
4
+Version: 1.17.14
5 5
 Author: Benilton S Carvalho, Robert Scharpf, Matt Ritchie, Ingo Ruczinski, Rafael A Irizarry
6 6
 Maintainer: Benilton S Carvalho <Benilton.Carvalho@cancer.org.uk>, Robert Scharpf <rscharpf@jhsph.edu>, Matt Ritchie <mritchie@wehi.EDU.AU>
7 7
 Description: Faster implementation of CRLMM specific to SNP 5.0 and 6.0 arrays, as well as a copy number tool specific to 5.0, 6.0, and Illumina platforms
8 8
 License: Artistic-2.0
9
-Depends: R (>= 2.14.0), oligoClasses (>= 1.21.4), preprocessCore (>= 1.17.7)
9
+Depends: R (>= 2.14.0), oligoClasses (>= 1.21.12), preprocessCore (>= 1.17.7)
10 10
 LinkingTo: preprocessCore (>= 1.17.7)
11 11
 Imports: methods,
12 12
          Biobase (>= 2.15.4),
13 13
          BiocGenerics,
14 14
          affyio (>= 1.23.2),
15
+         illuminaio,
15 16
          ellipse,
16
-         genefilter (>= 1.37.1),
17 17
          mvtnorm,
18 18
          splines,
19 19
          stats,
... ...
@@ -22,9 +22,10 @@ Imports: methods,
22 22
 	 lattice,
23 23
 	 ff,
24 24
 	 foreach,
25
-         RcppEigen
25
+         RcppEigen,
26
+	 matrixStats
26 27
 Suggests: hapmapsnp6,
27
-          genomewidesnp6Crlmm (>= 1.0.4),
28
+          genomewidesnp6Crlmm (>= 1.0.7),
28 29
           GGdata,
29 30
           snpStats,
30 31
 	  ellipse,
... ...
@@ -2,20 +2,26 @@ useDynLib("crlmm", .registration=TRUE)
2 2
 
3 3
 importClassesFrom(Biobase, AssayData, eSet)
4 4
 
5
-importClassesFrom(methods, ANY, character, formula, integer, list,
6
-                  matrix, oldClass)
7
-importFrom(methods, setOldClass)
5
+##importClassesFrom(methods, ANY, character, formula, integer, list,
6
+##                  matrix, oldClass)
7
+##importMethodsFrom(methods, initialize, show)
8
+import(methods)
9
+##importFrom(methods, setOldClass)
10
+##importFrom(methods, as, callNextMethod, is, new, validObject)
11
+##importFrom(methods, callNextMethod, new, validObject, coerce)
12
+
8 13
 importFrom(RcppEigen, fastLmPure)
9 14
 ## importClassesFrom(oligoClasses, CNSet, CNSetLM, ff_matrix,
10 15
 ##                   ff_or_matrix, oligoSnpSet)
11 16
 importClassesFrom(oligoClasses, CNSet, oligoSnpSet, ff_or_matrix)
12 17
 ##setOldClass(ff_or_matrix)
18
+import(matrixStats)
13 19
 
14 20
 importMethodsFrom(Biobase, annotatedDataFrameFrom, annotation,
15 21
                   assayData, experimentData, featureData,
16 22
                   "featureData<-", featureNames, "featureNames<-",
17 23
                   pData, "pData<-", phenoData, "phenoData<-",
18
-                  protocolData, "protocolData<-", rowMedians,
24
+                  protocolData, "protocolData<-",
19 25
                   sampleNames, snpCall, "snpCall<-",
20 26
                   snpCallProbability, "snpCallProbability<-",
21 27
                   storageMode, "storageMode<-", varLabels)
... ...
@@ -25,7 +31,7 @@ importMethodsFrom(BiocGenerics, cbind, colnames, Filter, get,
25 31
                   paste, pmax, pmin, rbind, rownames, sapply, setdiff,
26 32
                   table, union, unique)
27 33
 
28
-importMethodsFrom(genefilter, show)
34
+##importMethodsFrom(genefilter, show)
29 35
 
30 36
 importMethodsFrom(oligoClasses, A, "A<-", B, batch, batchNames,
31 37
                   batchStatistics, "batchStatistics<-", calls,
... ...
@@ -34,12 +40,14 @@ importMethodsFrom(oligoClasses, A, "A<-", B, batch, batchNames,
34 40
 
35 41
 importFrom(affyio, read.celfile, read.celfile.header)
36 42
 
43
+importFrom(illuminaio, readIDAT)
44
+
37 45
 importFrom(Biobase, assayDataElement, assayDataElementReplace,
38 46
            assayDataNew, copyEnv)
39 47
 
40 48
 importFrom(ellipse, ellipse)
41 49
 
42
-importFrom(genefilter, rowSds)
50
+##importFrom(genefilter, rowSds)
43 51
 
44 52
 importFrom(lattice, lpolygon, panel.grid, panel.number, panel.xyplot,
45 53
            xyplot)
... ...
@@ -75,14 +83,14 @@ exportMethods(CA, CB,
75 83
 	      A, B, corr, nuA, nuB, phiA, phiB,
76 84
 	      predictionRegion, posteriorProbability,
77 85
 	      tau2, Ns, medians, mads,
78
-	      xyplot, calculateRBaf)
86
+	      xyplot, calculateRBaf, OligoSetList,
87
+	      BafLrrSetList)
79 88
 export(crlmm,
80 89
        crlmmIllumina,
81 90
        crlmmIlluminaV2,
82 91
        constructAffyCNSet,
83 92
        genotype,
84 93
        genotypeAffy,
85
-       readIDAT,
86 94
        readIdatFiles,
87 95
        readGenCallOutput,
88 96
        snprma,
... ...
@@ -96,3 +104,5 @@ export(crlmm,
96 104
        crlmmCopynumber2, crlmmCopynumberLD, crlmmCopynumber)
97 105
 export(genotypes, totalCopynumber, rawCopynumber, xyplot)
98 106
 export(ABpanel, validCEL, celDates, validCdfNames)
107
+
108
+##export(constructOligoSetListFrom, constructBafLrrSetListFrom)
... ...
@@ -105,3 +105,7 @@ setGeneric("predictionRegion", function(object, copyNumber=0:4)
105 105
 setGeneric("xyplot", useAsDefault=function(x, data, ...) lattice::xyplot(x, data,...))
106 106
 setGeneric("xyplotcrlmm", function(x, data, predictRegion,...) standardGeneric("xyplotcrlmm"))
107 107
 setGeneric("calculateRBaf", function(object, batch.name, chrom) standardGeneric("calculateRBaf"))
108
+
109
+##setGeneric("mixtureParams<-", function(object,value) standardGeneric("mixtureParams<-"))
110
+setGeneric("OligoSetList", function(object,...) standardGeneric("OligoSetList"))
111
+setGeneric("BafLrrSetList", function(object,...) standardGeneric("BafLrrSetList"))
... ...
@@ -150,299 +150,6 @@ readIdatFiles = function(sampleSheet=NULL,
150 150
 }
151 151
 
152 152
 
153
-## the readIDAT() and readBPM() functions below were provided by Keith Baggerly, 27/8/2008
154
-## edits provided by Kasper Daniel Hansen, 4/10/2011
155
-readIDAT <- function(idatFile){
156
-  fileSize <- file.info(idatFile)$size
157
-
158
-  tempCon <- file(idatFile,"rb")
159
-  prefixCheck <- readChar(tempCon,4)
160
-#  if(prefixCheck != "IDAT"){
161
-#       warning("May need to check format of ", idatFile)
162
-#  }
163
-
164
-  versionNumber <- readBin(tempCon, "integer", n=1, size=8, endian="little")
165
-
166
-  if(versionNumber<3)
167
-	  stop("Older style IDAT files not supported:  consider updating your scanner settings")
168
-
169
-  nFields <- readBin(tempCon, "integer", n=1, size=4, endian="little")
170
-
171
-  fields <- matrix(0,nFields,3);
172
-  colnames(fields) <- c("Field Code", "Byte Offset", "Bytes")
173
-  for(i1 in 1:nFields){
174
-    fields[i1,"Field Code"] <-
175
-      readBin(tempCon, "integer", n=1, size=2, endian="little", signed=FALSE)
176
-    fields[i1,"Byte Offset"] <-
177
-      readBin(tempCon, "integer", n=1, size=8, endian="little")
178
-  }
179
-
180
-  knownCodes <-
181
-    c("nSNPsRead"  = 1000,
182
-      "IlluminaID" =  102,
183
-      "SD"         =  103,
184
-      "Mean"       =  104,
185
-      "NBeads"     =  107,
186
-      "MidBlock"   =  200,
187
-      "RunInfo"    =  300,
188
-      "RedGreen"   =  400,
189
-      "MostlyNull" =  401,
190
-      "Barcode"    =  402,
191
-      "ChipType"   =  403,
192
-      "MostlyA"    =  404,
193
-      "Unknown.1"  =  405,
194
-      "Unknown.2"  =  406,
195
-      "Unknown.3"  =  407,
196
-      "Unknown.4"  =  408,
197
-      "Unknown.5"  =  409,
198
-      "Unknown.6"  =  410,
199
-      "Unknown.7"  =  510
200
-      )
201
-
202
-  nNewFields <- 1
203
-  rownames(fields) <- paste("Null", 1:nFields)
204
-  for(i1 in 1:nFields){
205
-    temp <- match(fields[i1,"Field Code"], knownCodes)
206
-    if(!is.na(temp)){
207
-      rownames(fields)[i1] <- names(knownCodes)[temp]
208
-    }else{
209
-      rownames(fields)[i1] <- paste("newField", nNewFields, sep=".")
210
-      nNewFields <- nNewFields + 1
211
-    }
212
-  }
213
-
214
-  fields <- fields[order(fields[, "Byte Offset"]),]
215
-
216
-  seek(tempCon, fields["nSNPsRead", "Byte Offset"])
217
-  nSNPsRead <- readBin(tempCon, "integer", n=1, size=4, endian="little")
218
-
219
-  readBlock <- function(nam) {
220
-      switch(nam,
221
-             "IlluminaID" = {
222
-                 seek(tempCon, fields["IlluminaID", "Byte Offset"])
223
-                 IlluminaID <- readBin(tempCon, "integer", n=nSNPsRead, size=4, endian="little")
224
-                 IlluminaID
225
-             },
226
-             "SD" = {
227
-                 seek(tempCon, fields["SD", "Byte Offset"])
228
-                 SD <- readBin(tempCon, "integer", n=nSNPsRead, size=2, endian="little", signed=FALSE)
229
-                 SD
230
-             },
231
-             "Mean" = {
232
-                 seek(tempCon, fields["Mean", "Byte Offset"])
233
-                 Mean <- readBin(tempCon, "integer", n=nSNPsRead, size=2, endian="little", signed=FALSE)
234
-                 Mean
235
-             },
236
-             "NBeads" = {
237
-                 seek(tempCon, fields["NBeads", "Byte Offset"])
238
-                 NBeads <- readBin(tempCon, "integer", n=nSNPsRead, size=1, signed=FALSE)
239
-                 NBeads
240
-             },
241
-             "MidBlock" = {
242
-                 seek(tempCon, fields["MidBlock", "Byte Offset"])
243
-                 nMidBlockEntries <- readBin(tempCon, "integer", n=1, size=4, endian="little")
244
-                 MidBlock <- readBin(tempCon, "integer", n=nMidBlockEntries, size=4,
245
-                                     endian="little")
246
-                 MidBlock
247
-             },
248
-             "RunInfo" = {
249
-                 seek(tempCon, fields["RunInfo", "Byte Offset"])
250
-                 nRunInfoBlocks <- readBin(tempCon, "integer", n=1, size=4, endian="little")
251
-                 RunInfo <- matrix(NA, nRunInfoBlocks, 5)
252
-                 colnames(RunInfo) <- c("RunTime", "BlockType", "BlockPars",
253
-                                        "BlockCode", "CodeVersion")
254
-                 for(i1 in 1:2) { #nRunInfoBlocks){  ## MR edit
255
-                     for(i2 in 1:5){
256
-                         nChars <- readBin(tempCon, "integer", n=1, size=1, signed=FALSE)
257
-                         RunInfo[i1,i2] <- readChar(tempCon, nChars)
258
-                     }
259
-                 }
260
-                 RunInfo
261
-             },
262
-             "RedGreen" = {
263
-                 seek(tempCon, fields["RedGreen", "Byte Offset"])
264
-                 RedGreen <- readBin(tempCon, "numeric", n=1, size=4,
265
-                                     endian="little")
266
-                 RedGreen
267
-             },
268
-             "MostlyNull" = {
269
-                 seek(tempCon, fields["MostlyNull", "Byte Offset"])
270
-                 nChars <- readBin(tempCon, "integer", n=1, size=1, signed=FALSE)
271
-                 MostlyNull <- readChar(tempCon, nChars)
272
-                 MostlyNull
273
-             },
274
-             "Barcode" = {
275
-                 seek(tempCon, fields["Barcode", "Byte Offset"])
276
-                 nChars <- readBin(tempCon, "integer", n=1, size=1, signed=FALSE)
277
-                 Barcode <- readChar(tempCon, nChars)
278
-                 Barcode
279
-             },
280
-             "ChipType" = {
281
-                 seek(tempCon, fields["ChipType", "Byte Offset"])
282
-                 nChars <- readBin(tempCon, "integer", n=1, size=1, signed=FALSE)
283
-                 ChipType <- readChar(tempCon, nChars)
284
-                 ChipType
285
-             },
286
-             "MostlyA" = {
287
-                 seek(tempCon, fields["MostlyA", "Byte Offset"])
288
-                 nChars <- readBin(tempCon, "integer", n=1, size=1, signed=FALSE)
289
-                 MostlyA <- readChar(tempCon, nChars)
290
-             },
291
-             "Unknown.1" = {
292
-                 seek(tempCon, fields["Unknown.1", "Byte Offset"])
293
-                 nChars <- readBin(tempCon, "integer", n=1, size=1, signed=FALSE)
294
-                 Unknown.1 <- readChar(tempCon, nChars)
295
-                 Unknown.1
296
-             },
297
-             "Unknown.2" = {
298
-                 seek(tempCon, fields["Unknown.2", "Byte Offset"])
299
-                 nChars <- readBin(tempCon, "integer", n=1, size=1, signed=FALSE)
300
-                 Unknown.2 <- readChar(tempCon, nChars)
301
-                 Unknown.2
302
-             },
303
-             "Unknown.3" = {
304
-                 seek(tempCon, fields["Unknown.3", "Byte Offset"])
305
-                 nChars <- readBin(tempCon, "integer", n=1, size=1, signed=FALSE)
306
-                 Unknown.3 <- readChar(tempCon, nChars)
307
-                 Unknown.3
308
-             },
309
-             "Unknown.4" = {
310
-                 seek(tempCon, fields["Unknown.4", "Byte Offset"])
311
-                 nChars <- readBin(tempCon, "integer", n=1, size=1, signed=FALSE)
312
-                 Unknown.4 <- readChar(tempCon, nChars)
313
-                 Unknown.4
314
-             },
315
-             "Unknown.5" = {
316
-                 seek(tempCon, fields["Unknown.5", "Byte Offset"])
317
-                 nChars <- readBin(tempCon, "integer", n=1, size=1, signed=FALSE)
318
-                 Unknown.5 <- readChar(tempCon, nChars)
319
-                 Unknown.5
320
-             },
321
-             "Unknown.6" = {
322
-                 seek(tempCon, fields["Unknown.6", "Byte Offset"])
323
-                 nChars <- readBin(tempCon, "integer", n=1, size=1, signed=FALSE)
324
-                 Unknown.6 <- readChar(tempCon, nChars)
325
-                 Unknown.6
326
-             },
327
-             "Unknown.7" = {
328
-                 seek(tempCon, fields["Unknown.7", "Byte Offset"])
329
-                 nChars <- readBin(tempCon, "integer", n=1, size=1, signed=FALSE)
330
-                 Unknown.7 <- readChar(tempCon, nChars)
331
-                 Unknown.7
332
-             })
333
-  }
334
-
335
-  readFields <- setdiff(rownames(fields), "nSNPsRead")
336
-  names(readFields) <- readFields
337
-
338
-  allFields <- lapply(readFields, readBlock)
339
-
340
-  close(tempCon)
341
-
342
-  UnknownNames <- c("MostlyNull", "MostlyA", "Unknown.1",
343
-                    "Unknown.2", "Unknown.3", "Unknown.4",
344
-                    "Unknown.5", "Unknown.6", "Unknown.7")
345
-  Unknowns <- allFields[intersect(names(allFields), UnknownNames)]
346
-
347
-  Quants <- cbind(allFields$Mean, allFields$SD, allFields$NBeads)
348
-  colnames(Quants) <- c("Mean", "SD", "NBeads")
349
-  rownames(Quants) <- as.character(allFields$IlluminaID)
350
-
351
-  InfoNames <- c("MidBlock", "RunInfo", "RedGreen", "Barcode", "ChipType")
352
-  Info <- allFields[intersect(names(allFields), InfoNames)]
353
-
354
-  idatValues <-
355
-    list(fileSize=fileSize,
356
-         versionNumber=versionNumber,
357
-         nFields=nFields,
358
-         fields=fields,
359
-         nSNPsRead=nSNPsRead,
360
-         Quants=Quants)
361
-  idatValues <- c(idatValues, Info, list(Unknowns = Unknowns))
362
-  idatValues
363
-}
364
-
365
-
366
-readBPM <- function(bpmFile){
367
-
368
-  ## Reads and parses Illumina BPM files
369
-
370
-  fileSize <- file.info(bpmFile)$size
371
-
372
-  tempCon <- file(bpmFile,"rb")
373
-
374
-  # The first few bytes of the egtFile are some type of
375
-  # header, but there's no related byte offset information.
376
-
377
-  prefixCheck <- readChar(tempCon,3) ## should be "BPM"
378
-
379
-  null.1 <- readBin(tempCon, "integer", n=1, size=1, signed=FALSE)
380
-  ## should be 1
381
-
382
-  versionNumber <-
383
-    readBin(tempCon, "integer", n=1, size=4, endian="little")
384
-  ## should be 4
385
-
386
-  nChars <- readBin(tempCon, "integer", n=1, size=1, signed=FALSE)
387
-  chipType <- readChar(tempCon, nChars)
388
-
389
-  null.2 <- readBin(tempCon, "integer", n=2, size=1, signed=FALSE)
390
-
391
-  csvLines <- readLines(tempCon, 22)
392
-
393
-  entriesByteOffset <- seek(tempCon);
394
-  nEntries <- readBin(tempCon, "integer", n=1, size=4,
395
-                      endian="little")
396
-
397
-  if(FALSE){
398
-
399
-    snpIndexByteOffset <- seek(tempCon)
400
-    snpIndex <- readBin(tempCon, "integer", n=nEntries, size=4,
401
-                        endian="little")
402
-    ## for the 1M array, these are simply in order from 1 to 1072820.
403
-
404
-    snpNamesByteOffset <- seek(tempCon)
405
-    snpNames <- rep("A", nEntries)
406
-    for(i1 in 1:nEntries){
407
-      nChars <- readBin(tempCon, "integer", n=1, size=1, signed=FALSE)
408
-      snpNames[i1] <- readChar(tempCon, nChars)
409
-    }
410
-
411
-  }
412
-
413
-  seek(tempCon, 15278138)
414
-
415
-  normIDByteOffset <- seek(tempCon)
416
-  normID <- readBin(tempCon, "integer", n=nEntries, size=1, signed=FALSE) + 1
417
-
418
-  newBlockByteOffset <- seek(tempCon)
419
-  newBlock <- readBin(tempCon, "integer", n=10000, size=1, signed=FALSE)
420
-
421
-  close(tempCon)
422
-
423
-  byteOffsets <- list(entriesByteOffset=entriesByteOffset,
424
-                      #snpIndexByteOffset=snpIndexByteOffset,
425
-                      #snpNamesByteOffset=snpNamesByteOffset,
426
-                      normIDByteOffset=normIDByteOffset,
427
-                      newBlockByteOffset=newBlockByteOffset)
428
-
429
-  allStuff <- list(prefixCheck=prefixCheck,
430
-                   null.1=null.1,
431
-                   versionNumber=versionNumber,
432
-                   chipType=chipType,
433
-                   null.2=null.2,
434
-                   csvLines=csvLines,
435
-                   nEntries=nEntries,
436
-                   #snpIndex=snpIndex,
437
-                   #snpNames=snpNames,
438
-                   normID=normID,
439
-                   newBlock=newBlock,
440
-                   byteOffsets=byteOffsets)
441
-  allStuff
442
-
443
-}
444
-
445
-
446 153
 readGenCallOutput = function(file, path=".", cdfName,
447 154
     colnames=list("SampleID"="Sample ID", "SNPID"="SNP Name", "XRaw"="X Raw", "YRaw"="Y Raw"),
448 155
     type=list("SampleID"="character", "SNPID"="character", "XRaw"="integer", "YRaw"="integer"), verbose=FALSE) {
... ...
@@ -1,5 +1,6 @@
1 1
 setMethod("posteriorMean", signature(object="CNSet"), function(object) assayDataElement(object, "posteriorMean"))
2 2
 setReplaceMethod("posteriorMean", signature(object="CNSet", value="matrix"), function(object, value) assayDataElementReplace(object, "posteriorMean", value))
3
+##setReplaceMethod("mixtureParams", signature(object="CNSet", value="ANY"), function(object, value) object@mixtureParams <- mixtureParams)
3 4
 
4 5
 linearParamElementReplace <- function(obj, elt, value) {
5 6
     storage.mode <- storageMode(batchStatistics(obj))
... ...
@@ -668,3 +669,87 @@ calculateRBafCNSet <- function(object, batch.name, chrom){
668 669
 ##			      lrr=lrr)
669 670
 ##		  return(res)
670 671
 ##	  })
672
+
673
+
674
+setAs("CNSet", "oligoSetList", function(from, to){
675
+	constructOligoSetListFrom(from)
676
+})
677
+
678
+
679
+
680
+setMethod(OligoSetList, "CNSet", function(object,...){
681
+	constructOligoSetListFrom(object, ...)
682
+})
683
+setMethod(BafLrrSetList, "CNSet", function(object,...){
684
+	constructBafLrrSetListFrom(object, ...)
685
+})
686
+
687
+
688
+
689
+
690
+
691
+constructOligoSetListFrom <- function(object, ...){
692
+	##row.index <- seq_len(nrow(object))
693
+	##col.index <- seq_len(ncol(object))
694
+	is.lds <- ifelse(is(calls(object), "ff_matrix") | is(calls(object), "ffdf"), TRUE, FALSE)
695
+	if(is.lds) stopifnot(isPackageLoaded("ff"))
696
+	b.r <- calculateRBaf(object, ...)
697
+	b <- b.r[["baf"]]
698
+	r <- b.r[["lrr"]]
699
+	j <- match(colnames(r[[1]]), sampleNames(object))
700
+	rns <- lapply(r, rownames)
701
+	fDList <- foreach(featureid=rns) %do%{
702
+		featureData(object)[match(featureid, featureNames(object)), ]
703
+	}
704
+	names(fDList) <- sapply(fDList, function(x) chromosome(x)[1])
705
+	gtPlist <- gtlist <- vector("list", length(r))
706
+	for(i in seq_along(r)){
707
+		gtlist[[i]] <- initializeBigMatrix("call", nr=nrow(r[[i]]), nc=length(j), vmode="integer")
708
+		gtPlist[[i]] <- initializeBigMatrix("callPr", nr=nrow(r[[i]]), nc=length(j), vmode="integer")
709
+		featureid <- rownames(r[[i]])
710
+		ix <- match(featureid, featureNames(object))
711
+		rownames(gtPlist[[i]]) <- rownames(gtlist[[i]]) <- featureid
712
+		colnames(gtPlist[[i]]) <- colnames(gtlist[[i]]) <- colnames(r[[i]])
713
+		for(k in seq_along(j)){
714
+			gtlist[[i]][, k] <- calls(object)[ix, j[k]]
715
+			gtPlist[[i]][, k] <- snpCallProbability(object)[ix, j[k]]
716
+		}
717
+	}
718
+	ad <- AssayDataList(baf=b, copyNumber=r, call=gtlist, callProbability=gtPlist)
719
+	object <- new("oligoSetList",
720
+		      assayDataList=ad,
721
+		      featureDataList=fDList,
722
+		      chromosome=names(fDList),
723
+		      phenoData=phenoData(object)[j, ],
724
+		      annotation=annotation(object),
725
+		      genome=genomeBuild(object))
726
+	return(object)
727
+}
728
+
729
+
730
+
731
+constructBafLrrSetListFrom <- function(object, ...){
732
+	is.lds <- ifelse(is(calls(object), "ff_matrix") | is(calls(object), "ffdf"), TRUE, FALSE)
733
+	if(is.lds) stopifnot(isPackageLoaded("ff"))
734
+	b.r <- calculateRBaf(object, ...)
735
+	b <- b.r[["baf"]]
736
+	r <- b.r[["lrr"]]
737
+	j <- match(colnames(r[[1]]), sampleNames(object))
738
+	rns <- lapply(r, rownames)
739
+	featureid <- NULL
740
+	fDList <- foreach(featureid=rns) %do%{
741
+		featureData(object)[match(featureid, featureNames(object)), ]
742
+	}
743
+	names(fDList) <- sapply(fDList, function(x) chromosome(x)[1])
744
+	ad <- AssayDataList(baf=b, lrr=r)
745
+	object <- new("BafLrrSetList",
746
+		      assayDataList=ad,
747
+		      featureDataList=fDList,
748
+		      chromosome=names(fDList),
749
+		      phenoData=phenoData(object)[j, ],
750
+		      annotation=annotation(object),
751
+		      genome=genomeBuild(object))
752
+	return(object)
753
+}
754
+
755
+computeBR <- constructBafLrrSetListFrom
... ...
@@ -1,10 +1,6 @@
1 1
 # Loading required libraries
2 2
 THISPKG <- "crlmm"
3 3
 
4
-##.onLoad <- function(libname, pkgname) {
5
-##	require("methods")
6
-##}
7
-
8 4
 .onAttach <- function(libname, pkgname) {
9 5
 	packageStartupMessage("Welcome to crlmm version ", packageDescription(THISPKG, fields="Version"))
10 6
 }
11 7
new file mode 100644
12 8
Binary files /dev/null and b/man/.DS_Store differ
... ...
@@ -16,6 +16,8 @@
16 16
 \alias{phiA,CNSet-method}
17 17
 \alias{phiB,CNSet-method}
18 18
 \alias{tau2,CNSet-method}
19
+\alias{OligoSetList,CNSet-method}
20
+\alias{BafLrrSetList,CNSet-method}
19 21
 
20 22
 \title{crlmm methods for class "CNSet"}
21 23
 \description{
... ...
@@ -58,7 +60,17 @@
58 60
     \item{mads}{\code{signature(x="CNSet")}: ...}
59 61
     \item{medians}{\code{signature(object="CNSet")}: ...}
60 62
     \item{tau2}{\code{signature(object="CNSet")}: ...}
61
-	 }
63
+
64
+
65
+  \item{}{\code{OligoSetList(object)}: constructs an object of class
66
+    \code{OligoSetList} from \code{object} having class \code{CNSet}.
67
+  }
68
+
69
+  \item{}{\code{BafLrrSetList(object)}: constructs an object of class
70
+    \code{BafLrrSetList} from \code{object} having class \code{CNSet}.
71
+  }
72
+
73
+  }
62 74
 }
63 75
 
64 76
 \seealso{
65 77
new file mode 100644
... ...
@@ -0,0 +1,43 @@
1
+\name{ListClassConstructors}
2
+\alias{BafLrrSetList}
3
+\alias{OligoSetList}
4
+\title{ Methods for Function \code{BafLrrSetList} in Package \pkg{crlmm} ~~}
5
+\description{
6
+  Constructors for \code{BafLrrSetList} and \code{OligoSetList} objects.
7
+}
8
+
9
+\usage{
10
+BafLrrSetList(object, ...)
11
+OligoSetList(object, ...)
12
+}
13
+
14
+\arguments{
15
+  \item{object}{ A \code{CNSet} object.}
16
+  \item{...}{Additional arguments \code{batch.name} and \code{chrom} can
17
+  be used to specify specific batches or chromosomes in the \code{CNSet}
18
+  object.
19
+}
20
+}
21
+
22
+\details{
23
+
24
+  Constructs a \code{BafLrrSetList} object or a \code{OligoSetList}
25
+  object from an object of class \code{CNSet}.
26
+
27
+}
28
+
29
+\value{A \code{BafLrrSetList} or \code{OligoSetList}}
30
+
31
+\examples{
32
+data(cnSetExample)
33
+oligoList <- OligoSetList(cnSetExample)
34
+## only contains 1 chromosome, so list only has one element
35
+dims(oligoList)
36
+brList <- BafLrrSetList(cnSetExample)
37
+dims(brList)
38
+}
39
+
40
+\seealso{\code{\linkS4class{BeadStudioSetList}}}
41
+
42
+
43
+\keyword{manip}
0 44
\ No newline at end of file
1 45
deleted file mode 100644
... ...
@@ -1,51 +0,0 @@
1
-\name{readIDAT}
2
-\alias{readIDAT}
3
-\alias{readIDAT}
4
-
5
-\title{Low-level function to read idat files}
6
-
7
-\description{
8
-  Reads intensity information for each bead type from a single .idat file
9
-  from Infinium II platforms.  This is a low-level function which \code{readIdatFiles}
10
-  is a wrapper to}
11
-
12
-\usage{
13
-readIDAT(idatFile)
14
-}
15
-
16
-\arguments{
17
-  \item{idatFile}{character string specifying idat file to be read in}
18
-}
19
-
20
-\details{
21
-
22
-This function returns a list containing summarised intensities and other
23
-information extracted from a single .idat file.
24
-
25
-The \code{readIdatFiles} function makes use of \code{readIDAT} to read
26
-the paired Cy3 and Cy5 idats from one or more arrays.
27
-
28
-Thanks to Keith Baggerly who providing this code.
29
-}
30
-
31
-\value{
32
-  list which includes item \code{Quants} which contains average intensity (\code{Mean}),
33
-  number of beads (\code{NBeads}) and a measure of variability (\code{SD}) for
34
-  each bead type on the array.
35
-}
36
-
37
-\references{
38
-  Ritchie ME, Carvalho BS, Hetrick KN, Tavar\'{e} S, Irizarry RA.
39
-  R/Bioconductor software for Illumina's Infinium whole-genome
40
-  genotyping BeadChips. Bioinformatics. 2009 Oct 1;25(19):2621-3.
41
-}
42
-
43
-\author{Keith Baggerly, with modifications by Matt Ritchie}
44
-
45
-\examples{
46
-#idatdata = readIDAT("4019585367_A_Grn.idat")
47
-#names(idatdata
48
-#idatdata$Quants[1:5,]
49
-}
50
-\keyword{IO}
51
-