diff --git a/Configuration/limits.txt b/Configuration/limits.txt index 47f6be2..6da8c7d 100644 --- a/Configuration/limits.txt +++ b/Configuration/limits.txt @@ -7,47 +7,67 @@ GenomeCoverage ignore 0 IndelFrequencies ignore 0 InsertLengthDistribution ignore 0 MappingQualityDistribution ignore 0 +# deprecated SequenceQualityDistribution ignore 1 SNPFrequencies ignore 0 SNPFrequenciesByType ignore 0 SoftClipDistribution ignore 0 -# The following option switches off InsertFrequencies, SNPFrequencies, SNPFrequenciesByType and some statistics in BasicStatistics +# The following option switches off InsertFrequencies, SNPFrequencies, +# SNPFrequenciesByType and some statistics in BasicStatistics VariantCallDetection ignore 0 # BasicStatistics module -BasicStatistics_tot_seq_threshold warn 0 -BasicStatistics_tot_seq_threshold error 0 +BasicStatistics_min_tot_seq_threshold warn 0 +BasicStatistics_min_tot_seq_threshold error 0 BasicStatistics_unmapped_percent_threshold warn 50 BasicStatistics_unmapped_percent_threshold error 90 # ChromosomeReadDensity Module -#ChromosomeReadDensity +ChromosomeReadDensity_readNumber_threshold warn 25 +ChromosomeReadDensity_readNumber_threshold error 10 + + +# GenomeCoverage module +GenomeCoverage_plot_type_chromosomes_threshold ignore 50 +GenomeCoverage_plot_bins_all_chromosomes ignore 5000 +GenomeCoverage_plot_bins_per_chromosome ignore 500 +GenomeCoverage_uncovered_genome_percent_threshold error 10 +GenomeCoverage_uncovered_genome_percent_threshold warn 5 -# Annotation Module -AnnotationSet_annotation_cache_capacity ignore 50000 # Indel/SNP modules VariantCallPosition_indel_seqpercent_xaxis_threshold ignore 5 -VariantCallPosition_indel_threshold warn 0.5 -VariantCallPosition_indel_threshold error 1 +VariantCallPosition_indel_max_freq_threshold warn 5 +VariantCallPosition_indel_max_freq_threshold error 25 VariantCallPosition_snp_seqpercent_xaxis_threshold ignore 5 -VariantCallPosition_snp_threshold warn 1 -VariantCallPosition_snp_threshold error 2 +VariantCallPosition_snp_max_freq_threshold warn 5 +VariantCallPosition_snp_max_freq_threshold error 25 +VariantCallPosition_snp_max_freq_by_type_threshold warn 0.5 +VariantCallPosition_snp_max_freq_by_type_threshold error 2.5 -# Genome Coverage module -GenomeCoverage_plot_type_chromosomes_threshold ignore 50 -GenomeCoverage_plot_bins_all_chromosomes ignore 5000 -GenomeCoverage_plot_bins_per_chromosome ignore 500 # Insert Length Distribution module InsertLengthDistribution_max_insert_size ignore 10000.0 InsertLengthDistribution_bin_size ignore 1.0 InsertLengthDistribution_percentage_deviation error 50.0 InsertLengthDistribution_percentage_deviation warn 75.0 - + + # MappingQualityDistribution module MappingQualityDistribution_fraction error 0.50 MappingQualityDistribution_fraction warn 0.75 + +# SoftClipDistribution module +SoftClipDistribution_clip_number_threshold error 100 +SoftClipDistribution_clip_number_threshold warn 25 + + +# Annotation Module +AnnotationSet_annotation_cache_capacity ignore 50000 + + +# ------- EXPLICIT THRESHOLDS NOT YET IMPLEMENTED -------- # +# FeatureCoverage module diff --git a/uk/ac/babraham/BamQC/Graphs/ScatterGraph.java b/uk/ac/babraham/BamQC/Graphs/ScatterGraph.java index 1f9b94f..8f79f63 100644 --- a/uk/ac/babraham/BamQC/Graphs/ScatterGraph.java +++ b/uk/ac/babraham/BamQC/Graphs/ScatterGraph.java @@ -35,7 +35,6 @@ import java.awt.event.MouseEvent; import java.awt.geom.AffineTransform; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import java.util.Random; diff --git a/uk/ac/babraham/BamQC/Modules/BasicStatistics.java b/uk/ac/babraham/BamQC/Modules/BasicStatistics.java index cacb3b0..68f3f99 100644 --- a/uk/ac/babraham/BamQC/Modules/BasicStatistics.java +++ b/uk/ac/babraham/BamQC/Modules/BasicStatistics.java @@ -51,8 +51,8 @@ */ public class BasicStatistics extends AbstractQCModule { - private static final double ERROR_ACTUAL_COUNT = ModuleConfig.getParam("BasicStatistics_tot_seq_threshold", "error"); - private static final double WARNING_ACTUAL_COUNT = ModuleConfig.getParam("BasicStatistics_tot_seq_threshold", "warn"); + private static final double ERROR_ACTUAL_COUNT = ModuleConfig.getParam("BasicStatistics_min_tot_seq_threshold", "error"); + private static final double WARNING_ACTUAL_COUNT = ModuleConfig.getParam("BasicStatistics_min_tot_seq_threshold", "warn"); private static final double ERROR_UNMAPPED_PERCENT = ModuleConfig.getParam("BasicStatistics_unmapped_percent_threshold", "error"); private static final double WARNING_UNMAPPED_PERCENT = ModuleConfig.getParam("BasicStatistics_unmapped_percent_threshold", "warn"); diff --git a/uk/ac/babraham/BamQC/Modules/ChromosomeReadDensity.java b/uk/ac/babraham/BamQC/Modules/ChromosomeReadDensity.java index 75205eb..bf6dfa9 100644 --- a/uk/ac/babraham/BamQC/Modules/ChromosomeReadDensity.java +++ b/uk/ac/babraham/BamQC/Modules/ChromosomeReadDensity.java @@ -49,6 +49,9 @@ */ public class ChromosomeReadDensity extends AbstractQCModule { + private static final double ERROR_READ_NUMBER = ModuleConfig.getParam("ChromosomeReadDensity_readNumber_threshold", "error"); + private static final double WARNING_READ_NUMBER = ModuleConfig.getParam("ChromosomeReadDensity_readNumber_threshold", "warn"); + private String [] chromosomeNames; private double [] readNumber; private double [] chromosomeLength; @@ -175,11 +178,17 @@ public void reset() { } @Override public boolean raisesError() { + if(readNumber.length < ERROR_READ_NUMBER) { + return true; + } return false; } @Override public boolean raisesWarning() { + if(readNumber.length < WARNING_READ_NUMBER) { + return true; + } return false; } diff --git a/uk/ac/babraham/BamQC/Modules/FeatureCoverage.java b/uk/ac/babraham/BamQC/Modules/FeatureCoverage.java index f743348..3263d15 100644 --- a/uk/ac/babraham/BamQC/Modules/FeatureCoverage.java +++ b/uk/ac/babraham/BamQC/Modules/FeatureCoverage.java @@ -113,13 +113,13 @@ public void reset() { } @Override public boolean raisesError() { + if(datasetIsEmpty) + return true; return false; } @Override public boolean raisesWarning() { - if(datasetIsEmpty) - return true; return false; } diff --git a/uk/ac/babraham/BamQC/Modules/GenomeCoverage.java b/uk/ac/babraham/BamQC/Modules/GenomeCoverage.java index 318eae8..86edbba 100644 --- a/uk/ac/babraham/BamQC/Modules/GenomeCoverage.java +++ b/uk/ac/babraham/BamQC/Modules/GenomeCoverage.java @@ -48,17 +48,21 @@ public class GenomeCoverage extends AbstractQCModule { // logger private static Logger log = Logger.getLogger(GenomeCoverage.class); - private int plotTypeChromosomesThreshold = ModuleConfig.getParam("GenomeCoverage_plot_type_chromosomes_threshold", "ignore").intValue(); + private static final double ERROR_UNCOVERED_GENOME_PERCENT_THRESHOLD = ModuleConfig.getParam("GenomeCoverage_uncovered_genome_percent_threshold", "error"); + private static final double WARNING_UNCOVERED_GENOME_PERCENT_THRESHOLD = ModuleConfig.getParam("GenomeCoverage_uncovered_genome_percent_threshold", "warn"); + private static final int PLOT_TYPE_CHROMOSOMES_THRESHOLD = ModuleConfig.getParam("GenomeCoverage_plot_type_chromosomes_threshold", "ignore").intValue(); + + private long regionsWithNoCoverage = 0L; private String [] chromosomeNames = null; private double [][] binCounts = null; private long [] coverage = null; private double maxCoverage = 0.0; + private int binsToUse = 0; private int maxBins = 1; - @Override public void processSequence(SAMRecord read) { } @@ -84,11 +88,19 @@ public void reset() { @Override public boolean raisesError() { + long binCountsSize = chromosomeNames.length * binsToUse; + if(100.0d * regionsWithNoCoverage / binCountsSize > ERROR_UNCOVERED_GENOME_PERCENT_THRESHOLD) { + return true; + } return false; } @Override public boolean raisesWarning() { + long binCountsSize = chromosomeNames.length * binsToUse; + if(100.0d * regionsWithNoCoverage / binCountsSize > WARNING_UNCOVERED_GENOME_PERCENT_THRESHOLD) { + return true; + } return false; } @@ -107,7 +119,7 @@ public void processAnnotationSet(AnnotationSet annotation) { Chromosome [] chromosomes = annotation.chromosomeFactory().getAllChromosomes(); - if(chromosomes.length <= plotTypeChromosomesThreshold) { + if(chromosomes.length <= PLOT_TYPE_CHROMOSOMES_THRESHOLD) { // This will plot the chromosomes from 1 (top) to n (bottom) Arrays.sort(chromosomes, Collections.reverseOrder()); } else { @@ -133,7 +145,7 @@ public void processAnnotationSet(AnnotationSet annotation) { // configuration of how many bins per chromosome we want to plot. // This is the number of bins per chromosome for the official plot getResultsPanel() int plotBinsPerChromosome = 0; - if(chromosomeNames.length <= plotTypeChromosomesThreshold) { + if(chromosomeNames.length <= PLOT_TYPE_CHROMOSOMES_THRESHOLD) { plotBinsPerChromosome = ModuleConfig.getParam("GenomeCoverage_plot_bins_per_chromosome", "ignore").intValue(); } else { plotBinsPerChromosome = ModuleConfig.getParam("GenomeCoverage_plot_bins_all_chromosomes", "ignore").intValue(); @@ -144,7 +156,7 @@ public void processAnnotationSet(AnnotationSet annotation) { } } - int binsToUse = plotBinsPerChromosome; + binsToUse = plotBinsPerChromosome; double binRatio = maxBins/(double)plotBinsPerChromosome; @@ -154,7 +166,7 @@ public void processAnnotationSet(AnnotationSet annotation) { } log.debug("chromosomeNames.length: " + chromosomeNames.length); - log.debug("plotTypeChromosomesThreshold: " + plotTypeChromosomesThreshold); + log.debug("plotTypeChromosomesThreshold: " + PLOT_TYPE_CHROMOSOMES_THRESHOLD); log.debug("plotBinsPerChromosome: " + plotBinsPerChromosome); log.debug("maxBins: " + maxBins); log.debug("binRatio: " + binRatio); @@ -192,6 +204,7 @@ public void processAnnotationSet(AnnotationSet annotation) { if(binCounts[c][i] <= 0) { // Let's label these points having null coverage so that we don't miss them binCounts[c][i] = Double.NEGATIVE_INFINITY; + regionsWithNoCoverage++; continue; } // scale to log to enlarge the data differences. log_e makes it smaller than log_10. @@ -227,7 +240,7 @@ public JPanel getResultsPanel() { chromosomeNames[i] = chromosomeNames[i].substring(3); } - if(chromosomeNames.length <= plotTypeChromosomesThreshold) { + if(chromosomeNames.length <= PLOT_TYPE_CHROMOSOMES_THRESHOLD) { // plots the genome coverage for each chromosome separately return getSeparateChromosomeResultsPanel(); } diff --git a/uk/ac/babraham/BamQC/Modules/IndelFrequencies.java b/uk/ac/babraham/BamQC/Modules/IndelFrequencies.java index c73d215..a476a91 100644 --- a/uk/ac/babraham/BamQC/Modules/IndelFrequencies.java +++ b/uk/ac/babraham/BamQC/Modules/IndelFrequencies.java @@ -49,6 +49,9 @@ public class IndelFrequencies extends AbstractQCModule { private static Logger log = Logger.getLogger(IndelFrequencies.class); + private static final double ERROR_INDEL_MAX_FREQ = ModuleConfig.getParam("VariantCallPosition_indel_max_freq_threshold", "error"); + private static final double WARNING_INDEL_MAX_FREQ = ModuleConfig.getParam("VariantCallPosition_indel_max_freq_threshold", "warn"); + private String[] indelNames = {"Deletions", "Insertions"}; double[] dFirstDeletionPos = null; @@ -214,19 +217,55 @@ public void reset() { } @Override public boolean raisesError() { - double indelPercent = 100.0d*(variantCallDetection.getTotalDeletions() + variantCallDetection.getTotalInsertions() ) - / variantCallDetection.getTotal(); - if(indelPercent > ModuleConfig.getParam("VariantCallPosition_indel_threshold", "error").doubleValue()) - return true; + for(int i=0; i ERROR_INDEL_MAX_FREQ) { + return true; + } + } + for(int i=0; i ERROR_INDEL_MAX_FREQ) { + return true; + } + } + if(variantCallDetection.existPairedReads()) { + for(int i=0; i ERROR_INDEL_MAX_FREQ) { + return true; + } + } + for(int i=0; i ERROR_INDEL_MAX_FREQ) { + return true; + } + } + } return false; } @Override public boolean raisesWarning() { - double indelPercent = 100.0d*(variantCallDetection.getTotalDeletions() + variantCallDetection.getTotalInsertions() ) - / variantCallDetection.getTotal(); - if(indelPercent > ModuleConfig.getParam("VariantCallPosition_indel_threshold", "warn").doubleValue()) - return true; + for(int i=0; i WARNING_INDEL_MAX_FREQ) { + return true; + } + } + for(int i=0; i WARNING_INDEL_MAX_FREQ) { + return true; + } + } + if(variantCallDetection.existPairedReads()) { + for(int i=0; i WARNING_INDEL_MAX_FREQ) { + return true; + } + } + for(int i=0; i WARNING_INDEL_MAX_FREQ) { + return true; + } + } + } return false; } diff --git a/uk/ac/babraham/BamQC/Modules/SNPFrequencies.java b/uk/ac/babraham/BamQC/Modules/SNPFrequencies.java index 898bc8d..81d7832 100644 --- a/uk/ac/babraham/BamQC/Modules/SNPFrequencies.java +++ b/uk/ac/babraham/BamQC/Modules/SNPFrequencies.java @@ -49,6 +49,8 @@ public class SNPFrequencies extends AbstractQCModule { private static Logger log = Logger.getLogger(SNPFrequencies.class); + private static final double ERROR_SNP_MAX_FREQ = ModuleConfig.getParam("VariantCallPosition_snp_max_freq_threshold", "error"); + private static final double WARNING_SNP_MAX_FREQ = ModuleConfig.getParam("VariantCallPosition_snp_max_freq_threshold", "warn"); double[] dFirstSNPPos = null; double[] dSecondSNPPos = null; @@ -202,17 +204,35 @@ public void reset() { } @Override public boolean raisesError() { - double snpPercent = 100.0d*(variantCallDetection.getTotalMutations()) / variantCallDetection.getTotal(); - if(snpPercent > ModuleConfig.getParam("VariantCallPosition_snp_threshold", "error").doubleValue()) - return true; + for(int i=0; i ERROR_SNP_MAX_FREQ) { + return true; + } + } + if(variantCallDetection.existPairedReads()) { + for(int i=0; i ERROR_SNP_MAX_FREQ) { + return true; + } + } + } return false; } @Override public boolean raisesWarning() { - double snpPercent = 100.0d*(variantCallDetection.getTotalMutations()) / variantCallDetection.getTotal(); - if(snpPercent > ModuleConfig.getParam("VariantCallPosition_snp_threshold", "warn").doubleValue()) - return true; + for(int i=0; i WARNING_SNP_MAX_FREQ) { + return true; + } + } + if(variantCallDetection.existPairedReads()) { + for(int i=0; i WARNING_SNP_MAX_FREQ) { + return true; + } + } + } return false; } diff --git a/uk/ac/babraham/BamQC/Modules/SNPFrequenciesByType.java b/uk/ac/babraham/BamQC/Modules/SNPFrequenciesByType.java index 755bfc2..bf20ec8 100644 --- a/uk/ac/babraham/BamQC/Modules/SNPFrequenciesByType.java +++ b/uk/ac/babraham/BamQC/Modules/SNPFrequenciesByType.java @@ -57,6 +57,9 @@ public class SNPFrequenciesByType extends AbstractQCModule { //private static Logger log = Logger.getLogger(SNPFrequenciesByType.class); + private static final double ERROR_SNP_MAX_FREQ_BY_TYPE = ModuleConfig.getParam("VariantCallPosition_snp_max_freq_by_type_threshold", "error"); + private static final double WARNING_SNP_MAX_FREQ_BY_TYPE = ModuleConfig.getParam("VariantCallPosition_snp_max_freq_by_type_threshold", "warn"); + // original threshold for the plot x axis. private double firstMaxX=0.0d; private double secondMaxX=0.0d; @@ -171,17 +174,35 @@ public void reset() { } @Override public boolean raisesError() { - double snpPercent = 100.0d*(variantCallDetection.getTotalMutations()) / variantCallDetection.getTotal(); - if(snpPercent > ModuleConfig.getParam("VariantCallPosition_snp_threshold", "error").doubleValue()) - return true; + for(int i=0; i ERROR_SNP_MAX_FREQ_BY_TYPE) { + return true; + } + } + if(variantCallDetection.existPairedReads()) { + for(int i=0; i ERROR_SNP_MAX_FREQ_BY_TYPE) { + return true; + } + } + } return false; } @Override public boolean raisesWarning() { - double snpPercent = 100.0d*(variantCallDetection.getTotalMutations()) / variantCallDetection.getTotal(); - if(snpPercent > ModuleConfig.getParam("VariantCallPosition_snp_threshold", "warn").doubleValue()) - return true; + for(int i=0; i WARNING_SNP_MAX_FREQ_BY_TYPE) { + return true; + } + } + if(variantCallDetection.existPairedReads()) { + for(int i=0; i WARNING_SNP_MAX_FREQ_BY_TYPE) { + return true; + } + } + } return false; } diff --git a/uk/ac/babraham/BamQC/Modules/SoftClipDistribution.java b/uk/ac/babraham/BamQC/Modules/SoftClipDistribution.java index 3396e8a..f417013 100644 --- a/uk/ac/babraham/BamQC/Modules/SoftClipDistribution.java +++ b/uk/ac/babraham/BamQC/Modules/SoftClipDistribution.java @@ -52,6 +52,9 @@ public class SoftClipDistribution extends AbstractQCModule { // logger private static Logger log = Logger.getLogger(SoftClipDistribution.class); + private static final long ERROR_CLIP_NUMBER = ModuleConfig.getParam("SoftClipDistribution_clip_number_threshold", "error").longValue(); + private static final long WARNING_CLIP_NUMBER = ModuleConfig.getParam("SoftClipDistribution_clip_number_threshold", "warn").longValue(); + private long [] leftClipCounts = new long[1]; private long [] rightClipCounts = new long[1]; @@ -172,11 +175,31 @@ public void reset() { @Override public boolean raisesError() { + for(int i=0; i ERROR_CLIP_NUMBER) { + return true; + } + } + for(int i=0; i ERROR_CLIP_NUMBER) { + return true; + } + } return false; } @Override public boolean raisesWarning() { + for(int i=0; i WARNING_CLIP_NUMBER) { + return true; + } + } + for(int i=0; i WARNING_CLIP_NUMBER) { + return true; + } + } return false; }