Esempio n. 1
0
 def chunks_containing_region(self):
     breakpoints = BedTool(paths.reference + self.params.breakpointsfile)
     blocks = SnpPartition(self.refpanel, breakpoints, remove_mhc=True)
     self.A = SnpSubset(self.refpanel,
                        GenomicSubset(self.params.region).bedtool)
     return [
         int(i / self.chunk_size(blocks.ranges()))
         for i in blocks.indices_containing(self.A.irs)
     ]
Esempio n. 2
0
def mult_by_R_ldblocks(V, refpanel, refpanel_indices=None):
    breakpoints = BedTool(paths.reference + 'pickrell_breakpoints.hg19.eur.bed')
    blocks = SnpPartition(refpanel, breakpoints, remove_mhc=True)

    if refpanel_indices is not None:
        Vwithzeros = np.zeros((refpanel.M, V.shape[1]))
        Vwithzeros[refpanel_indices] = V
    else:
        Vwithzeros = V
    result = np.zeros(Vwithzeros.shape)
    for r in blocks.ranges():
        print('\tXTXV', r[0], r[1], 'of', refpanel.M)
        X = refpanel.get_standardized_genotypes(r)
        result[r[0]:r[1],:] = X.T.dot(X.dot(Vwithzeros[r[0]:r[1],:]))
    if refpanel_indices is not None:
        return result[refpanel_indices] / refpanel.N
    else:
        return result / refpanel.N
Esempio n. 3
0
def mult_by_R_ldblocks(V, refpanel, refpanel_indices=None):
    breakpoints = BedTool(paths.reference +
                          'pickrell_breakpoints.hg19.eur.bed')
    blocks = SnpPartition(refpanel, breakpoints, remove_mhc=True)

    if refpanel_indices is not None:
        Vwithzeros = np.zeros((refpanel.M, V.shape[1]))
        Vwithzeros[refpanel_indices] = V
    else:
        Vwithzeros = V
    result = np.zeros(Vwithzeros.shape)
    for r in blocks.ranges():
        print('\tXTXV', r[0], r[1], 'of', refpanel.M)
        X = refpanel.get_standardized_genotypes(r)
        result[r[0]:r[1], :] = X.T.dot(X.dot(Vwithzeros[r[0]:r[1], :]))
    if refpanel_indices is not None:
        return result[refpanel_indices] / refpanel.N
    else:
        return result / refpanel.N
Esempio n. 4
0
 def compute_covariance(self):
     breakpoints = BedTool(paths.reference + self.params.breakpointsfile)
     blocks = SnpPartition(self.refpanel, breakpoints, remove_mhc=True)
     myranges = self.ranges_in_chunk(blocks.ranges())
     print('working on', len(myranges), 'ld blocks')
     return BlockDiag.ld_matrix_blocks(self.refpanel, myranges)
Esempio n. 5
0
 def compute_covariance(self):
     breakpoints = BedTool(paths.reference + self.params.breakpointsfile)
     blocks = SnpPartition(self.refpanel, breakpoints, remove_mhc=True)
     myranges = self.ranges_in_chunk(blocks.ranges())
     print('working on', len(myranges), 'ld blocks')
     return BlockDiag.ld_matrix_blocks(self.refpanel, myranges)
Esempio n. 6
0
 def chunks_containing_region(self):
     breakpoints = BedTool(paths.reference + self.params.breakpointsfile)
     blocks = SnpPartition(self.refpanel, breakpoints, remove_mhc=True)
     self.A = SnpSubset(self.refpanel, GenomicSubset(self.params.region).bedtool)
     return [int(i / self.chunk_size(blocks.ranges()))
             for i in blocks.indices_containing(self.A.irs)]