[Patchwork-commits] r91 - pkg/patchwork/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Feb 15 14:27:38 CET 2012


Author: mayrhofer
Date: 2012-02-15 14:27:38 +0100 (Wed, 15 Feb 2012)
New Revision: 91

Modified:
   pkg/patchwork/R/patchwork.alleledata.r
   pkg/patchwork/R/patchwork.findCNs.r
Log:
fixed CELL% calc and some other stuff

Modified: pkg/patchwork/R/patchwork.alleledata.r
===================================================================
--- pkg/patchwork/R/patchwork.alleledata.r	2012-02-13 16:01:38 UTC (rev 90)
+++ pkg/patchwork/R/patchwork.alleledata.r	2012-02-15 13:27:38 UTC (rev 91)
@@ -30,7 +30,6 @@
 	alf$amin = alf$atot-alf$amax
 	#alf=alf[alf$atot<100,] # outlierz
 
-	alf=merge(alf,dbSnp[,c(1,3)], all=F, by=1:2)
 	
 	#Force compatability between naming of chromosomes to our chromosome names
 	#from ideogram file. chr1...chr22,chrX,chrY
@@ -52,6 +51,8 @@
 		}
 	
 	
+	alf=merge(alf,dbSnp[,c(1,3)], all=F, by=1:2)
+
 	#Finally, if a matched normal was available, remove SNPs that were not (somewhat) heterozygous there.
 	if (!is.null(normalalf)) {
 		normalalf <- normalalf[normalalf$amin/normalalf$atot > 0.1,]

Modified: pkg/patchwork/R/patchwork.findCNs.r
===================================================================
--- pkg/patchwork/R/patchwork.findCNs.r	2012-02-13 16:01:38 UTC (rev 90)
+++ pkg/patchwork/R/patchwork.findCNs.r	2012-02-15 13:27:38 UTC (rev 91)
@@ -260,8 +260,6 @@
     regions$Cn <- Cn
     regions$mCn <- mCn
     regions$fullCN <- fullCN
-
-	write.csv(regions,file='Copynumbers.csv')
 	
 	meanCn <- weightedMean(regions$Cn,regions$np)
 	ix1 <- regions$Cn==trunc(meanCn)
@@ -269,15 +267,21 @@
 	xdelta <- weightedMean(regions$median[ix2],regions$np[ix2]) - weightedMean(regions$median[ix1],regions$np[ix1])
 	expected_delta <- 1/meanCn
 	
-	tumor_percent <- xdelta / expected_delta
+	tumor_percentDNA <- xdelta / expected_delta
+    tumor_percent <- tumor_percentDNA/(meanCn/2) / ( tumor_percentDNA/(meanCn/2) + (1-tumor_percentDNA) )
 
+    regions$meanCn <- meanCn
+    regions$tumor_percent <- tumor_percent
+    write.csv(regions,file='Copynumbers.csv')
+
+
 	karyotype_check(regions$chr,regions$start,regions$end,regions$mean,regions$ai,
 					regions$Cn,regions$mCn,list(int=int,ai=ai),name=name,
-					xlim=c(0,2.4),ylim=c(0.3,1))
+					xlim=c(0,2.4),ylim=c(0.1,1))
 					
 	karyotype_chromsCN(regions$chr,regions$start,regions$end,regions$mean,regions$ai,
 						regions$Cn,regions$mCn,kbsegs$chr,
 						kbsegs$pos,kbsegs$ratio,alf$achr,alf$apos,
 						(1-alf$amin/alf$amax),name=name,xlim=c(0,2.4),
-						ylim=c(0.3,1))
+						ylim=c(0.1,1))
 	}
\ No newline at end of file



More information about the Patchwork-commits mailing list