ChIP-seq peak-calling, QC and differential analysis pipeline.

public public 1yr ago Version: 2.0.0 0 bookmarks

Introduction

nfcore/chipseq is a bioinformatics analysis pipeline used for Chromatin ImmunopreciPitation sequencing (ChIP-seq) data.

On release, automated continuous integration tests run the pipeline on a full-sized dataset on the AWS cloud infrastructure. The dataset consists of FoxA1 (transcription factor) and EZH2 (histone,mark) IP experiments from Franco et al. 2015 ( GEO: GSE59530 , PMID: 25752574 ) and Popovic et al. 2014 ( GEO: GSE57632 , PMID: 25188243 ), respectively. This ensures that the pipeline runs on AWS, has sensible resource allocation defaults set to run on real-world datasets, and permits the persistent storage of results to benchmark between pipeline releases and other analysis sources. The results obtained from running the full-sized tests can be viewed on the nf-core website .

The pipeline is built using Nextflow , a workflow tool to run tasks across multiple compute infrastructures in a very portable manner. It uses Docker/Singularity containers making installation trivial and results highly reproducible. The Nextflow DSL2 implementation of this pipeline uses one container per process which makes it much easier to maintain and update software dependencies. Where possible, these processes have been submitted to and installed from nf-core/modules in order to make them available to all nf-core pipelines, and to everyone within the Nextflow community!

Online videos

A short talk about the history, current status and functionality on offer in this pipeline was given by Jose Espinosa-Carrasco ( @joseespinosa ) on 26th July 2022 as part of the nf-core/bytesize series.

You can find numerous talks on the nf-core events page from various topics including writing pipelines/modules in Nextflow DSL2, using nf-core tooling, running nf-core pipelines as well as more generic content like contributing to Github. Please check them out!

Pipeline summary

  1. Raw read QC ( FastQC )

  2. Adapter trimming ( Trim Galore! )

  3. Choice of multiple aligners 1.( BWA ) 2.( Chromap ). For paired-end reads only working until mapping steps, see here 3.( Bowtie2 ) 4.( STAR )

  4. Mark duplicates ( picard )

  5. Merge alignments from multiple libraries of the same sample ( picard )

    1. Re-mark duplicates ( picard )

    2. Filtering to remove:

      • reads mapping to blacklisted regions ( SAMtools , BEDTools )

      • reads that are marked as duplicates ( SAMtools )

      • reads that are not marked as primary alignments ( SAMtools )

      • reads that are unmapped ( SAMtools )

      • reads that map to multiple locations ( SAMtools )

      • reads containing > 4 mismatches ( BAMTools )

      • reads that have an insert size > 2kb ( BAMTools ; paired-end only )

      • reads that map to different chromosomes ( Pysam ; paired-end only )

      • reads that arent in FR orientation ( Pysam ; paired-end only )

      • reads where only one read of the pair fails the above criteria ( Pysam ; paired-end only )

    3. Alignment-level QC and estimation of library complexity ( picard , Preseq )

    4. Create normalised bigWig files scaled to 1 million mapped reads ( BEDTools , bedGraphToBigWig )

    5. Generate gene-body meta-profile from bigWig files ( deepTools )

    6. Calculate genome-wide IP enrichment relative to control ( deepTools )

    7. Calculate strand cross-correlation peak and ChIP-seq quality measures including NSC and RSC ( phantompeakqualtools )

    8. Call broad/narrow peaks ( MACS2 )

    9. Annotate peaks relative to gene features ( HOMER )

    10. Create consensus peakset across all samples and create tabular file to aid in the filtering of the data ( BEDTools )

    11. Count reads in consensus peaks ( featureCounts )

    12. PCA and clustering ( R , DESeq2 )

  6. Create IGV session file containing bigWig tracks, peaks and differential sites for data visualisation ( IGV ).

  7. Present QC for raw read, alignment, peak-calling and differential binding results ( MultiQC , R )

