Esempio n. 1
0
 def test_ibd_segments_in_family(self):
     '''Test locating recombination locations and subsequently IBD regions between 
     parent and child haplotypes.'''
     segment_set = ibd.concatenate_segments(
         ip.ibd_segments_in_family(self.haplotype, self.family,
                                   PhaseParam.HET_FILL_THRESHOLD))
     assert_segments_almost_equal(segment_set, [
         ((3, 172), (17080378, 18541497, 1.461, 0), ((1, 1), (2, 1))),
         ((193, 3218), (18996226, 51156934, 32.161, 1), ((1, 0), (2, 1))),
         ((0, 3218), (16484792, 51156934, 34.672, 4), ((1, 0), (3, 1))),
         ((3, 240), (17080378, 19593301, 2.513, 0), ((1, 0), (4, 1))),
         ((256, 3218), (19873357, 51156934, 31.284, 0), ((4, 1), (1, 1))),
         ((0, 3218), (16484792, 51156934, 34.672, 0), ((5, 1), (1, 0))),
         ((3, 2696), (17080378, 46630634, 29.550, 0), ((6, 1), (1, 1))),
         ((2718, 3218), (46853292, 51156934, 4.304, 1), ((1, 0), (6, 1))),
         ((0, 3218), (16484792, 51156934, 34.672, 0), ((1, 0), (7, 1))),
         ((3, 1908), (17080378, 36572515, 19.492, 0), ((8, 1), (1, 0))),
         ((1939, 3218), (36804282, 51156934, 14.353, 0), ((8, 1), (1, 1)))
     ],
                                  full_data=True,
                                  decimal=3,
                                  err_msg='Wrong IBD segments')
     assert_equal(segment_set.errors, [[
         2997, 2997, 132, 1364, 2493, 2800, 132, 1364, 2493, 2800, 2997,
         2997
     ], [1, 2, 1, 1, 1, 1, 3, 3, 3, 3, 1, 6]], 'Wrong genotype errors')
    def test_ibd_segments_both_parents(self):
        '''Test computing GERMLINE IBD segments.'''
        h_mat = ig._HapMatrix(self.problem, self.sibs)
        m = self.ibd_computer.ibd_segments(h_mat)
        assert_segments_almost_equal(m,
                                     [((0   , 344), (16484792, 21449028, 4.964, 0), ((2, 0), (4, 0))),
                                      ((0   , 344), (16484792, 21449028, 4.964, 0), ((1, 0), (4, 0))),
                                      ((0   , 780), (16484792, 26920270, 10.435, 0), ((4, 1), (2, 1))),
                                      ((2145, 2996), (39608193, 48759228, 9.151, 0), ((1, 1), (2, 1))),
                                      ((2145, 2996), (39608193, 48759228, 9.151, 0), ((4, 1), (2, 1))),
                                      ((885 , 3218), (27425790, 51156933, 23.731, 0), ((4, 1), (1, 1))),
                                      ((0   , 3218), (16484792, 51156933, 34.672, 0), ((2, 0), (1, 0)))],
                                     full_data=True, decimal=3, err_msg='Wrong IBD segments, raw')
        # A transitive-logic test test to see that we don't miss any intervals with GERMLINE
        m.group_to_disjoint(False) 
        assert_segments_almost_equal(m,
                                     [((0   , 344), (16484792, 21449028, 4.964, 0), ((2, 0), (1, 0), (4, 0))),
                                      ((0   , 344), (16484792, 21449028, 4.964, 0), ((4, 1), (2, 1))),
                                      ((344 , 780), (21449028, 26920270, 5.471, 0), ((2, 0), (1, 0))),
                                      ((344 , 780), (21449028, 26920270, 5.471, 0), ((4, 1), (2, 1))),
                                      ((780 , 885), (26920270, 27425790, 0.506, 0), ((2, 0), (1, 0))),
                                      ((885 , 2145), (27425790, 39608193, 12.182, 0), ((2, 0), (1, 0))),
                                      ((885 , 2145), (27425790, 39608193, 12.182, 0), ((4, 1), (1, 1))),
                                      ((2145, 2996), (39608193, 48759228, 9.151, 0), ((4, 1), (1, 1), (2, 1))),
                                      ((2145, 2996), (39608193, 48759228, 9.151, 0), ((2, 0), (1, 0))),
                                      ((2996, 3218), (48759228, 51156933, 2.398, 0), ((2, 0), (1, 0))),
                                      ((2996, 3218), (48759228, 51156933, 2.398, 0), ((4, 1), (1, 1)))],
                                     full_data=True, decimal=3, err_msg='Wrong IBD segments, grouped')

        stats = np.array([(len(s.samples), s.length) for s in m])
        best_segment = np.lexsort((-stats[:, 1], -stats[:, 0]))[0]
        assert_equal(best_segment, 7, 'Wrong best segment (IBD set size + length)') 
        assert_almost_equal(m[best_segment].length, 9.15, decimal=2, err_msg='Wrong best segment (IBD set size + length)')
        assert_equal(m[best_segment].samples, set([(4, 1), (1, 1), (2, 1)]), err_msg='Wrong best segment (IBD set size + length)')
Esempio n. 3
0
    def test_ibs_segments(self):
        '''Test locating IBD segments between parent and child haplotypes.'''
        (parent, child, hap1, hap2) = (1, 2, 0, 1)
        het_snps = gt.where_heterozygous(self.haplotype.data, parent)

        segment_set = ibd.ibs_segments(self.haplotype, parent, child, hap1,
                                       hap2, het_snps, True)
        assert_segments_almost_equal(
            segment_set,
            [((3, 172), (17080378, 18541497, 1.461, 0), ((1, 1), (2, 1))),
             ((193, 3218), (18996226, 51156934, 32.161, 1), ((1, 0), (2, 1)))],
            full_data=True,
            decimal=3,
            err_msg='Wrong IBD segments')

        segment_set = ibd.ibs_segments(self.haplotype,
                                       parent,
                                       child,
                                       hap1,
                                       hap2,
                                       het_snps,
                                       True,
                                       length_bound='base_pair',
                                       min_segment_length=10.0)
        assert_segments_almost_equal(segment_set,
                                     [((193, 3218),
                                       (18996226, 51156934, 32.161, 1),
                                       ((1, 0), (2, 1)))],
                                     full_data=True,
                                     decimal=3,
                                     err_msg='Wrong IBD segments')
 def test_ibd_segments(self):
     '''Test calculating IBD segments from child recombinations.'''
     parent_type = PATERNAL
     template = 2
     (_, _, info) = self.child_recombinations(parent_type, template, remove_errors=True)
     self.comparator.phase_parent_by_template(info)
     #ibd.phase_by_ibd(self.problem, info.ibs_segments())
     segment_set = ibd.concatenate_segments(x for x in info.ibs_segments())
     #print segment_set.pprint_segments(True)
     assert_segments_almost_equal(segment_set,
                                  [((0   , 2800), (-1      , -1      , -1.000, 0), ((2, 0), (0, 0))),
                                   ((2800, 3218), (-1      , -1      , -1.000, 0), ((0, 1), (2, 0))),
                                   ((0   , 3218), (-1      , -1      , -1.000, 0), ((3, 0), (0, 0))),
                                   ((0   , 3218), (-1      , -1      , -1.000, 0), ((0, 0), (4, 0))),
                                   ((0   , 3218), (-1      , -1      , -1.000, 0), ((0, 1), (5, 0))),
                                   ((0   , 3218), (-1      , -1      , -1.000, 0), ((0, 0), (6, 0))),
                                   ((0   , 55), (-1      , -1      , -1.000, 0), ((0, 0), (7, 0))),
                                   ((55  , 2981), (-1      , -1      , -1.000, 0), ((0, 1), (7, 0))),
                                   ((2981, 3218), (-1      , -1      , -1.000, 0), ((0, 0), (7, 0))),
                                   ((0   , 637), (-1      , -1      , -1.000, 0), ((8, 0), (0, 0))),
                                   ((637 , 2447), (-1      , -1      , -1.000, 0), ((0, 1), (8, 0))),
                                   ((2447, 3218), (-1      , -1      , -1.000, 0), ((8, 0), (0, 0))),
                                   ((0   , 3218), (-1      , -1      , -1.000, 0), ((9, 0), (0, 0))),
                                   ((0   , 3218), (-1      , -1      , -1.000, 0), ((10, 0), (0, 0))),
                                   ((0   , 3046), (-1      , -1      , -1.000, 0), ((11, 0), (0, 0))),
                                   ((3046, 3218), (-1      , -1      , -1.000, 0), ((0, 1), (11, 0))),
                                   ((0   , 3081), (-1      , -1      , -1.000, 0), ((0, 1), (12, 0))),
                                   ((3081, 3218), (-1      , -1      , -1.000, 0), ((0, 0), (12, 0))),
                                   ((0   , 199), (-1      , -1      , -1.000, 0), ((0, 0), (13, 0))),
                                   ((199 , 3089), (-1      , -1      , -1.000, 0), ((0, 1), (13, 0))),
                                   ((3089, 3218), (-1      , -1      , -1.000, 0), ((0, 0), (13, 0))),
                                   ((0   , 860), (-1      , -1      , -1.000, 0), ((0, 0), (14, 0))),
                                   ((860 , 3218), (-1      , -1      , -1.000, 0), ((0, 1), (14, 0)))],
                                  decimal=3, err_msg='Wrong IBD segments') 
