Ejemplo n.º 1
0
 def test_segment_parallel(self):
     """The 'segment' command, in parallel."""
     cnarr = cnvlib.read("formats/amplicon.cnr")
     psegments = segmentation.do_segmentation(cnarr, "haar", processes=2)
     ssegments = segmentation.do_segmentation(cnarr, "haar", processes=1)
     self.assertEqual(psegments.data.shape, ssegments.data.shape)
     self.assertEqual(len(psegments.meta), len(ssegments.meta))
Ejemplo n.º 2
0
 def test_segment(self):
     """The 'segment' command."""
     # R methods are in another script
     segments = segmentation.do_segmentation("formats/amplicon.cnr", "haar")
     self.assertTrue(len(segments) > 0)
     segments = segmentation.do_segmentation("formats/amplicon.cnr", "haar",
                                             threshold=.001, skip_low=True)
     self.assertTrue(len(segments) > 0)
Ejemplo n.º 3
0
 def test_segment(self):
     """The 'segment' command."""
     cnarr = cnvlib.read("formats/amplicon.cnr")
     # R methods are in another script
     segments = segmentation.do_segmentation(cnarr, "haar")
     self.assertGreater(len(segments), 0)
     segments = segmentation.do_segmentation(cnarr, "haar", threshold=.001,
                                             skip_low=True)
     self.assertGreater(len(segments), 0)
Ejemplo n.º 4
0
 def test_segment(self):
     cnarr = cnvlib.read("formats/amplicon.cnr")
     # Each method
     for method in ("cbs", "flasso"):
         cns = segmentation.do_segmentation(cnarr, method)
         self.assertGreater(len(cns), 0)
         # With the R dataframe
         cns, dframe = segmentation.do_segmentation(cnarr, "flasso", 0.01,
                                                    save_dataframe=True)
         self.assertGreater(len(cns), 0)
         self.assertGreater(len(dframe), 0)
Ejemplo n.º 5
0
 def test_segment_hmm(self):
     """The 'segment' command with HMM methods."""
     for fname in ("formats/amplicon.cnr", "formats/p2-20_1.cnr"):
         cnarr = cnvlib.read(fname)
         n_chroms = cnarr.chromosome.nunique()
         # NB: R methods are in another script; haar is pure-Python
         segments = segmentation.do_segmentation(cnarr, "hmm")
         self.assertGreater(len(segments), n_chroms)
         segments = segmentation.do_segmentation(cnarr, "hmm-tumor",
                                                 skip_low=True)
         self.assertGreater(len(segments), n_chroms)
         segments = segmentation.do_segmentation(cnarr, "hmm-germline")
         self.assertGreater(len(segments), n_chroms)
Ejemplo n.º 6
0
 def test_segment(self):
     """The 'segment' command."""
     cnarr = cnvlib.read("formats/amplicon.cnr")
     n_chroms = cnarr.chromosome.nunique()
     # NB: R methods are in another script; haar is pure-Python
     segments = segmentation.do_segmentation(cnarr, "haar")
     self.assertGreater(len(segments), n_chroms)
     segments = segmentation.do_segmentation(cnarr, "haar", threshold=.0001,
                                             skip_low=True)
     self.assertGreater(len(segments), n_chroms)
     varr = tabio.read("formats/na12878_na12882_mix.vcf", "vcf")
     segments = segmentation.do_segmentation(cnarr, "haar", variants=varr)
     self.assertGreater(len(segments), n_chroms)
Ejemplo n.º 7
0
def _test_method(self, method):
    for cnr in (self.tas_cnr,
                # self.wgs_cnr
               ):
        cns, raw_str = segmentation.do_segmentation(cnr, method, processes=1,
                                                    save_dataframe=True)
        self.assertGreater(len(cns), 0)
        self.assertGreater(len(raw_str), 0)
        # Parallel should produce the same results
        p_cns, p_raw_str = segmentation.do_segmentation(cnr, method,
                                                        processes=2,
                                                        save_dataframe=True)
        self.assertEqual(cns.data.shape, p_cns.data.shape)
        self.assertEqual(len(cns.meta), len(p_cns.meta))
        self.assertEqual(raw_str, p_raw_str)