Quick Start

  1. Install Nextflow ( >=21.10.3 )

  2. Install any of Docker , Singularity (you can follow this tutorial ), Podman , Shifter or Charliecloud for full pipeline reproducibility (you can use Conda both to install Nextflow itself and also to manage software within pipelines. Please only use it within pipelines as a last resort; see docs ) .

  3. Download the pipeline and test it on a minimal dataset with a single command:

    nextflow run nf-core/chipseq -profile test,YOURPROFILE --outdir <OUTDIR>
    

    Note that some form of configuration will be needed so that Nextflow knows how to fetch the required software. This is usually done in the form of a config profile ( YOURPROFILE in the example command above). You can chain multiple config profiles in a comma-separated string.

    • The pipeline comes with config profiles called docker , singularity , podman , shifter , charliecloud and conda which instruct the pipeline to use the named tool for software management. For example, -profile test,docker .

    • Please check nf-core/configs to see if a custom config file to run nf-core pipelines already exists for your Institute. If so, you can simply use -profile <institute> in your command. This will enable either docker or singularity and set the appropriate execution settings for your local compute environment.

    • If you are using singularity , please use the nf-core download command to download images first, before running the pipeline. Setting the NXF_SINGULARITY_CACHEDIR or singularity.cacheDir Nextflow options enables you to store and re-use the images from a central location for future pipeline runs.

    • If you are using conda , it is highly recommended to use the NXF_CONDA_CACHEDIR or conda.cacheDir settings to store the environments in a central location for future pipeline runs.

  4. Start running your own analysis!

    nextflow run nf-core/chipseq --input samplesheet.csv --outdir <OUTDIR> --genome GRCh37 -profile <docker/singularity/podman/shifter/charliecloud/conda/institute>
    

    See usage docs for all of the available options when running the pipeline.

Documentation

The nf-core/chipseq pipeline comes with documentation about the pipeline: usage and output .

Credits

These scripts were originally written by Chuan Wang ( @chuan-wang ) and Phil Ewels ( @ewels ) for use at the National Genomics Infrastructure at SciLifeLab in Stockholm, Sweden. The pipeline was re-implemented by Harshil Patel ( @drpatelh ) from Seqera Labs, Spain and converted to Nextflow DSL2 by Jose Espinosa-Carrasco ( @JoseEspinosa ) from The Comparative Bioinformatics Group at The Centre for Genomic Regulation, Spain .

Many thanks to others who have helped out and contributed along the way too, including (but not limited to): @apeltzer , @bc2zb , @crickbabs , @drejom , @houghtos , @KevinMenden , @mashehu , @pditommaso , @Rotholandus , @sofiahaglund , @tiagochst and @winni2k .

Contributions and Support

If you would like to contribute to this pipeline, please see the contributing guidelines .

For further information or help, don't hesitate to get in touch on the Slack #chipseq channel (you can join with this invite ).

Citations

If you use nf-core/chipseq for your analysis, please cite it using the following doi: 10.5281/zenodo.3240506

An extensive list of references for the tools used by the pipeline can be found in the CITATIONS.md file.

You can cite the nf-core publication as follows:

The nf-core framework for community-curated bioinformatics pipelines.

Philip Ewels, Alexander Peltzer, Sven Fillinger, Harshil Patel, Johannes Alneberg, Andreas Wilm, Maxime Ulysse Garcia, Paolo Di Tommaso & Sven Nahnsen.

Nat Biotechnol. 2020 Feb 13. doi: 10.1038/s41587-020-0439-x .

Code Snippets

