Example #1
0
def phaser_stages13(debug=False, print_times=False):
    return new_phaser_chain([
                             prepare_phaser(),
                             trivial_phaser(),
                             family_phaser(),
                             family_child_comparison_phaser(),
                             ], debug=debug, print_times=print_times)
Example #2
0
def nuclear_family_phaser(debug=False, print_times=False):
    return new_phaser_chain([
                             prepare_phaser(),
                             trivial_phaser(),
                             family_phaser(),
                             family_child_comparison_phaser(),
                             family_sib_comparison_phaser(),
                             ], debug=debug, print_times=print_times)
Example #3
0
def phaser_stages13(debug=False, print_times=False):
    return new_phaser_chain([
        prepare_phaser(),
        trivial_phaser(),
        family_phaser(),
        family_child_comparison_phaser(),
    ],
                            debug=debug,
                            print_times=print_times)
 def test_child_comparison_one_parent(self):
     '''Test applying child comparison to a nuclear family with many genotyped kids but only
     one genotyped parent.'''
     problem = io.read_npz(itu.FAMILY945_ONE_PARENT_STAGE2)
     itu.assert_size_equals(problem.genotype, 3218, 8)
     itu.assert_problem_stats(problem, 51488, 44150, 96)
     phaser = family_child_comparison_phaser(debug=False)
     phaser.run(problem)
     itu.assert_problem_stats(problem, 51488, 47343, 101)
Example #5
0
def __build_phaser(options):
    '''Bulid and return the phasing processing chain by options - factory method.'''
    if options.stage == 0:
        # 07-DEC-12: disabling stage 4 (family_sib_comparison_phaser) since it degrades phasing & imputation
        chain = [
                 prepare_phaser(),
                 trivial_phaser(),
                 family_phaser(),
                 family_child_comparison_phaser(),
                 phase_distant.family_sib_comparison_phaser(),
                 phase_distant.distant_phaser()
                 ]
    elif options.stage == 1: chain = [prepare_phaser(), trivial_phaser()]
    elif options.stage == 2: chain = [family_phaser()]
    elif options.stage == 3: chain = [family_child_comparison_phaser()]
    elif options.stage == 4: chain = [phase_distant.family_sib_comparison_phaser()]
    elif options.stage == 5: chain = [phase_distant.distant_phaser()]
    return chain
 def test_child_comparison_one_parent(self):
     '''Test applying child comparison to a nuclear family with many genotyped kids but only
     one genotyped parent.'''
     problem = io.read_npz(itu.FAMILY945_ONE_PARENT_STAGE2)
     itu.assert_size_equals(problem.genotype, 3218, 8)
     itu.assert_problem_stats(problem, 51488, 44150, 96)
     phaser = family_child_comparison_phaser(debug=False)
     phaser.run(problem)
     itu.assert_problem_stats(problem, 51488, 47343, 101)
Example #7
0
def nuclear_family_phaser(debug=False, print_times=False):
    return new_phaser_chain([
        prepare_phaser(),
        trivial_phaser(),
        family_phaser(),
        family_child_comparison_phaser(),
        family_sib_comparison_phaser(),
    ],
                            debug=debug,
                            print_times=print_times)
 def setUp(self):
     '''Load test data and expected results.'''
     unittest.TestCase.setUp(self)
     
     # Load test data ready from previous phasing stagees 
     self.problem = io.read_npz(itu.FAMILY_TOO_ZEROED_STAGE1)
     self.family = self.problem.families()[0]
     self.phaser = phase_core.PhaseDecorator(FilterChain([trivial_phaser(),
                                                          family_phaser(),
                                                          family_child_comparison_phaser()]))
     self.comparator = ic.ChildComparator(Struct(problem=self.problem, params=PhaseParam()), self.family)
 def test_child_comparison_phaser(self):
     '''Test phasing a founder parent by comparing its partially-phased children. Test main
     phasing method here.'''
     h = self.problem.haplotype
     (f, m) = (self.family.father, self.family.mother)
     assert_almost_equal(h.fill_fraction(sample=f), 0.60, 2, 'Unexpected pre-phasing parent fill %')
     assert_almost_equal(h.fill_fraction(sample=m), 0.63, 2, 'Unexpected pre-phasing parent fill %')
     #print self.problem.fill_fraction(sample=self.family.member_set)
     phaser = family_child_comparison_phaser()
     phaser.run(self.problem, PhaseParam())
     #print self.problem.fill_fraction(sample=self.family.member_set)
     assert_almost_equal(h.fill_fraction(sample=f), 0.998, 3, 'Unexpected post-phasing parent fill %')        
     assert_almost_equal(h.fill_fraction(sample=m), 0.998, 3, 'Unexpected post-phasing parent fill %')