Esempio n. 5
0
 def test_ibs_segments(self):
     '''Test computing GERMLINE IBD segments.'''
     m = ig.ibd_germline(self.problem, self.sibs)
     assert_equal(m.length, 24, 'Wrong # IBD grouped segments')
     assert_segments_almost_equal(m,
                                  [((1   , 434), (17065079, 23614026, 6.549, 0), ((0, 1), (3, 1), (4, 1), (1, 1))),
                                   ((1   , 434), (17065079, 23614026, 6.549, 0), ((5, 1), (0, 0), (4, 0))),
                                   ((1   , 434), (17065079, 23614026, 6.549, 0), ((3, 0), (1, 0))),
                                   ((434 , 537), (23614026, 24732045, 1.118, 0), ((0, 1), (3, 1), (4, 1))),
                                   ((434 , 537), (23614026, 24732045, 1.118, 0), ((5, 1), (0, 0), (4, 0))),
                                   ((537 , 848), (24732045, 27321172, 2.589, 0), ((3, 0), (5, 1), (0, 0), (4, 0))),
                                   ((537 , 848), (24732045, 27321172, 2.589, 0), ((0, 1), (3, 1), (4, 1))),
                                   ((537 , 848), (24732045, 27321172, 2.589, 0), ((1, 1), (5, 0))),
                                   ((848 , 948), (27321172, 27671082, 0.350, 0), ((0, 1), (3, 1), (4, 1))),
                                   ((848 , 948), (27321172, 27671082, 0.350, 0), ((3, 0), (5, 1), (0, 0))),
                                   ((848 , 948), (27321172, 27671082, 0.350, 0), ((1, 1), (5, 0))),
                                   ((948 , 2481), (27671082, 44544028, 16.873, 0), ((0, 1), (3, 1), (4, 1))),
                                   ((948 , 2481), (27671082, 44544028, 16.873, 0), ((3, 0), (5, 1), (0, 0))),
                                   ((948 , 2481), (27671082, 44544028, 16.873, 0), ((1, 1), (5, 0))),
                                   ((948 , 2481), (27671082, 44544028, 16.873, 0), ((1, 0), (4, 0))),
                                   ((2481, 2583), (44544028, 45330235, 0.786, 0), ((0, 1), (3, 1), (4, 1))),
                                   ((2481, 2583), (44544028, 45330235, 0.786, 0), ((3, 0), (5, 1), (0, 0))),
                                   ((2481, 2583), (44544028, 45330235, 0.786, 0), ((1, 0), (4, 0))),
                                   ((2583, 3107), (45330235, 49669743, 4.340, 0), ((0, 1), (3, 1), (4, 1), (5, 0))),
                                   ((2583, 3107), (45330235, 49669743, 4.340, 0), ((3, 0), (5, 1), (0, 0))),
                                   ((2583, 3107), (45330235, 49669743, 4.340, 0), ((1, 0), (4, 0))),
                                   ((3107, 3218), (49669743, 51156933, 1.487, 0), ((0, 1), (3, 1), (4, 1), (1, 1), (5, 0))),
                                   ((3107, 3218), (49669743, 51156933, 1.487, 0), ((3, 0), (5, 1), (0, 0))),
                                   ((3107, 3218), (49669743, 51156933, 1.487, 0), ((1, 0), (4, 0)))],
                         full_data=True, decimal=3, err_msg='Wrong IBD segments')
     stats = np.array([(len(s.samples), s.length) for s in m])
     best_segment = np.lexsort((-stats[:, 1], -stats[:, 0]))[0]
     assert_equal(best_segment, 21, 'Wrong best segment (IBD set size + length)') 
 def test_ibd_segments_parent_child(self):
     '''Test IBD segments that are apparently cut too short between a parent and child.'''
     parent = self.family.mother
     child = 2
     parent_type = MATERNAL
     h = self.problem.haplotype
     het_snps = gt.where_heterozygous(h.data, parent)
     segment_set = ip.ibd_segments_parent_child(h, parent, child, parent_type, het_snps)
     assert_segments_almost_equal(segment_set,
                                  [((2   , 2650), (17075353, 45892433, 28.817, 0), ((1, 1), (2, 1))),
                                   ((2657, 3218), (45940934, 51156934, 5.216, 2), ((1, 0), (2, 1)))],
                                 full_data=True, decimal=3, err_msg='Wrong IBD segments')
Esempio n. 7
0
 def test_ibd_segments(self):
     '''Test computing GERMLINE IBD segments.'''
     m = self.ibd_computer.ibd_segments(ig._HapMatrix(self.problem, self.sibs)).group_to_disjoint()
     assert_segments_almost_equal(m,
                                  [((0   , 20), (16484792, 17318333, 0.834, 0), ((3, 1), (4, 1), (1, 1), (2, 1))),
                                   ((0   , 20), (16484792, 17318333, 0.834, 0), ((0, 1), (3, 0), (5, 0))),
                                   ((0   , 20), (16484792, 17318333, 0.834, 0), ((2, 0), (0, 0), (4, 0))),
                                   ((0   , 20), (16484792, 17318333, 0.834, 0), ((5, 1), (1, 0))),
                                   ((20  , 121), (17318333, 18235305, 0.917, 0), ((5, 1), (4, 1), (1, 1), (2, 1))),
                                   ((20  , 121), (17318333, 18235305, 0.917, 0), ((0, 1), (3, 0), (5, 0))),
                                   ((20  , 121), (17318333, 18235305, 0.917, 0), ((2, 0), (0, 0), (4, 0))),
                                   ((121 , 224), (18235305, 19455836, 1.221, 0), ((5, 1), (4, 1), (1, 1), (2, 1))),
                                   ((121 , 224), (18235305, 19455836, 1.221, 0), ((0, 1), (3, 0), (5, 0))),
                                   ((121 , 224), (18235305, 19455836, 1.221, 0), ((0, 0), (4, 0))),
                                   ((121 , 224), (18235305, 19455836, 1.221, 0), ((1, 0), (3, 1))),
                                   ((224 , 828), (19455836, 27236071, 7.780, 0), ((0, 1), (3, 0), (5, 0), (2, 0))),
                                   ((224 , 828), (19455836, 27236071, 7.780, 0), ((5, 1), (4, 1), (1, 1), (2, 1))),
                                   ((224 , 828), (19455836, 27236071, 7.780, 0), ((0, 0), (4, 0))),
                                   ((224 , 828), (19455836, 27236071, 7.780, 0), ((1, 0), (3, 1))),
                                   ((828 , 2039), (27236071, 37707962, 10.472, 0), ((0, 1), (3, 0), (5, 0), (2, 0))),
                                   ((828 , 2039), (27236071, 37707962, 10.472, 0), ((1, 0), (3, 1), (4, 1))),
                                   ((828 , 2039), (27236071, 37707962, 10.472, 0), ((5, 1), (1, 1), (2, 1))),
                                   ((828 , 2039), (27236071, 37707962, 10.472, 0), ((0, 0), (4, 0))),
                                   ((2039, 2442), (37707962, 44264502, 6.557, 0), ((0, 1), (3, 0), (5, 0), (2, 0))),
                                   ((2039, 2442), (37707962, 44264502, 6.557, 0), ((5, 1), (3, 1), (1, 1), (2, 1))),
                                   ((2039, 2442), (37707962, 44264502, 6.557, 0), ((0, 0), (4, 0))),
                                   ((2039, 2442), (37707962, 44264502, 6.557, 0), ((1, 0), (4, 1))),
                                   ((2442, 2542), (44264502, 44930087, 0.666, 0), ((0, 1), (3, 0), (5, 0), (2, 0))),
                                   ((2442, 2542), (44264502, 44930087, 0.666, 0), ((5, 1), (3, 1), (1, 1), (2, 1))),
                                   ((2442, 2542), (44264502, 44930087, 0.666, 0), ((1, 0), (4, 1))),
                                   ((2542, 2642), (44930087, 45823327, 0.893, 0), ((0, 1), (3, 0), (4, 0), (5, 0), (2, 0))),
                                   ((2542, 2642), (44930087, 45823327, 0.893, 0), ((5, 1), (3, 1), (1, 1), (2, 1))),
                                   ((2542, 2642), (44930087, 45823327, 0.893, 0), ((1, 0), (4, 1))),
                                   ((2642, 2742), (45823327, 47169675, 1.346, 0), ((0, 1), (3, 0), (5, 0), (4, 0))),
                                   ((2642, 2742), (45823327, 47169675, 1.346, 0), ((5, 1), (3, 1), (1, 1), (2, 1))),
                                   ((2642, 2742), (45823327, 47169675, 1.346, 0), ((1, 0), (4, 1))),
                                   ((2742, 2942), (47169675, 48530211, 1.361, 0), ((0, 1), (3, 0), (5, 0), (4, 0))),
                                   ((2742, 2942), (47169675, 48530211, 1.361, 0), ((5, 1), (3, 1), (1, 1), (2, 1))),
                                   ((2742, 2942), (47169675, 48530211, 1.361, 0), ((2, 0), (0, 0))),
                                   ((2742, 2942), (47169675, 48530211, 1.361, 0), ((1, 0), (4, 1))),
                                   ((2942, 3042), (48530211, 49168613, 0.638, 0), ((5, 1), (3, 1), (1, 1), (2, 1))),
                                   ((2942, 3042), (48530211, 49168613, 0.638, 0), ((0, 1), (3, 0), (4, 0))),
                                   ((2942, 3042), (48530211, 49168613, 0.638, 0), ((2, 0), (0, 0))),
                                   ((2942, 3042), (48530211, 49168613, 0.638, 0), ((1, 0), (4, 1))),
                                   ((3042, 3218), (49168613, 51156933, 1.988, 0), ((5, 1), (3, 1), (1, 1), (2, 1))),
                                   ((3042, 3218), (49168613, 51156933, 1.988, 0), ((0, 1), (3, 0), (4, 0))),
                                   ((3042, 3218), (49168613, 51156933, 1.988, 0), ((2, 0), (0, 0), (5, 0))),
                                   ((3042, 3218), (49168613, 51156933, 1.988, 0), ((1, 0), (4, 1)))],
                                  full_data=True, decimal=3, err_msg='Wrong IBD segments, grouped')
     stats = np.array([(len(s.samples), s.length) for s in m])
     best_segment = np.lexsort((-stats[:, 1], -stats[:, 0]))[0]
     assert_equal(best_segment, 26, 'Wrong best segment (IBD set size + length)') 
Esempio n. 8
0
 def test_ibd_segments_ibdld(self):
     '''Calculate IBD segments in a nuclear family using IBDLD.'''
     segment_cache = im.ibdld.ibd_ld.IbdSegmentGlobalCacheIbdld(itu.FAMILY7 + '.ibd')
     segment_computer = im.ibdld.ibd_ld.IbdSegmentComputerIbdld(segment_cache, self.haplotype,
                                                       chrom=22,
                                                       sample_id=self.problem.pedigree.sample_id,
                                                       samples=[2, 8],
                                                       threshold=0.9,
                                                       params=PhaseParam())
     segment_set = segment.break_and_group_segments(segment_computer.segments)
     assert_segments_almost_equal(segment_set,
                                  [((38  , 2849), [], ((8, 1), (2, 1)))],
                                  full_data=False, decimal=3, err_msg='Wrong grouped IBDLD IBD segments')
     assert_equal(segment_set.errors, empty_errors_array(), 'IBDLD does not support errors but they are output?!')
Esempio n. 9
0
    def test_ibd_segments_both_parents(self):
        '''Test computing GERMLINE IBD segments.'''
        h_mat = ig._HapMatrix(self.problem, self.sibs)
        m = self.ibd_computer.ibd_segments(h_mat)
        assert_segments_almost_equal(
            m,
            [((0, 344), (16484792, 21449028, 4.964, 0), ((2, 0), (4, 0))),
             ((0, 344), (16484792, 21449028, 4.964, 0), ((1, 0), (4, 0))),
             ((0, 780), (16484792, 26920270, 10.435, 0), ((4, 1), (2, 1))),
             ((2145, 2996), (39608193, 48759228, 9.151, 0), ((1, 1), (2, 1))),
             ((2145, 2996), (39608193, 48759228, 9.151, 0), ((4, 1), (2, 1))),
             ((885, 3218), (27425790, 51156933, 23.731, 0), ((4, 1), (1, 1))),
             ((0, 3218), (16484792, 51156933, 34.672, 0), ((2, 0), (1, 0)))],
            full_data=True,
            decimal=3,
            err_msg='Wrong IBD segments, raw')
        # A transitive-logic test test to see that we don't miss any intervals with GERMLINE
        m.group_to_disjoint(False)
        assert_segments_almost_equal(
            m,
            [((0, 344), (16484792, 21449028, 4.964, 0), ((2, 0), (1, 0),
                                                         (4, 0))),
             ((0, 344), (16484792, 21449028, 4.964, 0), ((4, 1), (2, 1))),
             ((344, 780), (21449028, 26920270, 5.471, 0), ((2, 0), (1, 0))),
             ((344, 780), (21449028, 26920270, 5.471, 0), ((4, 1), (2, 1))),
             ((780, 885), (26920270, 27425790, 0.506, 0), ((2, 0), (1, 0))),
             ((885, 2145), (27425790, 39608193, 12.182, 0), ((2, 0), (1, 0))),
             ((885, 2145), (27425790, 39608193, 12.182, 0), ((4, 1), (1, 1))),
             ((2145, 2996), (39608193, 48759228, 9.151, 0), ((4, 1), (1, 1),
                                                             (2, 1))),
             ((2145, 2996), (39608193, 48759228, 9.151, 0), ((2, 0), (1, 0))),
             ((2996, 3218), (48759228, 51156933, 2.398, 0), ((2, 0), (1, 0))),
             ((2996, 3218), (48759228, 51156933, 2.398, 0), ((4, 1), (1, 1)))],
            full_data=True,
            decimal=3,
            err_msg='Wrong IBD segments, grouped')

        stats = np.array([(len(s.samples), s.length) for s in m])
        best_segment = np.lexsort((-stats[:, 1], -stats[:, 0]))[0]
        assert_equal(best_segment, 7,
                     'Wrong best segment (IBD set size + length)')
        assert_almost_equal(
            m[best_segment].length,
            9.15,
            decimal=2,
            err_msg='Wrong best segment (IBD set size + length)')
        assert_equal(m[best_segment].samples,
                     set([(4, 1), (1, 1), (2, 1)]),
                     err_msg='Wrong best segment (IBD set size + length)')
