Hello!

To see the file structure, click on "tree".

Note that updates take place every 10 minutes, commits may not be seen immediately.
View Ontology Changes:
authormiles <miles@localhost>
Fri, 5 Apr 2013 00:09:45 +0000 (00:09 +0000)
committermiles <miles@localhost>
Fri, 5 Apr 2013 00:09:45 +0000 (00:09 +0000)
        -downloaded tab delimited file now has 0,0 field
        -ontologies can now be dynamically viewed or ignored

svn path=/; revision=458

Personnel/miles/Web Page/heatMap.php
Personnel/miles/Web Page/infoChoice.php
Personnel/miles/Web Page/viewOntology.php

index 1ad201b27e576b1daf176e43f1234e65d81439a8..33f1c887a72de7109c3167d7a2b569f70c2ad273 100644 (file)
@@ -155,7 +155,6 @@ for(var i=0; i<rareHeatMapData.length; i++) {
 var rawSpecies = "<?php echo implode(",",$includedSpecies); ?>";
 var allSpecies = rawSpecies.split(",");
 var speciesCount = allSpecies.length;
-alert(speciesCount*25 + 50);
 var rawClusterIDs = "<?php echo implode(",", $allClusterIDs); ?>";
 var allClusterIDs = rawClusterIDs.split(",");
 var maxCount = <?php echo $maxCount; ?>;
index 64362007a397845d722db976e5cfdec3244843d1..b51748ccda3c1e4f5ec9ab78e1c56a4e1037926c 100644 (file)
@@ -190,10 +190,6 @@ function process() {
   }
   document.viewOntology.ontologies.value = ontologies;
 }
-
-
-
-//2533488419
 </script>
 
 </body>
index 16172d0c6cf61577b016c8a5cb65a058c3d6d023..12ef2c0e21cc8a4a20557193d2e2b6fbeec89ce7 100644 (file)
@@ -1,6 +1,25 @@
 <!DOCTYPE html>
 <html>
 <body>
+
+<div id="Legend" style="float: right; height: 200px; width: 400px;">
+Note: The colors have no relevance to the data, they simply serve to distinguish rows visually. <br> <br>
+      The numbers printed inside each cell represent the confidence rating of the ontological assignment; a higher number indicates more confidence.<br><br>
+      An "A" after the term name signifies that it relates to anatomy, a "G" signifies that it relates to growth, development, or structure <br><br>
+      Click on a gene or term for detailed annotations from Plant Ontology. <br><br>
+      Select or deselect terms to be downloaded using the boxes underneath the term names.
+
+<form name="downloadImage" action="VOdownload.php" method="post">
+<input type="button" value="Download Tab Delimited File" onClick="downloadTabDem()"/>
+<input type="hidden" value="" name="genes">
+<input type="hidden" value="" name="terms">
+<input type="hidden" value="" name="cellData"/>
+</form>
+
+
+
+
+
 <?php
 //select term_id from gene_product inner join association on association.gene_product_id=gene_product.id where gene_product.full_name='AT1G32960';
 
@@ -12,11 +31,28 @@ if($_POST["ontologies"] != "null") {
 
 $ontologies = explode(",",$_POST["ontologies"]);
 
+
+      echo "<form name=\"redraw\">\n";
+      echo "<p> Include Ontologies: <br>";
+
+
   for($i = 0; $i < sizeof($ontologies); $i++) {
-    if($ontologies[$i] == "Anatomy") $ontologies[$i] = "plant_anatomy";
+      echo "<input type=\"checkbox\" name=\"" . $ontologies[$i] . "\" ";
+
+    //NOTE THIS is the list of ontologies that must be kept updated
+    if($ontologies[$i] == "Anatomy") {
+      $ontologies[$i] = "plant_anatomy";
+      }
     if($ontologies[$i] == "Growth") $ontologies[$i] = "plant_structure_development_stage";
 
+
+      echo "value=\"" . $ontologies[$i] . "\">";
+      echo $ontologies[$i] . " <br>";
   }
+      echo "<input type=\"button\" name=\"Redraw\" value=\"Redraw Ontologies\" onClick=\"redrawOntologies()\">";
+      echo "</form>";
+      echo "<br> <br>\n";
+      echo "</div>";
 
   //get rid of any of those messy .somethings after the gene ID
   $tmp = explode(",",$_POST['param']);
@@ -84,10 +120,8 @@ $ontologies = explode(",",$_POST["ontologies"]);
   $i = 0;
   for($row = mysql_fetch_row($results); $row != null; $row = mysql_fetch_row($results)) {
     $add = "";
-    if($row[1]=="plant_anatomy") $add= " (A)";
-    if($row[1]=="plant_structure_development_stage") $add= " (G)";
     $terms[$i][0] = $row[0];
-    $terms[$i][1] = $add;
+    $terms[$i][1] = $row[1];
     $i++;
     }
 
@@ -137,7 +171,7 @@ $ontologies = explode(",",$_POST["ontologies"]);
       }
     $printTerms;
     for($i = 0; $i < sizeof($terms); $i ++) {
-      $printTerms[$i] = $terms[$i][0] . $terms[$i][1];
+      $printTerms[$i] = implode(";",$terms[$i]);
     }
   }
 
