Commit ad0dac1c authored by Chris Cheshire's avatar Chris Cheshire
Browse files

igv and deep tools working

parent ad9d5c6c
Loading
Loading
Loading
Loading
+64 −35
Original line number Diff line number Diff line
@@ -652,48 +652,77 @@ if(params.run_peak_calling) {
    }
}

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





/*
========================================================================================
    REPORTING
========================================================================================
*/

//         /*
//         ========================================================================================
//             REPORTING
//         ========================================================================================
//         */
if(params.run_reporting && params.run_igv) {
    process {
        withName: 'NFCORE_CUTANDRUN:CUTANDRUN:IGV_SESSION' {
            publishDir   = [
                path: { "${params.outdir}/04_reporting/igv" },
                mode: 'copy',
                saveAs: { filename -> filename.equals('versions.yml') ? null : filename },
                enabled: true
            ]
        }
    }
}

//         "igv" {
//             publish_dir   = "04_reporting/igv"
//         }
if(params.run_reporting && params.run_deep_tools) {
    process {
        withName: 'NFCORE_CUTANDRUN:CUTANDRUN:AWK_EDIT_PEAK_BED' {
            ext.command = "'{split(\$6, summit, \":\"); split(summit[2], region, \"-\"); print summit[1]\"\\t\"region[1]\"\\t\"region[2]}'"
            ext.suffix  = ".max_signal"
            publishDir  = [
                enabled: false
            ]
        }

//         "dt_compute_mat_gene" {
//             args        = "scale-regions --beforeRegionStartLength 3000 --regionBodyLength 5000 --afterRegionStartLength 3000 --skipZeros --missingDataAsZero"
//             publish_dir = "04_reporting/heatmaps/gene"
//         }
        withName: 'NFCORE_CUTANDRUN:CUTANDRUN:DEEPTOOLS_COMPUTEMATRIX_GENE' {
            ext.args = "scale-regions --beforeRegionStartLength 3000 --regionBodyLength 5000 --afterRegionStartLength 3000 --skipZeros --missingDataAsZero"
            publishDir   = [
                path: { "${params.outdir}/04_reporting/heatmaps/gene" },
                mode: 'copy',
                saveAs: { filename -> filename.equals('versions.yml') ? null : filename },
                enabled: true
            ]
        }

//         "dt_compute_mat_peaks" {
//             args        = "reference-point -a 3000 -b 3000 --referencePoint center --skipZeros --missingDataAsZero"
//             publish_dir = "04_reporting/heatmaps/peaks"
//         }
        withName: 'NFCORE_CUTANDRUN:CUTANDRUN:DEEPTOOLS_PLOTHEATMAP_GENE' {
            ext.args = "--sortUsing sum"
            publishDir   = [
                path: { "${params.outdir}/04_reporting/heatmaps/gene" },
                mode: 'copy',
                saveAs: { filename -> filename.equals('versions.yml') ? null : filename },
                enabled: true
            ]
        }

//         "dt_plotheatmap_gene" {
//             args        = "--sortUsing sum"
//             publish_dir = "04_reporting/heatmaps/gene"
//         }
        withName: 'NFCORE_CUTANDRUN:CUTANDRUN:DEEPTOOLS_COMPUTEMATRIX_PEAKS' {
            ext.args = "reference-point -a 3000 -b 3000 --referencePoint center --skipZeros --missingDataAsZero"
            publishDir   = [
                path: { "${params.outdir}/04_reporting/heatmaps/peaks" },
                mode: 'copy',
                saveAs: { filename -> filename.equals('versions.yml') ? null : filename },
                enabled: true
            ]
        }

//         "dt_plotheatmap_peaks" {
//             args        = "--sortUsing sum --startLabel \"Peak Start\" --endLabel \"Peak End\" --xAxisLabel \"\" --regionsLabel \"Peaks\""
//             publish_dir = "04_reporting/heatmaps/peaks"
//         }
        withName: 'NFCORE_CUTANDRUN:CUTANDRUN:DEEPTOOLS_PLOTHEATMAP_PEAKS' {
            ext.args = "--sortUsing sum --startLabel \"Peak Start\" --endLabel \"Peak End\" --xAxisLabel \"\" --regionsLabel \"Peaks\""
            publishDir   = [
                path: { "${params.outdir}/04_reporting/heatmaps/peaks" },
                mode: 'copy',
                saveAs: { filename -> filename.equals('versions.yml') ? null : filename },
                enabled: true
            ]
        }
    }
}

