/** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { CategoryTableXYDataset d1 = new CategoryTableXYDataset(); d1.add(1.0, 1.1, "Series 1"); d1.add(2.0, 2.2, "Series 1"); CategoryTableXYDataset d2 = new CategoryTableXYDataset(); d2.add(1.0, 1.1, "Series 1"); d2.add(2.0, 2.2, "Series 1"); assertTrue(d1.equals(d2)); assertTrue(d2.equals(d1)); d1.add(3.0, 3.3, "Series 1"); assertFalse(d1.equals(d2)); d2.add(3.0, 3.3, "Series 1"); assertTrue(d1.equals(d2)); }
@NotNull static JFreeChart minorAllelePDF(@NotNull final List<PurpleCopyNumber> variants) { final CategoryTableXYDataset dataset = minorAllele(variants); final JFreeChart chart = ChartFactory.createXYBarChart("Minor Allele Ploidy PDF", "Ploidy", false, "BAF Count", dataset, PlotOrientation.VERTICAL, true, false, false); StackedXYBarRenderer renderer = new StackedXYBarRenderer(); renderer.setBarPainter(new StandardXYBarPainter()); renderer.setShadowVisible(false); XYPlot xyPlot = (XYPlot) chart.getPlot(); xyPlot.setRenderer(renderer); xyPlot.getDomainAxis().setRange(-1.1, 5.1); for (int i = 0; i < dataset.getSeriesCount(); i++) { renderer.setSeriesPaint(i, copyNumberColor(String.valueOf(dataset.getSeriesKey(i)))); } return chart; }
@NotNull static JFreeChart somaticPloidyPDF(@NotNull final List<PurityAdjustedSomaticVariant> variants) { final CategoryTableXYDataset dataset = variants(variants); final JFreeChart chart = ChartFactory.createXYBarChart("Somatic Variant Ploidy PDF", "Ploidy", false, "Count", dataset, PlotOrientation.VERTICAL, true, false, false); StackedXYBarRenderer renderer = new StackedXYBarRenderer(); renderer.setBarPainter(new StandardXYBarPainter()); renderer.setShadowVisible(false); XYPlot xyPlot = (XYPlot) chart.getPlot(); xyPlot.setRenderer(renderer); for (int i = 0; i < dataset.getSeriesCount(); i++) { renderer.setSeriesPaint(i, copyNumberColor(String.valueOf(dataset.getSeriesKey(i)))); } return chart; }
/** * This is a test for bug 1312066 - adding a new series should trigger a * recalculation of the interval width, if it is being automatically * calculated. */ public void testAddSeries() { CategoryTableXYDataset d1 = new CategoryTableXYDataset(); d1.setAutoWidth(true); d1.add(3.0, 1.1, "Series 1"); d1.add(7.0, 2.2, "Series 1"); assertEquals(3.0, d1.getXValue(0, 0), EPSILON); assertEquals(7.0, d1.getXValue(0, 1), EPSILON); assertEquals(1.0, d1.getStartXValue(0, 0), EPSILON); assertEquals(5.0, d1.getStartXValue(0, 1), EPSILON); assertEquals(5.0, d1.getEndXValue(0, 0), EPSILON); assertEquals(9.0, d1.getEndXValue(0, 1), EPSILON); // now add some more data d1.add(7.5, 1.1, "Series 2"); d1.add(9.0, 2.2, "Series 2"); assertEquals(3.0, d1.getXValue(1, 0), EPSILON); assertEquals(7.0, d1.getXValue(1, 1), EPSILON); assertEquals(7.5, d1.getXValue(1, 2), EPSILON); assertEquals(9.0, d1.getXValue(1, 3), EPSILON); assertEquals(7.25, d1.getStartXValue(1, 2), EPSILON); assertEquals(8.75, d1.getStartXValue(1, 3), EPSILON); assertEquals(7.75, d1.getEndXValue(1, 2), EPSILON); assertEquals(9.25, d1.getEndXValue(1, 3), EPSILON); // and check the first series too... assertEquals(2.75, d1.getStartXValue(0, 0), EPSILON); assertEquals(6.75, d1.getStartXValue(0, 1), EPSILON); assertEquals(3.25, d1.getEndXValue(0, 0), EPSILON); assertEquals(7.25, d1.getEndXValue(0, 1), EPSILON); }
@VisibleForTesting @NotNull static CategoryTableXYDataset minorAllele(@NotNull final List<PurpleCopyNumber> copyNumbers) { int positivePloidy = 5; int positiveBuckets = positivePloidy * 10; int negativePloidy = 1; int negativeBuckets = negativePloidy * 10; int totalBuckets = negativeBuckets + positiveBuckets; double[][] buckets = new double[MAX_COPY_NUMBER_SERIES + 1][totalBuckets + 1]; for (final PurpleCopyNumber copyNumber : copyNumbers) { double unboundMinorAllele = (1 - copyNumber.averageActualBAF()) * copyNumber.averageTumorCopyNumber(); int series = limit(copyNumber.averageTumorCopyNumber(), 0, MAX_COPY_NUMBER_SERIES); int column = limit(unboundMinorAllele / 0.1, -negativeBuckets, positiveBuckets) + negativeBuckets; buckets[series][column] += copyNumber.bafCount(); } CategoryTableXYDataset result = new CategoryTableXYDataset(); for (int i = 0; i <= MAX_COPY_NUMBER_SERIES; i++) { String seriesName = "CN" + i + (i == MAX_COPY_NUMBER_SERIES ? "+" : ""); for (int j = 0; j <= totalBuckets; j++) { if (!Doubles.isZero(buckets[i][j])) { result.add(-1 + (j * 0.1), buckets[i][j], seriesName); } } } return result; }
@Test public void testNegativeMinorBafs() { CategoryTableXYDataset dataset = minorAllele(newArrayList(createCopyNumber(1.1, 1))); assertEquals(-0.1, dataset.getX(0, 0).doubleValue(), EPSILON); assertEquals(10, dataset.getY(0, 0).doubleValue(), EPSILON); dataset = minorAllele(newArrayList(createCopyNumber(1.7, 1))); assertEquals(-0.7, dataset.getX(0, 0).doubleValue(), EPSILON); assertEquals(10, dataset.getY(0, 0).doubleValue(), EPSILON); }
@Test public void testLowerBoundary() { CategoryTableXYDataset dataset = minorAllele(newArrayList(createCopyNumber(2, 1))); assertEquals(-1, dataset.getX(0, 0).doubleValue(), EPSILON); assertEquals(10, dataset.getY(0, 0).doubleValue(), EPSILON); dataset = minorAllele(newArrayList(createCopyNumber(3, 1))); assertEquals(-1, dataset.getX(0, 0).doubleValue(), EPSILON); assertEquals(10, dataset.getY(0, 0).doubleValue(), EPSILON); }
@Test public void testUpperBoundary() { CategoryTableXYDataset dataset = minorAllele(newArrayList(createCopyNumber(0, 5))); assertEquals(5, dataset.getX(0, 0).doubleValue(), EPSILON); assertEquals(10, dataset.getY(0, 0).doubleValue(), EPSILON); dataset = minorAllele(newArrayList(createCopyNumber(0, 6))); assertEquals(5, dataset.getX(0, 0).doubleValue(), EPSILON); assertEquals(10, dataset.getY(0, 0).doubleValue(), EPSILON); }
public void processNode(Object name, Map map, Object value) throws Exception { if(value != null && value instanceof CategoryTableXYDataset) { this.xyDataset = (CategoryTableXYDataset)value; }else { // TODO } }
/** * Verify that this class implements {@link PublicCloneable}. */ public void testPublicCloneable() { CategoryTableXYDataset d1 = new CategoryTableXYDataset(); assertTrue(d1 instanceof PublicCloneable); }
/** * Getter for property xyDataset. * @return Value of property xyDataset. */ public CategoryTableXYDataset getXyDataset() { return this.xyDataset; }
/** * Setter for property xyDataset. * @param xyDataset New value of property xyDataset. */ public void setXyDataset(CategoryTableXYDataset xyDataset) { this.xyDataset = xyDataset; }