Skip to content

Commit

Permalink
Merge pull request omerwe#51 from shimaomao26/master
Browse files Browse the repository at this point in the history
Check the effect allele of priors and sumstats
  • Loading branch information
omerwe authored Jun 4, 2021
2 parents 9de4836 + 8f95c0f commit d31410f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions extract_snpvar.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,14 @@
logging.info('Merging sumstats with per-SNP h2 data...')
t0 = time.time()
df_meta = df_meta.loc[df_meta.index.isin(df_snps.index)]
df_snps = df_snps.rename(columns = {'A1': 'A_eff'})
df = df_meta.merge(df_snps.drop(columns=SNP_COLUMNS, errors='ignore'), left_index=True, right_index=True)
#flip Z-sign if A1 of prior not match A1 of sumstats
is_flipped = df['A2'] == df['A_eff']
if is_flipped.sum() > 0:
df.loc[is_flipped, 'Z'] *= -1
logging.info('Flipping the Z-sign of %d SNPs that A1 in sumstats = A2 in the per-SNP h2 data'%(is_flipped.sum()))
df = df.drop(columns = 'A_eff')
logging.info('Done in %0.2f seconds'%(time.time() - t0))

#If we didn't find everything, write a list of missing SNPs to an output file
Expand Down

0 comments on commit d31410f

Please sign in to comment.