Esempio n. 10
0
    def test_ibs_segments(self):
        '''Test locating IBD segments between parent and child haplotypes.'''
        (parent, child, hap1, hap2) = (1, 2, 0, 1)
        het_snps = gt.where_heterozygous(self.haplotype.data, parent)
        
        segment_set = ibd.ibs_segments(self.haplotype, parent, child, hap1, hap2, het_snps, True)
        assert_segments_almost_equal(segment_set,
                                     [((3   , 172), (17080378, 18541497, 1.461, 0), ((1, 1), (2, 1))),
                                      ((193 , 3218), (18996226, 51156934, 32.161, 1), ((1, 0), (2, 1)))],
                                     full_data=True, decimal=3, err_msg='Wrong IBD segments') 

        segment_set = ibd.ibs_segments(self.haplotype, parent, child, hap1, hap2, het_snps, True,
                                       length_bound='base_pair', min_segment_length=10.0)
        assert_segments_almost_equal(segment_set,
                                     [((193 , 3218), (18996226, 51156934, 32.161, 1), ((1, 0), (2, 1)))],
                                     full_data=True, decimal=3, err_msg='Wrong IBD segments') 
    def test_ibd_segments_ibs(self):
        '''Test locating IBD segments between distant individuals. No IBD posterior filter (IBS=>IBD).'''
        relatives = self.__phased_sibs(self.s)
        segment_set = im.idist.ibd_segments_with_relatives(self.problem, self.s, relatives, self.params,
                                                           im.ibd_distant.prob_ibd_ibs)
        segment_set.group_to_disjoint()
        assert_segments_almost_equal(segment_set,
[((0   , 38  ), (16484792, 17561913,   1.077, 0), ((5, 1),(1, 0),(1, 1),(2, 1))),
 ((38  , 180 ), (17561913, 18562888,   1.001, 0), ((1, 0),(1, 1),(2, 1))),
 ((180 , 195 ), (18562888, 19030336,   0.467, 0), ((1, 0),(1, 1),(5, 0),(2, 1))),
 ((195 , 329 ), (19030336, 21242544,   2.212, 0), ((1, 0),(5, 0),(2, 1))),
 ((329 , 369 ), (21242544, 22485301,   1.243, 0), ((5, 1),(1, 0),(5, 0),(2, 1))),
 ((369 , 435 ), (22485301, 23627369,   1.142, 0), ((1, 0),(5, 0),(2, 1))),
 ((435 , 506 ), (23627369, 24235198,   0.608, 0), ((1, 0),(1, 1),(5, 0),(2, 1))),
 ((506 , 581 ), (24235198, 25304473,   1.069, 0), ((5, 1),(1, 0),(1, 1),(5, 0),(2, 1))),
 ((581 , 865 ), (25304473, 27370273,   2.066, 0), ((1, 0),(1, 1),(5, 0),(2, 1))),
 ((865 , 1032), (27370273, 28120707,   0.750, 0), ((1, 0),(2, 1),(1, 1),(5, 0),(4, 0))),
 ((1032, 1037), (28120707, 28165334,   0.045, 0), ((5, 0),(1, 0),(4, 1),(1, 1),(2, 1),(4, 0))),
 ((1037, 1109), (28165334, 29400515,   1.235, 0), ((5, 0),(5, 1),(1, 0),(4, 1),(1, 1),(2, 1),(4, 0))),
 ((1109, 1138), (29400515, 29495373,   0.095, 0), ((1, 0),(2, 1),(1, 1),(5, 0),(4, 0))),
 ((1138, 1249), (29495373, 30864692,   1.369, 0), ((5, 0),(1, 0),(4, 1),(1, 1),(2, 1),(4, 0))),
 ((1249, 1276), (30864692, 31207207,   0.343, 0), ((1, 0),(2, 1),(1, 1),(5, 0),(4, 0))),
 ((1276, 1460), (31207207, 33291742,   2.085, 0), ((5, 0),(5, 1),(1, 0),(1, 1),(2, 1),(4, 0))),
 ((1460, 1792), (33291742, 35344317,   2.053, 0), ((1, 0),(2, 1),(1, 1),(5, 0),(4, 0))),
 ((1792, 1934), (35344317, 36746079,   1.402, 0), ((5, 0),(1, 0),(4, 1),(1, 1),(2, 1),(4, 0))),
 ((1934, 2008), (36746079, 37383809,   0.638, 0), ((1, 0),(2, 1),(1, 1),(5, 0),(4, 0))),
 ((2008, 2052), (37383809, 37977282,   0.593, 0), ((5, 0),(1, 0),(4, 1),(1, 1),(2, 1),(4, 0))),
 ((2052, 2068), (37977282, 38538246,   0.561, 0), ((5, 0),(5, 1),(1, 0),(4, 1),(1, 1),(2, 1),(4, 0))),
 ((2068, 2170), (38538246, 39988277,   1.450, 0), ((5, 0),(5, 1),(1, 0),(1, 1),(2, 1),(4, 0))),
 ((2170, 2187), (39988277, 40351438,   0.363, 0), ((1, 0),(2, 1),(1, 1),(5, 0),(4, 0))),
 ((2187, 2189), (40351438, 40395084,   0.044, 0), ((5, 0),(1, 0),(4, 1),(1, 1),(2, 1),(4, 0))),
 ((2189, 2269), (40395084, 42235352,   1.840, 0), ((5, 0),(5, 1),(1, 0),(4, 1),(1, 1),(2, 1),(4, 0))),
 ((2269, 2313), (42235352, 42919125,   0.684, 0), ((5, 0),(5, 1),(1, 0),(1, 1),(2, 1),(4, 0))),
 ((2313, 2314), (42919125, 42982572,   0.063, 0), ((5, 0),(5, 1),(1, 0),(4, 1),(1, 1),(2, 1),(4, 0))),
 ((2314, 2315), (42982572, 43013836,   0.031, 0), ((5, 0),(1, 0),(4, 1),(1, 1),(2, 1),(4, 0))),
 ((2315, 2393), (43013836, 44023173,   1.009, 0), ((5, 0),(5, 1),(1, 0),(4, 1),(1, 1),(2, 1),(4, 0))),
 ((2393, 2414), (44023173, 44101411,   0.078, 0), ((5, 0),(1, 0),(4, 1),(1, 1),(2, 1),(4, 0))),
 ((2414, 2598), (44101411, 45409136,   1.308, 0), ((1, 0),(2, 1),(1, 1),(5, 0),(4, 0))),
 ((2598, 2661), (45409136, 45972017,   0.563, 0), ((1, 0),(1, 1),(2, 1),(4, 0))),
 ((2661, 2666), (45972017, 46060541,   0.089, 0), ((5, 1),(1, 0),(1, 1),(2, 1),(4, 0))),
 ((2666, 2744), (46060541, 47175815,   1.115, 0), ((5, 0),(5, 1),(1, 0),(4, 1),(1, 1),(2, 1),(4, 0))),
 ((2744, 2779), (47175815, 47387316,   0.212, 0), ((5, 0),(5, 1),(1, 0),(1, 1),(2, 1),(4, 0))),
 ((2779, 2835), (47387316, 47786315,   0.399, 0), ((1, 0),(2, 1),(1, 1),(5, 0),(4, 0))),
 ((2835, 3043), (47786315, 49171641,   1.385, 0), ((1, 0),(1, 1),(2, 1),(4, 0))),
 ((3043, 3178), (49171641, 50120525,   0.949, 0), ((5, 0),(1, 0),(4, 1),(1, 1),(2, 1),(4, 0))),
 ((3178, 3218), (50120525, 51156934,   1.036, 0), ((5, 0),(5, 1),(1, 0),(4, 1),(1, 1),(2, 1),(4, 0)))],
                                      decimal=3, err_msg='Wrong IBD segments') 
Esempio n. 12
0
 def test_ibd_segments_in_family(self):
     '''Test locating recombination locations and subsequently IBD regions between 
     parent and child haplotypes.'''
     segment_set = ibd.concatenate_segments(ip.ibd_segments_in_family(self.haplotype, self.family,
                                                                      PhaseParam.HET_FILL_THRESHOLD))
     assert_segments_almost_equal(segment_set,
                                [((3   , 172), (17080378, 18541497, 1.461, 0), ((1, 1), (2, 1))),
                                 ((193 , 3218), (18996226, 51156934, 32.161, 1), ((1, 0), (2, 1))),
                                 ((0   , 3218), (16484792, 51156934, 34.672, 4), ((1, 0), (3, 1))),
                                 ((3   , 240), (17080378, 19593301, 2.513, 0), ((1, 0), (4, 1))),
                                 ((256 , 3218), (19873357, 51156934, 31.284, 0), ((4, 1), (1, 1))),
                                 ((0   , 3218), (16484792, 51156934, 34.672, 0), ((5, 1), (1, 0))),
                                 ((3   , 2696), (17080378, 46630634, 29.550, 0), ((6, 1), (1, 1))),
                                 ((2718, 3218), (46853292, 51156934, 4.304, 1), ((1, 0), (6, 1))),
                                 ((0   , 3218), (16484792, 51156934, 34.672, 0), ((1, 0), (7, 1))),
                                 ((3   , 1908), (17080378, 36572515, 19.492, 0), ((8, 1), (1, 0))),
                                 ((1939, 3218), (36804282, 51156934, 14.353, 0), ((8, 1), (1, 1)))],
                                 full_data=True, decimal=3, err_msg='Wrong IBD segments')
     assert_equal(segment_set.errors,
                  [[2997, 2997, 132, 1364, 2493, 2800, 132, 1364, 2493, 2800, 2997, 2997],
                   [   1, 2, 1, 1, 1, 1, 3, 3, 3, 3, 1, 6]],
                  'Wrong genotype errors')
