Skip to content

Commit 7ed79d4

Browse files
authored
Merge pull request #308 from drpatelh/updates
Add antibody directory to consensus peaks in IGV session
2 parents 59d32c8 + ed10bb9 commit 7ed79d4

File tree

6 files changed

+61
-34
lines changed

6 files changed

+61
-34
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
44
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
55

6-
## [[2.0.0](https://github.com/nf-core/chipseq/releases/tag/2.0.0)] - 2022-09-30
6+
## [[2.0.0](https://github.com/nf-core/chipseq/releases/tag/2.0.0)] - 2022-10-03
77

88
### Enhancements & fixes
99

bin/igv_files_to_session.py

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,16 @@
2424
## REQUIRED PARAMETERS
2525
argParser.add_argument("XML_OUT", help="XML output file.")
2626
argParser.add_argument(
27-
"LIST_FILE", help="Tab-delimited file containing two columns i.e. file_name\tcolour. Header isnt required."
27+
"LIST_FILE",
28+
help="Tab-delimited file containing two columns i.e. file_name\tcolour. Header isnt required.",
2829
)
2930
argParser.add_argument(
30-
"GENOME", help="Full path to genome fasta file or shorthand for genome available in IGV e.g. hg19."
31+
"REPLACE_FILE",
32+
help="Tab-delimited file containing two columns i.e. file_name\treplacement_file_name. Header isnt required.",
33+
)
34+
argParser.add_argument(
35+
"GENOME",
36+
help="Full path to genome fasta file or shorthand for genome available in IGV e.g. hg19.",
3137
)
3238

3339
## OPTIONAL PARAMETERS
@@ -65,10 +71,20 @@ def makedir(path):
6571
############################################
6672

6773

68-
def igv_files_to_session(XMLOut, ListFile, Genome, PathPrefix=""):
74+
def igv_files_to_session(XMLOut, ListFile, ReplaceFile, Genome, PathPrefix=""):
6975

7076
makedir(os.path.dirname(XMLOut))
7177

78+
replaceFileDict = {}
79+
fin = open(ReplaceFile, "r")
80+
while True:
81+
line = fin.readline()
82+
if line:
83+
ofile, rfile = line.strip().split("\t")
84+
replaceFileDict[ofile] = rfile
85+
else:
86+
break
87+
fin.close()
7288
fileList = []
7389
fin = open(ListFile, "r")
7490
while True:
@@ -77,10 +93,17 @@ def igv_files_to_session(XMLOut, ListFile, Genome, PathPrefix=""):
7793
ifile, colour = line.strip().split("\t")
7894
if len(colour.strip()) == 0:
7995
colour = "0,0,178"
96+
for ofile, rfile in replaceFileDict.items():
97+
if ofile in ifile:
98+
ifile = ifile.replace(ofile, rfile)
8099
fileList.append((PathPrefix.strip() + ifile, colour))
81100
else:
82101
break
83-
fout.close()
102+
fin.close()
103+
fout = open("igv_files.txt", "w")
104+
for ifile, colour in fileList:
105+
fout.write(ifile + "\n")
106+
fout.close()
84107

85108
## ADD RESOURCES SECTION
86109
XMLStr = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n'
@@ -138,7 +161,6 @@ def igv_files_to_session(XMLOut, ListFile, Genome, PathPrefix=""):
138161
'id="%s" name="%s" renderer="BASIC_FEATURE" sortable="false" visible="true" windowFunction="count"/>\n'
139162
% (ifile, os.path.basename(ifile))
140163
)
141-
142164
XMLStr += "\t</Panel>\n"
143165
# XMLStr += '\t<HiddenAttributes>\n\t\t<Attribute name="DATA FILE"/>\n\t\t<Attribute name="DATA TYPE"/>\n\t\t<Attribute name="NAME"/>\n\t</HiddenAttributes>\n'
144166
XMLStr += "</Session>"
@@ -153,7 +175,13 @@ def igv_files_to_session(XMLOut, ListFile, Genome, PathPrefix=""):
153175
############################################
154176
############################################
155177