19
20
21
22
23
24
25
26
27
"""
cut -f2- ${homer_peaks} | awk 'NR==1; NR > 1 {print \$0 | "sort -T '.' -k1,1 -k2,2n"}' | cut -f6- > tmp.txt
paste $boolean_txt tmp.txt > ${prefix}.boolean.annotatePeaks.txt

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    sed: \$(echo \$(sed --version 2>&1) | sed 's/^.*GNU sed) //; s/ .*\$//')
END_VERSIONS
"""
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
"""
samtools view \\
    $filter_params \\
    $dup_params \\
    $multimap_params \\
    $blacklist_params \\
    -b $bam \\
    | bamtools filter \\
        -out ${prefix}.bam \\
        -script $config

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    samtools: \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//')
    bamtools: \$(echo \$(bamtools --version 2>&1) | sed 's/^.*bamtools //; s/Part .*\$//')
END_VERSIONS
"""
24
25
26
27
28
29
30
31
32
"""
samtools sort -n -@ $task.cpus -o ${prefix}.name.sorted.bam -T ${prefix}.name.sorted $bam
bampe_rm_orphan.py ${prefix}.name.sorted.bam ${prefix}.bam $args

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    samtools: \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//')
END_VERSIONS
"""
34
35
36
37
38
39
40
41
"""
ln -s $bam ${prefix}.bam

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    samtools: \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//')
END_VERSIONS
"""
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
"""
SCALE_FACTOR=\$(grep '[0-9] mapped (' $flagstat | awk '{print 1000000/\$1}')
echo \$SCALE_FACTOR > ${prefix}.scale_factor.txt

bedtools \\
    genomecov \\
    -ibam $bam \\
    -bg \\
    -scale \$SCALE_FACTOR \\
    $pe \\
    $extend \\
    | sort -T '.' -k1,1 -k2,2n > ${prefix}.bedGraph

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    bedtools: \$(bedtools --version | sed -e "s/bedtools v//g")
END_VERSIONS
"""
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
"""
deseq2_qc.r \\
    --count_file $counts \\
    --outdir ./ \\
    --outprefix $prefix \\
    --cores $task.cpus \\
    $args

sed 's/deseq2_pca/deseq2_pca_${task.index}/g' <$deseq2_pca_header >tmp.txt
sed -i -e 's/DESeq2 /${meta.id} DESeq2 /g' tmp.txt
cat tmp.txt ${prefix}.pca.vals.txt > ${prefix}.pca.vals_mqc.tsv

sed 's/deseq2_clustering/deseq2_clustering_${task.index}/g' <$deseq2_clustering_header >tmp.txt
sed -i -e 's/DESeq2 /${meta.id} DESeq2 /g' tmp.txt
cat tmp.txt ${prefix}.sample.dists.txt > ${prefix}.sample.dists_mqc.tsv

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    r-base: \$(echo \$(R --version 2>&1) | sed 's/^.*R version //; s/ .*\$//')
    bioconductor-deseq2: \$(Rscript -e "library(DESeq2); cat(as.character(packageVersion('DESeq2')))")
END_VERSIONS
"""
20
21
22
23
24
25
26
27
28
29
30
"""
READS_IN_PEAKS=\$(intersectBed -a $bam -b $peak $args | awk -F '\t' '{sum += \$NF} END {print sum}')
samtools flagstat $bam > ${bam}.flagstat
grep 'mapped (' ${bam}.flagstat | grep -v "primary" | awk -v a="\$READS_IN_PEAKS" -v OFS='\t' '{print "${prefix}", a/\$1}' > ${prefix}.FRiP.txt

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    bedtools: \$(bedtools --version | sed -e "s/bedtools v//g")
    samtools: \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//')
END_VERSIONS
"""
23
24
25
26
27
28
29
30
"""
sortBed -i $blacklist -g $sizes | complementBed -i stdin -g $sizes > $file_out

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    bedtools: \$(bedtools --version | sed -e "s/bedtools v//g")
END_VERSIONS
"""
32
33
34
35
36
37
38
39
"""
awk '{print \$1, '0' , \$2}' OFS='\t' $sizes > $file_out

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    bedtools: \$(bedtools --version | sed -e "s/bedtools v//g")
END_VERSIONS
"""
18
19
20
21
22
23
24
25
26
27
"""
gtf2bed \\
    $gtf \\
    > ${gtf.baseName}.bed

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    perl: \$(echo \$(perl --version 2>&1) | sed 's/.*v\\(.*\\)) built.*/\\1/')
END_VERSIONS
"""
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
"""
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_dir" || test \$? = 1; } > consensus.igv.txt

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}":
    python: \$(python --version | sed 's/Python //g')
END_VERSIONS
"""
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
"""
sort -T '.' -k1,1 -k2,2n ${peaks.collect{it.toString()}.sort().join(' ')} \\
    | mergeBed -c $mergecols -o $collapsecols > ${prefix}.txt

macs2_merged_expand.py \\
    ${prefix}.txt \\
    ${peaks.collect{it.toString()}.sort().join(',').replaceAll("_peaks.${peak_type}","")} \\
    ${prefix}.boolean.txt \\
    --min_replicates $params.min_reps_consensus \\
    $expandparam

awk -v FS='\t' -v OFS='\t' 'FNR > 1 { print \$1, \$2, \$3, \$4, "0", "+" }' ${prefix}.boolean.txt > ${prefix}.bed

echo -e "GeneID\tChr\tStart\tEnd\tStrand" > ${prefix}.saf
awk -v FS='\t' -v OFS='\t' 'FNR > 1 { print \$4, \$1, \$2, \$3,  "+" }' ${prefix}.boolean.txt >> ${prefix}.saf

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')
    r-base: \$(echo \$(R --version 2>&1) | sed 's/^.*R version //; s/ .*\$//')
END_VERSIONS
"""
19
20
21
22
23
24
25
26
27
"""
cat $peak | wc -l | awk -v OFS='\t' '{ print "${prefix}", \$1 }' | cat $peak_count_header - > ${prefix}.peak_count_mqc.tsv
cat $frip_score_header $frip > ${prefix}.FRiP_mqc.tsv

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    sed: \$(echo \$(sed --version 2>&1) | sed 's/^.*GNU sed) //; s/ .*\$//')
END_VERSIONS
"""
21
22
23
24
25
26
27
28
29
30
31
32
"""
cp $correlation_header ${prefix}.spp_correlation_mqc.tsv
Rscript --max-ppsize=500000 -e "load('$rdata'); write.table(crosscorr\\\$cross.correlation, file=\\"${prefix}.spp_correlation_mqc.tsv\\", sep=",", quote=FALSE, row.names=FALSE, col.names=FALSE,append=TRUE)"

awk -v OFS='\t' '{print "${meta.id}", \$9}'  $spp | cat $nsc_header - > ${prefix}.spp_nsc_mqc.tsv
awk -v OFS='\t' '{print "${meta.id}", \$10}' $spp | cat $rsc_header - > ${prefix}.spp_rsc_mqc.tsv

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    r-base: \$(echo \$(R --version 2>&1) | sed 's/^.*R version //; s/ .*\$//')
END_VERSIONS
"""
60
61
62
63
64
65
66
67
68
69
70
71
"""
multiqc \\
    -f \\
    $args \\
    $custom_config \\
    .

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    multiqc: \$( multiqc --version | sed -e "s/multiqc, version //g" )
END_VERSIONS
"""
23
24
25
26
27
28
29
30
31
32
33
34
35
36
"""
plot_homer_annotatepeaks.r \\
    -i ${annos.join(',')} \\
    -s ${annos.join(',').replaceAll("${suffix}","")} \\
    -p $prefix \\
    $args

find ./ -type f -name "*summary.txt" -exec cat {} \\; | cat $mqc_header - > ${prefix}.summary_mqc.tsv

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    r-base: \$(echo \$(R --version 2>&1) | sed 's/^.*R version //; s/ .*\$//')
END_VERSIONS
"""
20
21
22
23
24
25
26
27
28
29
30
"""
plot_macs2_qc.r \\
    -i ${peaks.join(',')} \\
    -s ${peaks.join(',').replaceAll("_peaks.${peak_type}","")} \\
    $args

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    r-base: \$(echo \$(R --version 2>&1) | sed 's/^.*R version //; s/ .*\$//')
END_VERSIONS
"""
17
18
19
20
21
22
23
24
25
26
"""
check_samplesheet.py \\
    $samplesheet \\
    samplesheet.valid.csv

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    python: \$(python --version | sed 's/Python //g')
END_VERSIONS
"""
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
"""
STAR \\
    --genomeDir $index \\
    --readFilesIn $reads  \\
    --runThreadN $task.cpus \\
    --outFileNamePrefix $prefix. \\
    $out_sam_type \\
    $seq_center \\
    $args
$mv_unsorted_bam
if [ -f ${prefix}.Unmapped.out.mate1 ]; then
    mv ${prefix}.Unmapped.out.mate1 ${prefix}.unmapped_1.fastq
    gzip ${prefix}.unmapped_1.fastq
fi
if [ -f ${prefix}.Unmapped.out.mate2 ]; then
    mv ${prefix}.Unmapped.out.mate2 ${prefix}.unmapped_2.fastq
    gzip ${prefix}.unmapped_2.fastq
fi
cat <<-END_VERSIONS > versions.yml
"${task.process}":
    star: \$(STAR --version | sed -e "s/STAR_//g")
END_VERSIONS
"""
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
"""
mkdir star
STAR \\
    --runMode genomeGenerate \\
    --genomeDir star/ \\
    --genomeFastaFiles $fasta \\
    --sjdbGTFfile $gtf \\
    --runThreadN $task.cpus \\
    $memory \\
    ${args.join(' ')}
cat <<-END_VERSIONS > versions.yml
"${task.process}":
    star: \$(STAR --version | sed -e "s/STAR_//g")
END_VERSIONS
"""
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
"""
samtools faidx $fasta
NUM_BASES=`gawk '{sum = sum + \$2}END{if ((log(sum)/log(2))/2 - 1 > 14) {printf "%.0f", 14} else {printf "%.0f", (log(sum)/log(2))/2 - 1}}' ${fasta}.fai`
mkdir star
STAR \\
    --runMode genomeGenerate \\
    --genomeDir star/ \\
    --genomeFastaFiles $fasta \\
    --sjdbGTFfile $gtf \\
    --runThreadN $task.cpus \\
    --genomeSAindexNbases \$NUM_BASES \\
    $memory \\
    ${args.join(' ')}
cat <<-END_VERSIONS > versions.yml
"${task.process}":
    star: \$(STAR --version | sed -e "s/STAR_//g")
END_VERSIONS
"""
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
"""
INDEX=`find -L ./ -name "*.rev.1.bt2" | sed "s/.rev.1.bt2//"`
[ -z "\$INDEX" ] && INDEX=`find -L ./ -name "*.rev.1.bt2l" | sed "s/.rev.1.bt2l//"`
[ -z "\$INDEX" ] && echo "Bowtie2 index files not found" 1>&2 && exit 1

bowtie2 \\
    -x \$INDEX \\
    $reads_args \\
    --threads $task.cpus \\
    $unaligned \\
    $args \\
    2> ${prefix}.bowtie2.log \\
    | samtools $samtools_command $args2 --threads $task.cpus -o ${prefix}.bam -

if [ -f ${prefix}.unmapped.fastq.1.gz ]; then
    mv ${prefix}.unmapped.fastq.1.gz ${prefix}.unmapped_1.fastq.gz
fi

if [ -f ${prefix}.unmapped.fastq.2.gz ]; then
    mv ${prefix}.unmapped.fastq.2.gz ${prefix}.unmapped_2.fastq.gz
fi

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    bowtie2: \$(echo \$(bowtie2 --version 2>&1) | sed 's/^.*bowtie2-align-s version //; s/ .*\$//')
    samtools: \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//')
    pigz: \$( pigz --version 2>&1 | sed 's/pigz //g' )
END_VERSIONS
"""
22
23
24
25
26
27
28
29
"""
mkdir bowtie2
bowtie2-build $args --threads $task.cpus $fasta bowtie2/${fasta.baseName}
cat <<-END_VERSIONS > versions.yml
"${task.process}":
    bowtie2: \$(echo \$(bowtie2 --version 2>&1) | sed 's/^.*bowtie2-align-s version //; s/ .*\$//')
END_VERSIONS
"""
22
23
24
25
26
27
28
29
30
31
32
33
34
"""
mkdir bwa
bwa \\
    index \\
    $args \\
    -p bwa/${fasta.baseName} \\
    $fasta

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    bwa: \$(echo \$(bwa 2>&1) | sed 's/^.*Version: //; s/Contact:.*\$//')
END_VERSIONS
"""
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
"""
INDEX=`find -L ./ -name "*.amb" | sed 's/.amb//'`

bwa mem \\
    $args \\
    -t $task.cpus \\
    \$INDEX \\
    $reads \\
    | samtools $samtools_command $args2 --threads $task.cpus -o ${prefix}.bam -

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    bwa: \$(echo \$(bwa 2>&1) | sed 's/^.*Version: //; s/Contact:.*\$//')
    samtools: \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//')
END_VERSIONS
"""
55
56
57
58
    """
}
if (meta.single_end) {
    """
