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_errors(self):
     '''Return the number of genotypes that were called incorrectly. (A genotype is an allele pair.)''' 
     # Count entries that were called (positive AND are different than the corresponding original value
     return len(recode.where_error(self.recoded_genotype, self.r_orig)[0])
Example #4
0
 def total_errors(self):
     '''Return the number of genotypes that were called incorrectly. (A genotype is an allele pair.)'''
     # Count entries that were called (positive AND are different than the corresponding original value
     return len(recode.where_error(self.recoded_genotype, self.r_orig)[0])