diff --git a/coolpuppy/__main__.py b/coolpuppy/__main__.py index 99f54f4..b42e2bf 100644 --- a/coolpuppy/__main__.py +++ b/coolpuppy/__main__.py @@ -532,9 +532,10 @@ def _excepthook(exc_type, value, tb): json.dump(outdict, fp) # , sort_keys=True, indent=4) logging.info(f"Saved individual pileups to {json_path}") else: - pup = PU.pileupsWithControl(nproc) + pup, n = PU.pileupsWithControl(nproc) headerdict = vars(args) headerdict['resolution'] = int(c.binsize) + headerdict['n'] = int(n) try: save_array_with_header(pup, headerdict, os.path.join(args.outdir, outname)) except FileNotFoundError: diff --git a/coolpuppy/coolpup.py b/coolpuppy/coolpup.py index f0b1472..1956a98 100644 --- a/coolpuppy/coolpup.py +++ b/coolpuppy/coolpup.py @@ -1160,6 +1160,7 @@ def pileupsWithControl(self, nproc=1): loops, nums, cov_starts, cov_ends, ns = list(zip(*mymap(f, self.chroms))) loop = np.sum(loops, axis=0) n = np.sum(ns) + n_return = n num = np.sum(nums, axis=0) if self.coverage_norm: cov_start = np.sum(cov_starts, axis=0) @@ -1191,7 +1192,7 @@ def pileupsWithControl(self, nproc=1): if nproc > 1: p.close() loop[~np.isfinite(loop)] = 0 - return loop + return loop, n_return def pileupsByWindow( self, chrom, expected=False, ctrl=False,