Example #1
0
        public void TestSegment()
        {
            var counts = new List <SampleGenomicBin>
            {
                new SampleGenomicBin("chr17", 100000000, 110000000, 0, 100),
                new SampleGenomicBin("chr17", 100000000, 110000000, 0, 90),
                new SampleGenomicBin("chr17", 100000000, 110000000, 0, 110),
                new SampleGenomicBin("chr17", 100000000, 110000000, 0, 100),
                new SampleGenomicBin("chr17", 100000000, 110000000, 0, 95),
                new SampleGenomicBin("chr17", 100000000, 110000000, 0, 105)
            };
            var seg1 = new CanvasSegment("chr17", 100000000, 110000000, counts);

            // Silly constructor tests:
            Assert.Equal(100000000, seg1.Begin);
            Assert.Equal(110000000, seg1.End);
            Assert.Equal(seg1.BinCount, counts.Count);
            Assert.Equal("chr17", seg1.Chr);
            // Property test:
            Assert.Equal(100, seg1.MeanCount, 2);

            // Build a second segment, and merge them, and test results:
            var seg2 = new CanvasSegment("chr17", 110000000, 120000000, counts);

            seg1.MergeIn(seg2);
            Assert.Equal(12, seg1.Counts.Count);
            Assert.Equal(seg1.End, seg2.End);
        }
Example #2
0
        public void TestCipos()
        {
            // Merge two segments, and confirm we keep the correct confidence intervals post-merge:
            List <SampleGenomicBin> counts = new List <SampleGenomicBin>()
            {
                new SampleGenomicBin("chr1", 1, 2, 100),
                new SampleGenomicBin("chr1", 1, 2, 90),
                new SampleGenomicBin("chr1", 1, 2, 110),
                new SampleGenomicBin("chr1", 1, 2, 100),
                new SampleGenomicBin("chr1", 1, 2, 95),
                new SampleGenomicBin("chr1", 1, 2, 105)
            };
            CanvasSegment segment = new CanvasSegment("chr1", 1245, 678910, counts);

            segment.StartConfidenceInterval = new Tuple <int, int>(-100, 100);
            segment.EndConfidenceInterval   = new Tuple <int, int>(-80, 80);
            CanvasSegment segment2 = new CanvasSegment("chr1", 678910, 8787888, counts);

            segment2.StartConfidenceInterval = new Tuple <int, int>(-50, 50);
            segment2.EndConfidenceInterval   = new Tuple <int, int>(-30, 30);
            segment.MergeIn(segment2);
            Assert.Equal(8787888, segment.End);
            Assert.Equal(-30, segment.EndConfidenceInterval.Item1);
            Assert.Equal(100, segment.StartConfidenceInterval.Item2);
        }
Example #3
0
        public void MergeIn_PreviousSegment_KeepsBinsOrdered()
        {
            List <SampleGenomicBin> binsBefore = new List <SampleGenomicBin> {
                new SampleGenomicBin("chr1", 1, 2, 100)
            };
            CanvasSegment           segmentBefore = new CanvasSegment("chr1", 1, 2, binsBefore);
            List <SampleGenomicBin> bins          = new List <SampleGenomicBin> {
                new SampleGenomicBin("chr1", 2, 3, 100)
            };
            CanvasSegment segment = new CanvasSegment("chr1", 2, 3, bins);

            segment.MergeIn(segmentBefore);
            Assert.Equal(binsBefore.Concat(bins), segment.GenomicBins);
        }
Example #4
0
        public void MergeIn_PreviousSegment_KeepsBAllelesOrdered()
        {
            List <SampleGenomicBin> emptyBins = new List <SampleGenomicBin>();
            var bAllelesBefore = new Balleles(new List <Ballele> {
                new Ballele(1, 1, 1)
            });
            CanvasSegment segmentBefore = new CanvasSegment("chr1", 1, 2, emptyBins, bAllelesBefore);
            var           bAlleles      = new Balleles(new List <Ballele> {
                new Ballele(2, 1, 1)
            });
            CanvasSegment segment = new CanvasSegment("chr1", 2, 3, emptyBins, bAlleles);

            segment.MergeIn(segmentBefore);

            Assert.Equal(bAllelesBefore.Range.Concat(bAlleles.Range), segment.Balleles.Range);
        }
Example #5
0
        public void TestCIPOS()
        {
            // Merge two segments, and confirm we keep the correct confidence intervals post-merge:
            List <float> counts = new List <float>()
            {
                100, 90, 110, 100, 95, 105
            };
            CanvasSegment segment = new CanvasSegment("chr1", 1245, 678910, counts);

            segment.StartConfidenceInterval = new Tuple <int, int>(-100, 100);
            segment.EndConfidenceInterval   = new Tuple <int, int>(-80, 80);
            CanvasSegment segment2 = new CanvasSegment("chr1", 678910, 8787888, counts);

            segment2.StartConfidenceInterval = new Tuple <int, int>(-50, 50);
            segment2.EndConfidenceInterval   = new Tuple <int, int>(-30, 30);
            segment.MergeIn(segment2);
            Assert.AreEqual(segment.End, 8787888);
            Assert.AreEqual(segment.EndConfidenceInterval.Item1, -30);
            Assert.AreEqual(segment.StartConfidenceInterval.Item2, 100);
        }
Example #6
0
        public void TestSegment()
        {
            List <float> counts = new List <float>()
            {
                100, 90, 110, 100, 95, 105
            };
            CanvasSegment seg1 = new CanvasSegment("chr17", 100000000, 110000000, counts);

            // Silly constructor tests:
            Assert.AreEqual(seg1.Begin, 100000000);
            Assert.AreEqual(seg1.End, 110000000);
            Assert.AreEqual(seg1.BinCount, counts.Count);
            Assert.AreEqual(seg1.Chr, "chr17");
            // Property test:
            Assert.AreEqual(seg1.MeanCount, 100, 0.01);

            // Build a second segment, and merge them, and test results:
            CanvasSegment seg2 = new CanvasSegment("chr17", 110000000, 120000000, counts);

            seg1.MergeIn(seg2);
            Assert.AreEqual(seg1.Counts.Count, 12);
            Assert.AreEqual(seg1.End, seg2.End);
        }