Esempio n. 1
0
        public void TestCreateSegmentsFromCommonCnvs()
        {
            var sampleGenomicBins = new List <SampleGenomicBin>
            {
                new SampleGenomicBin("chr10", 1001, 2000, 0, 80),
                new SampleGenomicBin("chr10", 2001, 3000, 0, 79),
                new SampleGenomicBin("chr10", 3001, 4000, 0, 78),
                new SampleGenomicBin("chr10", 4001, 5000, 0, 77),
                new SampleGenomicBin("chr10", 5001, 6000, 0, 2),
                new SampleGenomicBin("chr10", 6001, 7000, 0, 2)
            };

            var intervals = new List <BedInterval>
            {
                new BedInterval(0, 3),
                new BedInterval(3, 5)
            };

            var balleles = new List <Balleles>
            {
                new Balleles(new List <Ballele>()),
                new Balleles(new List <Ballele> {
                    new Ballele(5501, 30, 30)
                })
            };

            var canvasSegments = CanvasSegment.CreateSegmentsFromCommonCnvs(sampleGenomicBins, intervals, balleles);

            Assert.Equal(canvasSegments.Count, intervals.Count);
            Assert.Equal(0, canvasSegments.First().Balleles.Size());
            Assert.Equal(1, canvasSegments.Last().Balleles.Size());
            Assert.Equal(3, canvasSegments.First().Counts.Count);
            Assert.Equal(2, canvasSegments.Last().Counts.Count);
        }
Esempio n. 2
0
        private static List <OverlappingSegmentsRegion> GetSegmentSets(int defaultAlleleCountThreshold, Dictionary <string, List <BedEntry> > commonRegions,
                                                                       Dictionary <string, IReadOnlyList <SampleGenomicBin> > genomicBinsByChromosome, Dictionary <string, List <BedInterval> > segmentIntervalsByChromosome,
                                                                       Dictionary <string, List <Balleles> > allelesByChromosomeCommonSegs, Segments segments)
        {
            var segmentsSetByChromosome = new ConcurrentDictionary <string, List <OverlappingSegmentsRegion> >();

            Parallel.ForEach(
                segments.GetChromosomes(),
                chr =>
            {
                var segmentsByChromosome = segments.GetSegmentsForChromosome(chr).ToList();

                if (commonRegions.Keys.Any(chromosome => chromosome == chr))
                {
                    var commonCnvCanvasSegments = CanvasSegment.CreateSegmentsFromCommonCnvs(genomicBinsByChromosome[chr],
                                                                                             segmentIntervalsByChromosome[chr], allelesByChromosomeCommonSegs[chr]);

                    segmentsSetByChromosome[chr] = CanvasSegment.MergeCommonCnvSegments(segmentsByChromosome,
                                                                                        commonCnvCanvasSegments, defaultAlleleCountThreshold);
                }
                else
                {
                    segmentsSetByChromosome[chr] = segmentsByChromosome.Select(
                        segment => new OverlappingSegmentsRegion(new List <CanvasSegment> {
                        segment
                    }, null)).ToList();
                }
            });
            return(segmentsSetByChromosome.OrderBy(i => i.Key).Select(x => x.Value).SelectMany(x => x).ToList());
        }