@@ -151,23 +185,6 @@ echo "No ontologies were selected!";
 
 }
 ?>
-<div id="Legend" style="float: right; height: 200px; width: 400px;">
-Note: The colors have no relevance to the data, they simply serve to distinguish rows visually. <br> <br>
-      The numbers printed inside each cell represent the confidence rating of the ontological assignment; a higher number indicates more confidence.<br><br>
-      An "A" after the term name signifies that it relates to anatomy, a "G" signifies that it relates to growth, development, or structure <br><br>
-      Click on a gene or term for detailed annotations from Plant Ontology. <br><br>
-      Select or deselect terms to be downloaded using the boxes underneath the term names.
-
-<form name="downloadImage" action="VOdownload.php" method="post">
-<input type="button" value="Download Tab Delimited File" onClick="downloadTabDem()"/>
-<input type="hidden" value="" name="genes">
-<input type="hidden" value="" name="terms">
-<input type="hidden" value="" name="cellData"/>
-</form>
-
-
-
-</div>
 
 
 <div id="canvasDiv" style="overflow: hidden; float: left; height: <?php echo $height ?>px; width: <?php echo $width ?>px;">
@@ -213,10 +230,6 @@ Your browser does not support the canvas element.
 
 
 
-
-
-
-
 <script type="text/javascript">
 
 var rawCellData = "<?php echo implode(".",$finalCellData); ?>";
@@ -238,8 +251,16 @@ var genes = rawGenes.split(",");
 var geneCount = genes.length;
 
 var rawTerms = "<?php echo implode(",",$printTerms) ?>";
-var terms = rawTerms.split(",");
+var rareTerms = rawTerms.split(",");
+var terms = new Array(rareTerms.length);
+for(var i=0;i<rareTerms.length;i++) {
+  terms[i] = new Array(2);
+  var temp = rareTerms[i].split(";");
+  terms[i][0] = temp[0];
+  terms[i][1] = temp[1];
+}
 var termCount = terms.length;
+
 var termColors = new Array(terms.length);
 var checkBoxes = new Array(terms.length);
 
@@ -250,8 +271,41 @@ var startTerm = 0;
 //to find out what our top offset should be:
 var maxTermSize = 0;
 for(var i = 0; i < terms.length; i ++) {
-  if(terms[i].length > maxTermSize) maxTermSize = terms[i].length;
+  if(terms[i][0].length > maxTermSize) maxTermSize = terms[i][0].length;
 }
+//to create a method for coloring each ontology differently
+var ontCount;
+var ontologies = new Array();
+ontologies[0] = terms[0][1];
+var j = 1;
+for(var i = 0; i < terms.length; i ++) {
+  var newOnt = !isIn(terms[i][1],ontologies);
+  if(newOnt) {
+    ontologies[j] = terms[i][1];
+    j++;
+  }
+}
+var legalOntologies = ontologies;
+
+//find whether an element is already included in an array
+function isIn(element, array) {
+  for(var i = 0; i < array.length; i ++) {
+    if(element == array[i]) {
+      return true;
+    }
+  }
+  return false;
+}
+
+function findIndex(element,array) {
+  for(var i = 0; i < array.length; i ++) {
+    if(element == array[i]) {
+      return i;
+    }
+  }
+  return -1;
+}
+
 
 var cellSize = 15; //NOTE if this is changed, the size of the topScrollDiv must also be changed by the same factor!
 
@@ -261,10 +315,11 @@ var topOffset = maxTermSize*5;//NOTE the *7 is just my own approximation: charac
 var leftOffset = 85;
 
 var maxRows = Math.floor((<?php echo $height ?>-topOffset-15)/cellSize);
