Skip to content
This repository has been archived by the owner. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
bugfixes + bump to 0.8.0
  • Loading branch information
msbentsen committed Sep 4, 2019
1 parent f9910a4 commit 6fc0861
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CHANGES
@@ -1,3 +1,7 @@
## 0.8.0 (2019-09-04)
- Added CreateNetwork to tools
- Smaller bugfixes

## 0.7.0 (2019-08-13)
- Updated the way p-values are calculated in BINDetect. Included 100-fold subsampling of background to estimate confidence interval.

Expand Down
2 changes: 1 addition & 1 deletion tobias/__init__.py
@@ -1 +1 @@
__version__ = "0.7.0"
__version__ = "0.8.0"
26 changes: 19 additions & 7 deletions tobias/motifs/score_bed.py
Expand Up @@ -47,7 +47,7 @@ def add_scorebed_arguments(parser):

#Optional arguments
optional = parser.add_argument_group('Optional arguments')
optional.add_argument('--output', metavar="", help="Path to output .bed-file (default: scored sites are written to stdout")
optional.add_argument('--output', metavar="", help="Path to output .bed-file (default: scored sites are written to stdout)")
optional.add_argument('--subset', metavar="", help="Subset scoring to .bed regions and set all other sites to --null value (default: all sites in input file will be scored)")
optional.add_argument('--null', metavar="", help="If --subset is given, which score/label to add to non-scored regions (default: 0)", default="0", type=float)
optional.add_argument('--position', metavar="", help="Position in sites to score (start/mid/end/full) (default: full)", choices=["mid", "start", "end", "full"], default="full")
Expand Down Expand Up @@ -132,6 +132,10 @@ def run_scorebed(args):

pybw = {bigwig_f: pyBigWig.open(bigwig_f) for bigwig_f in args.bigwigs} #open filehandles for all bigwigs

#Get chrom/start/stop from pybw objects
pybw_headers = {bigwig_f: pybw[bigwig_f].chroms() for bigwig_f in pybw}
logger.debug(pybw_headers)

logger.info("Starting scoring...")
#buff = [""]*args.buffer
#buff_idx = 0
Expand All @@ -148,14 +152,22 @@ def run_scorebed(args):
if overlap != 0:
for bigwig_f in args.bigwigs: #preserves order of bigwigs

signal = pybw[bigwig_f].values(chrom, start, end, numpy=True)

if len(signal) > 0:
signal = np.nan_to_num(signal)
score = round(score_func(signal), 5)
if chrom in pybw_headers[bigwig_f]: #only get score if chromosome is in bigwig; to prevent error from pybigwig.values
try:
signal = pybw[bigwig_f].values(chrom, start, end, numpy=True)
except:
logger.error("Error reading signal for site: {0}".format(line))
sys.exit()

if len(signal) > 0:
signal = np.nan_to_num(signal)
score = round(score_func(signal), 5)
else:
score = args.null
else:
score = args.null


#Format line with score
outline += "\t" + "{0:.5f}".format(score)
else:
outline += "\t" + "\t".join([args.null]*no_bigwigs)
Expand Down
2 changes: 1 addition & 1 deletion tobias/plotting/plot_heatmap.py
Expand Up @@ -139,7 +139,7 @@ def run_heatmap(args):
#Estimate region width
distri = heatmap_info[col][row]["regions"].get_width_distri()
if len(distri) > 1:
sys.exit(distri)
logger.warning("Input regions have differing lengths: {0}".format(distri))

heatmap_info[col][row]["width"] = list(distri.keys())[0]

Expand Down

0 comments on commit 6fc0861

Please sign in to comment.