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

matplotlib, bwAvg & pypi cicd #1260

Merged
merged 10 commits into from
Sep 27, 2023
1 change: 1 addition & 0 deletions .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ defaults:

jobs:
pypi:
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
name: upload to pypi
runs-on: ubuntu-latest
steps:
Expand Down
10 changes: 6 additions & 4 deletions deeptools/correlation.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,8 +503,9 @@ def plot_scatter(self, plot_filename, plot_title='', image_format=None, log1p=Fa
top=False,
bottom=False,
direction='out')
for tick in ax.xaxis.get_major_ticks():
tick.label.set_rotation(45)
ax.get_xaxis().set_tick_params(
which='major',
labelrotation=45)

if col != num_samples - 1:
ax.set_yticklabels([])
Expand All @@ -522,8 +523,9 @@ def plot_scatter(self, plot_filename, plot_title='', image_format=None, log1p=Fa
top=False,
bottom=True,
direction='out')
for tick in ax.xaxis.get_major_ticks():
tick.label.set_rotation(45)
ax.get_xaxis().set_tick_params(
which='major',
labelrotation=45)

else:
ax.set_xticklabels([])
Expand Down
12 changes: 12 additions & 0 deletions deeptools/test/test_bigwigAverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,15 @@ def test_bigwigAverageWithScale():
expected = ['3R\t0\t50\t0\n', '3R\t50\t100\t0.25\n', '3R\t100\t150\t0.75\n', '3R\t150\t200\t1\n']
assert f"{resp}" == f"{expected}", f"{resp} != {expected}"
unlink(outfile)


def test_bigwigAverageThree():
outfile = '/tmp/result.bg'
args = "--bigwigs {} {} {} -o {} --outFileFormat bedgraph --scaleFactors 0.75:0.75:.75".format(BIGWIG_A, BIGWIG_A, BIGWIG_B, outfile).split()
bwAve.main(args)
_foo = open(outfile, 'r')
resp = _foo.readlines()
_foo.close()
expected = ['3R\t0\t50\t0\n', '3R\t50\t100\t0.25\n', '3R\t100\t150\t0.75\n', '3R\t150\t200\t1\n']
assert f"{resp}" == f"{expected}", f"{resp} != {expected}"
unlink(outfile)
10 changes: 6 additions & 4 deletions deeptools/writeBedGraph_bam_and_bw.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def getCoverageFromBigwig(bigwigHandle, chrom, start, end, tileSize,
missingDataAsZero=False):
try:
coverage = np.asarray(bigwigHandle.values(chrom, start, end))
except TypeError:
except RuntimeError:
# this error happens when chromosome
# is not into the bigwig file
return []
Expand Down Expand Up @@ -170,7 +170,7 @@ def writeBedGraph(
chromNamesAndSize, __ = getCommonChrNames(bamHandles, verbose=verbose)
else:
genomeChunkLength = int(10e6)
cCommon = []
cCommon_number = {}
chromNamesAndSize = {}
for fileName, fileFormat in bamOrBwFileList:
if fileFormat == 'bigwig':
Expand All @@ -180,7 +180,7 @@ def writeBedGraph(

for chromName, size in list(fh.chroms().items()):
if chromName in chromNamesAndSize:
cCommon.append(chromName)
cCommon_number[chromName] += 1
if chromNamesAndSize[chromName] != size:
print("\nWARNING\n"
"Chromosome {} length reported in the "
Expand All @@ -193,14 +193,16 @@ def writeBedGraph(
chromNamesAndSize[chromName], size)
else:
chromNamesAndSize[chromName] = size
cCommon_number[chromName] = 1
fh.close()

# get the list of common chromosome names and sizes
if len(bamOrBwFileList) == 1:
chromNamesAndSize = [(k, v) for k, v in chromNamesAndSize.items()]
else:
chromNamesAndSize = [(k, v) for k, v in chromNamesAndSize.items()
if k in cCommon]
if k in cCommon_number and
cCommon_number[k] == len(bamOrBwFileList)]

if region:
# in case a region is used, append the tilesize
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ requires-python = ">=3.7"
dependencies = [
"numpy >= 1.9.0",
"scipy >= 0.17.0",
"matplotlib >= 3.3.0",
"matplotlib >= 3.5.0",
"pysam >= 0.14.0",
"numpydoc >= 0.5",
"pyBigWig >= 0.2.1",
Expand Down