-var maxCols = Math.floor((<?php echo $width ?>-leftOffset-30)/cellSize);
+var maxCols = Math.floor((<?php echo $width ?>-leftOffset-300)/cellSize); //NOTE the -300 accounts for the key
 
 var borderWidth = 1;
 
+// This is in order to set the random coloring of each column, and have it remain constant throughout each viewing session
 for(var i = 0; i < terms.length; i ++) {
     
     var blue = Math.floor(Math.random() * 200) + 55;
@@ -282,11 +337,38 @@ for(var i = 0; i < terms.length; i ++) {
 }
 
 canvas.addEventListener('mouseup', showInfo, false);
+
+function drawKey() {
+  ontMap.fillStyle="#000000";
+  ontMap.fillText("Ontology Color Key:",<?php echo $width ?>-250,topOffset+cellSize);
+  for(var i=0;i<legalOntologies.length;i++) {
+    // 0-255, 0-175, 255
+    var redfrequency = Math.floor((255/legalOntologies.length) * (legalOntologies.length-i));
+    var greenfrequency = Math.floor((1-redfrequency/255)*175);
+
+    var bluecolor = "ff";
+    var redcolor = redfrequency.toString(16);
+    var greencolor = greenfrequency.toString(16);
+    if(redcolor.length < 2) {
+      redcolor = "0" + redcolor;
+      }
+    if(greencolor.length < 2) {
+      bluecolor = "0" + bluecolor;
+    }
+    var color = "#" + redcolor + greencolor + bluecolor;
+    ontMap.fillStyle = color;
+    ontMap.fillText(legalOntologies[i],<?php echo $width ?>-250,topOffset+cellSize*(2+i))
+  }
+
+
+
+
+}
+var tempTerms = new Array();
 function drawTerms(startTerm) {
 
 
   //black for text
-  ontMap.fillStyle = "#000000";
 
   //rotating the canvas for labeling the terms
   ontMap.rotate(-90*Math.PI/180);
@@ -294,12 +376,36 @@ function drawTerms(startTerm) {
 
   //labeling the terms
   var translated = 0;
-  for (var s=startTerm; (s<termCount) && (s<=startTerm+maxCols); s++) {
-      term=terms[s];
-      finalTerm = term.replace("_", " ");
-      ontMap.fillText(finalTerm,4, leftOffset + 15);
-      ontMap.translate(0,cellSize);
-      translated = translated + cellSize;
+  var t=startTerm
+  var i=0;
+  for (var j=startTerm; (j<termCount) && (t<=startTerm+maxCols); j++) {
+      if(isIn(terms[j][1],legalOntologies)) {
+       tempTerms[i] = terms[j];
+       i++
+       term=terms[j][0];
+       finalTerm = term.replace("_", " ");
+
+       // 0-255, 0-175, 255
+       var redfrequency = Math.floor((255/legalOntologies.length) * (legalOntologies.length-findIndex(terms[j][1],legalOntologies)));
+       var greenfrequency = Math.floor((1-redfrequency/255)*175);
+
+       var bluecolor = "ff";
+       var redcolor = redfrequency.toString(16);
+       var greencolor = greenfrequency.toString(16);
+       if(redcolor.length < 2) {
+         redcolor = "0" + redcolor;
+         }
+       if(greencolor.length < 2) {
+         bluecolor = "0" + bluecolor;
+       }
+       var color = "#" + redcolor + greencolor + bluecolor;
+       ontMap.fillStyle = color;
+
+       ontMap.fillText(finalTerm,4, leftOffset + 15);
+       ontMap.translate(0,cellSize);
+       translated = translated + cellSize;
+       t++;
+      }
     }
   //resetting the canvas to start position
   ontMap.translate(0,-translated);
@@ -330,36 +436,41 @@ function drawMap(init) {
     startXCell = Math.floor(scrolledLeft/cellSize);
     startYCell = Math.floor(scrolledTop/cellSize);
     ontMap.strokeStyle="#0000FF";
-    for(var t=startXCell; (t<termCount) && ((t-startXCell)<=maxCols); t++) {
-      var xCoord = leftOffset+(t-startXCell)*cellSize+5;
-
-      var color = termColors[t];
-      ontMap.fillStyle=color;
-      ontMap.fillRect(xCoord,topOffset-(cellSize+10),cellSize,cellSize);
-      ontMap.fillStyle="#000000";
-      if(checkBoxes[t]) {
-       ontMap.font="14px Arial";
-       ontMap.fillText("X",xCoord+3,topOffset-(cellSize*2+3));
-       ontMap.font="10px Arial";
-      }
-      ontMap.strokeRect(xCoord,topOffset-(cellSize*3),cellSize,cellSize);
+    var t=startXCell;
+    for(var j=startXCell; (j<termCount) && ((t-startXCell)<=maxCols); j++) {
+      if(isIn(terms[j][1],legalOntologies)) {
+       var xCoord = leftOffset+(t-startXCell)*cellSize+5;
+
+       var color = termColors[j];
+       ontMap.fillStyle=color;
+       ontMap.fillRect(xCoord,topOffset-(cellSize+10),cellSize,cellSize);
+       ontMap.fillStyle="#000000";
+       if(checkBoxes[j]) {
+         ontMap.font="14px Arial";
+         ontMap.fillText("X",xCoord+3,topOffset-(cellSize*2+3));
+         ontMap.font="10px Arial";
+       }
+       ontMap.strokeRect(xCoord,topOffset-(cellSize*3),cellSize,cellSize);
 
-      for(var g=startYCell; (g<geneCount) && ((g-startYCell)<maxRows); g++) {
+       for(var g=startYCell; (g<geneCount) && ((g-startYCell)<maxRows); g++) {
 
-       if(cellData[g][t][0] == 0) ontMap.fillStyle= "#FFFFFF";
-       else ontMap.fillStyle=color;
+         if(cellData[g][j][0] == 0) ontMap.fillStyle= "#FFFFFF";
+         else ontMap.fillStyle=color;
 
-       var yCoord = topOffset+(g-startYCell)*cellSize;
+         var yCoord = topOffset+(g-startYCell)*cellSize;
 
-       ontMap.fillRect(xCoord, yCoord, cellSize, cellSize);
-       if(cellData[g][t][0] != 0) {
-         ontMap.fillStyle="#000000";
-         ontMap.fillText(cellData[g][t][1],xCoord,yCoord+cellSize);
+         ontMap.fillRect(xCoord, yCoord, cellSize, cellSize);
+         if(cellData[g][j][0] != 0) {
+           ontMap.fillStyle="#000000";
+           ontMap.fillText(cellData[g][j][1],xCoord,yCoord+cellSize);
+         }
        }
+       t++;
       }
     }
     drawTerms(startXCell);
     drawGenes(startYCell);
+    drawKey();
   }
 }
 
@@ -378,12 +489,14 @@ function showInfo(event) {
   }
   if((y<(topOffset-cellSize*3)) && (x>leftOffset)) { //for getting terms
     var index = Math.floor((x-leftOffset)/cellSize) + Math.floor(scrolledLeft/cellSize);
-    var term = terms[index].split("-")[0];
+    var term = tempTerms[index][0].split("-")[0];
     getTermInfo(term);
   }
   if(y<(topOffset-cellSize*2) && y>(topOffset-cellSize*3) && x>leftOffset) { //for checkBoxes
     var index = Math.floor((x-leftOffset-7)/cellSize) + Math.floor(scrolledLeft/cellSize); //NOTE the -7 is to account for funky mouse mapping.
-    checkBoxes[index] = !checkBoxes[index];
+    var term=tempTerms[index];
+    var chIndex = findIndex(term,terms);
+    checkBoxes[chIndex] = !checkBoxes[chIndex];
     drawMap(true);
   }
 //   if((y>topOffset) && ((y+scrolledTop)<(topOffset + cellSize*clusterCount)) && (x>leftOffset) && ((x+scrolledLeft)<leftOffset + speciesCount*cellSize)) {
@@ -411,7 +524,6 @@ function downloadTabDem() {
     if(checkBoxes[i]) size++;
   }
   if(size == 0) {
-    alert ("No terms were selected!");
     return;
   }
 
@@ -434,7 +546,7 @@ function downloadTabDem() {
   j = 0;
   for(var i = 0; i < terms.length; i ++) {
     if(checkBoxes[i]) {
-      sendTerms[j]=terms[i];
+      sendTerms[j]=terms[i][0];
       j++;
     }
   }
@@ -446,6 +558,21 @@ function downloadTabDem() {
   document.downloadImage.submit();
 }
 
+function redrawOntologies() {
+  var cb = document.getElementsByTagName('input');
+  var j=0;
+  legalOntologies = new Array();
+  for (var i=0; i<cb.length; i++) {
+    if (cb[i].getAttribute('type') == "checkbox") {
+      if (cb[i].checked==true) {
+       legalOntologies[j] = cb[i].value;
+       j++;
+      }
+    }
+  }
+  drawMap(true);
+}
+
 </script>
 
 </body>