NextFlow From line 55 of chromap/main.nf
74
75
76
    """
} else {
    """
NextFlow From line 74 of chromap/main.nf
93
"""
NextFlow From line 93 of chromap/main.nf
23
24
25
26
27
28
29
30
31
32
33
34
35
"""
chromap \\
    -i \\
    $args \\
    -t $task.cpus \\
    -r $fasta \\
    -o ${prefix}.index

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    chromap: \$(echo \$(chromap --version 2>&1))
END_VERSIONS
"""
23
24
25
26
27
28
29
30
31
"""
samtools faidx $fasta
cut -f 1,2 ${fasta}.fai > ${fasta}.sizes

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    custom: \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//')
END_VERSIONS
"""
25
26
27
28
29
30
31
32
33
34
35
36
37
38
"""
computeMatrix \\
    $args \\
    --regionsFileName $bed \\
    --scoreFileName $bigwig \\
    --outFileName ${prefix}.computeMatrix.mat.gz \\
    --outFileNameMatrix ${prefix}.computeMatrix.vals.mat.tab \\
    --numberOfProcessors $task.cpus

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    deeptools: \$(computeMatrix --version | sed -e "s/computeMatrix //g")
END_VERSIONS
"""
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
"""
plotFingerprint \\
    $args \\
    $extend \\
    --bamfiles ${bams.join(' ')} \\
    --plotFile ${prefix}.plotFingerprint.pdf \\
    --outRawCounts ${prefix}.plotFingerprint.raw.txt \\
    --outQualityMetrics ${prefix}.plotFingerprint.qcmetrics.txt \\
    --numberOfProcessors $task.cpus

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    deeptools: \$(plotFingerprint --version | sed -e "s/plotFingerprint //g")
END_VERSIONS
"""
24
25
26
27
28
29
30
31
32
33
34
35
"""
plotHeatmap \\
    $args \\
    --matrixFile $matrix \\
    --outFileName ${prefix}.plotHeatmap.pdf \\
    --outFileNameMatrix ${prefix}.plotHeatmap.mat.tab

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    deeptools: \$(plotHeatmap --version | sed -e "s/plotHeatmap //g")
END_VERSIONS
"""
24
25
26
27
28
29
30
31
32
33
34
35
"""
plotProfile \\
    $args \\
    --matrixFile $matrix \\
    --outFileName ${prefix}.plotProfile.pdf \\
    --outFileNameData ${prefix}.plotProfile.tab

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    deeptools: \$(plotProfile --version | sed -e "s/plotProfile //g")
END_VERSIONS
"""
26
27
28
29
30
31
32
33
34
"""
[ ! -f  ${prefix}.fastq.gz ] && ln -s $reads ${prefix}.fastq.gz
fastqc $args --threads $task.cpus ${prefix}.fastq.gz

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    fastqc: \$( fastqc --version | sed -e "s/FastQC v//g" )
END_VERSIONS
"""
36
37
38
39
40
41
42
43
44
45
"""
[ ! -f  ${prefix}_1.fastq.gz ] && ln -s ${reads[0]} ${prefix}_1.fastq.gz
[ ! -f  ${prefix}_2.fastq.gz ] && ln -s ${reads[1]} ${prefix}_2.fastq.gz
fastqc $args --threads $task.cpus ${prefix}_1.fastq.gz ${prefix}_2.fastq.gz

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    fastqc: \$( fastqc --version | sed -e "s/FastQC v//g" )
END_VERSIONS
"""
50
51
52
53
54
55
56
57
58
"""
touch ${prefix}.html
touch ${prefix}.zip

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    fastqc: \$( fastqc --version | sed -e "s/FastQC v//g" )
END_VERSIONS
"""
23
24
25
26
27
28
29
30
31
32
"""
gffread \\
    $gff \\
    $args \\
    -o ${prefix}.gtf
