Skip to content

Add tests for plotEnrichment #1371

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: 4.0.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
chrM 1 10
chrM 5 15
chrM 10 20
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 39 additions & 0 deletions pydeeptools/deeptools/test/test_plotEnrichment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import deeptools.plotEnrichment
import deeptools.utilities
import os.path
from os import unlink
from matplotlib.testing.compare import compare_images

ROOT = os.path.dirname(os.path.abspath(__file__)) + "/test_data/"


def test_plotEnrichment():
"""
Test minimal command line args for plotEnrichment
"""
BAM = ROOT + "bowtie2_test1.bam"
BED = ROOT + "multiBamSummary_regions.bed"
outpng = '/tmp/test_plot.png'
outcounts = '/tmp/test_counts.txt'

args = "--bamfiles {0} {0} --BED {1} {1} --minMappingQuality 0 --labels bowtie2_test1.bam bowtie2_test1.bam --regionLabels up down --plotWidth 20 --plotHeight 20 --numPlotsPerRow 4 --alpha 0.9 --plotFileFormat png --plotFile {2} --outRawCounts {3}".format(BAM, BED, outpng, outcounts).split()
deeptools.plotEnrichment.main(args)

res = compare_images(ROOT + 'plotEnrichment_output.png', outpng, 50)


assert res is None, res
unlink(outpng)

_foo = open(outcounts, 'r')
resp = _foo.readlines()
_foo.close()

expected = ['file\tfeatureType\tpercent\tfeatureReadCount\ttotalReadCount\n',
'bowtie2_test1.bam\tup\t100.00\t47\t47\n',
'bowtie2_test1.bam\tdown\t100.00\t47\t47\n',
'bowtie2_test1.bam\tup\t100.00\t47\t47\n',
'bowtie2_test1.bam\tdown\t100.00\t47\t47\n']

assert f"{resp}" == f"{expected}", f"{resp} != {expected}"
unlink(outcounts)
Loading