Esempio n. 13
0
 def test_ibd_segments(self):
     '''Test computing GERMLINE IBD segments.'''
     h_mat = ig._HapMatrix(self.problem, self.sibs)
     m = self.ibd_computer.ibd_segments(h_mat)
     m.group_to_disjoint()
     assert_segments_almost_equal(m,
                                 [((0   , 235), (16484792, 19567818, 3.083, 0), ((3, 0), (1, 0), (5, 0))),
                                  ((0   , 235), (16484792, 19567818, 3.083, 0), ((5, 1), (3, 1), (2, 1))),
                                  ((235 , 345), (19567818, 21809185, 2.241, 0), ((3, 0), (1, 0), (5, 0))),
                                  ((235 , 345), (19567818, 21809185, 2.241, 0), ((5, 1), (3, 1))),
                                  ((345 , 450), (21809185, 23817240, 2.008, 0), ((3, 0), (1, 0))),
                                  ((345 , 450), (21809185, 23817240, 2.008, 0), ((5, 1), (3, 1))),
                                  ((345 , 450), (21809185, 23817240, 2.008, 0), ((1, 1), (2, 1))),
                                  ((450 , 781), (23817240, 26924312, 3.107, 0), ((3, 0), (1, 0))),
                                  ((450 , 781), (23817240, 26924312, 3.107, 0), ((5, 1), (3, 1))),
                                  ((450 , 781), (23817240, 26924312, 3.107, 0), ((1, 1), (2, 1))),
                                  ((450 , 781), (23817240, 26924312, 3.107, 0), ((2, 0), (5, 0))),
                                  ((781 , 886), (26924312, 27427698, 0.503, 0), ((3, 0), (1, 0))),
                                  ((781 , 886), (26924312, 27427698, 0.503, 0), ((1, 1), (2, 1))),
                                  ((781 , 886), (26924312, 27427698, 0.503, 0), ((2, 0), (5, 0))),
                                  ((886 , 2157), (27427698, 39797178, 12.369, 0), ((5, 1), (1, 1), (2, 1))),
                                  ((886 , 2157), (27427698, 39797178, 12.369, 0), ((3, 0), (1, 0))),
                                  ((886 , 2157), (27427698, 39797178, 12.369, 0), ((2, 0), (5, 0))),
                                  ((2157, 2791), (39797178, 47440321, 7.643, 0), ((5, 1), (3, 1), (1, 1), (2, 1))),
                                  ((2157, 2791), (39797178, 47440321, 7.643, 0), ((3, 0), (1, 0))),
                                  ((2157, 2791), (39797178, 47440321, 7.643, 0), ((2, 0), (5, 0))),
                                  ((2791, 2901), (47440321, 48282594, 0.842, 0), ((5, 1), (3, 1), (1, 1), (2, 1))),
                                  ((2791, 2901), (47440321, 48282594, 0.842, 0), ((3, 0), (1, 0))),
                                  ((2901, 3012), (48282594, 48855412, 0.573, 0), ((5, 1), (3, 1), (1, 1), (2, 1))),
                                  ((2901, 3012), (48282594, 48855412, 0.573, 0), ((3, 0), (2, 0), (1, 0))),
                                  ((3012, 3218), (48855412, 51156933, 2.302, 0), ((3, 0), (2, 0), (1, 0))),
                                  ((3012, 3218), (48855412, 51156933, 2.302, 0), ((5, 1), (1, 1), (2, 1)))],
                         full_data=True, decimal=3, err_msg='Wrong IBD segments')
     stats = np.array([(len(s.samples), s.length) for s in m])
     best_segment = np.lexsort((-stats[:, 1], -stats[:, 0]))[0]
     #print np.lexsort((-stats[:, 1], -stats[:, 0]))
     # print m[best_segment]
     assert_equal(best_segment, 17, 'Wrong best segment (IBD set size + length)') 
