Skip to content

Commit

Permalink
#5 added WARN/FAIL thresholds
Browse files Browse the repository at this point in the history
  • Loading branch information
pdp10 committed Apr 10, 2018
1 parent 55ab776 commit f5e8a8c
Show file tree
Hide file tree
Showing 10 changed files with 191 additions and 47 deletions.
50 changes: 35 additions & 15 deletions Configuration/limits.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 0 additions & 1 deletion uk/ac/babraham/BamQC/Graphs/ScatterGraph.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions uk/ac/babraham/BamQC/Modules/BasicStatistics.java
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
9 changes: 9 additions & 0 deletions uk/ac/babraham/BamQC/Modules/ChromosomeReadDensity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions uk/ac/babraham/BamQC/Modules/FeatureCoverage.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
27 changes: 20 additions & 7 deletions uk/ac/babraham/BamQC/Modules/GenomeCoverage.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) { }

Expand All @@ -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;
}

Expand All @@ -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 {
Expand All @@ -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();
Expand All @@ -144,7 +156,7 @@ public void processAnnotationSet(AnnotationSet annotation) {
}
}

int binsToUse = plotBinsPerChromosome;
binsToUse = plotBinsPerChromosome;

double binRatio = maxBins/(double)plotBinsPerChromosome;

Expand All @@ -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);
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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();
}
Expand Down
55 changes: 47 additions & 8 deletions uk/ac/babraham/BamQC/Modules/IndelFrequencies.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<dFirstDeletionPos.length; i++) {
if(dFirstDeletionPos[i] > ERROR_INDEL_MAX_FREQ) {
return true;
}
}
for(int i=0; i<dFirstInsertionPos.length; i++) {
if(dFirstInsertionPos[i] > ERROR_INDEL_MAX_FREQ) {
return true;
}
}
if(variantCallDetection.existPairedReads()) {
for(int i=0; i<dSecondDeletionPos.length; i++) {
if(dSecondDeletionPos[i] > ERROR_INDEL_MAX_FREQ) {
return true;
}
}
for(int i=0; i<dSecondInsertionPos.length; i++) {
if(dSecondInsertionPos[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<dFirstDeletionPos.length; i++) {
if(dFirstDeletionPos[i] > WARNING_INDEL_MAX_FREQ) {
return true;
}
}
for(int i=0; i<dFirstInsertionPos.length; i++) {
if(dFirstInsertionPos[i] > WARNING_INDEL_MAX_FREQ) {
return true;
}
}
if(variantCallDetection.existPairedReads()) {
for(int i=0; i<dSecondDeletionPos.length; i++) {
if(dSecondDeletionPos[i] > WARNING_INDEL_MAX_FREQ) {
return true;
}
}
for(int i=0; i<dSecondInsertionPos.length; i++) {
if(dSecondInsertionPos[i] > WARNING_INDEL_MAX_FREQ) {
return true;
}
}
}
return false;
}

Expand Down
32 changes: 26 additions & 6 deletions uk/ac/babraham/BamQC/Modules/SNPFrequencies.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<dFirstSNPPos.length; i++) {
if(dFirstSNPPos[i] > ERROR_SNP_MAX_FREQ) {
return true;
}
}
if(variantCallDetection.existPairedReads()) {
for(int i=0; i<dSecondSNPPos.length; i++) {
if(dSecondSNPPos[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<dFirstSNPPos.length; i++) {
if(dFirstSNPPos[i] > WARNING_SNP_MAX_FREQ) {
return true;
}
}
if(variantCallDetection.existPairedReads()) {
for(int i=0; i<dSecondSNPPos.length; i++) {
if(dSecondSNPPos[i] > WARNING_SNP_MAX_FREQ) {
return true;
}
}
}
return false;
}

Expand Down
Loading

0 comments on commit f5e8a8c

Please sign in to comment.