Example #10
0
def __build_phaser(options):
    '''Bulid and return the phasing processing chain by options - factory method.'''
    if options.stage == 0:
        # 07-DEC-12: disabling stage 4 (family_sib_comparison_phaser) since it degrades phasing & imputation
        chain = [
            prepare_phaser(),
            trivial_phaser(),
            family_phaser(),
            family_child_comparison_phaser(),
            phase_distant.family_sib_comparison_phaser(),
            phase_distant.distant_phaser()
        ]
    elif options.stage == 1:
        chain = [prepare_phaser(), trivial_phaser()]
    elif options.stage == 2:
        chain = [family_phaser()]
    elif options.stage == 3:
        chain = [family_child_comparison_phaser()]
    elif options.stage == 4:
        chain = [phase_distant.family_sib_comparison_phaser()]
    elif options.stage == 5:
        chain = [phase_distant.distant_phaser()]
    return chain
    def setUp(self):
        '''Load test data and expected results.'''
        unittest.TestCase.setUp(self)

        # Load test data ready from previous phasing stagees
        self.problem = io.read_npz(itu.FAMILY13_STAGE2)
        self.family = self.problem.families()[0]
        self.phaser = phase_core.PhaseDecorator(
            FilterChain([
                trivial_phaser(),
                family_phaser(),
                family_child_comparison_phaser()
            ]))
        self.comparator = ic.ChildComparator(
            Struct(problem=self.problem, params=PhaseParam()), self.family)
 def test_child_comparison_phaser(self):
     '''Test phasing a founder parent by comparing its partially-phased children. Test main
     phasing method here.'''
     h = self.problem.haplotype
     (f, m) = (self.family.father, self.family.mother)
     assert_almost_equal(h.fill_fraction(sample=f), 0.60, 2,
                         'Unexpected pre-phasing parent fill %')
     assert_almost_equal(h.fill_fraction(sample=m), 0.63, 2,
                         'Unexpected pre-phasing parent fill %')
     #print self.problem.fill_fraction(sample=self.family.member_set)
     phaser = family_child_comparison_phaser()
     phaser.run(self.problem, PhaseParam())
     #print self.problem.fill_fraction(sample=self.family.member_set)
     assert_almost_equal(h.fill_fraction(sample=f), 0.998, 3,
                         'Unexpected post-phasing parent fill %')
     assert_almost_equal(h.fill_fraction(sample=m), 0.998, 3,
                         'Unexpected post-phasing parent fill %')
Example #13
0
if __name__ == '__main__':
    '''
    --------------------------------------------------
    Main program
    --------------------------------------------------
    '''
    old_printoptions = np.get_printoptions()
    np.set_printoptions(threshold=np.nan, linewidth=120)
    
    # Load data
    # Before: p, h
    # After: q, hh
    p = im.io.read_npz(im.itu.FAMILY225_STAGE1)
    q = im.io.read_npz(im.itu.FAMILY225_STAGE1)
    phaser = family_child_comparison_phaser(debug=True)
    (g, h) = p.data
    (gg, hh) = q.data
    f = p.families(genotyped=True)[0]
    (father, mother) = f.parents
    children = np.array(f.children_list)
    
    phaser.run(q)
    
    # Print a portion of the father and corresponding children haplotypes
    snps = np.arange(2094, 2118) #np.arange(0, p.num_snps)
    for parent_type in ALLELES:
        print_haps(h, hh, parent_type, snps)
    
    # Recombinations
    comparator = im.ic.ChildComparator(p, f)
Example #14
0
 def setUp(self):
     '''Load test data and expected results.'''
     unittest.TestCase.setUp(self)
     # The way to load a pedigree in conjunction with a genotype set is to recode
     # its sample IDs to consecutive for easier access by phasers.
     self.phaser = new_phaser_chain([trivial_phaser(), family_phaser(), family_child_comparison_phaser()])
Example #15
0
if __name__ == '__main__':
    '''
    --------------------------------------------------
    Main program
    --------------------------------------------------
    '''
    old_printoptions = np.get_printoptions()
    np.set_printoptions(threshold=np.nan, linewidth=120)

    # Load data
    # Before: p, h
    # After: q, hh
    p = im.io.read_npz(im.itu.FAMILY225_STAGE1)
    q = im.io.read_npz(im.itu.FAMILY225_STAGE1)
    phaser = family_child_comparison_phaser(debug=True)
    (g, h) = p.data
    (gg, hh) = q.data
    f = p.families(genotyped=True)[0]
    (father, mother) = f.parents
    children = np.array(f.children_list)

    phaser.run(q)

    # Print a portion of the father and corresponding children haplotypes
    snps = np.arange(2094, 2118)  #np.arange(0, p.num_snps)
    for parent_type in ALLELES:
        print_haps(h, hh, parent_type, snps)

    # Recombinations
    comparator = im.ic.ChildComparator(p, f)