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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Feb 15 16:29:40 CET 2012


Author: sebastian_d
Date: 2012-02-15 16:29:39 +0100 (Wed, 15 Feb 2012)
New Revision: 93

Modified:
   pkg/patchwork/R/karyotype.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
Log:
Updated color gradient scales and method for patchwork and patchworkCG

Modified: pkg/patchwork/R/karyotype.r
===================================================================
--- pkg/patchwork/R/karyotype.r	2012-02-15 13:29:40 UTC (rev 92)
+++ pkg/patchwork/R/karyotype.r	2012-02-15 15:29:39 UTC (rev 93)
@@ -9,8 +9,8 @@
     	
     	data(ideogram,package="patchworkData")
     	
-		colors_p <- colorRampPalette(c("#6600FF","#9900CC"),space="rgb")
-    	colors_q <- colorRampPalette(c("#CC0099","#CC0000"),space="rgb")
+    colors_p <- colorRampPalette(c("#2754e8","#ad09e8"),space="rgb")
+    colors_q <- colorRampPalette(c("#c309e8","#e81e2c"),space="rgb")
 
     	layout(matrix(1:25,nrow=5,byrow=T), widths=1,heights=1)
     	
@@ -35,11 +35,17 @@
         	this <- ideogram[ideogram$c==c,]
         	ix <- chr==this$chr
         	ix[is.na(ix)]=FALSE
+            
+            ix_p = ix & (pos < this$start)
+            ix_q = ix & (pos > this$end)
+            col <- rep('#B0B0B070',length(chr))
 
