[Patchwork-commits] r97 - in pkg: patchwork/R patchworkCG/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Feb 16 16:28:13 CET 2012


Author: sebastian_d
Date: 2012-02-16 16:28:12 +0100 (Thu, 16 Feb 2012)
New Revision: 97

Modified:
   pkg/patchwork/R/karyotype_check.r
   pkg/patchwork/R/karyotype_chroms.r
   pkg/patchwork/R/karyotype_chromsCN.r
   pkg/patchworkCG/R/CG_KaCh.r
   pkg/patchworkCG/R/CG_KaChCN.r
   pkg/patchworkCG/R/CG_karyotype.r
   pkg/patchworkCG/R/patchwork.CG.r
Log:
Further changes made to plotting functions of patchwork and patchworkCG. Changes made to the segmratio value as relcov didnt seem to quite do the trick. ratio is now based on depcov avgnormcov instead

Modified: pkg/patchwork/R/karyotype_check.r
===================================================================
--- pkg/patchwork/R/karyotype_check.r	2012-02-16 14:27:55 UTC (rev 96)
+++ pkg/patchwork/R/karyotype_check.r	2012-02-16 15:28:12 UTC (rev 97)
@@ -4,8 +4,8 @@
     png(paste(name,'_karyotype_check.png',sep=''),width=1300,height=1300)
  
 
-    	colors_p <- colorRampPalette(c("#6600FF","#9900CC"),space="rgb")
-    	colors_q <- colorRampPalette(c("#CC0099","#CC0000"),space="rgb")
+    	#colors_p <- colorRampPalette(c("#6600FF","#9900CC"),space="rgb")
+    	#colors_q <- colorRampPalette(c("#CC0099","#CC0000"),space="rgb")
 
     	#layout(matrix(1:25,nrow=5,byrow=T), widths=1,heights=1)
     

Modified: pkg/patchwork/R/karyotype_chroms.r
===================================================================
--- pkg/patchwork/R/karyotype_chroms.r	2012-02-16 14:27:55 UTC (rev 96)
+++ pkg/patchwork/R/karyotype_chroms.r	2012-02-16 15:28:12 UTC (rev 97)
@@ -74,8 +74,8 @@
         	#col[ix & (pos < this$mid)] <- paste(colors_p(sum(ix & (pos < this$mid))), '70', sep='')  
         	#col[ix & (pos > this$mid)] <- paste(colors_q(sum(ix & (pos > this$mid))), '70', sep='') 
         	col=rep('#000000',sum(ix))