Esempio n. 14
0
 def test_global_ibd_segments(self):
     '''Debug error that appeared after stage 2 - child had wrong hap color at SNP 2960
     in the middle of a long IBD segment. This error doesn''t appear in this isolated test.
     It depends on the ordering of processing samples and segments.'''
     
     # Before stage 2: no IBD segments should exist
     problem = im.io.read_npz(im.itu.FAMILY4_STAGE1)
     im.itu.assert_problem_stats(problem, 38616, 35586, 22)
     ibd = problem.info.ibd
     assert_equal(ibd.length, 0, 'Before stage 2: no IBD segments should exist')
     assert_equal(problem.h[2955:2965, 1, 0], [2, 2, 2, 2, 2, 2, 2, 2, 2, 0], 'Wrong mother haplotype') 
     assert_equal(problem.h[2955:2965, 4, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 1], 'Wrong child haplotype') 
     
     im.phase_family.family_phaser().run(problem, im.PhaseParam())
     
     # After: check IBD segment; (1, 0), (4, 1) should be IBD around SNP 2960
     assert_segments_almost_equal(ibd,
                                  [((0   , 176), (16484792, 18545634, 2.061, 0), ((2, 0), (0, 0))),
                                   ((187 , 2687), (18895227, 46242359, 27.347, 1), ((0, 1), (2, 0))),
                                   ((2687, 3216), (46336181, 51103692, 4.768, 0), ((2, 0), (0, 0))),
                                   ((0   , 3218), (16484792, 51156933, 34.672, 0), ((0, 1), (3, 0))),
                                   ((0   , 2470), (16484792, 44456692, 27.972, 0), ((0, 0), (4, 0))),
                                   ((2473, 3216), (44515806, 51103692, 6.588, 1), ((0, 1), (4, 0))),
                                   ((0   , 2985), (16484792, 48709188, 32.224, 0), ((0, 1), (5, 0))),
                                   ((2993, 3216), (48742097, 51103692, 2.362, 0), ((0, 0), (5, 0))),
                                   ((0   , 3218), (16484792, 51156933, 34.672, 0), ((1, 1), (2, 1))),
                                   ((4   , 36), (17087656, 17434521, 0.347, 0), ((3, 1), (1, 1))),
                                   ((42  , 2035), (17587680, 37662436, 20.075, 1), ((1, 0), (3, 1))),
                                   ((2047, 3217), (37902926, 51140316, 13.237, 0), ((3, 1), (1, 1))),
                                   ((11  , 804), (17285049, 27091750, 9.807, 0), ((4, 1), (1, 1))),
                                   ((823 , 3217), (27200942, 51140316, 23.939, 0), ((1, 0), (4, 1))),
                                   ((11  , 14), (17285049, 17307742, 0.023, 0), ((5, 1), (1, 0))),
                                   ((31  , 3217), (17415572, 51140316, 33.725, 1), ((5, 1), (1, 1)))],
                                  decimal=3, err_msg='Wrong IBD segments') 
     im.itu.assert_problem_stats(problem, 38616, 38576, 30)
     assert_equal(problem.h[2955:2965, 1, 0], [2, 2, 2, 2, 2, 2, 2, 2, 2, 1], 'Wrong mother haplotype') 
     assert_equal(problem.h[2955:2965, 4, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2, 1], 'Wrong child haplotype') 
    def test_ibd_segments_hmm(self):
        '''Test locating IBD segments between the unphased proband and its sib surrogate parents.
        Uses HMM IBD posterior.'''
        relatives = self.__phased_sibs(self.s)
        segment_set = im.idist.ibd_segments_with_relatives(self.problem, self.s, relatives, PhaseParam(debug=False),
                                                           im.ibd_hmm.prob_ibd_hmm)
        segment_set.group_to_disjoint()
        assert_segments_almost_equal(segment_set,
[((0   , 96  ), (16484792, 17948473,   1.464, 0), ((2, 0),(3, 1),(4, 1),(2, 1))),
 ((96  , 344 ), (17948473, 21460008,   3.512, 0), ((3, 1),(4, 1),(2, 1))),
 ((344 , 380 ), (21460008, 22554306,   1.094, 0), ((2, 0),(3, 1),(4, 1),(2, 1),(4, 0))),
 ((380 , 383 ), (22554306, 22555078,   0.001, 0), ((3, 1),(4, 1),(2, 1))),
 ((383 , 438 ), (22555078, 23636541,   1.081, 0), ((2, 0),(3, 1),(4, 1),(2, 1),(4, 0))),
 ((438 , 442 ), (23636541, 23695404,   0.059, 0), ((3, 1),(4, 1),(2, 1))),
 ((442 , 519 ), (23695404, 24406778,   0.711, 0), ((2, 0),(3, 1),(4, 1),(2, 1),(4, 0))),
 ((519 , 557 ), (24406778, 25088629,   0.682, 0), ((0, 1),(2, 0),(3, 1),(4, 1),(2, 1),(4, 0))),
 ((557 , 951 ), (25088629, 27698217,   2.610, 0), ((0, 1),(3, 1),(4, 1),(2, 1))),
 ((951 , 969 ), (27698217, 27832985,   0.135, 0), ((0, 1),(2, 0),(3, 1),(4, 1),(2, 1))),
 ((969 , 1019), (27832985, 28093392,   0.260, 0), ((2, 0),(3, 1),(4, 1),(2, 1))),
 ((1019, 1147), (28093392, 29670939,   1.578, 0), ((2, 0),(3, 1),(4, 1),(2, 1),(4, 0))),
 ((1147, 1188), (29670939, 30113960,   0.443, 0), ((2, 0),(3, 1),(4, 1),(2, 1))),
 ((1188, 1403), (30113960, 32950053,   2.836, 0), ((2, 0),(3, 1),(4, 1),(2, 1),(4, 0))),
 ((1403, 1943), (32950053, 36891858,   3.942, 0), ((2, 0),(3, 1),(4, 1),(2, 1))),
 ((1943, 2053), (36891858, 37982012,   1.090, 0), ((2, 0),(3, 1),(4, 1),(2, 1),(4, 0))),
 ((2053, 2055), (37982012, 38086574,   0.105, 0), ((2, 0),(3, 1),(4, 1),(2, 1))),
 ((2055, 2133), (38086574, 39454432,   1.368, 0), ((2, 0),(3, 1),(4, 1),(2, 1),(4, 0))),
 ((2133, 2174), (39454432, 40018212,   0.564, 0), ((2, 0),(3, 1),(4, 1),(2, 1))),
 ((2174, 2221), (40018212, 41107688,   1.089, 0), ((2, 0),(3, 1),(4, 1),(2, 1),(4, 0))),
 ((2221, 2612), (41107688, 45515269,   4.408, 0), ((2, 0),(3, 1),(4, 1),(2, 1))),
 ((2612, 2661), (45515269, 45972017,   0.457, 0), ((2, 0),(3, 1),(4, 1),(2, 1),(4, 0))),
 ((2661, 2735), (45972017, 47094390,   1.122, 0), ((0, 1),(0, 0),(3, 1),(2, 1),(2, 0),(1, 0),(4, 1),(1, 1),(4, 0))),
 ((2735, 2945), (47094390, 48569604,   1.475, 0), ((2, 0),(0, 0),(1, 0),(3, 1),(4, 1),(2, 1),(4, 0))),
 ((2945, 2991), (48569604, 48741583,   0.172, 0), ((2, 0),(0, 0),(1, 0),(3, 1),(4, 1),(4, 0))),
 ((2991, 3127), (48741583, 49752332,   1.011, 0), ((2, 0),(0, 0),(1, 0),(3, 1),(4, 1),(2, 1),(4, 0))),
 ((3127, 3177), (49752332, 50120255,   0.368, 0), ((2, 0),(1, 0),(3, 1),(4, 1),(0, 0))),
 ((3177, 3218), (50120255, 51156934,   1.037, 0), ((0, 1),(0, 0),(3, 1),(2, 1),(2, 0),(1, 0),(4, 1),(1, 1),(4, 0)))],
                                      decimal=3, err_msg='Wrong IBD segments') 
    def test_ibd_segments_in_family(self):
        '''Test locating recombination locations and subsequently IBD regions between 
        parent and child haplotypes.'''
        segment_set = ibd.concatenate_segments(ip.ibd_segments_in_family(self.problem.haplotype, self.family,
                                                                         PhaseParam.HET_FILL_THRESHOLD))
        assert_segments_almost_equal(segment_set,
                                   [((4   , 1411), (17087656, 32978753, 15.891, 0), ((2, 0), (0, 0))),
                                    ((1413, 3215), (33013062, 51103692, 18.091, 1), ((0, 1), (2, 0))),
                                    ((0   , 3218), (16484792, 51156934, 34.672, 1), ((0, 1), (3, 0))),
                                    ((4   , 2551), (17087656, 45007348, 27.920, 1), ((0, 1), (4, 0))),
                                    ((2569, 3215), (45198494, 51103692, 5.905, 0), ((0, 0), (4, 0))),
                                    ((0   , 3218), (16484792, 51156934, 34.672, 1), ((0, 0), (5, 0))),
                                    ((4   , 795), (17087656, 27011420, 9.924, 0), ((0, 0), (6, 0))),
                                    ((805 , 3215), (27119061, 51103692, 23.985, 1), ((0, 1), (6, 0))),
                                    ((2   , 2650), (17075353, 45892433, 28.817, 0), ((1, 1), (2, 1))),
                                    ((2657, 3218), (45940934, 51156934, 5.216, 2), ((1, 0), (2, 1))),
                                    ((1   , 576), (17065079, 25228375, 8.163, 0), ((3, 1), (1, 1))),
                                    ((600 , 3218), (25444874, 51156934, 25.712, 2), ((1, 0), (3, 1))),
                                    ((2   , 1978), (17075353, 37228277, 20.153, 2), ((1, 0), (4, 1))),
                                    ((2019, 3218), (37509844, 51156934, 13.647, 0), ((4, 1), (1, 1))),
                                    ((0   , 3218), (16484792, 51156934, 34.672, 3), ((5, 1), (1, 0))),
                                    ((2   , 301), (17075353, 20993766, 3.918, 0), ((6, 1), (1, 1))),
                                    ((334 , 3218), (21363960, 51156934, 29.793, 2), ((1, 0), (6, 1)))],
                                    full_data=True, decimal=3, err_msg='Wrong IBD segments')

        # Check that there are at most 4 distinct haplotypes at each SNP        
        segment_set.group_to_disjoint(True)
        assert_segments_almost_equal(segment_set,
                                     [((0   , 1), (16484792, 17065079, 0.580, 0), ((5, 1), (1, 0))),
                                      ((0   , 1), (16484792, 17065079, 0.580, 0), ((0, 1), (3, 0))),
                                      ((0   , 1), (16484792, 17065079, 0.580, 0), ((0, 0), (5, 0))),
                                      ((1   , 2), (17065079, 17075353, 0.010, 0), ((5, 1), (1, 0))),
                                      ((1   , 2), (17065079, 17075353, 0.010, 0), ((3, 1), (1, 1))),
                                      ((1   , 2), (17065079, 17075353, 0.010, 0), ((0, 1), (3, 0))),
                                      ((1   , 2), (17065079, 17075353, 0.010, 0), ((0, 0), (5, 0))),
                                      ((2   , 4), (17075353, 17087656, 0.012, 0), ((0, 0), (5, 0))),
                                      ((2   , 4), (17075353, 17087656, 0.012, 0), ((0, 1), (3, 0))),
                                      ((2   , 4), (17075353, 17087656, 0.012, 0), ((6, 1), (3, 1), (1, 1), (2, 1))),
                                      ((2   , 4), (17075353, 17087656, 0.012, 0), ((5, 1), (1, 0), (4, 1))),
                                      ((4   , 301), (17087656, 20993766, 3.906, 0), ((2, 0), (0, 0), (6, 0), (5, 0))),
                                      ((4   , 301), (17087656, 20993766, 3.906, 0), ((0, 1), (3, 0), (4, 0))),
                                      ((4   , 301), (17087656, 20993766, 3.906, 0), ((6, 1), (3, 1), (1, 1), (2, 1))),
                                      ((4   , 301), (17087656, 20993766, 3.906, 0), ((5, 1), (1, 0), (4, 1))),
                                      ((301 , 334), (20993766, 21363960, 0.370, 0), ((2, 0), (0, 0), (6, 0), (5, 0))),
                                      ((301 , 334), (20993766, 21363960, 0.370, 0), ((0, 1), (3, 0), (4, 0))),
                                      ((301 , 334), (20993766, 21363960, 0.370, 0), ((3, 1), (1, 1), (2, 1))),
                                      ((301 , 334), (20993766, 21363960, 0.370, 0), ((5, 1), (1, 0), (4, 1))),
                                      ((334 , 576), (21363960, 25228375, 3.864, 0), ((2, 0), (0, 0), (6, 0), (5, 0))),
                                      ((334 , 576), (21363960, 25228375, 3.864, 0), ((0, 1), (3, 0), (4, 0))),
                                      ((334 , 576), (21363960, 25228375, 3.864, 0), ((3, 1), (1, 1), (2, 1))),
                                      ((334 , 576), (21363960, 25228375, 3.864, 0), ((5, 1), (6, 1), (4, 1), (1, 0))),
                                      ((576 , 600), (25228375, 25444874, 0.216, 0), ((1, 1), (2, 1))),
                                      ((576 , 600), (25228375, 25444874, 0.216, 0), ((2, 0), (0, 0), (6, 0), (5, 0))),
                                     ((576 , 600), (25228375, 25444874, 0.216, 0), ((0, 1), (3, 0), (4, 0))),
                                     ((576 , 600), (25228375, 25444874, 0.216, 0), ((5, 1), (6, 1), (4, 1), (1, 0))),
                                     ((600 , 795), (25444874, 27011420, 1.567, 0), ((5, 1), (6, 1), (3, 1), (4, 1), (1, 0))),
                                     ((600 , 795), (25444874, 27011420, 1.567, 0), ((2, 0), (0, 0), (6, 0), (5, 0))),
                                     ((600 , 795), (25444874, 27011420, 1.567, 0), ((0, 1), (3, 0), (4, 0))),
                                     ((600 , 795), (25444874, 27011420, 1.567, 0), ((1, 1), (2, 1))),
                                     ((795 , 805), (27011420, 27119061, 0.108, 0), ((5, 1), (6, 1), (3, 1), (4, 1), (1, 0))),
                                     ((795 , 805), (27011420, 27119061, 0.108, 0), ((2, 0), (0, 0), (5, 0))),
                                     ((795 , 805), (27011420, 27119061, 0.108, 0), ((0, 1), (3, 0), (4, 0))),
                                     ((795 , 805), (27011420, 27119061, 0.108, 0), ((1, 1), (2, 1))),
                                     ((805 , 1411), (27119061, 32978753, 5.860, 0), ((5, 1), (6, 1), (3, 1), (4, 1), (1, 0))),
                                     ((805 , 1411), (27119061, 32978753, 5.860, 0), ((2, 0), (0, 0), (5, 0))),
                                     ((805 , 1411), (27119061, 32978753, 5.860, 0), ((0, 1), (3, 0), (6, 0), (4, 0))),
                                     ((805 , 1411), (27119061, 32978753, 5.860, 0), ((1, 1), (2, 1))),
                                     ((1411, 1413), (32978753, 33013062, 0.034, 0), ((5, 1), (6, 1), (3, 1), (4, 1), (1, 0))),
                                     ((1411, 1413), (32978753, 33013062, 0.034, 0), ((1, 1), (2, 1))),
                                     ((1411, 1413), (32978753, 33013062, 0.034, 0), ((0, 1), (3, 0), (6, 0), (4, 0))),
                                     ((1411, 1413), (32978753, 33013062, 0.034, 0), ((0, 0), (5, 0))),
                                     ((1413, 1978), (33013062, 37228277, 4.215, 0), ((5, 1), (6, 1), (3, 1), (4, 1), (1, 0))),
                                     ((1413, 1978), (33013062, 37228277, 4.215, 0), ((0, 1), (3, 0), (4, 0), (6, 0), (2, 0))),
                                     ((1413, 1978), (33013062, 37228277, 4.215, 0), ((1, 1), (2, 1))),
                                     ((1413, 1978), (33013062, 37228277, 4.215, 0), ((0, 0), (5, 0))),
                                     ((1978, 2019), (37228277, 37509844, 0.282, 0), ((1, 1), (2, 1))),
                                     ((1978, 2019), (37228277, 37509844, 0.282, 0), ((0, 1), (3, 0), (4, 0), (6, 0), (2, 0))),
                                     ((1978, 2019), (37228277, 37509844, 0.282, 0), ((5, 1), (6, 1), (3, 1), (1, 0))),
                                     ((1978, 2019), (37228277, 37509844, 0.282, 0), ((0, 0), (5, 0))),
                                     ((2019, 2551), (37509844, 45007348, 7.498, 0), ((0, 1), (3, 0), (4, 0), (6, 0), (2, 0))),
                                     ((2019, 2551), (37509844, 45007348, 7.498, 0), ((0, 0), (5, 0))),
                                     ((2019, 2551), (37509844, 45007348, 7.498, 0), ((5, 1), (6, 1), (3, 1), (1, 0))),
                                     ((2019, 2551), (37509844, 45007348, 7.498, 0), ((4, 1), (1, 1), (2, 1))),
                                     ((2551, 2569), (45007348, 45198494, 0.191, 0), ((0, 0), (5, 0))),
                                     ((2551, 2569), (45007348, 45198494, 0.191, 0), ((0, 1), (3, 0), (6, 0), (2, 0))),
                                     ((2551, 2569), (45007348, 45198494, 0.191, 0), ((5, 1), (6, 1), (3, 1), (1, 0))),
                                     ((2551, 2569), (45007348, 45198494, 0.191, 0), ((4, 1), (1, 1), (2, 1))),
                                     ((2569, 2650), (45198494, 45892433, 0.694, 0), ((0, 0), (5, 0), (4, 0))),
                                     ((2569, 2650), (45198494, 45892433, 0.694, 0), ((0, 1), (3, 0), (6, 0), (2, 0))),
                                     ((2569, 2650), (45198494, 45892433, 0.694, 0), ((5, 1), (6, 1), (3, 1), (1, 0))),
                                     ((2569, 2650), (45198494, 45892433, 0.694, 0), ((4, 1), (1, 1), (2, 1))),
                                     ((2650, 2657), (45892433, 45940934, 0.049, 0), ((0, 0), (5, 0), (4, 0))),
                                     ((2650, 2657), (45892433, 45940934, 0.049, 0), ((0, 1), (3, 0), (6, 0), (2, 0))),
                                     ((2650, 2657), (45892433, 45940934, 0.049, 0), ((5, 1), (6, 1), (3, 1), (1, 0))),
                                     ((2650, 2657), (45892433, 45940934, 0.049, 0), ((4, 1), (1, 1))),
                                     ((2657, 3215), (45940934, 51103692, 5.163, 0), ((5, 1), (6, 1), (3, 1), (1, 0), (2, 1))),
                                     ((2657, 3215), (45940934, 51103692, 5.163, 0), ((0, 1), (3, 0), (6, 0), (2, 0))),
                                     ((2657, 3215), (45940934, 51103692, 5.163, 0), ((0, 0), (5, 0), (4, 0))),
                                     ((2657, 3215), (45940934, 51103692, 5.163, 0), ((4, 1), (1, 1))),
                                     ((3215, 3218), (51103692, 51156934, 0.053, 0), ((5, 1), (6, 1), (3, 1), (1, 0), (2, 1))),
                                     ((3215, 3218), (51103692, 51156934, 0.053, 0), ((4, 1), (1, 1))),
                                     ((3215, 3218), (51103692, 51156934, 0.053, 0), ((0, 1), (3, 0))),
                                     ((3215, 3218), (51103692, 51156934, 0.053, 0), ((0, 0), (5, 0)))],
                                     full_data=True, decimal=3, err_msg='Wrong IBD segments')
        assert_equal(segment_set.errors,
                     [[2162, 2162, 2162, 2162, 2162, 2162, 2162, 2162, 2162, 2162, 2846, 3202, 2846,
                       3202, 1092, 3202, 1092, 3202, 3, 1092, 3, 1092, 3, 1092, 3202, 3, 1092, 3202,
                        1092, 3202, 1092, 3202],
                      [0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 1, 1, 2, 2, 1, 1, 3, 3, 1, 1, 4, 4, 1, 1, 1, 5, 5,
                       5, 1, 1, 6, 6]],
                     'Wrong genotype errors')
        
        self.assertTrue(max(len(list(g)) for (_, g) in itertools.groupby(segment_set, lambda segment: segment.snp)) <= 4,
                        'Too many distinct haplotypes in nuclear family')
        
        # Extract IBD segments of child's haplotype vs. sibs
        segments_of_30 = SegmentSet(Segment(x.snp, x.samples - set([(0, 0), (0, 1), (1, 0), (1, 1)]), x.bp, error_snps=x.error_snps)
                                   for x in segment_set if (3, 0) in x.samples)
        segments_of_30.merge_consecutive()
        assert_segments_almost_equal(segments_of_30,
                                     [((0   , 4), (16484792, 17087656, 0.603, 0), ((3, 0),)),
                                      ((4   , 805), (17087656, 27119061, 10.031, 0), ((3, 0), (4, 0))),
                                      ((805 , 1413), (27119061, 33013062, 5.894, 0), ((3, 0), (6, 0), (4, 0))),
                                      ((1413, 2551), (33013062, 45007348, 11.994, 0), ((3, 0), (2, 0), (6, 0), (4, 0))),
                                      ((2551, 3215), (45007348, 51103692, 6.096, 0), ((3, 0), (2, 0), (6, 0))),
                                      ((3215, 3218), (51103692, 51156934, 0.053, 0), ((3, 0),))],
                                     full_data=True, decimal=3, err_msg='Wrong IBD segments')

        segments_of_31 = SegmentSet(Segment(x.snp, x.samples - set([(0, 0), (0, 1), (1, 0), (1, 1)]), x.bp, error_snps=x.error_snps)
                                   for x in segment_set if (3, 1) in x.samples)
        segments_of_31.merge_consecutive()
        assert_segments_almost_equal(segments_of_31,
                                     [((1   , 2), (17065079, 17075353, 0.010, 0), ((3, 1),)),
                                      ((2   , 301), (17075353, 20993766, 3.918, 0), ((6, 1), (3, 1), (2, 1))),
                                      ((301 , 576), (20993766, 25228375, 4.235, 0), ((3, 1), (2, 1))),
                                      ((600 , 1978), (25444874, 37228277, 11.783, 0), ((5, 1), (6, 1), (3, 1), (4, 1))),
                                      ((1978, 2657), (37228277, 45940934, 8.713, 0), ((5, 1), (6, 1), (3, 1))),
                                      ((2657, 3218), (45940934, 51156934, 5.216, 0), ((5, 1), (6, 1), (3, 1), (2, 1)))],
                                     full_data=True, decimal=3, err_msg='Wrong IBD segments')
 def test_ibd_segments_ibs(self):
     '''Test locating IBD segments between distant individuals. No IBD posterior filter (IBS=>IBD).'''
     relatives = self.__phased_sibs(self.s)
     segment_set = im.idist.ibd_segments_with_relatives(
         self.problem, self.s, relatives, self.params,
         im.ibd_distant.prob_ibd_ibs)
     segment_set.group_to_disjoint()
     assert_segments_almost_equal(
         segment_set,
         [((0, 38), (16484792, 17561913, 1.077, 0), ((5, 1), (1, 0), (1, 1),
                                                     (2, 1))),
          ((38, 180), (17561913, 18562888, 1.001, 0), ((1, 0), (1, 1),
                                                       (2, 1))),
          ((180, 195), (18562888, 19030336, 0.467, 0), ((1, 0), (1, 1),
                                                        (5, 0), (2, 1))),
          ((195, 329), (19030336, 21242544, 2.212, 0), ((1, 0), (5, 0),
                                                        (2, 1))),
          ((329, 369), (21242544, 22485301, 1.243, 0), ((5, 1), (1, 0),
                                                        (5, 0), (2, 1))),
          ((369, 435), (22485301, 23627369, 1.142, 0), ((1, 0), (5, 0),
                                                        (2, 1))),
          ((435, 506), (23627369, 24235198, 0.608, 0), ((1, 0), (1, 1),
                                                        (5, 0), (2, 1))),
          ((506, 581), (24235198, 25304473, 1.069, 0),
           ((5, 1), (1, 0), (1, 1), (5, 0), (2, 1))),
          ((581, 865), (25304473, 27370273, 2.066, 0), ((1, 0), (1, 1),
                                                        (5, 0), (2, 1))),
          ((865, 1032), (27370273, 28120707, 0.750, 0),
           ((1, 0), (2, 1), (1, 1), (5, 0), (4, 0))),
          ((1032, 1037), (28120707, 28165334, 0.045, 0),
           ((5, 0), (1, 0), (4, 1), (1, 1), (2, 1), (4, 0))),
          ((1037, 1109), (28165334, 29400515, 1.235, 0),
           ((5, 0), (5, 1), (1, 0), (4, 1), (1, 1), (2, 1), (4, 0))),
          ((1109, 1138), (29400515, 29495373, 0.095, 0),
           ((1, 0), (2, 1), (1, 1), (5, 0), (4, 0))),
          ((1138, 1249), (29495373, 30864692, 1.369, 0),
           ((5, 0), (1, 0), (4, 1), (1, 1), (2, 1), (4, 0))),
          ((1249, 1276), (30864692, 31207207, 0.343, 0),
           ((1, 0), (2, 1), (1, 1), (5, 0), (4, 0))),
          ((1276, 1460), (31207207, 33291742, 2.085, 0),
           ((5, 0), (5, 1), (1, 0), (1, 1), (2, 1), (4, 0))),
          ((1460, 1792), (33291742, 35344317, 2.053, 0),
           ((1, 0), (2, 1), (1, 1), (5, 0), (4, 0))),
          ((1792, 1934), (35344317, 36746079, 1.402, 0),
           ((5, 0), (1, 0), (4, 1), (1, 1), (2, 1), (4, 0))),
          ((1934, 2008), (36746079, 37383809, 0.638, 0),
           ((1, 0), (2, 1), (1, 1), (5, 0), (4, 0))),
          ((2008, 2052), (37383809, 37977282, 0.593, 0),
           ((5, 0), (1, 0), (4, 1), (1, 1), (2, 1), (4, 0))),
          ((2052, 2068), (37977282, 38538246, 0.561, 0),
           ((5, 0), (5, 1), (1, 0), (4, 1), (1, 1), (2, 1), (4, 0))),
          ((2068, 2170), (38538246, 39988277, 1.450, 0),
           ((5, 0), (5, 1), (1, 0), (1, 1), (2, 1), (4, 0))),
          ((2170, 2187), (39988277, 40351438, 0.363, 0),
           ((1, 0), (2, 1), (1, 1), (5, 0), (4, 0))),
          ((2187, 2189), (40351438, 40395084, 0.044, 0),
           ((5, 0), (1, 0), (4, 1), (1, 1), (2, 1), (4, 0))),
          ((2189, 2269), (40395084, 42235352, 1.840, 0),
           ((5, 0), (5, 1), (1, 0), (4, 1), (1, 1), (2, 1), (4, 0))),
          ((2269, 2313), (42235352, 42919125, 0.684, 0),
           ((5, 0), (5, 1), (1, 0), (1, 1), (2, 1), (4, 0))),
          ((2313, 2314), (42919125, 42982572, 0.063, 0),
           ((5, 0), (5, 1), (1, 0), (4, 1), (1, 1), (2, 1), (4, 0))),
          ((2314, 2315), (42982572, 43013836, 0.031, 0),
           ((5, 0), (1, 0), (4, 1), (1, 1), (2, 1), (4, 0))),
          ((2315, 2393), (43013836, 44023173, 1.009, 0),
           ((5, 0), (5, 1), (1, 0), (4, 1), (1, 1), (2, 1), (4, 0))),
          ((2393, 2414), (44023173, 44101411, 0.078, 0),
           ((5, 0), (1, 0), (4, 1), (1, 1), (2, 1), (4, 0))),
          ((2414, 2598), (44101411, 45409136, 1.308, 0),
           ((1, 0), (2, 1), (1, 1), (5, 0), (4, 0))),
          ((2598, 2661), (45409136, 45972017, 0.563, 0), ((1, 0), (1, 1),
                                                          (2, 1), (4, 0))),
          ((2661, 2666), (45972017, 46060541, 0.089, 0),
           ((5, 1), (1, 0), (1, 1), (2, 1), (4, 0))),
          ((2666, 2744), (46060541, 47175815, 1.115, 0),
           ((5, 0), (5, 1), (1, 0), (4, 1), (1, 1), (2, 1), (4, 0))),
          ((2744, 2779), (47175815, 47387316, 0.212, 0),
           ((5, 0), (5, 1), (1, 0), (1, 1), (2, 1), (4, 0))),
          ((2779, 2835), (47387316, 47786315, 0.399, 0),
           ((1, 0), (2, 1), (1, 1), (5, 0), (4, 0))),
          ((2835, 3043), (47786315, 49171641, 1.385, 0), ((1, 0), (1, 1),
                                                          (2, 1), (4, 0))),
          ((3043, 3178), (49171641, 50120525, 0.949, 0),
           ((5, 0), (1, 0), (4, 1), (1, 1), (2, 1), (4, 0))),
          ((3178, 3218), (50120525, 51156934, 1.036, 0),
           ((5, 0), (5, 1), (1, 0), (4, 1), (1, 1), (2, 1), (4, 0)))],
         decimal=3,
         err_msg='Wrong IBD segments')