-        	col <- rep('#B0B0B070',length(chr))
-        
-        	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='')
+            #loc = list of colors
+            loc_p=colors_p(ceiling(this$start/100))
+            loc_q=colors_q(ceiling((this$length - this$end)/100))
+
+            col[ix_p] = paste(loc_p[ceiling(pos[ix_p]/100)],'70',sep='')
+            col[ix_q] = paste(loc_q[ceiling((pos[ix_q]-this$end)/100)],'70',sep='')
  
         	plot(c(int[!ix],int[ix]),c(ai[!ix],ai[ix]),
         		pch=16,

Modified: pkg/patchwork/R/karyotype_chroms.r
===================================================================
--- pkg/patchwork/R/karyotype_chroms.r	2012-02-15 13:29:40 UTC (rev 92)
+++ pkg/patchwork/R/karyotype_chroms.r	2012-02-15 15:29:39 UTC (rev 93)
@@ -10,8 +10,8 @@
     
     #create a color ramp palette to segue the color scheme for plot.
     
-    colors_p <- colorRampPalette(c("#6600FF","#9900CC"),space="rgb")
-    colors_q <- colorRampPalette(c("#CC0099","#CC0000"),space="rgb")
+  colors_p <- colorRampPalette(c("#2754e8","#ad09e8"),space="rgb")
+    colors_q <- colorRampPalette(c("#c309e8","#e81e2c"),space="rgb")
 
     ai[is.na(ai)]=0
     aix=ai!=0
@@ -38,10 +38,17 @@
         	mar.default <- c(5,4,4,2) + 0.1
 			par(mar = mar.default + c(0, 4, 0, 0)) 
         
-       	 	ix <- chr==this$chr
-        	col <- rep('#B0B0B070',length(chr))       
-        	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='') 
+            ix <- chr==this$chr
+            ix_p = ix & (pos < this$start)
+            ix_q = ix & (pos > this$end)
+            col <- rep('#B0B0B070',length(chr))
+
+            #loc = list of colors
+            loc_p=colors_p(ceiling(this$start/100))
+            loc_q=colors_q(ceiling((this$length - this$end)/100))
+
+            col[ix_p] = paste(loc_p[ceiling(pos[ix_p]/100)],'70',sep='')
+            col[ix_q] = paste(loc_q[ceiling((pos[ix_q]-this$end)/100)],'70',sep='')
         
         	plot(c(int[!ix],int[ix]),c(ai[!ix],ai[ix]),
             	pch=16,

Modified: pkg/patchwork/R/karyotype_chromsCN.r
===================================================================
--- pkg/patchwork/R/karyotype_chromsCN.r	2012-02-15 13:29:40 UTC (rev 92)
+++ pkg/patchwork/R/karyotype_chromsCN.r	2012-02-15 15:29:39 UTC (rev 93)
@@ -9,8 +9,8 @@
     
     data(ideogram,package="patchworkData")
     
-    colors_p <- colorRampPalette(c("#6600FF","#9900CC"),space="rgb")
-    colors_q <- colorRampPalette(c("#CC0099","#CC0000"),space="rgb")
+    colors_p <- colorRampPalette(c("#2754e8","#ad09e8"),space="rgb")
+    colors_q <- colorRampPalette(c("#c309e8","#e81e2c"),space="rgb")
 
     ai[is.na(ai)]=0
     aix=ai!=0
@@ -39,10 +39,17 @@
         	mar.default <- c(5,4,4,2) + 0.1
 			par(mar = mar.default + c(0, 4, 0, 0)) 
         	
-        	ix <- chr==this$chr
-        	col <- rep('#B0B0B070',length(chr))       
-        	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='') 
+            ix <- chr==this$chr
+            ix_p = ix & (pos < this$start)
+            ix_q = ix & (pos > this$end)
+            col <- rep('#B0B0B070',length(chr))
+
+            #loc = list of colors
+            loc_p=colors_p(ceiling(this$start/100))
+            loc_q=colors_q(ceiling((this$length - this$end)/100))
+
+            col[ix_p] = paste(loc_p[ceiling(pos[ix_p]/100)],'70',sep='')
+            col[ix_q] = paste(loc_q[ceiling((pos[ix_q]-this$end)/100)],'70',sep='')
         
         	plot(c(int[!ix],int[ix]),c(ai[!ix],ai[ix]),
             	pch=16,

Modified: pkg/patchworkCG/R/CG_KaCh.r
===================================================================
--- pkg/patchworkCG/R/CG_KaCh.r	2012-02-15 13:29:40 UTC (rev 92)
+++ pkg/patchworkCG/R/CG_KaCh.r	2012-02-15 15:29:39 UTC (rev 93)
@@ -10,9 +10,12 @@
     
     #create a color ramp palette to segue the color scheme for plot.
     
-    colors_p <- colorRampPalette(c("#6600FF","#9900CC"),space="rgb")
-    colors_q <- colorRampPalette(c("#CC0099","#CC0000"),space="rgb")
+    #colors_p <- colorRampPalette(c("#2754e8","#ad09e8"),space="rgb")
+    #colors_q <- colorRampPalette(c("#c309e8","#e81e2c"),space="rgb")
 
+    colors_p <- colorRampPalette(c("#2754e8","#ad09e8"),space="rgb")
+    colors_q <- colorRampPalette(c("#c309e8","#e81e2c"),space="rgb")
+
     ai[is.na(ai)]=0
     aix=ai!=0
     chr=chr[aix]
@@ -29,7 +32,7 @@
     size[length>5000000]=4
     size[length>10000000]=5
     size[length>20000000]=6
-       
+
     for (c in 1:24) 
     	{
         this <- ideogram[ideogram$c==c,]
@@ -41,9 +44,19 @@
 			par(mar = mar.default + c(0, 4, 0, 0)) 
         
        	 	ix <- chr==this$chr
-        	col <- rep('#B0B0B070',length(chr))       
-        	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='') 
+            ix_p = ix & (pos < this$start)
+            ix_q = ix & (pos > this$end)
+            col <- rep('#B0B0B070',length(chr))
+
+            #loc = list of colors
+            loc_p=colors_p(ceiling(this$start/100))
+            loc_q=colors_q(ceiling((this$length - this$end)/100))
+
+            col[ix_p] = paste(loc_p[ceiling(pos[ix_p]/100)],'70',sep='')
+            col[ix_q] = paste(loc_q[ceiling((pos[ix_q]-this$end)/100)],'70',sep='')
+                   
+        	#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='') 
         
         	plot(c(int[!ix],int[ix]),c(ai[!ix],ai[ix]),
             	pch=16,

Modified: pkg/patchworkCG/R/CG_KaChCN.r
===================================================================
--- pkg/patchworkCG/R/CG_KaChCN.r	2012-02-15 13:29:40 UTC (rev 92)
+++ pkg/patchworkCG/R/CG_KaChCN.r	2012-02-15 15:29:39 UTC (rev 93)
@@ -7,10 +7,12 @@
     #load(paste(packagepath,"/data/ideogram.RData",sep=""))
     
     data(ideogram,package="patchworkCG")
-    
-    colors_p <- colorRampPalette(c("#6600FF","#9900CC"),space="rgb")
-    colors_q <- colorRampPalette(c("#CC0099","#CC0000"),space="rgb")
 
+    #Origional
+    colors_p <- colorRampPalette(c("#2754e8","#ad09e8"),space="rgb")
+    colors_q <- colorRampPalette(c("#c309e8","#e81e2c"),space="rgb")
+    #colors_chrom = colorRampPalette(c("#6600FF","#CC0000"),space="rgb")
+
     ai[is.na(ai)]=0
     aix=ai!=0
     chr=chr[aix]
@@ -40,10 +42,23 @@
         	mar.default <- c(5,4,4,2) + 0.1
 			par(mar = mar.default + c(0, 4, 0, 0)) 
         	
-        	ix <- chr==this$chr
-        	col <- rep('#B0B0B070',length(chr))       
-        	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='') 
+            #Create a list of colors length of chromosome.
+            #Assign color by middle of segment. (pos as an int).
+
+            ix_p = ix & (pos < this$start)
+            ix_q = ix & (pos > this$end)
+            col <- rep('#B0B0B070',length(chr))
+
+            #loc = list of colors
+            loc_p=colors_p(ceiling(this$start/100))
+            loc_q=colors_q(ceiling((this$length - this$end)/100))
+
+            col[ix_p] = paste(loc_p[ceiling(pos[ix_p]/100)],'70',sep='')
+            col[ix_q] = paste(loc_q[ceiling((pos[ix_q]-this$end)/100)],'70',sep='')
+
+            #Origional       
+        	#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='') 
         
         	plot(c(int[!ix],int[ix]),c(ai[!ix],ai[ix]),
             	pch=16,

Modified: pkg/patchworkCG/R/CG_karyotype.r
===================================================================
--- pkg/patchworkCG/R/CG_karyotype.r	2012-02-15 13:29:40 UTC (rev 92)
+++ pkg/patchworkCG/R/CG_karyotype.r	2012-02-15 15:29:39 UTC (rev 93)
@@ -9,9 +9,12 @@
     	
     	data(ideogram,package="patchworkCG")
     	
-		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")
 
+        colors_p <- colorRampPalette(c("#2754e8","#ad09e8"),space="rgb")
+        colors_q <- colorRampPalette(c("#c309e8","#e81e2c"),space="rgb")
+
     	layout(matrix(1:25,nrow=5,byrow=T), widths=1,heights=1)
     	
     	aix=ai!=0
@@ -38,10 +41,16 @@
         	ix <- chr==this$chr
         	ix[is.na(ix)]=FALSE
 
-        	col <- rep('#B0B0B070',length(chr))
-        
-        	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='')
+            ix_p = ix & (pos < this$start)
+            ix_q = ix & (pos > this$end)
+            col <- rep('#B0B0B070',length(chr))
+
+            #loc = list of colors
+            loc_p=colors_p(ceiling(this$start/100))
+            loc_q=colors_q(ceiling((this$length - this$end)/100))
+
+            col[ix_p] = paste(loc_p[ceiling(pos[ix_p]/100)],'70',sep='')
+            col[ix_q] = paste(loc_q[ceiling((pos[ix_q]-this$end)/100)],'70',sep='')
  
         	plot(c(int[!ix],int[ix]),c(ai[!ix],ai[ix]),
         		pch=16,



More information about the Patchwork-commits mailing list