Skip to content

Commit 0aba595

Browse files
author
Juan Caballero
committed
Merge branch '4.0.0_viz' of github.com:deeptools/deepTools into 4.0.0_viz
2 parents c35e297 + e80c670 commit 0aba595

File tree

7 files changed

+47
-19
lines changed

7 files changed

+47
-19
lines changed

pydeeptools/deeptools/bamPEFragmentSize.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
from deeptools.getFragmentAndReadSize import get_read_and_fragment_length
1717
from importlib.metadata import version
1818

19-
2019
def parse_arguments():
2120
parser = argparse.ArgumentParser(
2221
description='This tool calculates the fragment sizes for read pairs given a BAM file from paired-end sequencing.'
@@ -48,7 +47,10 @@ def parse_arguments():
4847
'eps, pdf, svg and plotly.',
4948
default=None,
5049
choices=['png', 'pdf', 'svg', 'eps'])
51-
50+
parser.add_argument('--ggplot',
51+
help='Use ggplot theme for figures',
52+
action='store_true')
53+
5254
parser.add_argument('--numberOfProcessors', '-p',
5355
help='Number of processors to use. The default is '
5456
'to use 1. (Default: %(default)s)',
@@ -307,6 +309,9 @@ def main(args=None):
307309
if args.table is not None:
308310
printTable(args, fraglengths, readlengths)
309311

312+
if args.ggplot:
313+
plt.style.use('ggplot')
314+
310315
if args.histogram:
311316
if args.samplesLabel:
312317
if len(args.bamfiles) != len(args.samplesLabel):

pydeeptools/deeptools/plotCoverage.py

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616
from deeptools import parserCommon
1717
from deeptools.utilities import smartLabels
1818

19-
plt.style.use('ggplot')
20-
21-
2219
def parse_arguments(args=None):
2320
parent_parser = parserCommon.getParentArgParse(binSize=False)
2421
read_options_parser = parserCommon.read_options()
@@ -104,12 +101,15 @@ def required_args():
104101
'the generated image. Leave blank for no title. (Default: %(default)s)',
105102
default='')
106103

104+
optional.add_argument('--ggplot',
105+
help='Use ggplot theme for figures',
106+
action='store_true')
107+
107108
optional.add_argument('--skipZeros',
108109
help='By setting this option, genomic regions '
109110
'that have zero or nan values in _all_ samples '
110111
'are excluded.',
111-
action='store_true',
112-
required=False)
112+
action='store_true')
113113

114114
optional.add_argument('--numberOfSamples', '-n',
115115
help='Number of 1 bp regions to sample. (Default: %(default)s)',
@@ -230,16 +230,11 @@ def main(args=None):
230230
num_reads_per_bin = countR.remove_row_of_zeros(num_reads_per_bin)
231231

232232
if args.plotFile:
233-
if args.plotFileFormat == 'plotly':
234-
fig = go.Figure()
235-
fig['layout']['xaxis1'] = {'domain': [0.0, 0.48], 'anchor': 'x1', 'title': 'coverage (#reads per base)'}
236-
fig['layout']['xaxis2'] = {'domain': [0.52, 1.0], 'anchor': 'x2', 'title': 'coverage (#reads per base)'}
237-
fig['layout']['yaxis1'] = {'domain': [0.0, 1.0], 'anchor': 'x1', 'title': 'fraction of bases sampled'}
238-
fig['layout']['yaxis2'] = {'domain': [0.0, 1.0], 'anchor': 'x2', 'title': 'fraction of bases sampled >= coverage'}
239-
fig['layout'].update(title=args.plotTitle)
240-
else:
241-
fig, axs = plt.subplots(1, 2, figsize=(args.plotWidth, args.plotHeight))
242-
plt.suptitle(args.plotTitle)
233+
if args.ggplot:
234+
plt.style.use('ggplot')
235+
236+
fig, axs = plt.subplots(1, 2, figsize=(args.plotWidth, args.plotHeight))
237+
plt.suptitle(args.plotTitle)
243238

244239
# plot up to two std from mean
245240
num_reads_per_bin = num_reads_per_bin.astype(int)

pydeeptools/deeptools/plotFingerprint.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,11 @@ def get_optional_args():
125125
help='Title of the plot, to be printed on top of '
126126
'the generated image. Leave blank for no title. (Default: %(default)s)',
127127
default='')
128-
128+
129+
optional.add_argument('--ggplot',
130+
help='Use ggplot theme for figures',
131+
action='store_true')
132+
129133
optional.add_argument('--skipZeros',
130134
help='If set, then regions with zero overlapping reads'
131135
'for *all* given BAM files are ignored. This '
@@ -402,7 +406,8 @@ def main(args=None):
402406
x = np.arange(total).astype('float') / total # normalize from 0 to 1
403407

404408
if args.plotFile is not None:
405-
plt.style.use('ggplot')
409+
if args.ggplot:
410+
plt.style.use('ggplot')
406411

407412
i = 0
408413
# matplotlib won't iterate through line styles by itself
-1.32 KB
Loading
-9.28 KB
Loading
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import os
2+
import filecmp
3+
from matplotlib.testing.compare import compare_images
4+
from tempfile import NamedTemporaryFile
5+
import deeptools.plotFingerprint
6+
7+
TEST_DATA = os.path.dirname(os.path.abspath(__file__)) + "/test_data/"
8+
ROOT = os.path.dirname(os.path.abspath(__file__)) + "/test_plotFingerprint/"
9+
10+
print (TEST_DATA)
11+
print(ROOT)
12+
tolerance = 13
13+
14+
def test_plotFingerprint_default():
15+
plotfile = NamedTemporaryFile(suffix='.png', prefix='deeptools_testfile_', delete=False)
16+
args = "-b {0}test1.bam {0}test2.bam -o {1} --plotFileFormat png".format(TEST_DATA, plotfile.name).split()
17+
deeptools.plotProfile.main(args)
18+
19+
res = compare_images(ROOT + 'test_plotFingerprint_default.png', plotfile.name, tolerance)
20+
21+
assert res is None, res
22+
23+
os.remove(plotfile.name)
30.4 KB
Loading

0 commit comments

Comments
 (0)