def test_multiBigwigSummary():
    outfile = "/tmp/result.bg"
    args = "bins -b {} {} --binSize 50 -o {}".format(BIGWIG_A, BIGWIG_B, outfile).split()
    bwCorr.main(args)
    resp = np.load(outfile)
    matrix = resp["matrix"]
    labels = resp["labels"]
    nt.assert_equal(matrix, np.array([[np.nan, np.nan], [np.nan, 1.0], [1.0, 1.0], [1.0, 2.0]]))
    nt.assert_equal(labels, ["testA_skipNAs.bw", "testB_skipNAs.bw"])
    unlink(outfile)
예제 #2
0
def test_multiBigwigSummary_metagene():
    outfile = '/tmp/_test.npz'
    args = "BED-file --metagene -b {0} {0} --BED {1}/test.gtf -o {2}".format(BIGWIG_C, ROOT, outfile).split()
    bwCorr.main(args)
    resp = np.load(outfile)
    matrix = resp['matrix']
    labels = resp['labels']
    nt.assert_equal(labels, ['test1.bw.bw', 'test1.bw.bw'])
    nt.assert_allclose(matrix, np.array([[20.28956028, 20.28956028],
                                         [22.1923501, 22.1923501]]))
    unlink(outfile)
예제 #3
0
def test_multiBigwigSummary_gtf():
    outfile = '/tmp/_test.npz'
    args = "BED-file -b {0} {0} --BED {1}/test.gtf -o {2}".format(BIGWIG_C, ROOT, outfile).split()
    bwCorr.main(args)
    resp = np.load(outfile)
    matrix = resp['matrix']
    labels = resp['labels']
    nt.assert_equal(labels, ['test1.bw.bw', 'test1.bw.bw'])
    nt.assert_allclose(matrix, np.array([[27.475, 27.475],
                                         [27.31248719, 27.31248719]]))
    unlink(outfile)
def test_multiBigwigSummary_metagene():
    outfile = '/tmp/_test.npz'
    args = "BED-file --metagene -b {0} {0} --BED {1}/test.gtf -o {2}".format(BIGWIG_C, ROOT, outfile).split()
    bwCorr.main(args)
    resp = np.load(outfile)
    matrix = resp['matrix']
    labels = resp['labels']
    nt.assert_equal(labels, ['test1.bw.bw', 'test1.bw.bw'])
    nt.assert_allclose(matrix, np.array([[20.28956028, 20.28956028],
                                         [22.1923501, 22.1923501]]))
    unlink(outfile)
def test_multiBigwigSummary_gtf():
    outfile = '/tmp/_test.npz'
    args = "BED-file -b {0} {0} --BED {1}/test.gtf -o {2}".format(BIGWIG_C, ROOT, outfile).split()
    bwCorr.main(args)
    resp = np.load(outfile)
    matrix = resp['matrix']
    labels = resp['labels']
    nt.assert_equal(labels, ['test1.bw.bw', 'test1.bw.bw'])
    nt.assert_allclose(matrix, np.array([[27.475, 27.475],
                                         [27.31248719, 27.31248719]]))
    unlink(outfile)
예제 #6
0
def test_multiBigwigSummary():
    outfile = '/tmp/result.bg'
    args = "bins -b {} {} --binSize 50 -o {}".format(BIGWIG_A, BIGWIG_B,
                                                     outfile).split()
    bwCorr.main(args)
    resp = np.load(outfile)
    matrix = resp['matrix']
    labels = resp['labels']
    nt.assert_equal(
        matrix, np.array([[np.nan, np.nan], [np.nan, 1.], [1., 1.], [1., 2.]]))
    nt.assert_equal(labels, ['testA_skipNAs.bw', 'testB_skipNAs.bw'])
    unlink(outfile)
def test_multiBigwigSummary():
    outfile = '/tmp/result.bg'
    args = "bins -b {} {} --binSize 50 -o {}".format(BIGWIG_A, BIGWIG_B, outfile).split()
    bwCorr.main(args)
    resp = np.load(outfile)
    matrix = resp['matrix']
    labels = resp['labels']
    nt.assert_equal(matrix, np.array([[np.nan, np.nan],
                                      [np.nan, 1.],
                                      [1., 1.],
                                      [1., 2.]]))
    nt.assert_equal(labels, ['testA_skipNAs.bw', 'testB_skipNAs.bw'])
    unlink(outfile)
def test_multiBigwigSummary_outrawcounts():
    """
    Test multiBigwigSummary raw counts output
    """
    outfile = "/tmp/result.bg"
    args = "bins -b {} {} --binSize 50 -o /tmp/null --outRawCounts {} ".format(BIGWIG_A, BIGWIG_B, outfile).split()
    bwCorr.main(args)
    resp = open(outfile, "r").read()
    expected = """#'chr'	'start'	'end'	'testA_skipNAs.bw'	'testB_skipNAs.bw'
3R	0	50	nan	nan
3R	50	100	nan	1.0
3R	100	150	1.0	1.0
3R	150	200	1.0	2.0
"""
    assert resp == expected, "{} != {}".format(resp, expected)
    unlink(outfile)
    unlink("/tmp/null")
예제 #9
0
def test_multiBigwigSummary_outrawcounts():
    """
    Test multiBigwigSummary raw counts output
    """
    outfile = '/tmp/result.bg'
    args = "bins -b {} {} --binSize 50 -o /tmp/null --outRawCounts {} ".format(
        BIGWIG_A, BIGWIG_B, outfile).split()
    bwCorr.main(args)
    resp = open(outfile, 'r').read()
    expected = """#'chr'	'start'	'end'	'testA_skipNAs.bw'	'testB_skipNAs.bw'
3R	0	50	nan	nan
3R	50	100	nan	1.0
3R	100	150	1.0	1.0
3R	150	200	1.0	2.0
"""
    assert resp == expected, "{} != {}".format(resp, expected)
    unlink(outfile)
    unlink("/tmp/null")
    # output file as compressed numpy array
    out_file = bw + sample_name + '_replCorr' + '.npz'
    out_fileB = bw + sample_name + '_replCorr' + '.npz'

    # output figure in SVG format
    out_figP = bw + sample_name + '_replCorr_pear' + '.svg'
    out_figS = bw + sample_name + '_replCorr_spear' + '.svg'
    out_fig = bw + sample_name + '_replCorr' + '.svg'

    print repl1, repl2, out_file

    # --binSize 50
    #args = "bins -b {} {}  -o {}".format(repl1, repl2, out_file).split()
    args = "BED-file -b {} {}  -o {} --binSize 500 --BED {}".format(
        repl1, repl2, out_fileB, bed_merged).split()
    bwCorr.main(args)
    #~ if not(os.path.exists(out_file)):
    #~ args = "bins -b {} {}  -o {}".format(repl1, repl2, out_file).split()
    #~ #args = "BED-file -b {} {}  -o {} --BED {}".format(repl1, repl2, out_file, bed_merged).split()
    #~ bwCorr.main(args)

    # Pearson correlation
    argsP = "-in {} --whatToPlot scatterplot --labels {} {} --corMethod {} -o {}".format(
        out_fileB, lb1, lb2, 'pearson', out_figP).split()
    pltCorr.main(argsP)

    # Spearman correlation
    argsS = "-in {} --whatToPlot scatterplot --labels {} {} --corMethod {} -o {}".format(
        out_fileB, lb1, lb2, 'spearman', out_figS).split()
    pltCorr.main(argsS)