//         "awk_edit_peak_bed" {
//             command     = "'{split(\$6, summit, \":\"); split(summit[2], region, \"-\"); print summit[1]\"\\t\"region[1]\"\\t\"region[2]}'"
//             suffix      = ".max_signal"
//             publish_files = false
//         }

//         "export_meta" {
//             publish_dir   = "04_reporting"
+0 −3
Original line number Diff line number Diff line
@@ -3,9 +3,6 @@ colour_pallete = ['38,70,83', '231,111,81', '42,157,143', '244,162,97', '233,196
process IGV_SESSION {
    tag "igv"
    label 'process_low'
    publishDir "${params.outdir}",
        mode: params.publish_dir_mode,
        saveAs: { filename -> saveFiles(filename:filename, options:params.options, publish_dir:'pipeline_info', publish_id:'') }

    conda     (params.enable_conda ? "conda-forge::python=3.8.3" : null)
    container "quay.io/biocontainers/python:3.8.3"
+53 −52
Original line number Diff line number Diff line
@@ -102,8 +102,8 @@ include { INPUT_CHECK } from "../subworkflows/local/input_ch
include { AWK as AWK_NAME_PEAK_BED        } from "../modules/local/linux/awk"
include { AWK as AWK_FRAG_BIN             } from "../modules/local/linux/awk"
include { SAMTOOLS_CUSTOMVIEW             } from "../modules/local/samtools_custom_view"
// include { IGV_SESSION                     } from "../modules/local/python/igv_session"                 addParams( options: modules["igv"]                 )
// include { AWK as AWK_EDIT_PEAK_BED        } from "../modules/local/linux/awk"                          addParams( options: modules["awk_edit_peak_bed"]   )
include { IGV_SESSION                     } from "../modules/local/python/igv_session"
include { AWK as AWK_EDIT_PEAK_BED        } from "../modules/local/linux/awk"
// include { CALCULATE_FRIP                  } from "../modules/local/modules/calculate_frip/main"        addParams( options: modules["calc_frip"]           )
// include { CUT as CUT_CALC_REPROD          } from "../modules/local/linux/cut"                          addParams( options: modules["calc_peak_repro_cut"] )
// include { CALCULATE_PEAK_REPROD           } from "../modules/local/modules/calculate_peak_reprod/main" addParams( options: modules["calc_peak_repro"]     )
@@ -145,10 +145,10 @@ include { SEACR_CALLPEAK } from "../mo
include { SEACR_CALLPEAK as SEACR_CALLPEAK_NOIGG                   } from "../modules/nf-core/modules/seacr/callpeak/main"
include { MACS2_CALLPEAK                                           } from "../modules/nf-core/modules/macs2/callpeak/main"
include { MACS2_CALLPEAK as MACS2_CALLPEAK_NOIGG                   } from "../modules/nf-core/modules/macs2/callpeak/main"
// include { DEEPTOOLS_COMPUTEMATRIX as DEEPTOOLS_COMPUTEMATRIX_GENE  } from "../modules/nf-core/modules/deeptools/computematrix/main"     addParams( options: modules["dt_compute_mat_gene"]         )
// include { DEEPTOOLS_COMPUTEMATRIX as DEEPTOOLS_COMPUTEMATRIX_PEAKS } from "../modules/nf-core/modules/deeptools/computematrix/main"     addParams( options: modules["dt_compute_mat_peaks"]        )
// include { DEEPTOOLS_PLOTHEATMAP as DEEPTOOLS_PLOTHEATMAP_GENE      } from "../modules/nf-core/modules/deeptools/plotheatmap/main"       addParams( options: modules["dt_plotheatmap_gene"]         )
// include { DEEPTOOLS_PLOTHEATMAP as DEEPTOOLS_PLOTHEATMAP_PEAKS     } from "../modules/nf-core/modules/deeptools/plotheatmap/main"       addParams( options: modules["dt_plotheatmap_peaks"]        )
include { DEEPTOOLS_COMPUTEMATRIX as DEEPTOOLS_COMPUTEMATRIX_GENE  } from "../modules/nf-core/modules/deeptools/computematrix/main"
include { DEEPTOOLS_COMPUTEMATRIX as DEEPTOOLS_COMPUTEMATRIX_PEAKS } from "../modules/nf-core/modules/deeptools/computematrix/main"
include { DEEPTOOLS_PLOTHEATMAP as DEEPTOOLS_PLOTHEATMAP_GENE      } from "../modules/nf-core/modules/deeptools/plotheatmap/main"
include { DEEPTOOLS_PLOTHEATMAP as DEEPTOOLS_PLOTHEATMAP_PEAKS     } from "../modules/nf-core/modules/deeptools/plotheatmap/main"
// include { BEDTOOLS_INTERSECT                                       } from "../modules/nf-core/modules/bedtools/intersect/main.nf"       addParams( options: bedtools_intersect_options             )
include { CUSTOM_DUMPSOFTWAREVERSIONS                              } from "../modules/local/modules/custom/dumpsoftwareversions/main"

@@ -768,21 +768,20 @@ workflow CUTANDRUN {
            /*
            * CHANNEL: Remove IgG from bigwig channel
            */
            // UCSC_BEDGRAPHTOBIGWIG.out.bigwig
            //     .filter { it[0].group != "igg" }
            //     .set { ch_bigwig_no_igg }
            UCSC_BEDGRAPHTOBIGWIG.out.bigwig
                .filter { it[0].group != "igg" }
                .set { ch_bigwig_no_igg }
            //ch_bigwig_no_igg | view

            /*
            * MODULE: Create igv session
            */
            // IGV_SESSION (
            //     PREPARE_GENOME.out.fasta,
            //     PREPARE_GENOME.out.gtf,
            //     ch_peaks_bed.collect{it[1]}.ifEmpty([]), 
            //     UCSC_BEDGRAPHTOBIGWIG.out.bigwig.collect{it[1]}.ifEmpty([])
            // )
            //TODO - this version ouptut causes an error for an unknown reason
            IGV_SESSION (
                PREPARE_GENOME.out.fasta,
                PREPARE_GENOME.out.gtf,
                ch_peaks_bed.collect{it[1]}.ifEmpty([]), 
                UCSC_BEDGRAPHTOBIGWIG.out.bigwig.collect{it[1]}.ifEmpty([])
            )
            //ch_software_versions = ch_software_versions.mix(IGV_SESSION.out.versions)
        }

@@ -790,76 +789,78 @@ workflow CUTANDRUN {
            /*
            * MODULE: Extract max signal from peak beds
            */
            // AWK_EDIT_PEAK_BED (
            //     ch_peaks_bed
            // )
            // ch_software_versions = ch_software_versions.mix(AWK_EDIT_PEAK_BED.out.versions)
            AWK_EDIT_PEAK_BED (
                ch_peaks_bed
            )
            ch_software_versions = ch_software_versions.mix(AWK_EDIT_PEAK_BED.out.versions)
            //AWK_EDIT_PEAK_BED.out.file | view

            /*
            * CHANNEL: Structure output for join on id
            */
            // AWK_EDIT_PEAK_BED.out.file
            //     .map { row -> [row[0].id, row ].flatten()}
            //     .set { ch_peaks_bed_id }
            AWK_EDIT_PEAK_BED.out.file
                .map { row -> [row[0].id, row ].flatten()}
                .set { ch_peaks_bed_id }
            //ch_peaks_bed_id | view

            /*
            * CHANNEL: Join beds and bigwigs on id
            */
            // ch_bigwig_no_igg
            //     .map { row -> [row[0].id, row ].flatten()}
            //     .join ( ch_peaks_bed_id )
            //     .set { ch_dt_peaks }
            ch_bigwig_no_igg
                .map { row -> [row[0].id, row ].flatten()}
                .join ( ch_peaks_bed_id )
                .set { ch_dt_peaks }
            //ch_dt_peaks | view

            // ch_dt_peaks
            //     .map { row -> row[1,2] }
            //     .set { ch_ordered_bigwig }
            ch_dt_peaks
                .map { row -> row[1,2] }
                .set { ch_ordered_bigwig }
            //ch_ordered_bigwig | view

            // ch_dt_peaks
            //     .map { row -> row[-1] }
            //     .set { ch_ordered_peaks_max }
            ch_dt_peaks
                .map { row -> row[-1] }
                .set { ch_ordered_peaks_max }
            //ch_ordered_peaks_max | view

            /*
            * MODULE: Compute DeepTools matrix used in heatmap plotting for Genes
            */
            // DEEPTOOLS_COMPUTEMATRIX_GENE (
            //     ch_bigwig_no_igg,
            //     PREPARE_GENOME.out.bed
            // )
            // ch_software_versions = ch_software_versions.mix(DEEPTOOLS_COMPUTEMATRIX_GENE.out.versions)
            DEEPTOOLS_COMPUTEMATRIX_GENE (
                ch_bigwig_no_igg,
                PREPARE_GENOME.out.bed
            )
            ch_software_versions = ch_software_versions.mix(DEEPTOOLS_COMPUTEMATRIX_GENE.out.versions)

            /*
            * MODULE: Calculate DeepTools heatmap
            */
            // DEEPTOOLS_PLOTHEATMAP_GENE (
            //     DEEPTOOLS_COMPUTEMATRIX_GENE.out.matrix
            // )
            // ch_software_versions = ch_software_versions.mix(DEEPTOOLS_PLOTHEATMAP_GENE.out.versions)
            DEEPTOOLS_PLOTHEATMAP_GENE (
                DEEPTOOLS_COMPUTEMATRIX_GENE.out.matrix
            )
            ch_software_versions = ch_software_versions.mix(DEEPTOOLS_PLOTHEATMAP_GENE.out.versions)

            // ch_ordered_peaks_max
            //     .filter { it -> it.size() > 345}
            //     .set { ch_ordered_peaks_max }
            // Run if not empty file size > 1 byte
            ch_ordered_peaks_max
                .filter { it -> it.size() > 1}
                .set { ch_ordered_peaks_max_notempty }
            //ch_ordered_peaks_max_notempty | view

            /*
            * MODULE: Compute DeepTools matrix used in heatmap plotting for Peaks
            */
            // DEEPTOOLS_COMPUTEMATRIX_PEAKS (
            //     ch_ordered_bigwig,
            //     ch_ordered_peaks_max
            // )
            DEEPTOOLS_COMPUTEMATRIX_PEAKS (
                ch_ordered_bigwig,
                ch_ordered_peaks_max_notempty
            )
            //EXAMPLE CHANNEL STRUCT: [[META], MATRIX]
            //DEEPTOOLS_COMPUTEMATRIX_PEAKS.out.matrix | view

            /*
            * MODULE: Calculate DeepTools heatmap
            */
            // DEEPTOOLS_PLOTHEATMAP_PEAKS (
            //     DEEPTOOLS_COMPUTEMATRIX_PEAKS.out.matrix
            // )
            DEEPTOOLS_PLOTHEATMAP_PEAKS (
                DEEPTOOLS_COMPUTEMATRIX_PEAKS.out.matrix
            )
        }

        /*