cat <<-END_VERSIONS > versions.yml
"${task.process}":
    gffread: \$(gffread --version 2>&1)
END_VERSIONS
"""
23
24
25
26
27
28
29
30
31
32
33
"""
gunzip \\
    -f \\
    $args \\
    $archive

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    gunzip: \$(echo \$(gunzip --version 2>&1) | sed 's/^.*(gzip) //; s/ Copyright.*\$//')
END_VERSIONS
"""
NextFlow From line 23 of gunzip/main.nf
37
38
39
40
41
42
43
"""
touch $gunzip
cat <<-END_VERSIONS > versions.yml
"${task.process}":
    gunzip: \$(echo \$(gunzip --version 2>&1) | sed 's/^.*(gzip) //; s/ Copyright.*\$//')
END_VERSIONS
"""
NextFlow From line 37 of gunzip/main.nf
27
28
29
30
31
32
33
34
35
36
37
38
39
40
"""
annotatePeaks.pl \\
    $peak \\
    $fasta \\
    $args \\
    -gtf $gtf \\
    -cpu $task.cpus \\
    > ${prefix}.annotatePeaks.txt

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    homer: $VERSION
END_VERSIONS
"""
24
25
26
27
28
29
30
31
32
33
34
35
36
37
"""
unique-kmers.py \\
    -k $kmer_size \\
    -R report.txt \\
    $args \\
    $fasta