156-
igv_files_to_session(XMLOut=args.XML_OUT, ListFile=args.LIST_FILE, Genome=args.GENOME, PathPrefix=args.PATH_PREFIX)
178+
igv_files_to_session(
179+
XMLOut=args.XML_OUT,
180+
ListFile=args.LIST_FILE,
181+
ReplaceFile=args.REPLACE_FILE,
182+
Genome=args.GENOME,
183+
PathPrefix=args.PATH_PREFIX,
184+
)
157185

158186
############################################
159187
############################################

modules/local/deseq2_qc.nf

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ process DESEQ2_QC {
22
tag "$meta.id"
33
label 'process_medium'
44

5-
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)
5+
// (Bio)conda packages have intentionally not been pinned to a specific version
6+
// This was to avoid the pipeline failing due to package conflicts whilst creating the environment when using -profile conda
7+
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)
68
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
79
'https://depot.galaxyproject.org/singularity/mulled-v2-8849acf39a43cdd6c839a369a74c0adc823e2f91:ab110436faf952a33575c64dd74615a84011450b-0' :
810
'quay.io/biocontainers/mulled-v2-8849acf39a43cdd6c839a369a74c0adc823e2f91:ab110436faf952a33575c64dd74615a84011450b-0' }"

modules/local/igv.nf

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,34 @@ process IGV {
99
'quay.io/biocontainers/python:3.8.3' }"
1010

1111
input:
12+
val aligner_dir
13+
val peak_dir
1214
path fasta
13-
path ("${bigwig_publish_dir}/*")
14-
path ("${peak_publish_dir}/*")
15-
path ("${consensus_publish_dir}/*")
16-
val bigwig_publish_dir
17-
val peak_publish_dir
18-
val consensus_publish_dir
15+
path ("${aligner_dir}/mergedLibrary/bigwig/*")
16+
path ("${aligner_dir}/mergedLibrary/macs2/${peak_dir}/*")
17+
path ("${aligner_dir}/mergedLibrary/macs2/${peak_dir}/consensus/*")
18+
path ("mappings/*")
1919

2020
output:
2121
path "*files.txt" , emit: txt
2222
path "*.xml" , emit: xml
2323
path "versions.yml", emit: versions
2424

