Skip to content

Commit

Permalink
Merge pull request #203 from mkanai/fix_finemapper_mk
Browse files Browse the repository at this point in the history
Fix `assert df_snp.shape[0]==1` error in compute_ld_bgen
  • Loading branch information
omerwe authored Jul 28, 2024
2 parents 4b11c0c + 2d3a91d commit 3e657a1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions finemapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,16 +420,16 @@ def compute_ld_bgen(self, locus_start, locus_end, verbose=False):
snp_chrom = rsid.chrom
snp_pos = rsid.pos
assert len(snp_alleles) == 2, 'cannot handle SNPs with more than two alleles'
df_snp = df_z.query('SNP == "%s"'%(rsid))
df_snp = df_z.query('SNP == "%s"'%(rsid.rsid))
assert df_snp.shape[0]==1
a1, a2 = df_snp['A1'].iloc[0], df_snp['A2'].iloc[0]
snp_a1, snp_a2 = snp_alleles[0], snp_alleles[1]
if set([a1,a2]) != set([snp_a1, snp_a2]):
raise ValueError('The alleles for SNP %s are different in the sumstats and in the bgen file:\n \
bgen: A1=%s A2=%s\n \
sumstats: A1=%s A2=%s \
'%(rsid, snp_alleles[0], snp_alleles[1], a1, a2))
d = {'SNP':rsid, 'CHR':snp_chrom, 'BP':snp_pos, 'A1':snp_a1, 'A2':snp_a2}
'%(rsid.rsid, snp_alleles[0], snp_alleles[1], a1, a2))
d = {'SNP':rsid.rsid, 'CHR':snp_chrom, 'BP':snp_pos, 'A1':snp_a1, 'A2':snp_a2}
list_bgen.append(d)
df_bgen = pd.DataFrame(list_bgen)
df_bgen = set_snpid_index(df_bgen, allow_swapped_indel_alleles=self.allow_swapped_indel_alleles)
Expand Down

0 comments on commit 3e657a1

Please sign in to comment.