Skip to content

Commit fc0b521

Browse files
committed
Adding loghist for logarithmic histogram
1 parent 1802cfe commit fc0b521

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

hometools/hometools.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2151,7 +2151,7 @@ def reg_str_to_list(regstr):
21512151

21522152
def mapbp(args):
21532153
"""
2154-
Outputs mapping positions for the given reference genome coordinate
2154+
Outputs mapping positions for the given reference genome coordinate
21552155
"""
21562156
import pysam
21572157
from collections import defaultdict, deque

hometools/plot.py

+14-1
Original file line numberDiff line numberDiff line change
@@ -533,4 +533,17 @@ def inlineplotsr(ax, args):
533533
# sys.exit('Error in saving the figure. Try using a different backend.' + '\n' + e.with_traceback())
534534
# logger.info('Finished')
535535

536-
return ax
536+
return ax
537+
538+
539+
def loghist(x, ax, bins=10):
540+
"""
541+
Generate the plot on a logarithmic histogram
542+
"""
543+
import numpy as np
544+
hist, bins = np.histogram(x, bins=bins)
545+
logbins = np.logspace(np.log10(bins[0]), np.log10(bins[-1]), len(bins))
546+
ax.hist(x, bins=logbins)
547+
ax.set_xscale('log')
548+
return ax
549+
# END

0 commit comments

Comments
 (0)