コード例 #1
0
ファイル: test_scripts.py プロジェクト: daler/pybedtools
def test_venn_mpl():
    """
    compares output image to expected
    """
    try:
        import matplotlib
    except ImportError:
        import sys
        sys.stderr.write('Need matplotlib installed to test venn_mpl')
        return

    here = os.path.dirname(__file__)
    expected_fn = os.path.join(here, 'mpl-expected.png')

    original = pybedtools.example_bedtool('rmsk.hg18.chr21.small.bed').sort().merge()
    a = pybedtools.BedTool(original[:300]).saveas()
    b = pybedtools.BedTool(original[:20]).saveas().cat(pybedtools.BedTool(original[400:500]).saveas())
    c = pybedtools.BedTool(original[15:30]).saveas().cat(pybedtools.BedTool(original[450:650]).saveas())

    outfn = 'mplout.png'
    venn_mpl.venn_mpl(a=a.fn, b=b.fn, c=c.fn, colors=['r','b','g'], outfn=outfn, labels=['a','b','c'])

    # On a different machine, the created image is not visibly different but is
    # numerically different.  Not sure what a reasonable tolerance is, but this
    # seems to work for now....
    o = matplotlib.image.imread(outfn)
    e = matplotlib.image.imread(expected_fn)

    TOLERANCE = 200
    SUM = abs((o - e).sum())
    assert SUM < TOLERANCE, SUM

    os.unlink(outfn)
コード例 #2
0
def test_venn_mpl():
    """
    compares output image to expected
    """
    try:
        import matplotlib
    except ImportError:
        import sys
        sys.stderr.write('Need matplotlib installed to test venn_mpl')
        return

    here = os.path.dirname(__file__)
    expected_fn = os.path.join(here, 'mpl-expected.png')

    original = pybedtools.example_bedtool('rmsk.hg18.chr21.small.bed').sort().merge()
    a = pybedtools.BedTool(original[:300]).saveas()
    b = pybedtools.BedTool(original[:20]).saveas().cat(pybedtools.BedTool(original[400:500]).saveas())
    c = pybedtools.BedTool(original[15:30]).saveas().cat(pybedtools.BedTool(original[450:650]).saveas())

    outfn = 'mplout.png'
    venn_mpl.venn_mpl(a=a.fn, b=b.fn, c=c.fn, colors=['r','b','g'], outfn=outfn, labels=['a','b','c'])

    # On a different machine, the created image is not visibly different but is
    # numerically different.  Not sure what a reasonable tolerance is, but this
    # seems to work for now....
    o = matplotlib.image.imread(outfn)
    e = matplotlib.image.imread(expected_fn)

    TOLERANCE = 200
    SUM = abs((o - e).sum())
    assert SUM < TOLERANCE, SUM

    os.unlink(outfn)
コード例 #3
0
ファイル: test_scripts.py プロジェクト: Fabrices/pybedtools
def test_venn_mpl():
    """
    compares output image to expected
    """
    try:
        import matplotlib
    except ImportError:
        import sys
        sys.stderr.write('Need matplotlib installed to test venn_mpl')
        return

    here = os.path.dirname(__file__)
    expected_fn = os.path.join(here, 'mpl-expected.png')

    pybedtools.bedtool.random.seed(1)
    a = pybedtools.example_bedtool('rmsk.hg18.chr21.small.bed')
    b = a.random_subset(100).shuffle(genome='hg19', seed=1)
    b = b.cat(a.random_subset(100, seed=1))
    c = a.random_subset(200).shuffle(genome='hg19', seed=2)
    c = c.cat(b.random_subset(100, seed=1))

    outfn = 'mplout.png'
    venn_mpl.venn_mpl(a=a.fn, b=b.fn, c=c.fn, colors=['r','b','g'], outfn=outfn, labels=['a','b','c'])

    # On a different machine, the created image is not visibly different but is
    # numerically different.  Not sure what a reasonable tolerance is, but this
    # seems to work for now....
    o = matplotlib.image.imread(outfn)
    e = matplotlib.image.imread(expected_fn)

    TOLERANCE = 25
    assert abs((o - e).sum()) < TOLERANCE

    os.unlink(outfn)
コード例 #4
0
import pybedtools
from pybedtools.scripts import venn_mpl
from pybedtools.contrib import venn_maker

rheos = pybedtools.BedTool("/Users/siakhnin/data/giab/RMNISTHS_30xdownsample.chr20.rheos_kde_dels.bed")
delly = pybedtools.BedTool("/Users/siakhnin/data/giab/RMNISTHS_30xdownsample.chr20.no_spikein.delly.pass_only.dels.bed")
giab = pybedtools.BedTool("/Users/siakhnin/data/giab/Personalis_1000_Genomes_deduplicated_deletions_chr20_gt500bp.bed")
venn_mpl.venn_mpl(rheos, delly, giab, labels=["rheos", "delly", "giab"])
venn_maker.venn_maker(["/Users/siakhnin/data/giab/RMNISTHS_30xdownsample.chr20.rheos_kde_dels.bed",
                       "/Users/siakhnin/data/giab/RMNISTHS_30xdownsample.chr20.no_spikein.delly.pass_only.dels.bed",
                       "/Users/siakhnin/data/giab/Personalis_1000_Genomes_deduplicated_deletions_chr20_gt500bp.bed"],
                      names=["rheos","delly","giab"],
                      run=True,
                      figure_filename='out.png',
                      additional_args=['euler.d=TRUE',
                                       'scaled=TRUE',
                                       'cat.col=c("red","blue","green")',
                                       'col=c("red","blue","green")',
                                       'imagetype="png"']
                      )