Browse code

Fix bug in CB accessor for nonpolymorphic markers

CB returns 0 at nonpolymorphic loci instead of NA. While NA makes more
sense since we do not measure the alternative allele, this prevents
NA's from creeping into estimates of total copy number (CA+CB = NA vs
CA+CB=CA)

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

Rob Scharp authored on 16/02/2011 15:58:19
Showing2 changed files

... ...
@@ -508,9 +508,11 @@ ACN <- function(object, allele, i , j){
508 508
 			acn[acn.index, ] <- 0
509 509
 		}
510 510
 		if(any(is.auto)){
511
-			auto.index <- which(is.auto)
512
-			marker.index <- i[is.auto]
513
-			acn[auto.index, ] <- C2(object, marker.index, batch.index, j)
511
+			auto.index <- which(is.auto & is.snp)
512
+			if(length(auto.index) > 0){
513
+				marker.index <- i[is.auto]
514
+				acn[auto.index, ] <- C2(object, marker.index, batch.index, j)
515
+			}
514 516
 		}
515 517
 		if(any(is.X)){
516 518
 			if(is.ff){
... ...
@@ -164,6 +164,7 @@ if(!file.exists(file.path(outdir, "cnSet.rda"))){
164 164
 			     filenames=celFiles,
165 165
 			     cdfName=cdfName,
166 166
 			     batch=batch)
167
+}
167 168
 @
168 169
 
169 170
 The value returned by genotype is an instance of the class
... ...
@@ -244,6 +245,7 @@ stopifnot(all.equal(ct, ct2))
244 245
 
245 246
  Nonpolymorphic markers on chromosome X:
246 247
 
248
+
247 249
 <<nonpolymorphicX, fig=TRUE, width=8, height=4>>=
248 250
 npx.index <- which(chromosome(cnSet)==23 & !isSnp(cnSet))
249 251
 M <- sample(which(cnSet$gender==1), 5)
... ...
@@ -252,10 +254,7 @@ cn.M <- CA(cnSet, i=npx.index, j=M)
252 254
 cn.F <- CA(cnSet, i=npx.index, j=F)
253 255
 boxplot(data.frame(cbind(cn.M, cn.F)), pch=".", col="grey60", outline=FALSE)
254 256
 @
255
-\caption{Copy number estimates for nonpolymorphic loci on chromosome
256
-  X (5 men, 5 women).  crlmm assumes that the median copy number
257
-  across samples at a given marker on X is 1 for men and 2 for women.}
258
-\end{figure}
257
+
259 258
 
260 259
 \begin{figure}[t!]
261 260
  \centering