Example #1
0
    def __init__(self, g_orig, haplotype, num_errors):
        '''Initialize phasing statistics object for the original genotype g/and haplotype set problem.haplotype.'''
        h = haplotype.data
        r_orig = recode.recode_single_genotype(g_orig)
        r = recode.recode_single_genotype(h)
        
        # Sizes
        self.time = 0
        self.num_snps = haplotype.num_snps
        self.num_samples = haplotype.num_samples
        self.num_genotypes = haplotype.num_data / 2
        self.num_haplotypes = haplotype.num_data
        
        # Arrays
        self.fill = np.array([haplotype.fill_fraction(sample=x) for x in xrange(haplotype.num_samples)])
        
        # Fields
        # A Field factory method
        field = lambda index: StatsField(self, h, index)
        self.called_orig = field(recode.where_called(r_orig))
        self.imputed = field(recode.where_full_imputed(r, r_orig))
        self.imputed_partial = field(recode.where_partial_imputed(r, r_orig))
        self.errors = field(recode.where_error(r, r_orig))
        self.errors_partial = field(recode.where_partial_error(r, r_orig))
        self.called = field(recode.where_called(r))
        self.partial_called = field(recode.where_partial_called(r))
        self.still_missing = field(recode.where_still_missing(r, r_orig))

        # Scalars
        self.num_filled_haplotypes = haplotype.num_filled
        self.num_errors = num_errors  # Redundant
Example #2
0
    def __init__(self, g_orig, haplotype, num_errors):
        '''Initialize phasing statistics object for the original genotype g/and haplotype set problem.haplotype.'''
        h = haplotype.data
        r_orig = recode.recode_single_genotype(g_orig)
        r = recode.recode_single_genotype(h)

        # Sizes
        self.time = 0
        self.num_snps = haplotype.num_snps
        self.num_samples = haplotype.num_samples
        self.num_genotypes = haplotype.num_data / 2
        self.num_haplotypes = haplotype.num_data

        # Arrays
        self.fill = np.array([
            haplotype.fill_fraction(sample=x)
            for x in xrange(haplotype.num_samples)
        ])

        # Fields
        # A Field factory method
        field = lambda index: StatsField(self, h, index)
        self.called_orig = field(recode.where_called(r_orig))
        self.imputed = field(recode.where_full_imputed(r, r_orig))
        self.imputed_partial = field(recode.where_partial_imputed(r, r_orig))
        self.errors = field(recode.where_error(r, r_orig))
        self.errors_partial = field(recode.where_partial_error(r, r_orig))
        self.called = field(recode.where_called(r))
        self.partial_called = field(recode.where_partial_called(r))
        self.still_missing = field(recode.where_still_missing(r, r_orig))

        # Scalars
        self.num_filled_haplotypes = haplotype.num_filled
        self.num_errors = num_errors  # Redundant
Example #3
0
 def total_partial_called(self):
     '''Return the number of genotypes in which one alleles was called.''' 
     # Positive entries of r = called entries
     return len(recode.where_partial_called(self.recoded_genotype)[0])
Example #4
0
 def __remove_partial_calls(self):
     '''Set partially-imputed genotypes to missing. A prerequisite for loading into PLINK, for instance
     (but not PLINK-SEQ).'''
     self.h[recode.where_partial_called(
         recode.recode_single_genotype(self.h)), :] = MISSING
Example #5
0
 def total_partial_called(self):
     '''Return the number of genotypes in which one alleles was called.'''
     # Positive entries of r = called entries
     return len(recode.where_partial_called(self.recoded_genotype)[0])
Example #6
0
 def __remove_partial_calls(self):
     '''Set partially-imputed genotypes to missing. A prerequisite for loading into PLINK, for instance
     (but not PLINK-SEQ).'''
     self.h[recode.where_partial_called(recode.recode_single_genotype(self.h)), :] = MISSING