Skip to content

Commit

Permalink
Merge pull request #69 from yakirr/master
Browse files Browse the repository at this point in the history
fixed signed_sumstat datatype bug + 2 minor ldscore computation bugs
  • Loading branch information
hilaryfinucane authored Feb 12, 2017
2 parents f7c3316 + 4be3771 commit c42e055
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions ldscore/ldscore.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def __corSumVarBlocks__(self, block_left, c, func, snp_getter, annot=None):
m, n = self.m, self.n
block_sizes = np.array(np.arange(m) - block_left)
block_sizes = np.ceil(block_sizes / c)*c
if not np.any(annot):
if annot is None:
annot = np.ones((m, 1))
else:
annot_m = annot.shape[0]
Expand Down Expand Up @@ -204,7 +204,7 @@ def __corSumVarBlocks__(self, block_left, c, func, snp_getter, annot=None):
# this happens w/ sparse categories (i.e., pathways)
# update the block
old_b = b
b = block_sizes[l_B]
b = int(block_sizes[l_B])
if l_B > b0 and b > 0:
# block_size can't increase more than c
# block_size can't be less than c unless it is zero
Expand Down
10 changes: 8 additions & 2 deletions munge_sumstats.py
Original file line number Diff line number Diff line change
Expand Up @@ -634,8 +634,14 @@ def munge_sumstats(args, p=True):
merge_alleles = None

(openfunc, compression) = get_compression(args.sumstats)
dat_gen = pd.read_csv(args.sumstats, delim_whitespace=True, header=0, compression=compression,
usecols=cname_translation.keys(), na_values=['.', 'NA'], iterator=True, chunksize=args.chunksize)

# figure out which columns are going to involve sign information, so we can ensure
# they're read as floats
signed_sumstat_cols = [k for k,v in cname_translation.items() if v=='SIGNED_SUMSTAT']
dat_gen = pd.read_csv(args.sumstats, delim_whitespace=True, header=0,
compression=compression, usecols=cname_translation.keys(),
na_values=['.', 'NA'], iterator=True, chunksize=args.chunksize,
dtype={c:np.float64 for c in signed_sumstat_cols})

dat = parse_dat(dat_gen, cname_translation, merge_alleles, log, args)
if len(dat) == 0:
Expand Down

0 comments on commit c42e055

Please sign in to comment.