-        	col[pos[ix] < this$mid] <- colors_p(sum(pos[ix] < this$mid))
-        	col[pos[ix] > this$mid] <- colors_q(sum(pos[ix] > this$mid))
+        	col[pos[ix] < this$mid] <- loc_p[ceiling(pos[ix][pos[ix] < this$mid]/100)]
+            col[pos[ix] > this$mid] <- loc_q[ceiling((pos[ix][pos[ix] > this$mid] - this$mid)/100)]
         
         	plot(mpos[mix],mval[mix],
             	pch=16,

Modified: pkg/patchwork/R/karyotype_chromsCN.r
===================================================================
--- pkg/patchwork/R/karyotype_chromsCN.r	2012-02-16 14:27:55 UTC (rev 96)
+++ pkg/patchwork/R/karyotype_chromsCN.r	2012-02-16 15:28:12 UTC (rev 97)
@@ -70,8 +70,8 @@
         	mtext(text="Coverage, all segments",side=1,line=4,cex=2,las=1)
 		    	
 			col=rep('#000000',sum(ix))
-        	col[pos[ix] < this$mid] <- colors_p(sum(pos[ix] < this$mid))
-        	col[pos[ix] > this$mid] <- colors_q(sum(pos[ix] > this$mid))
+        	col[pos[ix] < this$mid] <- loc_p[ceiling(pos[ix][pos[ix] < this$mid]/100)]
+            col[pos[ix] > this$mid] <- loc_q[ceiling((pos[ix][pos[ix] > this$mid] - this$mid)/100)]
         	par(new=F)
         	
         	plot(1,1,type='n',

Modified: pkg/patchworkCG/R/CG_KaCh.r
===================================================================
--- pkg/patchworkCG/R/CG_KaCh.r	2012-02-16 14:27:55 UTC (rev 96)
+++ pkg/patchworkCG/R/CG_KaCh.r	2012-02-16 15:28:12 UTC (rev 97)
@@ -82,8 +82,15 @@
         	#col[ix & (pos < this$mid)] <- paste(colors_p(sum(ix & (pos < this$mid))), '70', sep='')  
         	#col[ix & (pos > this$mid)] <- paste(colors_q(sum(ix & (pos > this$mid))), '70', sep='') 
         	col=rep('#000000',sum(ix))
-        	col[pos[ix] < this$mid] <- colors_p(sum(pos[ix] < this$mid))
-        	col[pos[ix] > this$mid] <- colors_q(sum(pos[ix] > this$mid))
+            #Remove Alpha.
+            #col[ix_p] = loc_p[ceiling(pos[ix_p]/100)]
+            #col[ix_q] = loc_q[ceiling((pos[ix_q]-this$end)/100)]
+            col[pos[ix] < this$mid] <- loc_p[ceiling(pos[ix][pos[ix] < this$mid]/100)]
+            col[pos[ix] > this$mid] <- loc_q[ceiling((pos[ix][pos[ix] > this$mid] - this$mid)/100)]
+
+            #Origional
+        	#col[pos[ix] < this$mid] <- colors_p(sum(pos[ix] < this$mid))
+        	#col[pos[ix] > this$mid] <- colors_q(sum(pos[ix] > this$mid))
         
         	plot(mpos[mix],mval[mix],
             	pch=16,

Modified: pkg/patchworkCG/R/CG_KaChCN.r
===================================================================
--- pkg/patchworkCG/R/CG_KaChCN.r	2012-02-16 14:27:55 UTC (rev 96)
+++ pkg/patchworkCG/R/CG_KaChCN.r	2012-02-16 15:28:12 UTC (rev 97)
@@ -80,8 +80,8 @@
         	mtext(text="Coverage, all segments",side=1,line=4,cex=2,las=1)
 		    	
 			col=rep('#000000',sum(ix))
-        	col[pos[ix] < this$mid] <- colors_p(sum(pos[ix] < this$mid))
-        	col[pos[ix] > this$mid] <- colors_q(sum(pos[ix] > this$mid))
+        	col[pos[ix] < this$mid] <- loc_p[ceiling(pos[ix][pos[ix] < this$mid]/100)]
+            col[pos[ix] > this$mid] <- loc_q[ceiling((pos[ix][pos[ix] > this$mid] - this$mid)/100)]
         	par(new=F)
         	
         	plot(1,1,type='n',

Modified: pkg/patchworkCG/R/CG_karyotype.r
===================================================================
--- pkg/patchworkCG/R/CG_karyotype.r	2012-02-16 14:27:55 UTC (rev 96)
+++ pkg/patchworkCG/R/CG_karyotype.r	2012-02-16 15:28:12 UTC (rev 97)
@@ -70,7 +70,6 @@
 			par(new=F)  
     		}
     dev.off()
-    rm(ideogram)
 	}
 
 

Modified: pkg/patchworkCG/R/patchwork.CG.r
===================================================================
--- pkg/patchworkCG/R/patchwork.CG.r	2012-02-16 14:27:55 UTC (rev 96)
+++ pkg/patchworkCG/R/patchwork.CG.r	2012-02-16 15:28:12 UTC (rev 97)
@@ -1,4 +1,4 @@
-patchwork.CG <- function(path,name='CG_sample_',manual_file_input = FALSE,masterVarBeta=NULL,somaticCnvSegments=NULL,depthOfCoverage=NULL)
+patchwork.CG <- function(path=NULL,name='CG_sample_',manual_file_input = FALSE,masterVarBeta=NULL,somaticCnvSegments=NULL,depthOfCoverage=NULL)
 	{
 	
 	#------------------------------------------------#
@@ -134,6 +134,10 @@
 		}
 	else
 		{
+		if(length(path)==0)
+			{
+			stop("You must input the required files, either by the path parameter, manual_file_input parameter or individual pointer parameters to the files in question. See ?patchwork.CG")
+			}
 		mastervar_ = list.files(path=path,pattern="masterVar")
 		path_segm = paste(path,"/CNV",sep="")
 		segm_ = list.files(path=path_segm,pattern="somaticCnvSegmentsNondiploid")
@@ -238,7 +242,7 @@
 	mastervar$min = mastervar$tot_count - mastervar$max
 	mastervar$ratio = mastervar$tot_count / mean(mastervar$tot_count)
 		
-	segm = patchwork.AI(segm,mastervar)
+	#segm = patchwork.AI(segm,mastervar)
 	
 	segm$ai <- segm$snvs <- segm$ratio <- NA
 	
@@ -246,7 +250,10 @@
 	for (i in 1:nrow(segm))
 		{
 		#Calculate ratio between relcov and segment lengths
-		segm$ratio[i] = segm$relcov[i] / (sum(as.numeric(segm$relcov*(segm$end-segm$start))) / sum(as.numeric(segm$end - segm$start)))
+		#segm$ratio[i] = segm$relcov[i] / (sum(as.numeric(segm$relcov*(segm$end-segm$start))) / sum(as.numeric(segm$end - segm$start)))
+		#ix is the segment area from segm applied to the pieces from depcov on the correct chromosome.
+		ix <- depcov$chr==segm$chr[i] & (depcov$begin>=segm$start[i] & depcov$end<=segm$end[i])
+		segm$ratio[i] <- median(depcov$ratio[ix])
 		
 		#Index of correct snp positions to pull snp data from
 		#                right chromosome



More information about the Patchwork-commits mailing list