diff --git a/pydeeptools/deeptools/test/test_data/multiBamSummary_result1.npz b/pydeeptools/deeptools/test/test_data/multiBamSummary_result1.npz new file mode 100644 index 0000000000..1794296243 Binary files /dev/null and b/pydeeptools/deeptools/test/test_data/multiBamSummary_result1.npz differ diff --git a/pydeeptools/deeptools/test/test_data/plotCorrelation_result1.png b/pydeeptools/deeptools/test/test_data/plotCorrelation_result1.png new file mode 100644 index 0000000000..a212f44e5b Binary files /dev/null and b/pydeeptools/deeptools/test/test_data/plotCorrelation_result1.png differ diff --git a/pydeeptools/deeptools/test/test_data/plotCorrelation_result2.png b/pydeeptools/deeptools/test/test_data/plotCorrelation_result2.png new file mode 100644 index 0000000000..db092d9bde Binary files /dev/null and b/pydeeptools/deeptools/test/test_data/plotCorrelation_result2.png differ diff --git a/pydeeptools/deeptools/test/test_plotcorrelation.py b/pydeeptools/deeptools/test/test_plotcorrelation.py new file mode 100644 index 0000000000..27a7415ecd --- /dev/null +++ b/pydeeptools/deeptools/test/test_plotcorrelation.py @@ -0,0 +1,45 @@ +import deeptools.plotCorrelation as pc + +import os.path +from os import unlink +from matplotlib.testing.compare import compare_images + + +ROOT = os.path.dirname(os.path.abspath(__file__)) + "/test_data/" +COR_DATA_IN1 = ROOT + "multiBamSummary_result1.npz" +COR_PLOT_1 = ROOT + "plotCorrelation_result1.png" +COR_PLOT_2 = ROOT + "plotCorrelation_result2.png" + + +def test_correlation_plot_with_minimal_options(): + """ + Test minimal command line args for correlation plot + with output as correlation matrix along with matrix + """ + out_matrix = '/tmp/correlation_matrix.tsv' + out_png = '/tmp/correlation_plot1.png' + args = "--corData {} -p heatmap -c pearson -o {} --outFileCorMatrix {}".format(COR_DATA_IN1, out_png, out_matrix).split() + pc.main(args) + + _foo = open(out_matrix, "r") + resp = _foo.readlines()[2] + _foo.close() + expected = "'bowtie2 test1.bam'\t1.0000\t1.0000\n" + assert expected in resp, f"'{expected}' not found in '{resp}'" + + res = compare_images(COR_PLOT_1, out_png, 50) + assert res is None, "Plots do not match" + unlink(out_png) + + +def test_correlation_plot_scatter(): + """ + Test command line args for correlation plot with output as scatter plot + """ + out_png2 = '/tmp/correlation_plot2.png' + args = "--corData {} -p scatterplot -c pearson -o {}".format(COR_DATA_IN1, out_png2).split() + pc.main(args) + + res = compare_images(COR_PLOT_2, out_png2, 50) + assert res is None, "Plots do not match" + unlink(out_png2)