diff --git a/CHANGES.txt b/CHANGES.txt
index 4a02ee0742..b08c985143 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,3 +1,7 @@
+3.2.1
+
+ * Changed a bug in `estimateReadFiltering` where the estimated number of filtered reads was typically too low.
+
3.2.0
* Added access in the Galaxy wrapper to the `--labels` option in most tools (issue #738)
diff --git a/azure-pipelines.yml b/azure-pipelines.yml
index 7161acddaf..936cc2917d 100644
--- a/azure-pipelines.yml
+++ b/azure-pipelines.yml
@@ -62,5 +62,5 @@ jobs:
displayName: Installing deepTools
- script: |
source activate foo
- ./.planemo.sh
+ ./.planemo.sh $TESTGALAXY
displayName: Run planemo
diff --git a/deeptools/estimateReadFiltering.py b/deeptools/estimateReadFiltering.py
index be3b965c3a..c4b5268156 100644
--- a/deeptools/estimateReadFiltering.py
+++ b/deeptools/estimateReadFiltering.py
@@ -329,43 +329,43 @@ def main(args=None):
# nFiltered
metric = 0.0
if totals[idx] > 0:
- metric = blacklisted[idx] + float(nFiltered[idx]) / float(totals[idx]) * nFiltered[idx]
- of.write("\t{}".format(round(metric, 1)))
+ metric = blacklisted[idx] + float(nFiltered[idx]) / float(totals[idx]) * mapped[idx]
+ of.write("\t{}".format(min(round(metric, 1), mapped[idx])))
# MAPQ
metric = 0.0
if totals[idx] > 0:
metric = float(MAPQs[idx]) / float(totals[idx]) * mapped[idx]
- of.write("\t{}".format(round(metric, 1)))
+ of.write("\t{}".format(min(round(metric, 1), mapped[idx])))
# samFlagInclude
metric = 0.0
if totals[idx] > 0:
metric = float(flagIncludes[idx]) / float(totals[idx]) * mapped[idx]
- of.write("\t{}".format(round(metric, 1)))
+ of.write("\t{}".format(min(round(metric, 1), mapped[idx])))
# samFlagExclude
metric = 0.0
if totals[idx] > 0:
metric = float(flagExcludes[idx]) / float(totals[idx]) * mapped[idx]
- of.write("\t{}".format(round(metric, 1)))
+ of.write("\t{}".format(min(round(metric, 1), mapped[idx])))
# Internally determined duplicates
metric = 0.0
if totals[idx] > 0:
metric = float(internalDupes[idx]) / float(totals[idx]) * mapped[idx]
- of.write("\t{}".format(round(metric, 1)))
+ of.write("\t{}".format(min(round(metric, 1), mapped[idx])))
# Externally marked duplicates
metric = 0.0
if totals[idx] > 0:
metric = float(externalDupes[idx]) / float(totals[idx]) * mapped[idx]
- of.write("\t{}".format(round(metric, 1)))
+ of.write("\t{}".format(min(round(metric, 1), mapped[idx])))
# Singletons
metric = 0.0
if totals[idx] > 0:
metric = float(singletons[idx]) / float(totals[idx]) * mapped[idx]
- of.write("\t{}".format(round(metric, 1)))
+ of.write("\t{}".format(min(round(metric, 1), mapped[idx])))
# filterRNAstrand
metric = 0.0
if totals[idx] > 0:
metric = float(rnaStrand[idx]) / float(totals[idx]) * mapped[idx]
- of.write("\t{}".format(round(metric, 1)))
+ of.write("\t{}".format(min(round(metric, 1), mapped[idx])))
of.write("\n")
if args.outFile is not None:
diff --git a/deeptools/test/test_readFiltering.py b/deeptools/test/test_readFiltering.py
index 2d9979519b..ae74df5601 100644
--- a/deeptools/test/test_readFiltering.py
+++ b/deeptools/test/test_readFiltering.py
@@ -34,7 +34,7 @@ def test_estimate_read_filtering_minimal():
def test_estimate_read_filtering_params():
"""
- Minimal testing
+ --minMappingQuality 10 --samFlagExclude 512 --ignoreDuplicates -bl
"""
outfile = '/tmp/test_params.txt'
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():
_[0] = os.path.basename(_[0])
resp[1] = "\t".join(_)
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',
- 'test_filtering.bam\t193\t193\t7\t176.1\t41.4\t0.0\t186.5\t31.6\t0.0\t0.0\t0.0\n']
+ 'test_filtering.bam\t193\t193\t7\t193\t41.4\t0.0\t186.5\t31.6\t0.0\t0.0\t0.0\n']
assert_equal(resp, expected)
unlink(outfile)
diff --git a/galaxy/wrapper/bamCompare.xml b/galaxy/wrapper/bamCompare.xml
index 3a6a5e83b0..a63210c8fb 100644
--- a/galaxy/wrapper/bamCompare.xml
+++ b/galaxy/wrapper/bamCompare.xml
@@ -166,8 +166,8 @@
-
-
+
+
+
-
-
-
-
-
-
diff --git a/galaxy/wrapper/deepTools_macros.xml b/galaxy/wrapper/deepTools_macros.xml
index ade78b9ef6..f4c88d0f0b 100644
--- a/galaxy/wrapper/deepTools_macros.xml
+++ b/galaxy/wrapper/deepTools_macros.xml
@@ -512,7 +512,7 @@ is vital to you, select Yes below.">
#silent $labels.append("'%s'" % $identifier)
#end for
#end if
- #if $custom_labels_conditional.custom_labels_select == "Yes":
+ #if $custom_sample_labels_conditional.custom_labels_select == "Yes":
#set labels=custom_labels
#end if
]]>
diff --git a/galaxy/wrapper/test-data/estimateReadFiltering.txt b/galaxy/wrapper/test-data/estimateReadFiltering.txt
index 47bd2b85fc..d859bd1b71 100644
--- a/galaxy/wrapper/test-data/estimateReadFiltering.txt
+++ b/galaxy/wrapper/test-data/estimateReadFiltering.txt
@@ -1,3 +1,3 @@
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
-paired_chr2L.bam 12644 12589 0 1395.9 4149.0 0.0 0.0 0.0 0.0 55.0 0.0
-paired_chr2L.bam 12644 12589 0 1395.9 4149.0 0.0 0.0 0.0 0.0 55.0 0.0
+paired_chr2L.bam 12644 12589 0 4192.0 4149.0 0.0 0.0 0.0 0.0 55.0 0.0
+paired_chr2L.bam 12644 12589 0 4192.0 4149.0 0.0 0.0 0.0 0.0 55.0 0.0