Skip to content

Commit 5562fea

Browse files
authored
Merge pull request #212 from deeptools/fail_proof_hicaggregate
added a hidden parameter to disable "bbox=tight", hoping that this ch…
2 parents ef87680 + 489500d commit 5562fea

9 files changed

+45
-13
lines changed

hicexplorer/hicAggregateContacts.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,10 @@ def parse_arguments(args=None):
157157
type=float,
158158
default=None)
159159

160+
# If set, then the bbox=tight option is disable. Used for automatic testing
161+
parserPlot.add_argument('--disable_bbox_tight',
162+
help=argparse.SUPPRESS,
163+
action='store_true')
160164
return parser
161165

162166

@@ -407,7 +411,11 @@ def plot_aggregated_contacts(chrom_matrix, chrom_contact_position, cluster_ids,
407411
cbar_x = plt.subplot(gs[-1, idx])
408412
fig.colorbar(img, cax=cbar_x, orientation='horizontal')
409413

410-
plt.savefig(args.outFileName.name, dpi=100, bbox_inches='tight')
414+
if args.disable_bbox_tight:
415+
plt.savefig(args.outFileName.name, dpi=100)
416+
else:
417+
plt.savefig(args.outFileName.name, dpi=100, bbox_inches='tight')
418+
411419
plt.close()
412420

413421

523 KB
Binary file not shown.
Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
1-
hicAggregateContacts --matrix ../Li_et_al_2015.cool --BED test_regions.bed \
1+
hicAggregateContacts --matrix ../Li_et_al_2015.h5 --BED test_regions.bed \
22
--outFileName master_aggregate.png \
3-
--numberOfBins 30 --range 50000:900000
3+
--numberOfBins 30 --range 50000:900000 --disable_bbox_tight
44

5-
hicAggregateContacts --matrix ../Li_et_al_2015.cool --BED test_regions.bed \
5+
hicAggregateContacts --matrix ../Li_et_al_2015.h5 --BED test_regions.bed \
66
--outFileName master_aggregate_hclust4.png \
77
--numberOfBins 30 --range 50000:900000 --hclust 4 \
8-
--diagnosticHeatmapFile master_heatmap.png --howToCluster diagonal
8+
--diagnosticHeatmapFile master_heatmap.png --howToCluster diagonal --disable_bbox_tight
99

10-
hicAggregateContacts --matrix ../Li_et_al_2015.cool --BED test_regions.bed \
10+
hicAggregateContacts --matrix ../Li_et_al_2015.h5 --BED test_regions.bed \
1111
--outFileName master_aggregate_3d.png \
1212
--numberOfBins 30 --range 50000:900000 --hclust 2 \
1313
--plotType 3d \
14-
--BED2 test_regions.bed
14+
--BED2 test_regions.bed --disable_bbox_tight
15+
16+
hicAggregateContacts --matrix ../Li_et_al_2015.cool --BED test_regions.bed \
17+
--outFileName master_aggregate_cool.png \
18+
--numberOfBins 30 --range 50000:900000 --disable_bbox_tight
930 Bytes
Loading
-3.88 KB
Loading
14.9 KB
Loading
4.25 KB
Loading
0 Bytes
Loading

hicexplorer/test/test_hicAggregateContacts.py

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ def test_hicAggregateContacts():
2828

2929
outfile_aggregate_plots = NamedTemporaryFile(suffix='.png', prefix='hicaggregate_test_', delete=False)
3030

31-
args = "--matrix {root}/Li_et_al_2015.cool --BED {root}/hicAggregateContacts/test_regions.bed " \
32-
"--outFileName {out_agg} --numberOfBins 30 --range 50000:900000".\
31+
args = "--matrix {root}/Li_et_al_2015.h5 --BED {root}/hicAggregateContacts/test_regions.bed " \
32+
"--outFileName {out_agg} --numberOfBins 30 --range 50000:900000 --disable_bbox_tight ".\
3333
format(root=ROOT, out_agg=outfile_aggregate_plots.name)
3434

3535
test_image_agg = ROOT + 'hicAggregateContacts/master_aggregate.png'
@@ -42,16 +42,36 @@ def test_hicAggregateContacts():
4242
os.remove(outfile_aggregate_plots.name)
4343

4444

45+
@pytest.mark.skipif(MID_MEMORY > memory,
46+
reason="Travis has too less memory to run it.")
47+
def test_hicAggregateContacts_cooler():
48+
49+
outfile_aggregate_plots = NamedTemporaryFile(suffix='.png', prefix='hicaggregate_test_', delete=False)
50+
51+
args = "--matrix {root}/Li_et_al_2015.cool --BED {root}/hicAggregateContacts/test_regions.bed " \
52+
"--outFileName {out_agg} --numberOfBins 30 --range 50000:900000 --disable_bbox_tight ".\
53+
format(root=ROOT, out_agg=outfile_aggregate_plots.name)
54+
55+
test_image_agg = ROOT + 'hicAggregateContacts/master_aggregate_cool.png'
56+
57+
hicexplorer.hicAggregateContacts.main(args.split())
58+
59+
res = compare_images(test_image_agg, outfile_aggregate_plots.name, tolerance)
60+
assert res is None, res
61+
62+
os.remove(outfile_aggregate_plots.name)
63+
64+
4565
@pytest.mark.skipif(MID_MEMORY > memory,
4666
reason="Travis has too less memory to run it.")
4767
def test_hicAggregateContacts_clustering():
4868

4969
outfile_aggregate_plots = NamedTemporaryFile(suffix='.png', prefix='hicaggregate_test_', delete=False)
5070
outfile_heatmaps = NamedTemporaryFile(suffix='.png', prefix='hicaggregate_heatmap_', delete=False)
5171

52-
args = "--matrix {root}/Li_et_al_2015.cool --BED {root}/hicAggregateContacts/test_regions.bed " \
72+
args = "--matrix {root}/Li_et_al_2015.h5 --BED {root}/hicAggregateContacts/test_regions.bed " \
5373
"--outFileName {out_agg} --numberOfBins 30 --range 50000:900000 --hclust 4 " \
54-
"--diagnosticHeatmapFile {out_heat} --howToCluster diagonal " \
74+
"--diagnosticHeatmapFile {out_heat} --howToCluster diagonal --disable_bbox_tight " \
5575
"--BED2 {root}/hicAggregateContacts/test_regions.bed".format(root=ROOT, out_agg=outfile_aggregate_plots.name,
5676
out_heat=outfile_heatmaps.name)
5777

@@ -76,9 +96,9 @@ def test_hicAggregateContacts_3d():
7696

7797
outfile_aggregate_3d = NamedTemporaryFile(suffix='.png', prefix='hicaggregate_test_3d', delete=False)
7898

79-
args = "--matrix {root}/Li_et_al_2015.cool --BED {root}/hicAggregateContacts/test_regions.bed " \
99+
args = "--matrix {root}/Li_et_al_2015.h5 --BED {root}/hicAggregateContacts/test_regions.bed " \
80100
"--outFileName {out_agg} --numberOfBins 30 --range 50000:900000 --hclust 2 " \
81-
"--plotType 3d " \
101+
"--plotType 3d --disable_bbox_tight " \
82102
"--BED2 {root}/hicAggregateContacts/test_regions.bed".format(root=ROOT, out_agg=outfile_aggregate_3d.name)
83103

84104
test_image_agg_3d = ROOT + 'hicAggregateContacts/master_aggregate_3d.png'

0 commit comments

Comments
 (0)