grep ^number report.txt | sed 's/^.*:.[[:blank:]]//g' > kmers.txt

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    khmer: \$( unique-kmers.py --version 2>&1 | grep ^khmer | sed 's/^khmer //;s/ .*\$//' )
END_VERSIONS
"""
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
"""
macs2 \\
    callpeak \\
    ${args_list.join(' ')} \\
    --gsize $macs2_gsize \\
    --format $format \\
    --name $prefix \\
    --treatment $ipbam \\
    $control

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    macs2: \$(macs2 --version | sed -e "s/macs2 //g")
END_VERSIONS
"""
28
29
30
31
32
33
34
35
36
"""
RUN_SPP=`which run_spp.R`
Rscript $args -e "library(caTools); source(\\"\$RUN_SPP\\")" -c="$bam" -savp="${prefix}.spp.pdf" -savd="${prefix}.spp.Rdata" -out="${prefix}.spp.out" $args2

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    phantompeakqualtools: $VERSION
END_VERSIONS
"""
33
34
35
36
37
38
39
40
41
42
43
44
45
46
"""
picard \\
    -Xmx${avail_mem}g \\
    CollectMultipleMetrics \\
    $args \\
    --INPUT $bam \\
    --OUTPUT ${prefix}.CollectMultipleMetrics \\
    $reference

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    picard: \$(picard CollectMultipleMetrics --version 2>&1 | grep -o 'Version.*' | cut -f2- -d:)
END_VERSIONS
"""
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
"""
touch ${prefix}.CollectMultipleMetrics.alignment_summary_metrics
touch ${prefix}.CollectMultipleMetrics.insert_size_metrics
touch ${prefix}.CollectMultipleMetrics.quality_distribution.pdf
touch ${prefix}.CollectMultipleMetrics.base_distribution_by_cycle_metrics
touch ${prefix}.CollectMultipleMetrics.quality_by_cycle_metrics
touch ${prefix}.CollectMultipleMetrics.read_length_histogram.pdf
touch ${prefix}.CollectMultipleMetrics.base_distribution_by_cycle.pdf
touch ${prefix}.CollectMultipleMetrics.quality_by_cycle.pdf
touch ${prefix}.CollectMultipleMetrics.insert_size_histogram.pdf
touch ${prefix}.CollectMultipleMetrics.quality_distribution_metrics

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    picard: \$(echo \$(picard CollectMultipleMetrics --version 2>&1) | grep -o 'Version:.*' | cut -f2- -d:)
END_VERSIONS
"""
31
32
33
34
35
36
37
38
39
40
41
42
43
44
"""
picard \\
    -Xmx${avail_mem}g \\
    MarkDuplicates \\
    $args \\
    --INPUT $bam \\
    --OUTPUT ${prefix}.bam \\
    --METRICS_FILE ${prefix}.MarkDuplicates.metrics.txt

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    picard: \$(echo \$(picard MarkDuplicates --version 2>&1) | grep -o 'Version:.*' | cut -f2- -d:)
END_VERSIONS
"""
48
49
50
51
52
53
54
55
56
57
"""
touch ${prefix}.bam
touch ${prefix}.bam.bai
touch ${prefix}.MarkDuplicates.metrics.txt

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    picard: \$(echo \$(picard MarkDuplicates --version 2>&1) | grep -o 'Version:.*' | cut -f2- -d:)
END_VERSIONS
"""
31
32
33
34
35
36
37
38
39
40
41
42
"""
picard \\
    -Xmx${avail_mem}g \\
    MergeSamFiles \\
    $args \\
    ${'--INPUT '+bam_files.join(' --INPUT ')} \\
    --OUTPUT ${prefix}.bam
