Browse code

merged matt's changes on the collab branch

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

Rob Scharp authored on 03/02/2014 14:03:16
Showing4 changed files

... ...
@@ -1,8 +1,8 @@
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.21.1
5
-Date: Wed Oct 30 21:42:52 EDT 2013
4
+Version: 1.21.4
5
+Date: Mon Feb  3 09:02:42 EST 2014
6 6
 Author: Benilton S Carvalho, Robert Scharpf, Matt Ritchie, Ingo Ruczinski, Rafael A Irizarry
7 7
 Maintainer: Benilton S Carvalho <Benilton.Carvalho@cancer.org.uk>, Robert Scharpf <rscharpf@jhsph.edu>, Matt Ritchie <mritchie@wehi.EDU.AU>
8 8
 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
... ...
@@ -18,7 +18,7 @@ importClassesFrom(oligoClasses, CNSet, oligoSnpSet, ff_or_matrix)
18 18
 import(matrixStats)
19 19
 
20 20
 importMethodsFrom(Biobase, annotatedDataFrameFrom, annotation,
21
-                  assayData, experimentData, featureData,
21
+                  AnnotatedDataFrame, assayData, experimentData, featureData,
22 22
                   "featureData<-", featureNames, "featureNames<-",
23 23
                   pData, "pData<-", phenoData, "phenoData<-",
24 24
                   protocolData, "protocolData<-",
... ...
@@ -90,8 +90,12 @@ readIdatFiles = function(sampleSheet=NULL,
90 90
 		       warning("Chips are not of the same type.  Skipping ", basename(grnidats[i]), " and ", basename(redidats[i]))
91 91
 		       next()
92 92
 	       }
93
-	       dates$decode[i] = G$RunInfo[1, 1]
94
-	       dates$scan[i] = G$RunInfo[2, 1]
93
+               if(saveDate) {
94
+                      if(nrow(G$RunInfo)>=2) {
95
+	              dates$decode[i] = G$RunInfo[1, 1]
96
+	              dates$scan[i] = G$RunInfo[2, 1]
97
+                      }
98
+               }
95 99
 	       if(i==1) {
96 100
 		       if(is.null(ids) && !is.null(G)){
97 101
 			       ids = idsG
... ...
@@ -99,9 +103,9 @@ readIdatFiles = function(sampleSheet=NULL,
99 103
 		       nprobes = length(ids)
100 104
 		       narrays = length(arrayNames)
101 105
 		       RG = new("NChannelSet",
102
-		                 R=matrix(NA, nprobes, narrays),
103
-		                 G=matrix(NA, nprobes, narrays),
104
-		                 zero=matrix(NA, nprobes, narrays),
106
+		                 R=matrix(0, nprobes, narrays),
107
+		                 G=matrix(0, nprobes, narrays),
108
+		                 zero=matrix(1, nprobes, narrays),
105 109
 				 annotation=headerInfo$Manifest[1],
106 110
 				 phenoData=pd, storage.mode="environment")
107 111
 		       featureNames(RG) = ids
... ...
@@ -117,8 +121,9 @@ readIdatFiles = function(sampleSheet=NULL,
117 121
 		       }
118 122
 	       } else {
119 123
 		       indG = match(ids, idsG)
120
-		       RG@assayData$G[,i] = G$Quants[indG, "Mean"]
121
-		       zeroG = G$Quants[indG, "NBeads"]==0
124
+                       nasG = is.na(indG)
125
+		       RG@assayData$G[!nasG,i] = G$Quants[indG[!nasG], "Mean"]
126
+		       zeroG = G$Quants[indG[!nasG], "NBeads"]==0
122 127
 	       }
123 128
 	       rm(G)
124 129
 	       gc(verbose=FALSE)
... ...
@@ -132,13 +137,16 @@ readIdatFiles = function(sampleSheet=NULL,
132 137
 		       if(sum(ids==idsR)==nprobes) {
133 138
 			       RG@assayData$R[,i] = R$Quants[ ,"Mean"]
134 139
 		               zeroR = R$Quants[ ,"NBeads"]==0
140
+                               RG@assayData$zero[,i] = zeroG | zeroR
135 141
 		       }
136 142
 	       } else {
137 143
 		       indR = match(ids, idsR)
138
-		       RG@assayData$R[,i] = R$Quants[indR, "Mean"]
139
-		       zeroR = R$Quants[indR, "NBeads"]==0
144
+	               nasR = is.na(indR)
145
+		       RG@assayData$R[!nasR,i] = R$Quants[indR[!nasR], "Mean"]
146
+		       zeroR = R$Quants[indR[!nasR], "NBeads"]==0
147
+                       RG@assayData$zero[!nasR,i] = zeroG | zeroR
140 148
 	       }
141
-	       RG@assayData$zero[,i] = zeroG | zeroR
149
+#	       RG@assayData$zero[,i] = zeroG | zeroR
142 150
 	       rm(R, zeroG, zeroR)
143 151
 	       gc(verbose=FALSE)
144 152
        }
... ...
@@ -150,7 +158,6 @@ readIdatFiles = function(sampleSheet=NULL,
150 158
 }
151 159
 
152 160
 
153
-
154 161
 getNumberOfSNPs = function(afile, path){
155 162
     fullfilename = file.path(path, afile)
156 163
     headerSection = readLines(fullfilename, n=15)
... ...
@@ -624,8 +631,8 @@ preprocessInfinium2 = function(XY, mixtureSampleSize=10^5,
624 631
   ##NOTE: We actually dont need to save S. Only for pics etc...
625 632
   ##f is the correction. we save to avoid recomputing
626 633
 
627
-  A = matrix(NA, nprobes, narrays)
628
-  B = matrix(NA, nprobes, narrays)
634
+  A = matrix(0, nprobes, narrays)
635
+  B = matrix(0, nprobes, narrays)
629 636
   zero = matrix(NA, nprobes, narrays)
630 637
   if(verbose && fitMixture){
631 638
      message("Calibrating ", narrays, " arrays.")
... ...
@@ -904,8 +911,10 @@ getProtocolData.Illumina = function(filenames, sep="_", fileExt="Grn.idat", verb
904 911
 		       warning("Chips are not of the same type.  Skipping ", basename(filenames[i]))
905 912
 		       next()
906 913
 	       }
907
-	       scanDates$ScanDate[i] = G$RunInfo[1, 1]
908
-	       scanDates$DecodeDate[i] = G$RunInfo[2, 1]
914
+               if(nrow(G$RunInfo)>=2) {
915
+   	           scanDates$ScanDate[i] = G$RunInfo[1, 1]
916
+	           scanDates$DecodeDate[i] = G$RunInfo[2, 1]
917
+               }
909 918
 	       rm(G)
910 919
 	       gc(verbose=FALSE)
911 920
        }
... ...
@@ -1226,7 +1235,7 @@ genotype.Illumina <- function(sampleSheet=NULL,
1226 1235
 			      cdfName,
1227 1236
 			      copynumber=TRUE,
1228 1237
 			      batch=NULL,
1229
-			      saveDate=TRUE,
1238
+			      saveDate=FALSE,
1230 1239
 			      stripNorm=TRUE,
1231 1240
 			      useTarget=TRUE,
1232 1241
                               quantile.method="between",                             
... ...
@@ -43,6 +43,7 @@
43 43
 \section{Set up}
44 44
 
45 45
 <<crlmm, results=hide, echo=FALSE>>=
46
+library(Biobase)
46 47
 library(crlmm)
47 48
 options(width=70)
48 49
 options(continue=" ")
... ...
@@ -238,7 +239,6 @@ cnSet <- genotype.Illumina(sampleSheet=samplesheet,
238 239
 			   arrayInfoColNames=arrayInfo,
239 240
 			   cdfName="human370v1c",
240 241
 			   batch=batch)
241
-stop()
242 242
 @
243 243
 
244 244