Python matplotlib.testing.compare.compare_images() Examples

The following are 30 code examples of matplotlib.testing.compare.compare_images(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module matplotlib.testing.compare , or try the search function .
Example #1
Source File: test_hicCorrelate.py    From HiCExplorer with GNU General Public License v3.0 6 votes vote down vote up
def test_correlate():
    outfile_heatmap = NamedTemporaryFile(suffix='heatmap.png', prefix='hicexplorer_test', delete=False)
    outfile_scatter = NamedTemporaryFile(suffix='scatter.png', prefix='hicexplorer_test', delete=False)

    args = "--matrices {} {} --labels 'first' 'second' " \
        " --method spearman --log1p --colorMap jet "\
        "--outFileNameHeatmap {} --outFileNameScatter {}".format(ROOT + "hicCorrectMatrix/small_test_matrix_ICEcorrected_chrUextra_chr3LHet.h5",
                                                                 ROOT + "hicCorrectMatrix/small_test_matrix_ICEcorrected_chrUextra_chr3LHet.h5",
                                                                 outfile_heatmap.name, outfile_scatter.name).split()
    hicCorrelate.main(args)

    res = compare_images(ROOT + "hicCorrelate" + '/heatmap.png', outfile_heatmap.name, tol=40)
    assert res is None, res

    res = compare_images(ROOT + "hicCorrelate" + '/scatter.png', outfile_scatter.name, tol=40)
    assert res is None, res
    os.remove(outfile_heatmap.name)
    os.remove(outfile_scatter.name) 
Example #2
Source File: test_hiCMatrixTracks.py    From pyGenomeTracks with GNU General Public License v3.0 6 votes vote down vote up
def test_plot_tracks_with_hic():

    outfile = NamedTemporaryFile(suffix='.png', prefix='pyGenomeTracks_test_',
                                 delete=False)
    args = "--tracks {0} --region X:2500000-3500000 "\
           "--trackLabelFraction 0.23 --width 38 " \
           "--dpi 130 --outFileName {1}" \
           "".format(os.path.join(ROOT, 'browser_tracks_hic.ini'),
                     outfile.name).split()
    pygenometracks.plotTracks.main(args)
    res = compare_images(os.path.join(ROOT, 'master_plot_hic.png'),
                         outfile.name, tolerance)
    print("saving test to {}".format(outfile.name))
    assert res is None, res

    os.remove(outfile.name) 
Example #3
Source File: test_hiCMatrixTracks.py    From pyGenomeTracks with GNU General Public License v3.0 6 votes vote down vote up
def test_plot_tracks_with_hic_dec():

    outfile = NamedTemporaryFile(suffix='.png', prefix='pyGenomeTracks_test_',
                                 delete=False)
    args = "--tracks {0} --region X:2500000-3500000 "\
           "--trackLabelFraction 0.23 --width 38 " \
           "--dpi 130 --outFileName {1} --decreasingXAxis" \
           "".format(os.path.join(ROOT, 'browser_tracks_hic.ini'),
                     outfile.name).split()
    pygenometracks.plotTracks.main(args)
    res = compare_images(os.path.join(ROOT, 'master_plot_hic_dec.png'),
                         outfile.name, tolerance)
    print("saving test to {}".format(outfile.name))
    assert res is None, res

    os.remove(outfile.name) 
Example #4
Source File: test_chicPlotViewpoint.py    From HiCExplorer with GNU General Public License v3.0 6 votes vote down vote up
def test_one_viewpoint_per_file_batch_mode():
    output_folder = mkdtemp(prefix="output_")

    args = "-if {} -iff {} --range {} {} --outputFolder {} -psn {} -bm -t {}".format(ROOT + 'chicViewpoint/fileNames_one_matrix.txt',
                                                                                     ROOT + 'chicViewpoint/output_4',
                                                                                     200000, 200000,
                                                                                     output_folder, 1, 1).split()
    chicPlotViewpoint.main(args)

    res = compare_images(ROOT + 'chicPlotViewpoint/batchMode/one/Eya1_FL-E13-5_chr1_chr1_14300280.png',
                         output_folder + '/Eya1_FL-E13-5_chr1_chr1_14300280.png', tolerance)
    assert res is None, res
    res = compare_images(ROOT + 'chicPlotViewpoint/batchMode/one/Sox17_FL-E13-5_chr1_chr1_4487435.png',
                         output_folder + '/Sox17_FL-E13-5_chr1_chr1_4487435.png', tolerance)
    assert res is None, res
    res = compare_images(ROOT + 'chicPlotViewpoint/batchMode/one/Tfap2d_FL-E13-5_chr1_chr1_19093103.png',
                         output_folder + '/Tfap2d_FL-E13-5_chr1_chr1_19093103.png', tolerance)
    assert res is None, res
    assert set(os.listdir(ROOT + "chicPlotViewpoint/batchMode/one")
               ) == set(os.listdir(output_folder)) 
Example #5
Source File: test_hiCMatrixTracks.py    From pyGenomeTracks with GNU General Public License v3.0 6 votes vote down vote up
def test_plot_tracks_with_hic_rasterize_height():

    outfile = NamedTemporaryFile(suffix='.pdf', prefix='pyGenomeTracks_test_',
                                 delete=False)
    args = "--tracks {0} --region X:2500000-2600000 "\
           "--trackLabelFraction 0.23 --width 38 " \
           "--dpi 10 --outFileName {1}" \
           "".format(os.path.join(ROOT,
                                  'browser_tracks_hic_rasterize_height.ini'),
                     outfile.name).split()
    pygenometracks.plotTracks.main(args)
    res = compare_images(os.path.join(ROOT,
                                      'master_plot_hic_rasterize_height.pdf'),
                         outfile.name, tolerance)
    assert res is None, res

    os.remove(outfile.name) 
Example #6
Source File: test_hicCorrelate.py    From HiCExplorer with GNU General Public License v3.0 6 votes vote down vote up
def test_correlate_chromosomes():
    outfile_heatmap = NamedTemporaryFile(suffix='heatmap.png', prefix='hicexplorer_test', delete=False)
    outfile_scatter = NamedTemporaryFile(suffix='scatter.png', prefix='hicexplorer_test', delete=False)

    args = "--matrices {} {} --labels 'first' 'second' " \
        " --method spearman --log1p --colorMap jet "\
        "--outFileNameHeatmap {} --outFileNameScatter {} " \
        "--chromosomes chrUextra chr3LHet".format(ROOT + "hicCorrectMatrix/small_test_matrix_ICEcorrected_chrUextra_chr3LHet.h5",
                                                  ROOT + "hicCorrectMatrix/small_test_matrix_ICEcorrected_chrUextra_chr3LHet.h5",
                                                  outfile_heatmap.name, outfile_scatter.name).split()
    hicCorrelate.main(args)

    res = compare_images(ROOT + "hicCorrelate" + '/heatmap_chrom.png', outfile_heatmap.name, tol=40)
    assert res is None, res

    res = compare_images(ROOT + "hicCorrelate" + '/scatter_chrom.png', outfile_scatter.name, tol=40)
    assert res is None, res
    os.remove(outfile_heatmap.name)
    os.remove(outfile_scatter.name) 
Example #7
Source File: test_hicAggregateContacts.py    From HiCExplorer with GNU General Public License v3.0 6 votes vote down vote up
def test_hicAggregateContacts_3d_cooler():

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

    args = "--matrix {root}/Li_et_al_2015.cool --BED {root}/hicAggregateContacts/test_regions.bed " \
           "--outFileName {out_agg} --numberOfBins 30 --range 50000:900000 --hclust 2 --dpi 100 " \
           "--plotType 3d --disable_bbox_tight " \
           "--BED2 {root}/hicAggregateContacts/test_regions.bed".format(root=ROOT, out_agg=outfile_aggregate_3d.name)

    test_image_agg_3d = ROOT + 'hicAggregateContacts/master_aggregate_3d.png'

    hicexplorer.hicAggregateContacts.main(args.split())

    res = compare_images(test_image_agg_3d, outfile_aggregate_3d.name, tolerance)
    assert res is None, res

    os.remove(outfile_aggregate_3d.name) 
Example #8
Source File: test_hicAggregateContacts.py    From HiCExplorer with GNU General Public License v3.0 6 votes vote down vote up
def test_hicAggregateContacts_clustering_cool():

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

    args = "--matrix {root}/Li_et_al_2015.cool --BED {root}/hicAggregateContacts/test_regions.bed " \
           "--outFileName {out_agg} --numberOfBins 30 --range 50000:900000 --hclust 4 " \
           "--diagnosticHeatmapFile {out_heat} --howToCluster diagonal  --disable_bbox_tight --dpi 100 " \
           "--BED2 {root}/hicAggregateContacts/test_regions.bed".format(root=ROOT, out_agg=outfile_aggregate_plots.name,
                                                                        out_heat=outfile_heatmaps.name)

    test_image_agg = ROOT + 'hicAggregateContacts/master_aggregate_hclust4.png'
    test_image_heatmap = ROOT + 'hicAggregateContacts/master_heatmap.png'

    hicexplorer.hicAggregateContacts.main(args.split())

    res = compare_images(test_image_agg, outfile_aggregate_plots.name, tolerance)
    assert res is None, res

    res = compare_images(test_image_heatmap, outfile_heatmaps.name, tolerance)
    assert res is None, res

    os.remove(outfile_aggregate_plots.name)
    os.remove(outfile_heatmaps.name) 
Example #9
Source File: test_hicAggregateContacts.py    From HiCExplorer with GNU General Public License v3.0 6 votes vote down vote up
def test_hicAggregateContacts_clustering():

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

    args = "--matrix {root}/Li_et_al_2015.h5 --BED {root}/hicAggregateContacts/test_regions.bed " \
           "--outFileName {out_agg} --numberOfBins 30 --range 50000:900000 --hclust 4 " \
           "--diagnosticHeatmapFile {out_heat} --howToCluster diagonal  --disable_bbox_tight --dpi 100 " \
           "--BED2 {root}/hicAggregateContacts/test_regions.bed".format(root=ROOT, out_agg=outfile_aggregate_plots.name,
                                                                        out_heat=outfile_heatmaps.name)

    test_image_agg = ROOT + 'hicAggregateContacts/master_aggregate_hclust4.png'
    test_image_heatmap = ROOT + 'hicAggregateContacts/master_heatmap.png'

    hicexplorer.hicAggregateContacts.main(args.split())

    res = compare_images(test_image_agg, outfile_aggregate_plots.name, tolerance)
    assert res is None, res

    res = compare_images(test_image_heatmap, outfile_heatmaps.name, tolerance)
    assert res is None, res

    os.remove(outfile_aggregate_plots.name)
    os.remove(outfile_heatmaps.name) 
Example #10
Source File: test_hicAggregateContacts.py    From HiCExplorer with GNU General Public License v3.0 6 votes vote down vote up
def test_hicAggregateContacts_cooler():

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

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

    test_image_agg = ROOT + 'hicAggregateContacts/master_aggregate.png'  # noqa: F841

    hicexplorer.hicAggregateContacts.main(args.split())

    res = compare_images(test_image_agg, outfile_aggregate_plots.name, tolerance)
    assert res is None, res

    os.remove(outfile_aggregate_plots.name) 
Example #11
Source File: test_compare_images.py    From neural-network-animation with MIT License 6 votes vote down vote up
def image_comparison_expect_rms(im1, im2, tol, expect_rms):
    """Compare two images, expecting a particular RMS error.

    im1 and im2 are filenames relative to the baseline_dir directory.

    tol is the tolerance to pass to compare_images.

    expect_rms is the expected RMS value, or None. If None, the test will
    succeed if compare_images succeeds. Otherwise, the test will succeed if
    compare_images fails and returns an RMS error almost equal to this value.
    """
    im1 = os.path.join(baseline_dir, im1)
    im2_src = os.path.join(baseline_dir, im2)
    im2 = os.path.join(result_dir, im2)
    # Move im2 from baseline_dir to result_dir. This will ensure that
    # compare_images writes the diff file to result_dir, instead of trying to
    # write to the (possibly read-only) baseline_dir.
    shutil.copyfile(im2_src, im2)
    results = compare_images(im1, im2, tol=tol, in_decorator=True)

    if expect_rms is None:
        assert_equal(None, results)
    else:
        assert_not_equal(None, results)
        assert_almost_equal(expect_rms, results['rms'], places=4) 
Example #12
Source File: test_hicAggregateContacts.py    From HiCExplorer with GNU General Public License v3.0 6 votes vote down vote up
def test_hicAggregateContacts():

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

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

    test_image_agg = ROOT + 'hicAggregateContacts/master_aggregate.png'

    hicexplorer.hicAggregateContacts.main(args.split())

    res = compare_images(test_image_agg, outfile_aggregate_plots.name, tolerance)
    assert res is None, res

    os.remove(outfile_aggregate_plots.name) 
Example #13
Source File: test_chicPlotViewpoint.py    From HiCExplorer with GNU General Public License v3.0 5 votes vote down vote up
def test_two_viewpoint_background_differential():
    outfile = NamedTemporaryFile(suffix='.png', delete=False)
    outfile.close()
    args = "-if {} {} --range {} {} -o {} -bmf {} --differentialTestResult {} -t {}".format(
        ROOT + 'chicViewpoint/output_1/FL-E13-5_chr1_chr1_14300280_14300280_Eya1.txt',
        ROOT + 'chicViewpoint/output_1/MB-E10-5_chr1_chr1_14300280_14300280_Eya1.txt',
        200000, 200000, outfile.name, ROOT + 'background.txt',
        ROOT + 'chicDifferentialTest/batch_mode_fisher/FL-E13-5_MB-E10-5_chr1_chr1_14300280_14300280_Eya1_H0_rejected.txt', 1).split()
    chicPlotViewpoint.main(args)

    res = compare_images(
        ROOT + 'chicPlotViewpoint/two_viewpoint_background_differential.png', outfile.name, tolerance)
    assert res is None, res 
Example #14
Source File: test_hicPlotMatrix.py    From HiCExplorer with GNU General Public License v3.0 5 votes vote down vote up
def test_hicPlotMatrix_cool_log_region1_region2():

    outfile = NamedTemporaryFile(suffix='.png', prefix='hicexplorer_test_cool', delete=False)

    args = "--matrix {0}/Li_et_al_2015.cool --region chrX:3000000-3500000 --region2 chrX:3100000-3600000 " \
           "--outFileName  {1} --log ".format(ROOT, outfile.name).split()
    hicexplorer.hicPlotMatrix.main(args)
    res = compare_images(ROOT + "hicPlotMatrix" + '/Li_chrX30-35-chrX31-36_cool_log.png', outfile.name, tol=tolerance)
    assert res is None, res
    if REMOVE_OUTPUT:
        os.remove(outfile.name)


# @pytest.mark.xfail 
Example #15
Source File: test_hicPlotMatrix.py    From HiCExplorer with GNU General Public License v3.0 5 votes vote down vote up
def test_hicPlotMatrix_h5_full():

    outfile = NamedTemporaryFile(suffix='.png', prefix='hicexplorer_test_h5', delete=False)

    args = "--matrix {0}/Li_et_al_2015.h5 " \
           "--outFileName  {1} ".format(ROOT, outfile.name).split()
    hicexplorer.hicPlotMatrix.main(args)
    res = compare_images(ROOT + "hicPlotMatrix" + '/Li_h5.png', outfile.name, tol=tolerance)
    assert res is None, res
    if REMOVE_OUTPUT:
        os.remove(outfile.name) 
Example #16
Source File: test_hicPlotMatrix.py    From HiCExplorer with GNU General Public License v3.0 5 votes vote down vote up
def test_hicPlotMatrix_h5_log():

    outfile = NamedTemporaryFile(suffix='.png', prefix='hicexplorer_test_h5', delete=False)

    args = "--matrix {0}/Li_et_al_2015.h5 --log " \
           "--outFileName  {1} ".format(ROOT, outfile.name).split()
    hicexplorer.hicPlotMatrix.main(args)
    res = compare_images(ROOT + "hicPlotMatrix" + '/Li_h5_log.png', outfile.name, tol=tolerance)
    assert res is None, res
    if REMOVE_OUTPUT:
        os.remove(outfile.name) 
Example #17
Source File: test_hicPlotMatrix.py    From HiCExplorer with GNU General Public License v3.0 5 votes vote down vote up
def test_hicPlotMatrix_h5_log1p():

    outfile = NamedTemporaryFile(suffix='.png', prefix='hicexplorer_test_h5', delete=False)

    args = "--matrix {0}/Li_et_al_2015.h5 --log1p " \
           "--outFileName  {1} ".format(ROOT, outfile.name).split()
    hicexplorer.hicPlotMatrix.main(args)
    res = compare_images(ROOT + "hicPlotMatrix" + '/Li_h5_log1p.png', outfile.name, tol=tolerance)
    assert res is None, res
    if REMOVE_OUTPUT:
        os.remove(outfile.name) 
Example #18
Source File: test_hicPlotMatrix.py    From HiCExplorer with GNU General Public License v3.0 5 votes vote down vote up
def test_hicPlotMatrix_cool_log1p_region1_region2():

    outfile = NamedTemporaryFile(suffix='.png', prefix='hicexplorer_test_cool', delete=False)

    args = "--matrix {0}/Li_et_al_2015.cool --region chrX:3000000-3500000 --region2 chrX:3100000-3600000 " \
           "--outFileName  {1} --log1p ".format(ROOT, outfile.name).split()
    hicexplorer.hicPlotMatrix.main(args)
    res = compare_images(ROOT + "hicPlotMatrix" + '/Li_chrX30-35-chrX31-36_cool_log1p.png', outfile.name, tol=tolerance)
    assert res is None, res
    if REMOVE_OUTPUT:
        os.remove(outfile.name) 
Example #19
Source File: test_hicPlotMatrix.py    From HiCExplorer with GNU General Public License v3.0 5 votes vote down vote up
def test_hicPlotMatrix_cool_perChr_log1p():

    outfile = NamedTemporaryFile(suffix='.png', prefix='hicexplorer_test', delete=False)

    args = "--matrix {0}/small_test_matrix_50kb_res.h5 --perChr  --disable_tight_layout " \
           "--outFileName  {1} --log1 --vMax 10 ".format(ROOT, outfile.name).split()
    hicexplorer.hicPlotMatrix.main(args)
    res = compare_images(ROOT + "hicPlotMatrix" + '/small_test_matrix_50kb_res_perChr_log.png', outfile.name, tol=tolerance)
    assert res is None, res
    if REMOVE_OUTPUT:
        os.remove(outfile.name)


# @pytest.mark.xfail 
Example #20
Source File: test_hicPlotMatrix.py    From HiCExplorer with GNU General Public License v3.0 5 votes vote down vote up
def test_hicPlotMatrix_cool_perChr_log1p_chromosomeOrder():

    outfile = NamedTemporaryFile(suffix='.png', prefix='hicexplorer_test', delete=False)

    args = "--matrix {0}/small_test_matrix_50kb_res.cool --perChr " \
           "--outFileName  {1} --log1p --chromosomeOrder chr2L chr3L chr3R chr2R".format(ROOT, outfile.name).split()
    hicexplorer.hicPlotMatrix.main(args)
    res = compare_images(ROOT + "hicPlotMatrix" + '/small_test_matrix_perChr_log1p_chromosomeOrder.png', outfile.name, tol=tolerance)
    assert res is None, res
    if REMOVE_OUTPUT:
        os.remove(outfile.name) 
Example #21
Source File: test_hicPlotMatrix.py    From HiCExplorer with GNU General Public License v3.0 5 votes vote down vote up
def test_hicPlotMatrix_h5_perChr_log1p_chromosomeOrder():
    outfile = NamedTemporaryFile(suffix='.png', prefix='hicexplorer_test', delete=False)

    args = "--matrix {0}/small_test_matrix_50kb_res.h5 --perChr  --disable_tight_layout " \
           "--outFileName  {1} --log --chromosomeOrder chr2L chr3L chr3R chr2R".format(ROOT, outfile.name).split()
    hicexplorer.hicPlotMatrix.main(args)
    res = compare_images(ROOT + "hicPlotMatrix" + '/small_test_matrix_perChr_log1p_chromosomeOrder_disable_tight_layout.png', outfile.name, tol=tolerance)
    assert res is None, res
    if REMOVE_OUTPUT:
        os.remove(outfile.name) 
Example #22
Source File: test_chicPlotViewpoint.py    From HiCExplorer with GNU General Public License v3.0 5 votes vote down vote up
def test_one_viewpoint_colormap_pvalue_truncate_zeros():
    outfile = NamedTemporaryFile(suffix='.png', delete=False)
    outfile.close()
    args = "-if {} --range {} {} --pValue --colorMapPvalue {} -o {} --pValue --colorMapPvalue plasma --maxPValue 0.5 --minPValue 0.1 -t {} --truncateZeroPvalues".format(
        ROOT + 'chicViewpoint/output_1/FL-E13-5_chr1_chr1_14300280_14300280_Eya1.txt', 200000, 200000, 'plasma', outfile.name, 1).split()
    chicPlotViewpoint.main(args)

    res = compare_images(
        ROOT + 'chicPlotViewpoint/two_viewpoint_pvalue.png', outfile.name, tolerance)
    assert res is None, res 
Example #23
Source File: test_chicPlotViewpoint.py    From HiCExplorer with GNU General Public License v3.0 5 votes vote down vote up
def test_one_viewpoint_colormap_pvalue():
    outfile = NamedTemporaryFile(suffix='.png', delete=False)
    outfile.close()
    args = "-if {} --range {} {} --pValue --colorMapPvalue {} -o {} --pValue --colorMapPvalue plasma --maxPValue 0.5 --minPValue 0.1 -t {}".format(
        ROOT + 'chicViewpoint/output_1/FL-E13-5_chr1_chr1_14300280_14300280_Eya1.txt', 200000, 200000, 'plasma', outfile.name, 1).split()
    chicPlotViewpoint.main(args)

    res = compare_images(
        ROOT + 'chicPlotViewpoint/two_viewpoint_pvalue.png', outfile.name, tolerance)
    assert res is None, res 
Example #24
Source File: test_chicQualityControl.py    From HiCExplorer with GNU General Public License v3.0 5 votes vote down vote up
def test_two_matrices():

    outfile = NamedTemporaryFile(suffix='.bed', delete=False)
    outfile_histogram = NamedTemporaryFile(suffix='.png', delete=False)
    outfile_sparsity = NamedTemporaryFile(suffix='.png', delete=False)

    outfile.close()
    args = "--matrices {} {} --referencePoints {} --sparsity {} --outFileName {} --outFileNameHistogram {} --outFileNameSparsity  {} -t {}".format(ROOT + 'FL-E13-5_chr1.cool',
                                                                                                                                                   ROOT + 'MB-E10-5_chr1.cool',
                                                                                                                                                   ROOT + 'referencePoints_qc.bed',
                                                                                                                                                   0.05,
                                                                                                                                                   outfile.name, outfile_histogram.name, outfile_sparsity.name, 1).split()
    chicQualityControl.main(args)

    assert are_files_equal(
        ROOT + "chicQualityControl/new_referencepoints.bed", outfile.name)
    assert are_files_equal(
        ROOT + "chicQualityControl/new_referencepoints.bed_raw_filter", outfile.name + '_raw_filter', skip=4)
    assert are_files_equal(ROOT + "chicQualityControl/new_referencepoints.bed_rejected_filter",
                           outfile.name + '_rejected_filter', skip=2)
    assert are_files_equal(ROOT + "chicQualityControl/new_referencepoints.bed_report",
                           outfile.name + '_report', skip=2)
    assert are_files_equal(ROOT + "chicQualityControl/new_referencepoints.bed_failed_reference_points",
                           outfile.name + '_report', skip=2)

    res = compare_images(
        ROOT + "chicQualityControl/histogram.png", outfile_histogram.name, 50)
    assert res is None, res

    res = compare_images(
        ROOT + "chicQualityControl/sparsity.png", outfile_sparsity.name, 50)
    assert res is None, res 
Example #25
Source File: test_chicPlotViewpoint.py    From HiCExplorer with GNU General Public License v3.0 5 votes vote down vote up
def test_two_viewpoint_background_significant():
    outfile = NamedTemporaryFile(suffix='.png', delete=False)
    outfile.close()
    args = "-if {} {} --range {} {} -o {} -bmf {} --significantInteractions {} {} -t {}".format(
        ROOT + 'chicViewpoint/output_1/FL-E13-5_chr1_chr1_14300280_14300280_Eya1.txt',
        ROOT + 'chicViewpoint/output_1/MB-E10-5_chr1_chr1_14300280_14300280_Eya1.txt',
        200000, 200000, outfile.name, ROOT + 'background.txt',
        ROOT + 'chicSignificantInteractions/output_3/FL-E13-5_chr1_chr1_14300280_14300280_Eya1_output_significant.txt',
        ROOT + 'chicSignificantInteractions/output_3/MB-E10-5_chr1_chr1_14300280_14300280_Eya1_output_significant.txt', 1).split()
    chicPlotViewpoint.main(args)

    res = compare_images(
        ROOT + 'chicPlotViewpoint/two_viewpoint_background_significant.png', outfile.name, tolerance)
    assert res is None, res 
Example #26
Source File: test_chicPlotViewpoint.py    From HiCExplorer with GNU General Public License v3.0 5 votes vote down vote up
def test_two_viewpoint_fileformat_dpi():
    outfile = NamedTemporaryFile(suffix='.pdf', delete=False)
    outfile.close()
    args = "-if {} {} --range {} {} -o {} --dpi {} --outputFormat {} -t {}".format(
        ROOT + 'chicViewpoint/output_1/FL-E13-5_chr1_chr1_14300280_14300280_Eya1.txt',
        ROOT + 'chicViewpoint/output_1/MB-E10-5_chr1_chr1_14300280_14300280_Eya1.txt',
        200000, 200000, outfile.name, 100, 'pdf', 1).split()
    chicPlotViewpoint.main(args)

    res = compare_images(
        ROOT + 'chicPlotViewpoint/two_viewpoint.pdf', outfile.name, tolerance)
    assert res is None, res
# additional background model 
Example #27
Source File: test_chicPlotViewpoint.py    From HiCExplorer with GNU General Public License v3.0 5 votes vote down vote up
def test_one_viewpoint():
    outfile = NamedTemporaryFile(suffix='.png', delete=False)
    outfile.close()
    args = "-if {} --range {} {} -o {} -t {}".format(
        ROOT + 'chicViewpoint/output_1/FL-E13-5_chr1_chr1_14300280_14300280_Eya1.txt', 200000, 200000, outfile.name, 1).split()
    chicPlotViewpoint.main(args)

    res = compare_images(
        ROOT + 'chicPlotViewpoint/FL-E13-5_chr1_chr1_14300280_14300280_Eya1.png', outfile.name, tolerance)
    assert res is None, res

# n - viewpoints, jpg 
Example #28
Source File: test_hicCompartmentalization.py    From HiCExplorer with GNU General Public License v3.0 5 votes vote down vote up
def test_compartmentalization():
    outfile = NamedTemporaryFile(suffix='.png', delete=False)
    outfile.close()

    args = " -m {} --pca {} -o {} --outliers 0.0 --quantile 30".format(ROOT + "hicPCA/obsexp_norm.h5",
                                                                       ROOT + "hicCompartmentalization/pca1.bedgraph",
                                                                       outfile.name).split()
    hicCompartmentalization.main(args)
    test = ROOT + "hicCompartmentalization/compartmentalizationRatio.png"
    res = compare_images(test, outfile.name, tolerance)
    assert res is None, res

    os.unlink(outfile.name) 
Example #29
Source File: test_bedGraphMatrixTrack.py    From pyGenomeTracks with GNU General Public License v3.0 5 votes vote down vote up
def test_bedgraphmatrix_track():
    region = "X:2850000-3150000"
    outfile = NamedTemporaryFile(suffix='.png', prefix='bedgraph_test_', delete=False)
    args = "--tracks {ini} --region {region} --trackLabelFraction 0.2 " \
           "--dpi 130 --outFileName {outfile}" \
           "".format(ini=os.path.join(ROOT, "bedgraph.ini"),
                     outfile=outfile.name, region=region).split()
    pygenometracks.plotTracks.main(args)
    print("saving test to {}".format(outfile.name))
    res = compare_images(os.path.join(ROOT, 'master_bedgraph.png'),
                         outfile.name, tolerance)
    assert res is None, res

    os.remove(outfile.name) 
Example #30
Source File: test_arcs.py    From pyGenomeTracks with GNU General Public License v3.0 5 votes vote down vote up
def test_short_long_arcs():

    outfile = NamedTemporaryFile(suffix='.png', prefix='pyGenomeTracks_test_', delete=False)
    args = "--tracks {0} --region chr11:40000000-46000000 --trackLabelFraction 0.2" \
           " --width 38 --dpi 130 --outFileName {1}" \
           "".format(os.path.join(ROOT, "short_long_arcs.ini"),
                     outfile.name).split()
    pygenometracks.plotTracks.main(args)
    print("saving test to {}".format(outfile.name))
    res = compare_images(os.path.join(ROOT, 'master_short_long_arcs.png'),
                         outfile.name, tolerance)
    assert res is None, res

    os.remove(outfile.name)