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

Implement #816 #825

Merged
merged 7 commits into from
Apr 1, 2019
Merged
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
7 changes: 7 additions & 0 deletions deeptools/bigwigCompare.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ def parse_arguments(args=None):
type=float,
required=False)

parser.add_argument('--skipZeroOverZero',
help='Skip bins where BOTH BAM files lack coverage. '
'This is determined BEFORE any applicable pseudocount '
'is added.',
action='store_true')

parser.add_argument('--operation',
help='The default is to output the log2ratio of the '
'two samples. The reciprocal ratio returns the '
Expand Down Expand Up @@ -159,6 +165,7 @@ def main(args=None):
blackListFileName=args.blackListFileName,
verbose=args.verbose,
numberOfProcessors=args.numberOfProcessors,
skipZeroOverZero=args.skipZeroOverZero,
format=args.outFileFormat,
smoothLength=False,
missingDataAsZero=not args.skipNonCoveredRegions,
Expand Down
12 changes: 12 additions & 0 deletions deeptools/test/test_bigwigCompare_and_multiBigwigSummary.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,18 @@ def test_bigwigCompare_skipnas():
unlink(outfile)


def test_bigwigCompare_skipZeroOverZero():
outfile = '/tmp/result.bg"'
args = "-b1 {} -b2 {} -o {} --skipZeroOverZero --pseudocount 1 3 --outFileFormat bedgraph".format(BIGWIG_A, BIGWIG_A, outfile).split()
bwComp.main(args)
_foo = open(outfile, 'r')
resp = _foo.readlines()
_foo.close()
expected = ['3R\t100\t200\t-1\n']
assert resp == expected, "{} != {}".format(resp, expected)
unlink(outfile)


def test_multiBigwigSummary():
outfile = '/tmp/result.bg'
args = "bins -b {} {} --binSize 50 -o {}".format(BIGWIG_A, BIGWIG_B, outfile).split()
Expand Down
10 changes: 7 additions & 3 deletions deeptools/writeBedGraph_bam_and_bw.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def writeBedGraph_wrapper(args):
def writeBedGraph_worker(
chrom, start, end, tileSize, defaultFragmentLength,
bamOrBwFileList, func, funcArgs, extendPairedEnds=True, smoothLength=0,
missingDataAsZero=False, fixed_step=False):
skipZeroOverZero=False, missingDataAsZero=False, fixed_step=False):
r"""
Writes a bedgraph having as base a number of bam files.

Expand Down Expand Up @@ -102,6 +102,10 @@ def writeBedGraph_worker(
"files. Remove this chromosome from the bigwig file "
"to continue".format(chrom))

if skipZeroOverZero and np.sum(tileCoverage) == 0:
previousValue = None
continue

value = func(tileCoverage, funcArgs)

if fixed_step:
Expand Down Expand Up @@ -147,7 +151,7 @@ def writeBedGraph(
bamOrBwFileList, outputFileName, fragmentLength,
func, funcArgs, tileSize=25, region=None, blackListFileName=None, numberOfProcessors=1,
format="bedgraph", extendPairedEnds=True, missingDataAsZero=False,
smoothLength=0, fixed_step=False, verbose=False):
skipZeroOverZero=False, smoothLength=0, fixed_step=False, verbose=False):
r"""
Given a list of bamfiles, a function and a function arguments,
this method writes a bedgraph file (or bigwig) file
Expand Down Expand Up @@ -206,7 +210,7 @@ def writeBedGraph(

res = mapReduce.mapReduce((tileSize, fragmentLength, bamOrBwFileList,
func, funcArgs, extendPairedEnds, smoothLength,
missingDataAsZero, fixed_step),
skipZeroOverZero, missingDataAsZero, fixed_step),
writeBedGraph_wrapper,
chromNamesAndSize,
genomeChunkLength=genomeChunkLength,
Expand Down
6 changes: 1 addition & 5 deletions galaxy/wrapper/bamCompare.xml
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,7 @@
<expand macro="read_processing_options" />

<expand macro="skipNAs" />
<param argument="--skipZeroOverZero" type="select" label="Skip bins of no coverage"
help="Skip bins where BOTH files lack coverage.">
<option value="" selected="true">No</option>
<option value="--skipZeroOverZero">Yes, skip them.</option>
</param>
<expand macro="skipZeroOverZero" />

<param argument="--ignoreForNormalization" type="text" value="" size="50"
label="regions that should be excluded for calculating the scaling factor"
Expand Down
2 changes: 2 additions & 0 deletions galaxy/wrapper/bigwigCompare.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#if $advancedOpt.showAdvancedOpt == "yes":

$advancedOpt.skipNAs
$advancedOpt.skipZeroOverZero
--scaleFactors '$advancedOpt.scaleFactor1:$advancedOpt.scaleFactor2'
--binSize $advancedOpt.binSize

Expand Down Expand Up @@ -95,6 +96,7 @@
help="Size of the bins in bases for the output of the bigwig/bedgraph file."/>

<expand macro="skipNAs" />
<expand macro="skipZeroOverZero" />
<expand macro="scaleFactors" />
<expand macro="plotTitle" />
<expand macro="blacklist" />
Expand Down
8 changes: 8 additions & 0 deletions galaxy/wrapper/deepTools_macros.xml
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,14 @@ is vital to you, select Yes below.">
(default: False)" />
</xml>

<xml name="skipZeroOverZero">
<param argument="--skipZeroOverZero" type="select" label="Skip bins of no coverage"
help="Skip bins where BOTH files lack coverage.">
<option value="" selected="true">No</option>
<option value="--skipZeroOverZero">Yes, skip them.</option>
</param>
</xml>

<xml name="exactScaling">
<param argument="--exactScaling" type="boolean" truevalue="--exactScaling" falsevalue="" checked="False"
label="Compute an exact scaling factor"
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ def openREADME():
"scipy >= 0.17.0",
"matplotlib >= 2.1.2",
"pysam >= 0.14.0",
"numpydoc >=0.5",
"pyBigWig >=0.2.1",
"numpydoc >= 0.5",
"pyBigWig >= 0.2.1",
"py2bit >= 0.2.0",
"plotly >= 2.0.0",
"deeptoolsintervals >= 0.1.7"
Expand Down