Esempio n. 18
0
 def test_ibd_segments_hmm(self):
     '''Test locating IBD segments between the unphased proband and its sib surrogate parents.
     Uses HMM IBD posterior.'''
     relatives = self.__phased_sibs(self.s)
     segment_set = im.idist.ibd_segments_with_relatives(
         self.problem, self.s, relatives, PhaseParam(debug=False),
         im.ibd_hmm.prob_ibd_hmm)
     segment_set.group_to_disjoint()
     assert_segments_almost_equal(
         segment_set,
         [((0, 96), (16484792, 17948473, 1.464, 0), ((2, 0), (3, 1), (4, 1),
                                                     (2, 1))),
          ((96, 344), (17948473, 21460008, 3.512, 0), ((3, 1), (4, 1),
                                                       (2, 1))),
          ((344, 380), (21460008, 22554306, 1.094, 0),
           ((2, 0), (3, 1), (4, 1), (2, 1), (4, 0))),
          ((380, 383), (22554306, 22555078, 0.001, 0), ((3, 1), (4, 1),
                                                        (2, 1))),
          ((383, 438), (22555078, 23636541, 1.081, 0),
           ((2, 0), (3, 1), (4, 1), (2, 1), (4, 0))),
          ((438, 442), (23636541, 23695404, 0.059, 0), ((3, 1), (4, 1),
                                                        (2, 1))),
          ((442, 519), (23695404, 24406778, 0.711, 0),
           ((2, 0), (3, 1), (4, 1), (2, 1), (4, 0))),
          ((519, 557), (24406778, 25088629, 0.682, 0),
           ((0, 1), (2, 0), (3, 1), (4, 1), (2, 1), (4, 0))),
          ((557, 951), (25088629, 27698217, 2.610, 0), ((0, 1), (3, 1),
                                                        (4, 1), (2, 1))),
          ((951, 969), (27698217, 27832985, 0.135, 0),
           ((0, 1), (2, 0), (3, 1), (4, 1), (2, 1))),
          ((969, 1019), (27832985, 28093392, 0.260, 0), ((2, 0), (3, 1),
                                                         (4, 1), (2, 1))),
          ((1019, 1147), (28093392, 29670939, 1.578, 0),
           ((2, 0), (3, 1), (4, 1), (2, 1), (4, 0))),
          ((1147, 1188), (29670939, 30113960, 0.443, 0), ((2, 0), (3, 1),
                                                          (4, 1), (2, 1))),
          ((1188, 1403), (30113960, 32950053, 2.836, 0),
           ((2, 0), (3, 1), (4, 1), (2, 1), (4, 0))),
          ((1403, 1943), (32950053, 36891858, 3.942, 0), ((2, 0), (3, 1),
                                                          (4, 1), (2, 1))),
          ((1943, 2053), (36891858, 37982012, 1.090, 0),
           ((2, 0), (3, 1), (4, 1), (2, 1), (4, 0))),
          ((2053, 2055), (37982012, 38086574, 0.105, 0), ((2, 0), (3, 1),
                                                          (4, 1), (2, 1))),
          ((2055, 2133), (38086574, 39454432, 1.368, 0),
           ((2, 0), (3, 1), (4, 1), (2, 1), (4, 0))),
          ((2133, 2174), (39454432, 40018212, 0.564, 0), ((2, 0), (3, 1),
                                                          (4, 1), (2, 1))),
          ((2174, 2221), (40018212, 41107688, 1.089, 0),
           ((2, 0), (3, 1), (4, 1), (2, 1), (4, 0))),
          ((2221, 2612), (41107688, 45515269, 4.408, 0), ((2, 0), (3, 1),
                                                          (4, 1), (2, 1))),
          ((2612, 2661), (45515269, 45972017, 0.457, 0),
           ((2, 0), (3, 1), (4, 1), (2, 1), (4, 0))),
          ((2661, 2735), (45972017, 47094390, 1.122, 0),
           ((0, 1), (0, 0), (3, 1), (2, 1), (2, 0), (1, 0), (4, 1), (1, 1),
            (4, 0))),
          ((2735, 2945), (47094390, 48569604, 1.475, 0),
           ((2, 0), (0, 0), (1, 0), (3, 1), (4, 1), (2, 1), (4, 0))),
          ((2945, 2991), (48569604, 48741583, 0.172, 0),
           ((2, 0), (0, 0), (1, 0), (3, 1), (4, 1), (4, 0))),
          ((2991, 3127), (48741583, 49752332, 1.011, 0),
           ((2, 0), (0, 0), (1, 0), (3, 1), (4, 1), (2, 1), (4, 0))),
          ((3127, 3177), (49752332, 50120255, 0.368, 0),
           ((2, 0), (1, 0), (3, 1), (4, 1), (0, 0))),
          ((3177, 3218), (50120255, 51156934, 1.037, 0),
           ((0, 1), (0, 0), (3, 1), (2, 1), (2, 0), (1, 0), (4, 1), (1, 1),
            (4, 0)))],
         decimal=3,
         err_msg='Wrong IBD segments')