2525
script: // scripts are bundled with the pipeline in nf-core/chipseq/bin/
26+
def consensus_dir = "${aligner_dir}/mergedLibrary/macs2/${peak_dir}/consensus/*"
2627
"""
2728
find * -type l -name "*.bigWig" -exec echo -e ""{}"\\t0,0,178" \\; > bigwig.igv.txt
2829
find * -type l -name "*Peak" -exec echo -e ""{}"\\t0,0,178" \\; > peaks.igv.txt
2930
# Avoid error when consensus not produced
30-
find * -type l -name "*.bed" -exec echo -e ""{}"\\t0,0,178" \\; | { grep "^$consensus_publish_dir" || test \$? = 1; } > bed.igv.txt
31+
find * -type l -name "*.bed" -exec echo -e ""{}"\\t0,0,178" \\; | { grep "^$consensus_dir" || test \$? = 1; } > consensus.igv.txt
3132
32-
cat *.txt > igv_files.txt
33-
igv_files_to_session.py igv_session.xml igv_files.txt ../../genome/${fasta.getName()} --path_prefix '../../'
33+
touch replace_paths.txt
34+
if [ -d "mappings" ]; then
35+
cat mappings/* > replace_paths.txt
36+
fi
37+
38+
cat *.igv.txt > igv_files_orig.txt
39+
igv_files_to_session.py igv_session.xml igv_files_orig.txt replace_paths.txt ../../genome/${fasta.getName()} --path_prefix '../../'
3440
3541
cat <<-END_VERSIONS > versions.yml
3642
"${task.process}":

modules/local/macs2_consensus.nf

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ process MACS2_CONSENSUS {
1717
tuple val(meta), path("*.bed") , emit: bed
1818
tuple val(meta), path("*.saf") , emit: saf
1919
tuple val(meta), path("*.pdf") , emit: pdf
20+
tuple val(meta), path("*.antibody.txt") , emit: txt
2021
tuple val(meta), path("*.boolean.txt") , emit: boolean_txt
2122
tuple val(meta), path("*.intersect.txt"), emit: intersect_txt
2223
path "versions.yml" , emit: versions
@@ -25,7 +26,6 @@ process MACS2_CONSENSUS {
2526
task.ext.when == null || task.ext.when
2627

2728
script: // This script is bundled with the pipeline, in nf-core/chipseq/bin/
28-
2929
def prefix = task.ext.prefix ?: "${meta.id}"
3030
def peak_type = params.narrow_peak ? 'narrowPeak' : 'broadPeak'
3131
def mergecols = params.narrow_peak ? (2..10).join(',') : (2..9).join(',')
@@ -49,6 +49,8 @@ process MACS2_CONSENSUS {
4949
5050
plot_peak_intersect.r -i ${prefix}.boolean.intersect.txt -o ${prefix}.boolean.intersect.plot.pdf
5151
52+
echo "${prefix}.bed\t${meta.id}/${prefix}.bed" > ${prefix}.antibody.txt
53+
5254
cat <<-END_VERSIONS > versions.yml
5355
"${task.process}":
5456
python: \$(python --version | sed 's/Python //g')

workflows/chipseq.nf

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,7 @@ workflow CHIPSEQ {
543543
// Consensus peaks analysis
544544
//
545545
ch_macs2_consensus_bed_lib = Channel.empty()
546+
ch_macs2_consensus_txt_lib = Channel.empty()
546547
ch_deseq2_pca_multiqc = Channel.empty()
547548
ch_deseq2_clustering_multiqc = Channel.empty()
548549
if (!params.skip_consensus_peaks) {
@@ -579,6 +580,7 @@ workflow CHIPSEQ {
579580
ch_antibody_peaks
580581
)
581582
ch_macs2_consensus_bed_lib = MACS2_CONSENSUS.out.bed
583+
ch_macs2_consensus_txt_lib = MACS2_CONSENSUS.out.txt
582584
ch_versions = ch_versions.mix(MACS2_CONSENSUS.out.versions)
583585

584586
if (!params.skip_peak_annotation) {
@@ -653,26 +655,13 @@ workflow CHIPSEQ {
653655
//
654656
if (!params.skip_igv) {
655657
IGV (
658+
params.aligner,
659+
params.narrow_peak ? 'narrowPeak' : 'broadPeak',
656660
PREPARE_GENOME.out.fasta,
657661
UCSC_BEDGRAPHTOBIGWIG.out.bigwig.collect{it[1]}.ifEmpty([]),
658662
ch_macs2_peaks.collect{it[1]}.ifEmpty([]),
659663
ch_macs2_consensus_bed_lib.collect{it[1]}.ifEmpty([]),
660-
{ "${params.aligner}/mergedLibrary/bigwig" },
661-
{
662-
[
663-
"${params.aligner}/mergedLibrary/macs2",
664-
params.narrow_peak ? '/narrowPeak' : '/broadPeak'
665-
]
666-
.join('')
667-
},
668-
{
669-
[
670-
"${params.aligner}/mergedLibrary/macs2",
671-
params.narrow_peak ? '/narrowPeak' : '/broadPeak',
672-
'/consensus'
673-
]
674-
.join('')
675-
}
664+
ch_macs2_consensus_txt_lib.collect{it[1]}.ifEmpty([])
676665
)
677666
ch_versions = ch_versions.mix(IGV.out.versions)
678667
}

0 commit comments

Comments
 (0)