From: elserj Date: Wed, 15 Aug 2012 17:40:48 +0000 (+0000) Subject: Add back code to use the heatchart.java method X-Git-Url: http://gitweb.planteome.org/?a=commitdiff_plain;h=acc0478331acd2b5de2ba46bdb3eb19245e810c0;p=old-jaiswallab-svn%2F.git Add back code to use the heatchart.java method svn path=/; revision=375 --- diff --git a/Personnel/miles/2/src/Heatmap.java b/Personnel/miles/2/src/Heatmap.java index f747003..df9a90d 100644 --- a/Personnel/miles/2/src/Heatmap.java +++ b/Personnel/miles/2/src/Heatmap.java @@ -55,7 +55,7 @@ public class Heatmap { private static void generateHeatMapImage(Species[] species) { - File output = new File("heatMap"); + File output = new File("heatMap.gif"); int heatMapHeight = 25*allClusterIDs.length; int heatMapWidth = 25*species.length; @@ -91,7 +91,8 @@ public class Heatmap { chartGraphics.drawString("Heat Map", 25, 25); for (int c = 0; c < allClusterIDs.length; c ++) { - String clusterID = Integer.toString(allClusterIDs[c]); + String clusterID = Integer.toString(allClusterIDs[c] + 1); + System.out.println(allClusterIDs[c]); chartGraphics.drawString(clusterID, 5, (speciesNameLength + 15 + c*25)); } @@ -117,6 +118,54 @@ public class Heatmap { } catch (IOException e) { System.out.println("Unable to write Heat Map Image"); } + + /* + double[][] heatMapVals = new double[allClusterIDs.length][species.length]; + for (int s = 0; s < species.length; s ++) { + for (int c = 0; c < allClusterIDs.length; c ++) { + int frequency = species[s].findClusterFrequency(allClusterIDs[c]); + // -1 means that species contains no genes in the specified cluster, but can't have negative color + // ensure that frequency is never negative + if (frequency == -1) { + frequency = 0; + } + heatMapVals[c][s] = frequency; + } + } + String[] names = new String[species.length]; + for (int s = 0; s < species.length; s ++) { + names[s] = species[s].name; + } + HeatChart heatChart = new HeatChart(heatMapVals); + Color axisColor = new Color(0, 0, 0); + Color background = new Color(255, 255, 255); + Dimension cellSize = new Dimension(20, 20); + heatChart.setAxisColour(axisColor); + heatChart.setBackgroundColour(background); + heatChart.setCellSize(cellSize); + heatChart.setXValues(names); + heatChart.setTitle("Heat Map"); + heatChart.setYAxisLabel("Cluster ID"); + heatChart.setXAxisLabel("Species"); + heatChart.setHighValueColour(Color.red); + heatChart.setLowValueColour(Color.blue); + heatChart.setAxisThickness(1); + heatChart.setColourScale(0.8); + heatChart.setHighValueColour(Color.red); + heatChart.setLowValueColour(Color.blue); + heatChart.setAxisThickness(1); + heatChart.setColourScale(0.8); + + Image heatMap = heatChart.getChartImage(); + + File output = new File("heatMap.gif"); + + try { + ImageIO.write((RenderedImage) heatMap, "gif", output); + } catch (IOException e) { + System.out.println("Unable to write image to file"); + } + */ }