Changeset 227


Ignore:
Timestamp:
Jan 17, 2007, 4:48:19 PM (16 years ago)
Author:
Johan Enell
Message:

Fixes #37 Added boxplot

Location:
trunk/se/lu/onk/Smooth/src/smooth
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/se/lu/onk/Smooth/src/smooth/Smooth.java

    r222 r227  
    117117          if (stop < reporters.size())
    118118          {
     119            winSizes.add(reporters.get(stop).getChrPosition() - reporters.get(start).getChrPosition());
    119120            if (!window.isEmpty())
    120121            {
     
    128129            }
    129130          }
    130           winSizes.add(reporters.get(stop).getChrPosition() - reporters.get(start).getChrPosition());
    131131        }
    132132        else if (winType.equals("bp"))
     
    134134          if (stop < reporters.size())
    135135          {
     136            winSizes.add(stop - start);
    136137            while (!window.isEmpty() && r.getChrPosition() - reporters.get(start).getChrPosition() > winSize / 2)
    137138            {
     
    145146            }
    146147          }
    147           winSizes.add(stop - start);
    148148        }
    149149        float mean = Float.NaN;
  • trunk/se/lu/onk/Smooth/src/smooth/SmoothMain.java

    r222 r227  
    2727import org.jfree.chart.JFreeChart;
    2828import org.jfree.chart.axis.CategoryAxis;
    29 import org.jfree.chart.axis.LogarithmicAxis;
    3029import org.jfree.chart.axis.NumberAxis;
    31 import org.jfree.chart.axis.ValueAxis;
    3230import org.jfree.chart.plot.CategoryPlot;
     31import org.jfree.chart.plot.PlotRenderingInfo;
    3332import org.jfree.chart.renderer.category.BoxAndWhiskerRenderer;
    34 import org.jfree.data.RangeType;
     33import org.jfree.chart.renderer.category.CategoryItemRendererState;
    3534import org.jfree.data.statistics.BoxAndWhiskerItem;
    3635import org.jfree.data.statistics.DefaultBoxAndWhiskerCategoryDataset;
     
    4140import basefile.BASEFileSpotSection;
    4241
     42import java.awt.Graphics2D;
     43import java.awt.geom.Rectangle2D;
    4344import java.io.File;
    4445import java.io.IOException;
     
    5556public class SmoothMain
    5657{
     58
     59  private static String wType = "";
    5760
    5861  /**
     
    8083      }
    8184
    82       String wType = bfs.findStringOpt("w_type");
     85      wType = bfs.findStringOpt("w_type");
    8386      String average = bfs.findStringOpt("average");
    8487      int wSize = bfs.findIntOpt("w_size");
     
    173176    {
    174177      BoxAndWhiskerItem bw = smooth.getBoxAndWhiskerItem(assayId);
    175       data.add(bw, "Windows distibution", assays.get(assayId));
    176     }
    177    
    178     CategoryAxis domainAxis = new CategoryAxis("Sample"); // x axis
    179     NumberAxis rangeAxis = new NumberAxis("Window size"); // y axis fdr
    180     rangeAxis.setAutoRangeIncludesZero(true);
    181    
    182     BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
    183     CategoryPlot plot = new CategoryPlot(data, domainAxis, rangeAxis, renderer);
     178      data.add(bw, "Window distibution", assays.get(assayId));
     179    }
     180   
     181    CategoryAxis xAxis = new CategoryAxis("Sample");
     182    NumberAxis yAxis = new NumberAxis("Window size (" + (wType.equals("cl") ? "bp" : "clones") + ")");
     183    yAxis.setAutoRangeIncludesZero(false);
     184   
     185    BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer()
     186    {
     187      @Override
     188      public CategoryItemRendererState initialise(Graphics2D g2, Rectangle2D dataArea, CategoryPlot plot, int rendererIndex, PlotRenderingInfo info)
     189      {
     190        CategoryItemRendererState state = super.initialise(g2, dataArea, plot, rendererIndex, info);
     191        state.setBarWidth(20);
     192        return state;
     193      }
     194    };
     195    CategoryPlot plot = new CategoryPlot(data, xAxis, yAxis, renderer);
     196   
    184197   
    185198    JFreeChart chart = new JFreeChart(plot);
     199    chart.removeLegend();
    186200    chart.setAntiAlias(false);
    187201
    188     ChartUtilities.saveChartAsPNG(new File("windowsize.png"), chart, 800, 600);
     202    int w = 150 + 40 * assays.size();
     203    ChartUtilities.saveChartAsPNG(new File("windowsize.png"), chart, w, 600);
    189204  }
    190205
Note: See TracChangeset for help on using the changeset viewer.