Browse code

commented gc() calls

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

Rob Scharp authored on 21/08/2010 02:48:21
Showing3 changed files

... ...
@@ -151,7 +151,7 @@ genotype <- function(filenames,
151 151
 		suppressWarnings(A(callSet)[snp.index, j] <- snprmaRes[["A"]])
152 152
 		suppressWarnings(B(callSet)[snp.index, j] <- snprmaRes[["B"]])
153 153
 		mixtureParams[, j] <- snprmaRes$mixtureParams
154
-		rm(snprmaRes); gc()
154
+		rm(snprmaRes); ##gc()
155 155
 		if(copynumber){
156 156
 			np.index <- which(isSnp(callSet) == 0)
157 157
 			cnrmaRes <- cnrma(filenames=filenames[j],
... ...
@@ -162,7 +162,7 @@ genotype <- function(filenames,
162 162
 					  verbose=verbose)
163 163
 			stopifnot(identical(featureNames(callSet)[np.index], rownames(cnrmaRes)))
164 164
 			A(callSet)[np.index, j] <- cnrmaRes
165
-			rm(cnrmaRes); gc()
165
+			rm(cnrmaRes); ##gc()
166 166
 		}
167 167
 		## as.matrix needed when ffdf is used
168 168
 		tmp <- crlmmGT(A=as.matrix(A(callSet)[snp.index, j]),
... ...
@@ -278,7 +278,7 @@ genotypeLD <- function(filenames,
278 278
 			   sns=sns,
279 279
 			   seed=seed,
280 280
 			   verbose=verbose)
281
-	rm(cnrmaRes); gc()
281
+	rm(cnrmaRes); ##gc()
282 282
 	## as.matrix needed when ffdf is used
283 283
 	tmp <- crlmmGT2(A=snprmaRes[["A"]],
284 284
 			B=snprmaRes[["B"]],
... ...
@@ -634,7 +634,7 @@ crlmmCopynumber <- function(object,
634 634
 					lM(object)[[k]][row.index, column] <- fData(tmp)[, k]
635 635
 				}
636 636
 			}			
637
-			rm(tmp); gc()
637
+			rm(tmp); ##gc()
638 638
 			ii <- ii+1
639 639
 		}
640 640
 	}
... ...
@@ -891,7 +891,7 @@ fit.lm1 <- function(idxBatch,
891 891
 			muB[index[[j]], -kk] <- mus[, 3:4]
892 892
 		}
893 893
 		rm(betahat, X, Y, mus, index, noAA, noAB, noBB, res)
894
-		gc()
894
+		##gc()
895 895
 		negA <- rowSums(muA < 0) > 0
896 896
 		negB <- rowSums(muB < 0) > 0
897 897
 		flags[, J] <- rowSums(Ns == 0) > 0
... ...
@@ -934,7 +934,7 @@ fit.lm1 <- function(idxBatch,
934 934
 ##		cA[, k] <- matrix((1/phiA[, J]*(A-nuA[, J])), nrow(A), ncol(A))
935 935
 ##		cB[, k] <- matrix((1/phiB[, J]*(B-nuB[, J])), nrow(B), ncol(B))
936 936
 		rm(G, A, B, NORM, wA, wB, YA,YB, res, negA, negB, Np, Ns)
937
-		gc()
937
+		##gc()
938 938
 	}
939 939
 ##	cA[cA < 0.05] <- 0.05
940 940
 ##	cB[cB < 0.05] <- 0.05
... ...
@@ -1276,7 +1276,7 @@ fit.lm3 <- function(idxBatch,
1276 1276
 ##		cA[, k] <- (A-nuA[, J]-phiA2[, J]*cB[, k])/phiA[, J]
1277 1277
 		##some of the snps are called for the men, but not the women
1278 1278
 		rm(YA, YB, wA, wB, res, tmp, phistar, A, B, G, index)
1279
-		gc()
1279
+		##gc()
1280 1280
 	}
1281 1281
 ##	cA[cA < 0.05] <- 0.05
1282 1282
 ##	cB[cB < 0.05] <- 0.05
... ...
@@ -1479,7 +1479,7 @@ fit.lm4 <- function(idxBatch,
1479 1479
 ##		tmp[, gend==2] <- CT2
1480 1480
 ##		cA[, k] <- tmp
1481 1481
 		rm(tmp, CT1, CT2, A.F, normal.f, G, AA, BB, Y, X, Ns)
1482
-		gc()
1482
+		##gc()
1483 1483
 	}
1484 1484
 ##	cA[cA < 0.05] <- 0.05
1485 1485
 ##	cA[cA > 5] <-  5
... ...
@@ -2096,7 +2096,7 @@ locationAndScale <- function(object, cnOptions, tmp.objects){
2096 2096
 	index.AA <- index[[1]]
2097 2097
 	index.AB <- index[[2]]
2098 2098
 	index.BB <- index[[3]]
2099
-	rm(index); gc()
2099
+	rm(index); ##gc()
2100 2100
 
2101 2101
 	GT.A <- tmp.objects[["GT.A"]]
2102 2102
 	GT.B <- tmp.objects[["GT.B"]]
... ...
@@ -243,17 +243,36 @@ setMethod("CB",
243 243
 		  ##assayDataElement(object, "CB")
244 244
 		  browser()
245 245
 	  })
246
+
246 247
 setMethod("CA",
247 248
 	  signature=signature(object="CNSet", i="integerOrMissing", j="integerOrMissing"),
248 249
 	  function(object, i, j) {
249 250
 		  browser()
251
+		  if(missing(i) & missing(j)){
252
+			  if(inherits(A(object), "ff") | inherits(A(object), "ffdf")) stop("Must specify i and/or j for ff objects")
253
+		  }
254
+		  if(missing(i) & !missing(j)){
255
+			  ## calculate ca only for batches indexed by j
256
+			  batches <- unique(batch(object))[j]
257
+			  for(k in seq_along(batches)){
258
+				  bb <- batches[k]
259
+			  }
260
+		  }
261
+		  if(!missing(i) & missing(j)){
262
+			  ## calculate ca, cb for all batches
263
+			  batches <- unique(batch(object))
264
+		  }
265
+		  if(!missing(i) & !missing(j)){
266
+
267
+		  }
268
+		  return(ca)
250 269
 	  })
251 270
 
252 271
 setMethod("totalCopyNumber",
253 272
 	  signature=signature(object="CNSet", i="integerOrMissing", j="integerOrMissing"),
254 273
 	  function(object, i, j, ...){
255 274
 	if(missing(i) & missing(j)){
256
-		if(inherits(CA(object), "ff") | inherits(CA(object), "ffdf")) stop("Must specify i and/or j for ff objects")
275
+		if(inherits(A(object), "ff") | inherits(A(object), "ffdf")) stop("Must specify i and/or j for ff objects")
257 276
 	}
258 277
 	if(missing(i) & !missing(j)){
259 278
 		snp.index <- which(isSnp(object))	
... ...
@@ -145,7 +145,11 @@ computation had already been performed as part of the batch job.
145 145
 cnSet.assayData_matrix <- checkExists("cnSet.assayData_matrix",
146 146
 				      .path=outdir,
147 147
 				      .FUN=crlmmCopynumber,
148
-				      object=gtSet.assayData_matrix)
148
+				      object=gtSet.assayData_matrix,
149
+				      chromosome=22)
150
+Rprof(interval=0.1)
151
+obj <- crlmmCopynumber(gtSet.assayData_matrix, chromosome=22)
152
+Rprof(NULL)
149 153
 if(file.exists(file.path(outdir, "gtSet.assayData_matrix.rda")))
150 154
 	unlink(file.path(outdir, "gtSet.assayData_matrix.rda"))
151 155
 @ 
... ...
@@ -177,6 +181,7 @@ so that subsequent calls to \verb@Sweave@ can be run interactively.
177 181
 
178 182
 <<LDS_genotype>>=
179 183
 if(!file.exists(file.path(outdir, "cnSet.assayData_ff.rda"))){
184
+	library(ff)
180 185
 	gtSet.assayData_ff <- checkExists("gtSet.assayData_ff",
181 186
 					  .path=outdir,
182 187
 					  .FUN=genotypeLD,