diff --git a/workflow/main.nf b/workflow/main.nf index 4e9c50da22e13af3685c0682aa4e50767eaebed2..2d89d8179bec42d15d2d0fc7905e4613ce798dc7 100644 --- a/workflow/main.nf +++ b/workflow/main.nf @@ -198,7 +198,7 @@ process experimentQC { output: - file '*.{png,npz}' into deepToolsStats + file '*.{pdf,npz}' into deepToolsStats script: diff --git a/workflow/scripts/experiment_qc.py b/workflow/scripts/experiment_qc.py index d884eaf5c572607dbbf2a4c51e59dcea27fe7087..466f84795f7c2783f68c166a8c53dcc268fd19ff 100644 --- a/workflow/scripts/experiment_qc.py +++ b/workflow/scripts/experiment_qc.py @@ -77,10 +77,10 @@ def generate_read_summary(design, extension): return mbs_filename -def check_correlation(mbs): +def check_spearman_correlation(mbs): '''Check Spearman pairwise correlation of samples based on read counts.''' - spearman_filename = 'heatmap_SpearmanCorr.png' + spearman_filename = 'heatmap_SpearmanCorr.pdf' spearman_params = "--corMethod spearman --skipZero" + \ " --plotTitle \"Spearman Correlation of Read Counts\"" + \ " --whatToPlot heatmap --colorMap RdYlBu --plotNumbers" @@ -96,12 +96,31 @@ def check_correlation(mbs): out, err = spearman_correlation.communicate() +def check_pearson_correlation(mbs): + '''Check Pearson pairwise correlation of samples based on read counts.''' + + pearson_filename = 'heatmap_PearsonCorr.pdf' + pearson_params = "--corMethod pearson --skipZero" + \ + " --plotTitle \"Pearson Correlation of Read Counts\"" + \ + " --whatToPlot heatmap --colorMap RdYlBu --plotNumbers" + + pearson_command = ( + "plotCorrelation -in %s %s -o %s" + % (mbs, pearson_params, pearson_filename) + ) + + logger.info("Running deeptools with %s", pearson_command) + + pearson_correlation = subprocess.Popen(pearson_command, shell=True) + out, err = pearson_correlation.communicate() + + def check_coverage(design, extension): '''Asses the sequencing depth of samples.''' bam_files = ' '.join(design['bam_reads']) labels = ' '.join(design['sample_id']) - coverage_filename = 'coverage.png' + coverage_filename = 'coverage.pdf' coverage_params = "-n 1000000 --plotTitle \"Sample Coverage\"" + \ " --ignoreDuplicates --minMappingQuality 10" @@ -137,7 +156,7 @@ def update_controls(design): def check_enrichment(sample_id, control_id, sample_reads, control_reads, extension): '''Asses the enrichment per sample.''' - fingerprint_filename = sample_id + '_fingerprint.png' + fingerprint_filename = sample_id + '_fingerprint.pdf' fingerprint_command = ( "plotFingerprint -b %s %s --extendReads %d --labels %s %s --plotFile %s" @@ -167,7 +186,9 @@ def main(): # Run correlation mbs_filename = generate_read_summary(design_df, extension) - check_correlation(mbs_filename) + check_spearman_correlation(mbs_filename) + check_pearson_correlation(mbs_filename) + # Run coverage check_coverage(design_df, extension) diff --git a/workflow/tests/test_experiment_qc.py b/workflow/tests/test_experiment_qc.py index 98853b9d6c2eabc4e4b9887cfb51c07a6af08fa4..17f8eaa42e19fcadd144fd8802ec441f22929f78 100644 --- a/workflow/tests/test_experiment_qc.py +++ b/workflow/tests/test_experiment_qc.py @@ -41,6 +41,11 @@ def test_spearman_singleend(): assert os.path.exists(os.path.join(test_output_path, 'heatmap_SpearmanCorr.png')) +@pytest.mark.singleend +def test_pearson_singleend(): + assert os.path.exists(os.path.join(test_output_path, 'heatmap_PearsonCorr.png')) + + @pytest.mark.singleend def test_fingerprint_singleend(): assert os.path.exists(os.path.join(test_output_path, 'ENCLB144FDT_fingerprint.png')) @@ -58,6 +63,11 @@ def test_spearman_pairedend(): assert os.path.exists(os.path.join(test_output_path, 'heatmap_SpearmanCorr.png')) +@pytest.mark.pairdend +def test_pearson_pairedend(): + assert os.path.exists(os.path.join(test_output_path, 'heatmap_PearsonCorr.png')) + + @pytest.mark.pairdend def test_fingerprint_pairedend(): assert os.path.exists(os.path.join(test_output_path, 'ENCLB568IYX_fingerprint.png'))