Esempio n. 19
0
    def test_ibd_segments(self):
        '''Test locating IBD segments between distant individuals..'''
        segment_set = im.ibd_distant.ibd_segments_with_surrogate_parents(self.problem, 14, 1, 6, params=im.PhaseParam(debug=False),
                                                                         prob_ibd_calculator=im.ibd_hmm.prob_ibd_hmm)
        segment_set.group_to_disjoint()
        assert_segments_almost_equal(segment_set,
[((0   , 76), (16484792, 17844295, 1.360, 0), ((16, 1), (16, 0), (23, 0), (14, 0), (23, 1), (1, 0), (1, 1))),
 ((0   , 76), (16484792, 17844295, 1.360, 0), ((5, 1), (14, 1), (5, 0))),
 ((76  , 90), (17844295, 17909524, 0.065, 0), ((16, 1), (23, 0), (14, 0), (23, 1), (1, 0), (1, 1))),
 ((76  , 90), (17844295, 17909524, 0.065, 0), ((5, 1), (14, 1), (5, 0))),
 ((90  , 95), (17909524, 17930263, 0.021, 0), ((16, 1), (16, 0), (23, 0), (14, 0), (23, 1), (1, 0), (1, 1))),
 ((90  , 95), (17909524, 17930263, 0.021, 0), ((5, 1), (14, 1), (5, 0))),
 ((95  , 96), (17930263, 17948473, 0.018, 0), ((16, 1), (16, 0), (14, 0), (23, 1), (1, 0), (1, 1))),
 ((95  , 96), (17930263, 17948473, 0.018, 0), ((5, 1), (14, 1), (5, 0))),
 ((96  , 100), (17948473, 17987962, 0.039, 0), ((16, 1), (16, 0), (14, 0), (1, 1))),
 ((100 , 226), (17987962, 19486391, 1.498, 0), ((16, 1), (16, 0), (23, 0), (14, 0), (23, 1), (1, 0), (1, 1))),
 ((100 , 226), (17987962, 19486391, 1.498, 0), ((5, 1), (14, 1), (5, 0))),
 ((226 , 251), (19486391, 19787736, 0.301, 0), ((16, 0), (23, 0), (14, 0), (23, 1), (1, 0), (1, 1))),
 ((226 , 251), (19486391, 19787736, 0.301, 0), ((5, 1), (14, 1), (5, 0))),
 ((251 , 275), (19787736, 20075858, 0.288, 0), ((16, 1), (16, 0), (23, 0), (14, 0), (23, 1), (1, 0), (1, 1))),
 ((251 , 275), (19787736, 20075858, 0.288, 0), ((5, 1), (14, 1), (5, 0))),
 ((275 , 279), (20075858, 20742450, 0.667, 0), ((16, 1), (1, 0), (14, 0))),
 ((279 , 300), (20742450, 20993519, 0.251, 0), ((16, 1), (23, 0), (14, 0), (23, 1), (1, 0), (1, 1))),
 ((279 , 300), (20742450, 20993519, 0.251, 0), ((5, 1), (14, 1), (5, 0))),
 ((300 , 380), (20993519, 22554306, 1.561, 0), ((16, 1), (16, 0), (23, 0), (14, 0), (23, 1), (1, 0), (1, 1))),
 ((300 , 380), (20993519, 22554306, 1.561, 0), ((5, 1), (14, 1), (5, 0))),
 ((380 , 383), (22554306, 22555078, 0.001, 0), ((16, 1), (1, 0), (23, 1), (1, 1), (14, 0))),
 ((380 , 383), (22554306, 22555078, 0.001, 0), ((14, 1), (5, 0))),
 ((383 , 385), (22555078, 22583252, 0.028, 0), ((16, 1), (16, 0), (14, 0), (23, 1), (1, 0), (1, 1))),
 ((383 , 385), (22555078, 22583252, 0.028, 0), ((14, 1), (5, 0))),
 ((385 , 401), (22583252, 23275227, 0.692, 0), ((16, 1), (16, 0), (23, 0), (14, 0), (23, 1), (1, 0), (1, 1))),
 ((385 , 401), (22583252, 23275227, 0.692, 0), ((5, 1), (14, 1), (5, 0))),
 ((401 , 444), (23275227, 23753059, 0.478, 0), ((0, 1), (16, 1), (16, 0), (23, 0), (14, 0), (23, 1), (24, 1), (1, 0), (1, 1))),
 ((401 , 444), (23275227, 23753059, 0.478, 0), ((5, 1), (14, 1), (5, 0))),
 ((444 , 454), (23753059, 23834889, 0.082, 0), ((0, 1), (16, 1), (23, 0), (14, 0), (23, 1), (24, 1), (1, 0), (1, 1))),
 ((444 , 454), (23753059, 23834889, 0.082, 0), ((5, 1), (14, 1), (5, 0))),
 ((454 , 466), (23834889, 23877733, 0.043, 0), ((0, 1), (23, 0), (14, 0), (23, 1), (24, 1), (1, 0), (1, 1))),
 ((454 , 466), (23834889, 23877733, 0.043, 0), ((5, 1), (14, 1), (5, 0))),
 ((466 , 499), (23877733, 24209759, 0.332, 0), ((0, 1), (27, 1), (0, 0), (23, 0), (14, 0), (23, 1), (24, 1), (1, 0), (24, 0), (1, 1))),
 ((466 , 499), (23877733, 24209759, 0.332, 0), ((5, 1), (14, 1), (5, 0))),
 ((499 , 570), (24209759, 25205719, 0.996, 0), ((0, 1), (27, 1), (0, 0), (14, 0), (23, 1), (24, 1), (1, 0), (24, 0), (1, 1))),
 ((499 , 570), (24209759, 25205719, 0.996, 0), ((14, 1), (5, 0))),
 ((570 , 582), (25205719, 25305370, 0.100, 0), ((0, 1), (27, 0), (27, 1), (0, 0), (14, 0), (23, 1), (24, 1), (1, 0), (24, 0), (1, 1))),
 ((570 , 582), (25205719, 25305370, 0.100, 0), ((14, 1), (5, 0))),
 ((582 , 584), (25305370, 25319244, 0.014, 0), ((0, 1), (27, 0), (27, 1), (0, 0), (14, 0), (23, 1), (24, 1), (24, 0))),
 ((582 , 584), (25305370, 25319244, 0.014, 0), ((14, 1), (5, 0))),
 ((584 , 674), (25319244, 26234080, 0.915, 0), ((0, 1), (27, 0), (27, 1), (7, 1), (0, 0), (14, 0), (23, 1), (24, 1), (24, 0))),
 ((584 , 674), (25319244, 26234080, 0.915, 0), ((14, 1), (5, 0))),
 ((674 , 679), (26234080, 26250271, 0.016, 0), ((0, 1), (27, 1), (7, 1), (0, 0), (14, 0), (23, 1), (24, 1), (24, 0))),
 ((674 , 679), (26234080, 26250271, 0.016, 0), ((14, 1), (5, 0))),
 ((679 , 700), (26250271, 26380870, 0.131, 0), ((0, 1), (0, 0), (26, 1), (7, 1), (27, 1), (14, 0), (23, 1), (24, 1), (24, 0))),
 ((679 , 700), (26250271, 26380870, 0.131, 0), ((14, 1), (5, 0))),
 ((700 , 710), (26380870, 26496622, 0.116, 0), ((0, 1), (14, 0), (26, 1), (7, 1), (24, 1), (23, 1))),
 ((700 , 710), (26380870, 26496622, 0.116, 0), ((14, 1), (5, 0))),
 ((710 , 1008), (26496622, 28019908, 1.523, 0), ((0, 1), (9, 1), (26, 1), (7, 1), (24, 1), (23, 1), (14, 0))),
 ((710 , 1008), (26496622, 28019908, 1.523, 0), ((14, 1), (5, 0))),
 ((1008, 1032), (28019908, 28120707, 0.101, 0), ((0, 1), (7, 0), (9, 1), (26, 1), (7, 1), (14, 0), (23, 1), (24, 1))),
 ((1008, 1032), (28019908, 28120707, 0.101, 0), ((14, 1), (5, 0))),
 ((1032, 1039), (28120707, 28169949, 0.049, 0), ((0, 1), (7, 0), (9, 1), (26, 1), (7, 1), (23, 0), (14, 0), (23, 1), (24, 1))),
 ((1032, 1039), (28120707, 28169949, 0.049, 0), ((5, 1), (14, 1), (5, 0))),
 ((1039, 1088), (28169949, 29130300, 0.960, 0), ((0, 1), (9, 0), (7, 0), (9, 1), (26, 1), (7, 1), (26, 0), (23, 0), (14, 0), (23, 1), (24, 1))),
 ((1039, 1088), (28169949, 29130300, 0.960, 0), ((5, 1), (14, 1), (5, 0))),
 ((1088, 1091), (29130300, 29145539, 0.015, 0), ((0, 1), (9, 0), (0, 0), (7, 0), (9, 1), (26, 1), (7, 1), (26, 0), (23, 0), (14, 0), (23, 1), (24, 1))),
 ((1088, 1091), (29130300, 29145539, 0.015, 0), ((5, 1), (14, 1), (5, 0))),
 ((1091, 1123), (29145539, 29465677, 0.320, 0), ((0, 1), (9, 0), (0, 0), (7, 0), (9, 1), (26, 1), (7, 1), (26, 0), (14, 0), (23, 1), (24, 1))),
 ((1091, 1123), (29145539, 29465677, 0.320, 0), ((14, 1), (5, 0))),
 ((1123, 1146), (29465677, 29661341, 0.196, 0), ((0, 1), (9, 0), (0, 0), (9, 1), (26, 1), (7, 1), (26, 0), (14, 0), (23, 1), (24, 1))),
 ((1123, 1146), (29465677, 29661341, 0.196, 0), ((14, 1), (5, 0))),
 ((1146, 1160), (29661341, 29834766, 0.173, 0), ((0, 1), (9, 0), (0, 0), (7, 0), (9, 1), (26, 1), (7, 1), (26, 0), (14, 0), (23, 1), (24, 1))),
 ((1146, 1160), (29661341, 29834766, 0.173, 0), ((14, 1), (5, 0))),
 ((1160, 1207), (29834766, 30433373, 0.599, 0), ((0, 1), (9, 0), (0, 0), (7, 0), (9, 1), (26, 1), (7, 1), (26, 0), (14, 0), (23, 1), (24, 1), (1, 1))),
 ((1160, 1207), (29834766, 30433373, 0.599, 0), ((14, 1), (5, 0))),
 ((1207, 1216), (30433373, 30575812, 0.142, 0), ((0, 1), (9, 0), (7, 0), (9, 1), (26, 1), (7, 1), (26, 0), (14, 0), (23, 1), (24, 1), (1, 1))),
 ((1207, 1216), (30433373, 30575812, 0.142, 0), ((14, 1), (5, 0))),
 ((1216, 1283), (30575812, 31288769, 0.713, 0), ((0, 1), (9, 0), (0, 0), (7, 0), (9, 1), (26, 1), (7, 1), (26, 0), (14, 0), (23, 1), (24, 1), (1, 1))),
 ((1216, 1283), (30575812, 31288769, 0.713, 0), ((14, 1), (5, 0))),
 ((1283, 1284), (31288769, 31323900, 0.035, 0), ((0, 1), (0, 0), (7, 0), (9, 1), (26, 1), (7, 1), (26, 0), (14, 0), (23, 1), (24, 1), (1, 1))),
 ((1283, 1284), (31288769, 31323900, 0.035, 0), ((14, 1), (5, 0))),
 ((1284, 1298), (31323900, 31546951, 0.223, 0), ((0, 1), (9, 0), (0, 0), (7, 0), (9, 1), (26, 1), (7, 1), (26, 0), (14, 0), (23, 1), (24, 1), (1, 1))),
 ((1284, 1298), (31323900, 31546951, 0.223, 0), ((14, 1), (5, 0))),
 ((1298, 1326), (31546951, 32210300, 0.663, 0), ((0, 1), (9, 0), (0, 0), (7, 0), (9, 1), (26, 1), (7, 1), (26, 0), (23, 0), (14, 0), (23, 1), (24, 1), (1, 0), (24, 0), (1, 1))),
 ((1298, 1326), (31546951, 32210300, 0.663, 0), ((5, 1), (14, 1), (5, 0))),
 ((1326, 1371), (32210300, 32683165, 0.473, 0), ((0, 1), (9, 0), (7, 0), (9, 1), (26, 1), (7, 1), (26, 0), (23, 0), (14, 0), (23, 1), (24, 1), (1, 0), (24, 0), (1, 1))),
 ((1326, 1371), (32210300, 32683165, 0.473, 0), ((5, 1), (14, 1), (5, 0))),
 ((1371, 1385), (32683165, 32850349, 0.167, 0), ((0, 1), (9, 0), (9, 1), (26, 1), (7, 1), (26, 0), (23, 0), (14, 0), (23, 1), (24, 1), (24, 0), (1, 1))),
 ((1371, 1385), (32683165, 32850349, 0.167, 0), ((5, 1), (14, 1), (5, 0))),
 ((1385, 1389), (32850349, 32878244, 0.028, 0), ((0, 1), (9, 1), (26, 1), (7, 1), (23, 0), (14, 0), (23, 1), (24, 1), (24, 0), (1, 1))),
 ((1385, 1389), (32850349, 32878244, 0.028, 0), ((5, 1), (14, 1), (5, 0))),
 ((1389, 1551), (32878244, 33995211, 1.117, 0), ((0, 1), (9, 1), (26, 1), (7, 1), (14, 0), (23, 1), (24, 1), (1, 1))),
 ((1389, 1551), (32878244, 33995211, 1.117, 0), ((14, 1), (5, 0))),
 ((1551, 1632), (33995211, 34523488, 0.528, 0), ((0, 1), (9, 1), (26, 1), (7, 1), (26, 0), (14, 0), (23, 1), (24, 1), (1, 1))),
 ((1551, 1632), (33995211, 34523488, 0.528, 0), ((14, 1), (5, 0))),
 ((1632, 1798), (34523488, 35412768, 0.889, 0), ((0, 1), (7, 0), (9, 1), (26, 1), (7, 1), (26, 0), (14, 0), (23, 1), (24, 1), (1, 1))),
 ((1632, 1798), (34523488, 35412768, 0.889, 0), ((14, 1), (5, 0))),
 ((1798, 1802), (35412768, 35440705, 0.028, 0), ((0, 1), (7, 0), (9, 1), (26, 1), (7, 1), (26, 0), (23, 0), (14, 0), (23, 1), (24, 1), (24, 0), (1, 1))),
 ((1798, 1802), (35412768, 35440705, 0.028, 0), ((5, 1), (14, 1), (5, 0))),
 ((1802, 1864), (35440705, 35893156, 0.452, 0), ((0, 1), (7, 0), (9, 1), (26, 1), (7, 1), (23, 0), (14, 0), (23, 1), (24, 1), (24, 0), (1, 1))),
 ((1802, 1864), (35440705, 35893156, 0.452, 0), ((5, 1), (14, 1), (5, 0))),
 ((1864, 1948), (35893156, 36934821, 1.042, 0), ((0, 1), (23, 0), (14, 0), (26, 1), (23, 1), (24, 1), (24, 0))),
 ((1864, 1948), (35893156, 36934821, 1.042, 0), ((5, 1), (14, 1), (5, 0))),
 ((1948, 1986), (36934821, 37311806, 0.377, 0), ((0, 1), (0, 0), (26, 1), (23, 0), (14, 0), (23, 1), (24, 1), (24, 0))),
 ((1948, 1986), (36934821, 37311806, 0.377, 0), ((5, 1), (14, 1), (5, 0))),
 ((1986, 1994), (37311806, 37323988, 0.012, 0), ((0, 1), (0, 0), (14, 0), (26, 1), (23, 1), (24, 1))),
 ((1986, 1994), (37311806, 37323988, 0.012, 0), ((14, 1), (5, 0))),
 ((1994, 1998), (37323988, 37338286, 0.014, 0), ((0, 1), (0, 0), (14, 0), (26, 1), (23, 1), (24, 1), (26, 0))),
 ((1994, 1998), (37323988, 37338286, 0.014, 0), ((14, 1), (5, 0))),
 ((1998, 2000), (37338286, 37367308, 0.029, 0), ((0, 1), (0, 0), (26, 1), (26, 0), (23, 0), (14, 0), (23, 1), (24, 1), (24, 0))),
 ((1998, 2000), (37338286, 37367308, 0.029, 0), ((5, 1), (14, 1), (5, 0))),
 ((2000, 2004), (37367308, 37375117, 0.008, 0), ((0, 1), (0, 0), (26, 0), (23, 0), (14, 0), (23, 1), (24, 1), (24, 0))),
 ((2000, 2004), (37367308, 37375117, 0.008, 0), ((5, 1), (14, 1), (5, 0))),
 ((2004, 2087), (37375117, 38818676, 1.444, 0), ((0, 1), (0, 0), (26, 1), (26, 0), (23, 0), (14, 0), (23, 1), (24, 1), (24, 0))),
 ((2004, 2087), (37375117, 38818676, 1.444, 0), ((5, 1), (14, 1), (5, 0))),
 ((2087, 2093), (38818676, 38907849, 0.089, 0), ((26, 0), (14, 0), (26, 1))),
 ((2093, 2121), (38907849, 39197939, 0.290, 0), ((14, 0), (26, 1))),
 ((2129, 2219), (39320828, 41090009, 1.769, 0), ((26, 0), (14, 0))),
 ((2233, 2298), (41369108, 42654327, 1.285, 0), ((14, 0), (26, 1))),
 ((2298, 2462), (42654327, 44391234, 1.737, 0), ((26, 0), (14, 0), (26, 1))),
 ((2462, 2483), (44391234, 44557063, 0.166, 0), ((26, 0), (14, 0))),
 ((2483, 3108), (44557063, 49669972, 5.113, 0), ((26, 0), (14, 0), (26, 1))),
 ((3108, 3218), (49669972, 51156934, 1.487, 0), ((26, 0), (14, 0), (26, 1))),
 ((3108, 3218), (49669972, 51156934, 1.487, 0), ((14, 1), (6, 1)))],
                                     decimal=3, err_msg='Wrong IBD segments')