cat <<-END_VERSIONS > versions.yml
"${task.process}":
    picard: \$( echo \$(picard MergeSamFiles --version 2>&1) | grep -o 'Version:.*' | cut -f2- -d:)
END_VERSIONS
"""
44
45
46
47
48
49
50
"""
ln -s ${bam_files[0]} ${prefix}.bam
cat <<-END_VERSIONS > versions.yml
"${task.process}":
    picard: \$( echo \$(picard MergeSamFiles --version 2>&1) | grep -o 'Version:.*' | cut -f2- -d:)
END_VERSIONS
"""
26
27
28
29
30
31
32
33
34
35
36
37
38
39
"""
preseq \\
    lc_extrap \\
    $args \\
    $paired_end \\
    -output ${prefix}.lc_extrap.txt \\
    $bam
cp .command.err ${prefix}.command.log

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    preseq: \$(echo \$(preseq 2>&1) | sed 's/^.*Version: //; s/Usage:.*\$//')
END_VERSIONS
"""
23
24
25
26
27
28
29
30
31
32
33
34
"""
samtools \\
    flagstat \\
    --threads ${task.cpus-1} \\
    $bam \\
    > ${prefix}.flagstat

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    samtools: \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//')
END_VERSIONS
"""
24
25
26
27
28
29
30
31
32
33
34
"""
samtools \\
    idxstats \\
    $bam \\
    > ${prefix}.idxstats

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    samtools: \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//')
END_VERSIONS
"""
24
25
26
27
28
29
30
31
32
33
34
35
"""
samtools \\
    index \\
    -@ ${task.cpus-1} \\
    $args \\
    $input

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    samtools: \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//')
END_VERSIONS
"""
38
39
40
41
42
43
44
45
46
47
"""
touch ${input}.bai
touch ${input}.crai
touch ${input}.csi

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    samtools: \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//')
END_VERSIONS
"""
NextFlow From line 38 of index/main.nf
24
25
26
27
28
29
30
"""
samtools sort $args -@ $task.cpus -o ${prefix}.bam -T $prefix $bam
cat <<-END_VERSIONS > versions.yml
"${task.process}":
    samtools: \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//')
