Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix assert df_snp.shape[0]==1 error in compute_ld_bgen #203

Merged
merged 1 commit into from
Jul 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading