Changeset 213


Ignore:
Timestamp:
Dec 7, 2006, 11:18:50 AM (15 years ago)
Author:
Johan Enell
Message:

Fixes #28

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/se/lu/onk/ZTest/src/ztest/Start.java

    r207 r213  
    2323 */
    2424package ztest;
     25
     26import org.jfree.chart.ChartUtilities;
     27import org.jfree.chart.JFreeChart;
     28import org.jfree.chart.axis.LogarithmicAxis;
     29import org.jfree.chart.axis.NumberAxis;
     30import org.jfree.chart.plot.SeriesRenderingOrder;
     31import org.jfree.chart.plot.XYPlot;
     32import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
     33import org.jfree.data.RangeType;
     34import org.jfree.data.xy.XYSeries;
     35import org.jfree.data.xy.XYSeriesCollection;
    2536
    2637import java.io.File;
     
    101112      });
    102113      print(bfss);
     114     
    103115    }
    104116    catch (FileNotFoundException e)
     
    125137    try
    126138    {
     139      XYSeries oSeries = new XYSeries("Observed");
     140      XYSeries eSeries = new XYSeries("Expected");
     141     
    127142      PrintWriter html = new PrintWriter(new File("index.html"));
    128143      PrintWriter tab = new PrintWriter(new File("result.tsv"));
     
    137152      html.println("</head>");
    138153      html.println("<table>");
    139       html.println("<tr><th>Reporter</th>" +
    140           "<th>Gene symbol</th>" +
    141           "<th>Locus Link</th>" +
    142           "<th>Average M</th>" +
    143           "<th>P</th>" +
    144           "<th>Number of values</th>" +
    145           "<th>Rank</th>" +
    146           "<th>Expected</th>" +
    147           "<th>FDR</th></tr>");
    148 
    149       tab.println("Reporter\t" +
    150           "GeneSymbol\t" +
    151           "LocusLink\t" +
    152           "AverageM\t" +
    153           "P\t" +
    154           "NumberOfValues\t" +
    155           "Rank\t" +
    156           "Expected\t" +
    157           "FDR");
     154      html.println("<tr><th>Reporter</th><th>Gene symbol</th><th>Locus Link</th><th>Average M</th>" +
     155          "<th>P</th><th>Number of values</th><th>Rank</th><th>Expected</th><th>FDR</th></tr>");
     156      tab.println("Reporter\tGeneSymbol\tLocusLink\tAverageM\tP\tNumberOfValues\tRank\tExpected\tFDR");
    158157     
    159158      for (int i = 0; i < bfss.getReporterSize(); i++)
     
    189188          expected,
    190189          fdr);
     190       
     191          oSeries.add(rank, rank, true);
     192          eSeries.add(rank, expected, true);
    191193      }
    192194      html.println("</table>");
    193 
    194195      html.print("</html>");
    195196      html.close();
    196197     
    197198      tab.close();
    198     }
    199     catch (FileNotFoundException e)
    200     {}
     199     
     200     
     201      XYSeriesCollection allSeries = new XYSeriesCollection();
     202      allSeries.addSeries(oSeries);
     203      allSeries.addSeries(eSeries);
     204     
     205      NumberAxis domainAxis = new LogarithmicAxis(""); //x axis
     206      domainAxis.setAutoRangeIncludesZero(false);
     207      domainAxis.setRangeType(RangeType.POSITIVE);
     208      NumberAxis rangeAxis = new NumberAxis(); //y axis
     209      rangeAxis.setRangeType(RangeType.POSITIVE);
     210      rangeAxis.setAutoRangeIncludesZero(true);
     211      XYPlot oePlot = new XYPlot(allSeries, domainAxis, rangeAxis, new XYLineAndShapeRenderer(true, false));
     212      oePlot.setSeriesRenderingOrder(SeriesRenderingOrder.FORWARD);
     213
     214      JFreeChart oeChart;
     215      oeChart = new JFreeChart(oePlot);
     216      oeChart.setAntiAlias(false);
     217     
     218      ChartUtilities.saveChartAsPNG(new File("oeplot.png"), oeChart, 800, 600);
     219    }
     220    catch (IOException e)
     221    {
     222      e.printStackTrace();
     223    }
    201224
    202225  }
     226 
    203227}
Note: See TracChangeset for help on using the changeset viewer.