END_VERSIONS
"""
34
35
36
37
38
39
40
41
"""
touch ${prefix}.bam

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    samtools: \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//')
END_VERSIONS
"""
NextFlow From line 34 of sort/main.nf
25
26
27
28
29
30
31
32
33
34
35
36
37
"""
samtools \\
    stats \\
    --threads ${task.cpus-1} \\
    ${reference} \\
    ${input} \\
    > ${prefix}.stats

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    samtools: \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//')
END_VERSIONS
"""
41
42
43
44
45
46
47
48
"""
touch ${prefix}.stats

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    samtools: \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//')
END_VERSIONS
"""
NextFlow From line 41 of stats/main.nf
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
"""
featureCounts \\
    $args \\
    $paired_end \\
    -T $task.cpus \\
    -a $annotation \\
    -s $strandedness \\
    -o ${prefix}.featureCounts.txt \\
    ${bams.join(' ')}

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    subread: \$( echo \$(featureCounts -v 2>&1) | sed -e "s/featureCounts v//g")
END_VERSIONS
"""
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
"""
[ ! -f  ${prefix}.fastq.gz ] && ln -s $reads ${prefix}.fastq.gz
trim_galore \\
    $args \\
    --cores $cores \\
    --gzip \\
    $c_r1 \\
    $tpc_r1 \\
    ${prefix}.fastq.gz

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    trimgalore: \$(echo \$(trim_galore --version 2>&1) | sed 's/^.*version //; s/Last.*\$//')
    cutadapt: \$(cutadapt --version)
END_VERSIONS
"""
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
"""
[ ! -f  ${prefix}_1.fastq.gz ] && ln -s ${reads[0]} ${prefix}_1.fastq.gz
[ ! -f  ${prefix}_2.fastq.gz ] && ln -s ${reads[1]} ${prefix}_2.fastq.gz
trim_galore \\
    $args \\
    --cores $cores \\
    --paired \\
    --gzip \\
    $c_r1 \\
    $c_r2 \\
    $tpc_r1 \\
    $tpc_r2 \\
    ${prefix}_1.fastq.gz \\
    ${prefix}_2.fastq.gz

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    trimgalore: \$(echo \$(trim_galore --version 2>&1) | sed 's/^.*version //; s/Last.*\$//')
    cutadapt: \$(cutadapt --version)
END_VERSIONS
"""
26
27
28
29
30
31
32
33
34
35
36
"""
bedGraphToBigWig \\
    $bedgraph \\
    $sizes \\
    ${prefix}.bigWig

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    ucsc: $VERSION
END_VERSIONS
"""
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
"""
mkdir output

tar \\
    -C output --strip-components 1 \\
    -xzvf \\
    $args \\
    $archive \\
    $args2

mv output ${untar}

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    untar: \$(echo \$(tar --version 2>&1) | sed 's/^.*(GNU tar) //; s/ Copyright.*\$//')
END_VERSIONS
"""
NextFlow From line 25 of untar/main.nf
45
46
47
48
49
50
51
52
"""
touch $untar

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    untar: \$(echo \$(tar --version 2>&1) | sed 's/^.*(GNU tar) //; s/ Copyright.*\$//')
END_VERSIONS
"""
NextFlow From line 45 of untar/main.nf
ShowHide 44 more snippets with no or duplicated tags.

Login to post a comment if you would like to share your experience with this workflow.

Do you know this workflow well? If so, you can request seller status , and start supporting this workflow.

Free

Created: 1yr ago
Updated: 1yr ago
Maitainers: public
URL: https://nf-co.re/chipseq
Name: chipseq
Version: 2.0.0
Badge:
workflow icon

Insert copied code into your website to add a link to this workflow.

Downloaded: 0
Copyright: Public Domain
License: None
  • Future updates

Related Workflows

cellranger-snakemake-gke
snakemake workflow to run cellranger on a given bucket using gke.
A Snakemake workflow for running cellranger on a given bucket using Google Kubernetes Engine. The usage of this workflow ...