diff --git a/CHANGELOG.md b/CHANGELOG.md index 289c062c..1f475919 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [[2.0.0](https://github.com/nf-core/chipseq/releases/tag/2.0.0)] - 2022-09-30 +## [[2.0.0](https://github.com/nf-core/chipseq/releases/tag/2.0.0)] - 2022-10-03 ### Enhancements & fixes diff --git a/bin/igv_files_to_session.py b/bin/igv_files_to_session.py index ce1fac70..629e6cc9 100755 --- a/bin/igv_files_to_session.py +++ b/bin/igv_files_to_session.py @@ -24,10 +24,16 @@ ## REQUIRED PARAMETERS argParser.add_argument("XML_OUT", help="XML output file.") argParser.add_argument( - "LIST_FILE", help="Tab-delimited file containing two columns i.e. file_name\tcolour. Header isnt required." + "LIST_FILE", + help="Tab-delimited file containing two columns i.e. file_name\tcolour. Header isnt required.", ) argParser.add_argument( - "GENOME", help="Full path to genome fasta file or shorthand for genome available in IGV e.g. hg19." + "REPLACE_FILE", + help="Tab-delimited file containing two columns i.e. file_name\treplacement_file_name. Header isnt required.", +) +argParser.add_argument( + "GENOME", + help="Full path to genome fasta file or shorthand for genome available in IGV e.g. hg19.", ) ## OPTIONAL PARAMETERS @@ -65,10 +71,20 @@ def makedir(path): ############################################ -def igv_files_to_session(XMLOut, ListFile, Genome, PathPrefix=""): +def igv_files_to_session(XMLOut, ListFile, ReplaceFile, Genome, PathPrefix=""): makedir(os.path.dirname(XMLOut)) + replaceFileDict = {} + fin = open(ReplaceFile, "r") + while True: + line = fin.readline() + if line: + ofile, rfile = line.strip().split("\t") + replaceFileDict[ofile] = rfile + else: + break + fin.close() fileList = [] fin = open(ListFile, "r") while True: @@ -77,10 +93,17 @@ def igv_files_to_session(XMLOut, ListFile, Genome, PathPrefix=""): ifile, colour = line.strip().split("\t") if len(colour.strip()) == 0: colour = "0,0,178" + for ofile, rfile in replaceFileDict.items(): + if ofile in ifile: + ifile = ifile.replace(ofile, rfile) fileList.append((PathPrefix.strip() + ifile, colour)) else: break - fout.close() + fin.close() + fout = open("igv_files.txt", "w") + for ifile, colour in fileList: + fout.write(ifile + "\n") + fout.close() ## ADD RESOURCES SECTION XMLStr = '\n' @@ -138,7 +161,6 @@ def igv_files_to_session(XMLOut, ListFile, Genome, PathPrefix=""): 'id="%s" name="%s" renderer="BASIC_FEATURE" sortable="false" visible="true" windowFunction="count"/>\n' % (ifile, os.path.basename(ifile)) ) - XMLStr += "\t\n" # XMLStr += '\t\n\t\t\n\t\t\n\t\t\n\t\n' XMLStr += "" @@ -153,7 +175,13 @@ def igv_files_to_session(XMLOut, ListFile, Genome, PathPrefix=""): ############################################ ############################################ -igv_files_to_session(XMLOut=args.XML_OUT, ListFile=args.LIST_FILE, Genome=args.GENOME, PathPrefix=args.PATH_PREFIX) +igv_files_to_session( + XMLOut=args.XML_OUT, + ListFile=args.LIST_FILE, + ReplaceFile=args.REPLACE_FILE, + Genome=args.GENOME, + PathPrefix=args.PATH_PREFIX, +) ############################################ ############################################ diff --git a/modules/local/deseq2_qc.nf b/modules/local/deseq2_qc.nf index 7fc5a9f2..84ff0d5f 100644 --- a/modules/local/deseq2_qc.nf +++ b/modules/local/deseq2_qc.nf @@ -2,7 +2,9 @@ process DESEQ2_QC { tag "$meta.id" label 'process_medium' - conda (params.enable_conda ? "conda-forge::r-base=4.0 bioconda::bioconductor-deseq2=1.28.0 bioconda::bioconductor-biocparallel bioconda::bioconductor-tximport bioconda::bioconductor-complexheatmap conda-forge::r-optparse conda-forge::r-ggplot2 conda-forge::r-rcolorbrewer conda-forge::r-pheatmap" : null) + // (Bio)conda packages have intentionally not been pinned to a specific version + // This was to avoid the pipeline failing due to package conflicts whilst creating the environment when using -profile conda + conda (params.enable_conda ? "conda-forge::r-base bioconda::bioconductor-deseq2 bioconda::bioconductor-biocparallel bioconda::bioconductor-tximport bioconda::bioconductor-complexheatmap conda-forge::r-optparse conda-forge::r-ggplot2 conda-forge::r-rcolorbrewer conda-forge::r-pheatmap" : null) container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? 'https://depot.galaxyproject.org/singularity/mulled-v2-8849acf39a43cdd6c839a369a74c0adc823e2f91:ab110436faf952a33575c64dd74615a84011450b-0' : 'quay.io/biocontainers/mulled-v2-8849acf39a43cdd6c839a369a74c0adc823e2f91:ab110436faf952a33575c64dd74615a84011450b-0' }" diff --git a/modules/local/igv.nf b/modules/local/igv.nf index 8578092b..213904b3 100644 --- a/modules/local/igv.nf +++ b/modules/local/igv.nf @@ -9,13 +9,13 @@ process IGV { 'quay.io/biocontainers/python:3.8.3' }" input: + val aligner_dir + val peak_dir path fasta - path ("${bigwig_publish_dir}/*") - path ("${peak_publish_dir}/*") - path ("${consensus_publish_dir}/*") - val bigwig_publish_dir - val peak_publish_dir - val consensus_publish_dir + path ("${aligner_dir}/mergedLibrary/bigwig/*") + path ("${aligner_dir}/mergedLibrary/macs2/${peak_dir}/*") + path ("${aligner_dir}/mergedLibrary/macs2/${peak_dir}/consensus/*") + path ("mappings/*") output: path "*files.txt" , emit: txt @@ -23,14 +23,20 @@ process IGV { path "versions.yml", emit: versions script: // scripts are bundled with the pipeline in nf-core/chipseq/bin/ + def consensus_dir = "${aligner_dir}/mergedLibrary/macs2/${peak_dir}/consensus/*" """ find * -type l -name "*.bigWig" -exec echo -e ""{}"\\t0,0,178" \\; > bigwig.igv.txt find * -type l -name "*Peak" -exec echo -e ""{}"\\t0,0,178" \\; > peaks.igv.txt # Avoid error when consensus not produced - find * -type l -name "*.bed" -exec echo -e ""{}"\\t0,0,178" \\; | { grep "^$consensus_publish_dir" || test \$? = 1; } > bed.igv.txt + find * -type l -name "*.bed" -exec echo -e ""{}"\\t0,0,178" \\; | { grep "^$consensus_dir" || test \$? = 1; } > consensus.igv.txt - cat *.txt > igv_files.txt - igv_files_to_session.py igv_session.xml igv_files.txt ../../genome/${fasta.getName()} --path_prefix '../../' + touch replace_paths.txt + if [ -d "mappings" ]; then + cat mappings/* > replace_paths.txt + fi + + cat *.igv.txt > igv_files_orig.txt + igv_files_to_session.py igv_session.xml igv_files_orig.txt replace_paths.txt ../../genome/${fasta.getName()} --path_prefix '../../' cat <<-END_VERSIONS > versions.yml "${task.process}": diff --git a/modules/local/macs2_consensus.nf b/modules/local/macs2_consensus.nf index f28dc732..ab9ef93a 100644 --- a/modules/local/macs2_consensus.nf +++ b/modules/local/macs2_consensus.nf @@ -17,6 +17,7 @@ process MACS2_CONSENSUS { tuple val(meta), path("*.bed") , emit: bed tuple val(meta), path("*.saf") , emit: saf tuple val(meta), path("*.pdf") , emit: pdf + tuple val(meta), path("*.antibody.txt") , emit: txt tuple val(meta), path("*.boolean.txt") , emit: boolean_txt tuple val(meta), path("*.intersect.txt"), emit: intersect_txt path "versions.yml" , emit: versions @@ -25,7 +26,6 @@ process MACS2_CONSENSUS { task.ext.when == null || task.ext.when script: // This script is bundled with the pipeline, in nf-core/chipseq/bin/ - def prefix = task.ext.prefix ?: "${meta.id}" def peak_type = params.narrow_peak ? 'narrowPeak' : 'broadPeak' def mergecols = params.narrow_peak ? (2..10).join(',') : (2..9).join(',') @@ -49,6 +49,8 @@ process MACS2_CONSENSUS { plot_peak_intersect.r -i ${prefix}.boolean.intersect.txt -o ${prefix}.boolean.intersect.plot.pdf + echo "${prefix}.bed\t${meta.id}/${prefix}.bed" > ${prefix}.antibody.txt + cat <<-END_VERSIONS > versions.yml "${task.process}": python: \$(python --version | sed 's/Python //g') diff --git a/workflows/chipseq.nf b/workflows/chipseq.nf index 06b95b37..ffe99518 100644 --- a/workflows/chipseq.nf +++ b/workflows/chipseq.nf @@ -543,6 +543,7 @@ workflow CHIPSEQ { // Consensus peaks analysis // ch_macs2_consensus_bed_lib = Channel.empty() + ch_macs2_consensus_txt_lib = Channel.empty() ch_deseq2_pca_multiqc = Channel.empty() ch_deseq2_clustering_multiqc = Channel.empty() if (!params.skip_consensus_peaks) { @@ -579,6 +580,7 @@ workflow CHIPSEQ { ch_antibody_peaks ) ch_macs2_consensus_bed_lib = MACS2_CONSENSUS.out.bed + ch_macs2_consensus_txt_lib = MACS2_CONSENSUS.out.txt ch_versions = ch_versions.mix(MACS2_CONSENSUS.out.versions) if (!params.skip_peak_annotation) { @@ -653,26 +655,13 @@ workflow CHIPSEQ { // if (!params.skip_igv) { IGV ( + params.aligner, + params.narrow_peak ? 'narrowPeak' : 'broadPeak', PREPARE_GENOME.out.fasta, UCSC_BEDGRAPHTOBIGWIG.out.bigwig.collect{it[1]}.ifEmpty([]), ch_macs2_peaks.collect{it[1]}.ifEmpty([]), ch_macs2_consensus_bed_lib.collect{it[1]}.ifEmpty([]), - { "${params.aligner}/mergedLibrary/bigwig" }, - { - [ - "${params.aligner}/mergedLibrary/macs2", - params.narrow_peak ? '/narrowPeak' : '/broadPeak' - ] - .join('') - }, - { - [ - "${params.aligner}/mergedLibrary/macs2", - params.narrow_peak ? '/narrowPeak' : '/broadPeak', - '/consensus' - ] - .join('') - } + ch_macs2_consensus_txt_lib.collect{it[1]}.ifEmpty([]) ) ch_versions = ch_versions.mix(IGV.out.versions) }