Repository 'pirna_pipeline'
hg clone https://toolshed.g2.bx.psu.edu/repos/romaingred/pirna_pipeline

Changeset 11:ee6b4b2072a9 (2017-10-13)
Previous changeset 10:42bc59c7db3a (2017-10-13) Next changeset 12:eec6ce306605 (2017-10-16)
Commit message:
Uploaded
modified:
bin/Rcall.pm
b
diff -r 42bc59c7db3a -r ee6b4b2072a9 bin/Rcall.pm
--- a/bin/Rcall.pm Fri Oct 13 04:20:17 2017 -0400
+++ b/bin/Rcall.pm Fri Oct 13 08:46:31 2017 -0400
[
@@ -49,9 +49,17 @@
   $R->send( 
   qq`library('Sushi')
   fai =read.table("$fai")
-  bgP = read.table("$bgP")
-  bgM = read.table("$bgM")
-  fun = function(chr,end) {
+  if ( file.info("$bgP")\$size !=0 )
+  {
+    bgP = read.table("$bgP")
+  } else { bgP = data.frame(factor(),integer()) }
+
+  if ( file.info("$bgM")\$size !=0 )
+  {
+    bgM = read.table("$bgM")
+  } else { bgM = data.frame(factor(),integer()) }
+
+  f_both = function(chr,end) {
     jpeg( paste0("$dir",as.character(chr),".png"), quality=100)
     par(mfrow=c(2,1),mar=c(1,10,1,3))
     plotBedgraph(bgP, chrom=chr,chromstart=0,chromend=end,transparency=.50,  color=SushiColors(2)(2)[1])
@@ -63,7 +71,34 @@
     mtext("Scaled Read Depth",side=2,line=4.5,cex=1,font=2)
     dev.off() 
   }
-  mapply( fun, fai\$V1, fai\$V2)`);
+
+  f_plus = function(chr,end) {
+    jpeg( paste0("$dir",as.character(chr),".png"), quality=100)
+    plotBedgraph(bgP, chrom=chr,chromstart=0,chromend=end,transparency=.50,  color=SushiColors(2)(2)[1])
+    labelgenome(chrom=chr,chromstart=0,chromend=end,n=3,scale="$sb", line=0,  chromline = 0.5,  scaleline = 0.5, scaleadjust =1.05, chromadjust = -0.4)
+    axis(side=2,las=2,tcl=.2)
+    mtext("Scaled Read Depth",side=2,line=4,cex=1,font=2)
+    dev.off()
+  }
+
+  f_minus = function(chr,end) {
+    jpeg( paste0("$dir",as.character(chr),".png"), quality=100)
+    plotBedgraph(bgM, chrom=chr,chromstart=0,chromend=end,transparency=.50, flip=TRUE, color=SushiColors(2)(2)[2])    
+    labelgenome(chrom=chr,chromstart=0,chromend=end,n=3,scale="$sb", line=0,  chromline = 0.5,  scaleline = 0.5, scaleadjust =1.05, chromadjust = -0.4)
+    axis(side=2,las=2,tcl=.2,at=pretty(par("yaxp")[c(1,2)]),labels=-1*pretty(par("yaxp")[c(1,2)]))
+    mtext("Scaled Read Depth",side=2,line=4.5,cex=1,font=2)
+    dev.off()
+  }
+
+  fai_b = fai[fai\$V1 %in% intersect(bgM\$V1,bgP\$V1), ]
+  mapply( f_both, fai_b\$V1, fai_b\$V2)
+
+  fai_p = fai[fai\$V1 %in% setdiff(bgP\$V1,bgM\$V1), ]
+  mapply( f_plus, fai_p\$V1, fai_p\$V2)
+
+  fai_m = fai[fai\$V1 %in% setdiff(bgM\$V1,bgP\$V1), ]
+  mapply( f_minus, fai_m\$V1, fai_m\$V2) `);
+
   $R->stopR();
 }