From a5e859c4514ebfb35a57f2b98cb983f04e7e146f Mon Sep 17 00:00:00 2001 From: Sebastian Proost Date: Mon, 29 Aug 2016 09:58:19 +0200 Subject: [PATCH 1/3] checks to prevent qc to fail on empty samples --- pipeline/check/quality.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pipeline/check/quality.py b/pipeline/check/quality.py index 31ebf23..64fe6e7 100644 --- a/pipeline/check/quality.py +++ b/pipeline/check/quality.py @@ -53,14 +53,16 @@ def check_htseq(filename, cutoff=0, log=None): else: values[gene] = int(value) - total = sum([mapped_reads, values['__no_feature'], values['__ambiguous']]) + total = sum([mapped_reads, + values['__no_feature'] if '__no_feature' in values.keys() else 0, + values['__ambiguous'] if '__ambiguous' in values.keys() else 0]) - percentage_mapped = (mapped_reads*100)/total + percentage_mapped = ((mapped_reads*100)/total) if total > 0 else 0 if percentage_mapped >= cutoff: return True else: - if log is not None: + if log is not None: print('WARNING:', filename, 'didn\'t pass HTSEQ-Count Quality check!', percentage_mapped , 'reads mapped. Cutoff,', cutoff, file=log) From 2981bd23feaf0ffc026d2b3be1662f6c3edc4119 Mon Sep 17 00:00:00 2001 From: Sebastian Proost Date: Mon, 29 Aug 2016 09:59:58 +0200 Subject: [PATCH 2/3] checks to prevent qc to fail on empty samples --- pipeline/check/quality.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pipeline/check/quality.py b/pipeline/check/quality.py index 64fe6e7..d5422a6 100644 --- a/pipeline/check/quality.py +++ b/pipeline/check/quality.py @@ -55,7 +55,8 @@ def check_htseq(filename, cutoff=0, log=None): total = sum([mapped_reads, values['__no_feature'] if '__no_feature' in values.keys() else 0, - values['__ambiguous'] if '__ambiguous' in values.keys() else 0]) + values['__ambiguous'] if '__ambiguous' in values.keys() else 0] + ) percentage_mapped = ((mapped_reads*100)/total) if total > 0 else 0 From 4bf7c89f3592f433c914413f387ce23fbabb7cf3 Mon Sep 17 00:00:00 2001 From: Sebastian Proost Date: Mon, 29 Aug 2016 11:53:53 +0200 Subject: [PATCH 3/3] avoid division by zero --- helper/htseq_count_stats.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/helper/htseq_count_stats.py b/helper/htseq_count_stats.py index bb1e781..52eb5d4 100644 --- a/helper/htseq_count_stats.py +++ b/helper/htseq_count_stats.py @@ -36,4 +36,5 @@ print('sample', 'mapped_reads', 'no_feature', 'ambiguous', '% mapped', '% no_feature', '% ambiguous', sep='\t') for s, m, n, a in zip(values['samples'], values['mapped_reads'], values['__no_feature'], values['__ambiguous']): total = sum([m, n, a]) - print(s, m, n, a, m*100/total, n*100/total, a*100/total, sep='\t') + if total > 0: + print(s, m, n, a, m*100/total, n*100/total, a*100/total, sep='\t')