Commit 8d473267 authored by Chris Cheshire's avatar Chris Cheshire
Browse files

Consensus peaks working

parent 057cef16
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -11,11 +11,15 @@ params {
    run_input_check        = true
    run_cat_fastq          = true
    run_trim_galore_fastqc = true

    run_alignment          = true
    run_q_filter           = false
    run_mark_dups          = true
    run_remove_dups        = true

    run_peak_calling       = true
    run_consensus_all      = false

    run_reporting          = true
    run_deep_tools         = true
    run_multiqc            = true
@@ -28,6 +32,7 @@ params {
params.callers = params.peakcaller ? params.peakcaller.split(',').collect{ it.trim().toLowerCase() } : ['seacr']

if(params.dedup_target_reads)           { params.dedup_control_only = false }
if(params.consensus_peak_mode == 'all') { params.run_consensus_all  = true  }

if(params.minimum_alignment_q_score > 0)                  { params.run_q_filter      = true  }
if(params.skip_removeduplicates || !params.run_mark_dups) { params.run_remove_dups   = false }
+74 −30
Original line number Diff line number Diff line
@@ -496,44 +496,88 @@ if(params.run_peak_calling && 'macs2' in params.callers) {
    }
}

/*
========================================================================================
    CONSENSUS PEAKS
========================================================================================
*/

// //TODO: PEAK PLOTTING options - infact all reporting options - how t
if(params.run_peak_calling) {
    process {
        withName: 'NFCORE_CUTANDRUN:CUTANDRUN:AWK_NAME_PEAK_BED' {
            ext.command = "'{OFS = \"\\t\"} {print \$0, FILENAME}'"
            ext.ext     = "bed"
            publishDir = [
                enabled: false
            ]
        }

        withName: '.*:CONSENSUS_PEAKS:SORT|.*:CONSENSUS_PEAKS_ALL:SORT' {
            ext.args   = "-k1,1 -k2,2n"
            ext.ext    = "bed"
            publishDir = [
                enabled: false
            ]
        }

//         /*
//         ========================================================================================
//             CONSENSUS PEAKS
//         ========================================================================================
//         */
        withName: '.*:CONSENSUS_PEAKS:BEDTOOLS_MERGE|.*:CONSENSUS_PEAKS_ALL:BEDTOOLS_MERGE' {
            ext.args   = " -c 2,3,4,5,6,7,7 -o collapse,collapse,collapse,collapse,collapse,collapse,count_distinct"
            ext.suffix = ".consensus.peaks"
            publishDir = [
                path: { "${params.outdir}/03_peak_calling/05_consensus_peaks" },
                mode: 'copy',
                saveAs: { filename -> filename.equals('versions.yml') ? null : filename },
                enabled: true
            ]
        }

        withName: '.*:CONSENSUS_PEAKS:PLOT_CONSENSUS_PEAKS|.*:CONSENSUS_PEAKS_ALL:PLOT_CONSENSUS_PEAKS' {
            publishDir = [
                path: { "${params.outdir}/04_reporting" },
                mode: 'copy',
                saveAs: { filename -> filename.equals('versions.yml') ? null : filename },
                enabled: params.skip_upset_plots
            ]
        }
    }
}

if(params.run_peak_calling && !params.run_consensus_all) {
    process {
        withName: 'NFCORE_CUTANDRUN:CUTANDRUN:CONSENSUS_PEAKS:AWK' {
            ext.command = "' \$10 >= 1 {print \$0}'"
            ext.ext     = "bed"
            publishDir  = [
                path: { "${params.outdir}/03_peak_calling/05_consensus_peaks" },
                mode: 'copy',
                saveAs: { filename -> filename.equals('versions.yml') ? null : filename },
                enabled: true
            ]
        }
    }
}

if(params.run_peak_calling && params.run_consensus_all) {
    process {
        withName: 'NFCORE_CUTANDRUN:CUTANDRUN:CONSENSUS_PEAKS_ALL:AWK' {
            ext.command = "' \$10 >= " + params.replicate_threshold.toString() + " {print \$0}'"
            ext.ext    = "bed"
            publishDir = [
                path: { "${params.outdir}/03_peak_calling/05_consensus_peaks" },
                mode: 'copy',
                saveAs: { filename -> filename.equals('versions.yml') ? null : filename },
                enabled: true
            ]
        }
    }
}

// //TODO: PEAK PLOTTING options - infact all reporting options - how t

//         "awk_name_peak_bed" {
//             command       = "'{OFS = \"\\t\"} {print \$0, FILENAME}'"
//             publish_files = false
//             ext           = "bed"
//         }

//         "sort_group_peaks" {
//             args          = "-k1,1 -k2,2n"
//             publish_files = false
//             ext           = "bed"
//         }

//         "bedtools_merge_groups" {
//             args          = " -c 2,3,4,5,6,7,7 -o collapse,collapse,collapse,collapse,collapse,collapse,count_distinct"
//             // args          = " -c 7 -o collapse"
//             publish_dir   = "03_peak_calling/05_consensus_peaks"
//             suffix        = ".consensus.peaks"
//         }

//         "awk_threshold" {
//             publish_dir   = "03_peak_calling/05_consensus_peaks"
//             suffix        = ".consensus.peaks.filtered"
//             ext           = "bed"
//         }

//         "plot_peaks" {
//             publish_dir = "04_reporting"
//         }

//         /*
//         ========================================================================================
+0 −4
Original line number Diff line number Diff line
process PLOT_CONSENSUS_PEAKS {
    label 'process_low'
    publishDir "${params.outdir}",
        mode: params.publish_dir_mode,
        saveAs: { filename -> saveFiles(filename:filename, options:params.options, publish_dir:getSoftwareName(task.process), publish_id:'') }


    conda (params.enable_conda ? "conda-forge::python=3.8.3 conda-forge::numpy=1.20.* conda-forge::pandas=1.2.* conda-forge::upsetplot=0.4.4" : null)
    container "luslab/cutandrun-dev-plot-consensus-peaks:latest"
+4 −1
Original line number Diff line number Diff line
@@ -73,12 +73,15 @@ params {
    macs2_gsize                = 2.7e9
    run_narrow_peak            = false

    // Consensus Peaks
    consensus_peak_mode        = 'group'
    skip_upset_plots           = false

    // Reporting and Visualisation
    skip_reporting             = false
    skip_igv                   = false
    skip_heatmaps              = false
    skip_multiqc               = false
    skip_upset_plots           = false

    // Boilerplate options
    outdir                     = "./results"
+2 −4
Original line number Diff line number Diff line
@@ -2,11 +2,10 @@
 * Create group consensus peaks
 */


include { SORT                 } from '../../modules/local/linux/sort'
include { BEDTOOLS_MERGE       } from '../../modules/nf-core/modules/bedtools/merge/main'
include { AWK                  } from '../../modules/local/linux/awk'
include { PLOT_CONSENSUS_PEAKS } from '../../modules/local/python/plot_consensus_peaks'
include { PLOT_CONSENSUS_PEAKS } from '../../modules/local/modules/plot_consensus_peaks/main'

workflow CONSENSUS_PEAKS {

@@ -14,7 +13,6 @@ workflow CONSENSUS_PEAKS {
    bed       //  channel: [ val(meta), [ bed ], count]
    skip_plot // boolean: true/false


    main:
    ch_versions = Channel.empty()

@@ -31,7 +29,7 @@ workflow CONSENSUS_PEAKS {

    // Plot consensus peak sets
    if(!skip_plot) {
        PLOT_CONSENSUS_PEAKS ( BEDTOOLS_MERGE.out.bed.collect{it[1]}.ifEmpty([]) )
        PLOT_CONSENSUS_PEAKS ( BEDTOOLS_MERGE.out.bed.collect{it[1]} )
        ch_versions = ch_versions.mix(PLOT_CONSENSUS_PEAKS.out.versions)
    }

Loading