Ejemplo n.º 8
0
 def test_gainloss(self):
     probes = cnvlib.read("formats/amplicon.cnr")
     rows = commands.do_gainloss(probes, male_reference=True)
     self.assertTrue(len(rows) > 0)
     segs = segmentation.do_segmentation("formats/amplicon.cnr", False,
                                         "haar")
     rows = commands.do_gainloss(probes, segs, True, 0.3, 4)
     self.assertTrue(len(rows) > 0)
Ejemplo n.º 9
0
 def test_segment(self):
     """The 'segment' command."""
     cnarr = cnvlib.read("formats/amplicon.cnr")
     n_chroms = cnarr.chromosome.nunique()
     # NB: R methods are in another script; haar is pure-Python
     segments = segmentation.do_segmentation(cnarr, "haar")
     self.assertGreater(len(segments), n_chroms)
     self.assertTrue((segments.start < segments.end).all())
     segments = segmentation.do_segmentation(cnarr,
                                             "haar",
                                             threshold=.0001,
                                             skip_low=True)
     self.assertGreater(len(segments), n_chroms)
     self.assertTrue((segments.start < segments.end).all())
     varr = tabio.read("formats/na12878_na12882_mix.vcf", "vcf")
     segments = segmentation.do_segmentation(cnarr, "haar", variants=varr)
     self.assertGreater(len(segments), n_chroms)
     self.assertTrue((segments.start < segments.end).all())
Ejemplo n.º 10
0
 def test_segment_hmm(self):
     """The 'segment' command with HMM methods."""
     for fname in ("formats/amplicon.cnr", "formats/p2-20_1.cnr"):
         cnarr = cnvlib.read(fname)
         n_chroms = cnarr.chromosome.nunique()
         # NB: R methods are in another script; haar is pure-Python
         segments = segmentation.do_segmentation(cnarr, "hmm")
         self.assertGreater(len(segments), n_chroms)
         self.assertTrue((segments.start < segments.end).all())
         segments = segmentation.do_segmentation(cnarr, "hmm-tumor",
                                                 skip_low=True)
         self.assertGreater(len(segments), n_chroms)
         self.assertTrue((segments.start < segments.end).all())
         segments = segmentation.do_segmentation(cnarr, "hmm-germline")
         self.assertGreater(len(segments), n_chroms)
         self.assertTrue((segments.start < segments.end).all())
         varr = tabio.read("formats/na12878_na12882_mix.vcf", "vcf")
         segments = segmentation.do_segmentation(cnarr, "hmm", variants=varr)
         self.assertGreater(len(segments), n_chroms)
Ejemplo n.º 11
0
 def test_segment_hmm(self):
     """The 'segment' command with HMM methods."""
     for fname in ("formats/amplicon.cnr", "formats/p2-20_1.cnr"):
         cnarr = cnvlib.read(fname)
         n_chroms = cnarr.chromosome.nunique()
         # NB: R methods are in another script; haar is pure-Python
         segments = segmentation.do_segmentation(cnarr, "hmm")
         self.assertGreater(len(segments), n_chroms)
         self.assertTrue((segments.start < segments.end).all())
         segments = segmentation.do_segmentation(cnarr,
                                                 "hmm-tumor",
                                                 skip_low=True)
         self.assertGreater(len(segments), n_chroms)
         self.assertTrue((segments.start < segments.end).all())
         segments = segmentation.do_segmentation(cnarr, "hmm-germline")
         self.assertGreater(len(segments), n_chroms)
         self.assertTrue((segments.start < segments.end).all())
         varr = tabio.read("formats/na12878_na12882_mix.vcf", "vcf")
         segments = segmentation.do_segmentation(cnarr,
                                                 "hmm",
                                                 variants=varr)
         self.assertGreater(len(segments), n_chroms)
Ejemplo n.º 12
0
 def test_segment(self):
     # R methods are in another script
     cns = segmentation.do_segmentation("formats/amplicon.cnr", False,
                                        "haar")
     self.assertTrue(len(cns) > 0)
Ejemplo n.º 13
0
 def test_breaks(self):
     probes = cnvlib.read("formats/amplicon.cnr")
     segs = segmentation.do_segmentation("formats/amplicon.cnr", False,
                                         "haar")
     rows = commands.do_breaks(probes, segs, 4)
     self.assertTrue(len(rows) > 0)