Skip to content
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

add plotPCA test #1374

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
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 32 additions & 0 deletions pydeeptools/deeptools/test/test_plotPCA.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import deeptools.plotPCA
import deeptools.utilities
import os.path
from os import unlink
from matplotlib.testing.compare import compare_images
import numpy as np
import numpy.testing as nt

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

def test_plotPCA():
"""
Test minimal command line args for plotPCA
"""
COR = ROOT + "multiBamSummary_result2b.npz"
outpng = '/tmp/test_plot.png'
outdata = '/tmp/test_plot_data.txt'

args = "--corData {} --plotTitle Test-Plot --plotFile {} --outFileNameData {}".format(COR,outpng, outdata).split()
deeptools.plotPCA.main(args)

res = compare_images(ROOT + 'plotPCA_result.png', outpng, 50)
assert res is None, res
unlink(outpng)

resp = np.loadtxt(outdata, skiprows=2, delimiter='\t')

expected = np.array([[1,-0.7071067811865476,-0.7071067811865475,4.0],
[2,-0.7071067811865475,0.7071067811865476,1.2325951644078315e-28]])

nt.assert_allclose(resp, expected, atol=1e-10)
unlink(outdata)
Loading