diff ChipSeqRatioAnalysis.R @ 5:378565f5a875 draft

Uploaded
author petr-novak
date Fri, 22 Nov 2019 07:56:48 -0500
parents e320ef2d105a
children f224513123a1
line wrap: on
line diff
--- a/ChipSeqRatioAnalysis.R	Wed Sep 18 06:30:04 2019 -0400
+++ b/ChipSeqRatioAnalysis.R	Fri Nov 22 07:56:48 2019 -0500
@@ -3,82 +3,28 @@
 library(base64enc, quietly=T)
 
 
-htmlheader="
-	 <html xmlns:mml=\"http://www.w3.org/1998/Math/MathML\">
+htmlheader=
+"	<html xmlns:mml=\"http://www.w3.org/1998/Math/MathML\">
   <head>
   <title> ChIP-Seq Mapper Output </title>
-  <style>
-  <!--
-  table { background:#FFFFFF;
-  border:1px solid gray;
-  border-collapse:collapse;
-  color:#fff;
-  font:normal 13px verdana, arial, helvetica, sans-serif;
-    width: 100%;
+ <style>
+html,body{font-family:Verdana,sans-serif;font-size:15px;line-height:1.5}
 
-  }
-  caption { border:1px solid #5C443A;
-  color:#5C443A;
-  font-weight:bold;
-  font-size:20pt
-  padding:6px 4px 8px 0px;
-  text-align:center;
-  
-  }
-  td, th { color:#363636;
-  padding:.4em;
-  }
-  tr { border:1px dotted gray;
-  }
-  thead th, tfoot th { background:#5C443A;
-  color:#FFFFFF;
-  padding:3px 10px 3px 10px;
-  text-align:left;
-  text-transform:uppercase;
-  }
-  tbody td a { color:#3636FF;
-  text-decoration:underline;
-  }
-  tbody td a:visited { color:gray;
-  text-decoration:line-through;
-  }
-  tbody td a:hover { text-decoration:underline;
-  }
-  tbody th a { color:#3636FF;
-  font-weight:normal;
-  text-decoration:none;
-  }
-  tbody th a:hover { color:#363636;
-  }
-  tbody td+td+td+td a { background-image:url('bullet_blue.png');
-  background-position:left center;
-  background-repeat:no-repeat;
-  color:#FFFFFF;
-  padding-left:15px;
-  }
-  tbody td+td+td+td a:visited { background-image:url('bullet_white.png');
-  background-position:left center;
-  background-repeat:no-repeat;
-  }
-  tbody th, tbody td { text-align:left;
-  vertical-align:top;
-  }
-  tfoot td { background:#5C443A;
-  color:#FFFFFF;
-  padding-top:3px;
-  }
-  .odd { background:#fff;
-  }
-  tbody tr:hover { background:#EEEEEE;
-  border:1px solid #03476F;
-  color:#000000;
-  }
-  -->
-  </style>
+table {
+  border-collapse: collapse;
+  border: 1px solid black;
+  width: 1000pt
+}
+table, th, td {
+  border: 1px solid black;
+}
+</style>
   
   </head>
-  
-  "
+
+
+
+"
 
 
                                         #arguments
@@ -97,21 +43,20 @@
 df$"Ratio Chip/(Chip+Input)"=df$Chip_Hits/(df$Chip_Hits + df$Input_Hits)
 df$"Normalized ratio Chip/(Chip+Input)"=(df$Chip_Hits/chipN)/((df$Input_Hits/inputN)+(df$Chip_Hits/chipN))
 
-outputTable = df[df$"Normalized ratio Chip/(Chip+Input)" > threshld,]
-outputTable = outputTable[!is.na(outputTable$Cluster),]
+outputTable = df[df$"Normalized ratio Chip/(Chip+Input)" > threshld,
+                 ]
+outputTable = outputTable[!is.na(outputTable$Cluster),
+                          c('Cluster',	'Chip_Hits',	'Input_Hits',
+                            'Normalized ratio Chip/Input','Normalized ratio Chip/(Chip+Input)')]
 save.image("tmp.RData")                                        #Plot creation
 pngfile <- tempfile()
 png(pngfile, width = 1000, height = 1200, pointsize=20)
-par(mfrow=c(3,1))
+par(mfrow=c(2,1))
 lims=range(df$"Normalized ratio Chip/Input"[df$"Normalized ratio Chip/Input">0], finite = TRUE)
 suppressWarnings(plot(df$Cluster,df$"Normalized ratio Chip/Input", log="y", xlab="Cluster Nr.", ylab="Normalized ChiP/Seq ratio", pch=20, ylim=lims))
 abline(h=1,col='#00000080', lwd = 2)
 abline(h=2,col='#FF000080', lwd = 2)
 
-lims=range(df$"Normalized ratio Chip/Input", finite = TRUE)
-suppressWarnings(plot(df$Cluster,df$"Normalized ratio Chip/Input", xlab="Cluster Nr.", ylab="Normalize ChiP/Seq ratio", pch=20, ylim=lims))
-abline(h=1,col='#00000080', lwd = 2)
-abline(h=2,col='#FF000080', lwd = 2)
 
 suppressWarnings(plot(df$Cluster,df$"Normalized ratio Chip/(Chip+Input)", xlab="Cluster Nr.", ylab="Normalized Chip/(Chip+Input)", pch=20))
 abline(h=0.5,col='#00000080', lwd = 2)
@@ -133,7 +78,8 @@
 
 HTML(graph, file=filename)
 if (nrow(outputTable)>0){
-    HTML(outputTable, file=filename, classtable = "dataframe", row.names=FALSE, Align='left')
+  HTML(outputTable, file=filename, classtable = "dataframe",
+       row.names=FALSE, align='left', caption="Clusters with Normalized ChIP/Input ratio > 2", captionalign="top")
 }
 HTMLEndFile(filename) 
 file.rename(from=filename, to=HTMLfile)