Skip to content

Commit 3cefc7d

Browse files
authored
Estimated filtering fix (#813)
* oops * fix testing and set a max number of filtered reads * apparently a bunch of things were getting skipped * fix wrappers * update computeMatrix wrapper
1 parent 6507b14 commit 3cefc7d

8 files changed

+24
-30
lines changed

Diff for: CHANGES.txt

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
3.2.1
2+
3+
* Changed a bug in `estimateReadFiltering` where the estimated number of filtered reads was typically too low.
4+
15
3.2.0
26

37
* Added access in the Galaxy wrapper to the `--labels` option in most tools (issue #738)

Diff for: azure-pipelines.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,5 @@ jobs:
6262
displayName: Installing deepTools
6363
- script: |
6464
source activate foo
65-
./.planemo.sh
65+
./.planemo.sh $TESTGALAXY
6666
displayName: Run planemo

Diff for: deeptools/estimateReadFiltering.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -329,43 +329,43 @@ def main(args=None):
329329
# nFiltered
330330
metric = 0.0
331331
if totals[idx] > 0:
332-
metric = blacklisted[idx] + float(nFiltered[idx]) / float(totals[idx]) * nFiltered[idx]
333-
of.write("\t{}".format(round(metric, 1)))
332+
metric = blacklisted[idx] + float(nFiltered[idx]) / float(totals[idx]) * mapped[idx]
333+
of.write("\t{}".format(min(round(metric, 1), mapped[idx])))
334334
# MAPQ
335335
metric = 0.0
336336
if totals[idx] > 0:
337337
metric = float(MAPQs[idx]) / float(totals[idx]) * mapped[idx]
338-
of.write("\t{}".format(round(metric, 1)))
338+
of.write("\t{}".format(min(round(metric, 1), mapped[idx])))
339339
# samFlagInclude
340340
metric = 0.0
341341
if totals[idx] > 0:
342342
metric = float(flagIncludes[idx]) / float(totals[idx]) * mapped[idx]
343-
of.write("\t{}".format(round(metric, 1)))
343+
of.write("\t{}".format(min(round(metric, 1), mapped[idx])))
344344
# samFlagExclude
345345
metric = 0.0
346346
if totals[idx] > 0:
347347
metric = float(flagExcludes[idx]) / float(totals[idx]) * mapped[idx]
348-
of.write("\t{}".format(round(metric, 1)))
348+
of.write("\t{}".format(min(round(metric, 1), mapped[idx])))
349349
# Internally determined duplicates
350350
metric = 0.0
351351
if totals[idx] > 0:
352352
metric = float(internalDupes[idx]) / float(totals[idx]) * mapped[idx]
353-
of.write("\t{}".format(round(metric, 1)))
353+
of.write("\t{}".format(min(round(metric, 1), mapped[idx])))
354354
# Externally marked duplicates
355355
metric = 0.0
356356
if totals[idx] > 0:
357357
metric = float(externalDupes[idx]) / float(totals[idx]) * mapped[idx]
358-
of.write("\t{}".format(round(metric, 1)))
358+
of.write("\t{}".format(min(round(metric, 1), mapped[idx])))
359359
# Singletons
360360
metric = 0.0
361361
if totals[idx] > 0:
362362
metric = float(singletons[idx]) / float(totals[idx]) * mapped[idx]
363-
of.write("\t{}".format(round(metric, 1)))
363+
of.write("\t{}".format(min(round(metric, 1), mapped[idx])))
364364
# filterRNAstrand
365365
metric = 0.0
366366
if totals[idx] > 0:
367367
metric = float(rnaStrand[idx]) / float(totals[idx]) * mapped[idx]
368-
of.write("\t{}".format(round(metric, 1)))
368+
of.write("\t{}".format(min(round(metric, 1), mapped[idx])))
369369
of.write("\n")
370370

371371
if args.outFile is not None:

Diff for: deeptools/test/test_readFiltering.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def test_estimate_read_filtering_minimal():
3434

3535
def test_estimate_read_filtering_params():
3636
"""
37-
Minimal testing
37+
--minMappingQuality 10 --samFlagExclude 512 --ignoreDuplicates -bl
3838
"""
3939
outfile = '/tmp/test_params.txt'
4040
args = '-b {} --minMappingQuality 10 --samFlagExclude 512 --ignoreDuplicates -bl {} -o {}'.format(BAMFILE_FILTER, BEDFILE_FILTER, outfile).split()
@@ -48,7 +48,7 @@ def test_estimate_read_filtering_params():
4848
_[0] = os.path.basename(_[0])
4949
resp[1] = "\t".join(_)
5050
expected = ['Sample\tTotal Reads\tMapped Reads\tAlignments in blacklisted regions\tEstimated mapped reads filtered\tBelow MAPQ\tMissing Flags\tExcluded Flags\tInternally-determined Duplicates\tMarked Duplicates\tSingletons\tWrong strand\n',
51-
'test_filtering.bam\t193\t193\t7\t176.1\t41.4\t0.0\t186.5\t31.6\t0.0\t0.0\t0.0\n']
51+
'test_filtering.bam\t193\t193\t7\t193\t41.4\t0.0\t186.5\t31.6\t0.0\t0.0\t0.0\n']
5252
assert_equal(resp, expected)
5353
unlink(outfile)
5454

Diff for: galaxy/wrapper/bamCompare.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,8 @@
166166
<expand macro="skipNAs" />
167167
<param argument="--skipZeroOverZero" type="select" label="Skip bins of no coverage"
168168
help="Skip bins where BOTH files lack coverage.">
169-
<option value="no" selected="true">No</option>
170-
<option value="yes">Yes, skip them.</option>
169+
<option value="" selected="true">No</option>
170+
<option value="--skipZeroOverZero">Yes, skip them.</option>
171171
</param>
172172

173173
<param argument="--ignoreForNormalization" type="text" value="" size="50"

Diff for: galaxy/wrapper/computeMatrix.xml

+2-12
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
--scoreFileName #echo ' '.join($files)#
2525
2626
--outFileName '$outFileName'
27+
--samplesLabel #echo ' '.join($labels)#
2728
2829
@THREADS@
2930
@@ -72,9 +73,6 @@
7273
#if $advancedOpt.scale is not None and str($advancedOpt.scale) != '':
7374
--scale $advancedOpt.scale
7475
#end if
75-
#if $advancedOpt.samplesLabel is not None and str($advancedOpt.samplesLabel) != '':
76-
--samplesLabel $advancedOpt.samplesLabel
77-
#end if
7876
7977
@ADVANCED_OPTS_GTF@
8078
@@ -91,6 +89,7 @@
9189
</repeat>
9290

9391
<expand macro="multiple_input_bigwigs" MIN="1" LABEL="Score file" TITLE="Score files"/>
92+
<expand macro="custom_sample_labels" />
9493

9594
<conditional name="mode" >
9695
<param name="mode_select" type="select"
@@ -207,15 +206,6 @@
207206
bias the average values. (--maxThreshold)"/>
208207
<param name="scale" type="float" optional="True" label="Scaling factor"
209208
help="If set, all values are multiplied by this number. (--scale)"/>
210-
<param argument="--samplesLabel" type="text" size="30"
211-
label="Labels for the samples (each bigwig)"
212-
help="The default is to use the history item label. The sample labels should be separated by
213-
spaces and quoted if a label itself contains a space E.g. label-1 &quot;label 2&quot;">
214-
<sanitizer>
215-
<valid initial="string.printable">
216-
</valid>
217-
</sanitizer>
218-
</param>
219209

220210
<expand macro="gtf_options" />
221211

Diff for: galaxy/wrapper/deepTools_macros.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ is vital to you, select Yes below.">
512512

513513
<token name="@multiple_input_bigwigs@">
514514
<![CDATA[
515-
#if $custom_labels_conditional.custom_labels_select == "Yes":
515+
#if $custom_sample_labels_conditional.custom_labels_select == "Yes":
516516
#set custom_labels=labels
517517
#end if
518518
#set files=[]
@@ -533,7 +533,7 @@ is vital to you, select Yes below.">
533533
#silent $labels.append("'%s'" % $identifier)
534534
#end for
535535
#end if
536-
#if $custom_labels_conditional.custom_labels_select == "Yes":
536+
#if $custom_sample_labels_conditional.custom_labels_select == "Yes":
537537
#set labels=custom_labels
538538
#end if
539539
]]>

Diff for: galaxy/wrapper/test-data/estimateReadFiltering.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
Sample Total Reads Mapped Reads Alignments in blacklisted regions Estimated mapped reads filtered Below MAPQ Missing Flags Excluded Flags Internally-determined Duplicates Marked Duplicates Singletons Wrong strand
2-
paired_chr2L.bam 12644 12589 0 1395.9 4149.0 0.0 0.0 0.0 0.0 55.0 0.0
3-
paired_chr2L.bam 12644 12589 0 1395.9 4149.0 0.0 0.0 0.0 0.0 55.0 0.0
2+
paired_chr2L.bam 12644 12589 0 4192.0 4149.0 0.0 0.0 0.0 0.0 55.0 0.0
3+
paired_chr2L.bam 12644 12589 0 4192.0 4149.0 0.0 0.0 0.0 0.0 55.0 0.0

0 commit comments

Comments
 (0)