Analysis of Chromosome Conformation Capture data (Hi-C)

public public 1yr ago Version: 2.1.0 0 bookmarks

Introduction

nf-core/hic is a bioinformatics best-practice analysis pipeline for Analysis of Chromosome Conformation Capture data (Hi-C).

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!

On release, automated continuous integration tests run the pipeline on a full-sized dataset on the AWS cloud infrastructure. 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 the full-sized test can be viewed on the nf-core website .

Pipeline summary

  1. Read QC ( FastQC )

  2. Hi-C data processing

    1. HiC-Pro

      1. Mapping using a two steps strategy to rescue reads spanning the ligation sites ( bowtie2 )

      2. Detection of valid interaction products

      3. Duplicates removal

      4. Generate raw and normalized contact maps ( iced )

  3. Create genome-wide contact maps at various resolutions ( cooler )

  4. Contact maps normalization using balancing algorithm ( cooler )

  5. Export to various contact maps formats ( HiC-Pro , cooler )

  6. Quality controls ( HiC-Pro , HiCExplorer )

  7. Compartments calling ( cooltools )

  8. TADs calling ( HiCExplorer , cooltools )

  9. Quality control report ( MultiQC )

Usage

Note If you are new to Nextflow and nf-core, please refer to this page on how to set-up Nextflow. Make sure to test your setup with -profile test before running the workflow on actual data.

First, prepare a samplesheet with your input data that looks as follows:

samplesheet.csv :

sample,fastq_1,fastq_2
HIC_ES_4,SRR5339783_1.fastq.gz,SRR5339783_2.fastq.gz

Each row represents a pair of fastq files (paired end). Now, you can run the pipeline using:

nextflow run nf-core/hic \
 -profile <docker/singularity/.../institute> \
 --input samplesheet.csv \
 --genome GRCh37 \
 --outdir <OUTDIR>

Warning: Please provide pipeline parameters via the CLI or Nextflow -params-file option. Custom config files including those provided by the -c Nextflow option can be used to provide any configuration except for parameters ; see docs .

For more details, please refer to the usage documentation and the parameter documentation .

Pipeline output

To see the the results of a test run with a full size dataset refer to the results tab on the nf-core website pipeline page. For more details about the output files and reports, please refer to the output documentation .

Credits

nf-core/hic was originally written by Nicolas Servant.

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 #hic channel (you can join with this invite ).

Citations

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

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

26
27
28
29
30
31
32
33
34
35
"""
cooltools genome binnify --all-names ${chrsize} ${resolution} > genome_bins.txt
cooltools genome gc genome_bins.txt ${fasta} > genome_gc.txt
cooltools eigs-cis ${args} -o ${prefix}_compartments ${cool}

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    cooltools: \$(cooltools --version 2>&1 | grep version | sed 's/cooltools, version //')
END_VERSIONS
"""
24
25
26
27
28
29
30
31
"""
cooltools insulation ${cool} ${args} > ${prefix}_insulation.tsv

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    cooltools: \$(cooltools --version 2>&1 | sed 's/cooltools, version //')
END_VERSIONS
"""
23
24
25
26
27
28
29
30
31
32
33
"""
hicFindTADs --matrix ${cool} \
    --outPrefix ${prefix}_hicfindtads \
    ${args} \
    --numberOfProcessors ${task.cpus}

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    hicexplorer: \$(hicFindTADs --version 2>&1 | sed 's/hicFindTADs //')
END_VERSIONS
"""
24
25
26
27
28
29
30
31
32
33
"""
hicPlotDistVsCounts --matrices ${cool} \
                    --plotFile ${prefix}_distcount.png \
                    --outFileData ${prefix}_distcount.txt

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    hicexplorer: \$(hicPlotDistVsCounts --version 2>&1 | sed 's/hicPlotDistVsCounts //')
END_VERSIONS
"""
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
"""
samtools merge -@ ${task.cpus} \\
    -f ${prefix}_bwt2merged.bam \\
    ${bam1} ${bam2}

samtools sort -@ ${task.cpus} -m 800M \\
    -n \\
    -o ${prefix}_bwt2merged.sorted.bam \\
    ${prefix}_bwt2merged.bam

mv ${prefix}_bwt2merged.sorted.bam ${prefix}_bwt2merged.bam

echo "## ${prefix}" > ${prefix}.mapstat
echo -n "total_${tag}\t" >> ${prefix}.mapstat
samtools view -c ${prefix}_bwt2merged.bam >> ${prefix}.mapstat
echo -n "mapped_${tag}\t" >> ${prefix}.mapstat
samtools view -c -F 4 ${prefix}_bwt2merged.bam >> ${prefix}.mapstat
echo -n "global_${tag}\t" >> ${prefix}.mapstat
samtools view -c -F 4 ${bam1} >> ${prefix}.mapstat
echo -n "local_${tag}\t"  >> ${prefix}.mapstat
samtools view -c -F 4 ${bam2} >> ${prefix}.mapstat

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    samtools: \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//')
END_VERSIONS
"""
19
20
21
22
23
24
25
26
"""
build_matrix \\
    --matrix-format upper  \\
    --binsize ${resolution} \\
    --chrsizes ${chrsize} \\
    --ifile ${vpairs} \\
    --oprefix ${prefix}
"""
21
22
23
24
25
26
27
28
"""
mergeSAM.py -f ${bam[0]} -r ${bam[1]} -o ${prefix}_bwt2pairs.bam ${args}

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    python: \$(echo \$(python --version 2>&1) | sed 's/Python //')
END_VERSIONS
"""
21
22
23
24
25
26
27
28
29
30
"""
echo "## ${prefix}" > ${prefix}.mapstat
echo -n "total_${tag}\t" >> ${prefix}.mapstat
samtools view -c ${bam} >> ${prefix}.mapstat
echo -n "mapped_${tag}\t" >> ${prefix}.mapstat
samtools view -c -F 4 ${bam} >> ${prefix}.mapstat
echo -n "global_${tag}\t" >> ${prefix}.mapstat
samtools view -c -F 4 ${bam} >> ${prefix}.mapstat
echo -n "local_${tag}\t0"  >> ${prefix}.mapstat
"""
19
20
21
22
23
24
25
26
"""
digest_genome.py -r ${res_site} -o restriction_fragments.bed ${fasta}

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    python: \$(echo \$(python --version 2>&1) | sed 's/Python //')
END_VERSIONS
"""
20
21
22
23
24
25
26
27
28
29
"""
mapped_2hic_dnase.py \\
    -r ${bam} \\
    ${args}

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    python: \$(echo \$(python --version 2>&1) | sed 's/Python //')
END_VERSIONS
"""
25
26
27
28
29
30
31
32
33
34
35
36
"""
mapped_2hic_fragments.py \\
    -f ${resfrag} \\
    -r ${bam} \\
    --all \\
    ${args}

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    python: \$(echo \$(python --version 2>&1) | sed 's/Python //')
END_VERSIONS
"""
20
21
22
23
24
25
26
27
28
29
30
"""
##columns: readID chr1 pos1 chr2 pos2 strand1 strand2
awk '{OFS="\t";print \$1,\$2,\$3,\$5,\$6,\$4,\$7}' $vpairs | bgzip -c > ${prefix}_contacts.pairs.gz
##sort -k2,2 -k4,4 -k3,3n -k5,5n ${prefix}_contacts.pairs | bgzip -c > ${prefix}_contacts.pairs.gz
pairix -f ${prefix}_contacts.pairs.gz

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    pairix: \$(echo \$(pairix 2>&1 | grep Version | sed -e 's/Version: //'))
END_VERSIONS
"""
22
23
24
25
26
27
28
29
30
31
"""
mkdir -p ${meta.id}
merge_statfiles.py -f ${fstat} > ${meta.id}.${ext}
cp *${ext} ${meta.id}/

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    python: \$(echo \$(python --version 2>&1) | sed 's/Python //')
END_VERSIONS
"""
22
23
24
25
26
27
28
29
30
31
32
33
"""
hicpro_merge_validpairs.sh ${args} -p ${prefix} ${vpairs}

## For MultiQC
mkdir -p ${prefix}
cp ${prefix}_allValidPairs.mergestat ${prefix}/

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    sort: \$(echo \$(sort --version 2>&1 | head -1 | awk '{print \$NF}' 2>&1))
END_VERSIONS
"""
20
21
22
23
24
25
26
27
28
29
30
31
"""
ice --filter_low_counts_perc ${params.ice_filter_low_count_perc} \
    --results_filename ${prefix}_iced.matrix \
    --filter_high_counts_perc ${params.ice_filter_high_count_perc} \
    --max_iter ${params.ice_max_iter} --eps ${params.ice_eps} --remove-all-zeros-loci --output-bias 1 --verbose 1 ${rmaps}

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    python: \$(echo \$(python --version 2>&1) | sed 's/Python //')
    iced: \$(python -c "import iced; print(iced.__version__)")
END_VERSIONS
"""
19
20
21
22
23
24
25
26
27
28
29
30
31
"""
zcat ${reads} > tmp.fastq
cutsite_trimming --fastq tmp.fastq \\
    --cutsite ${motif[0]} \\
    --out ${reads.simpleName}_trimmed.fastq
gzip ${reads.simpleName}_trimmed.fastq
/bin/rm -f tmp.fastq

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    gzip: \$(echo \$(gzip --version 2>&1) | head -1 | cut -d" " -f2)
END_VERSIONS
"""
27
28
29
30
31
32
33
34
"""
multiqc -f $args .

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    multiqc: \$( multiqc --version | sed -e "s/multiqc, version //g" )
END_VERSIONS
"""
21
22
23
24
25
26
27
28
29
30
"""
check_samplesheet.py \\
    $samplesheet \\
    samplesheet.valid.csv

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    python: \$(python --version | sed 's/Python //g')
END_VERSIONS
"""
23
24
25
26
27
28
29
30
31
"""
cat ${bedpe} | awk '{OFS="\t"; print \$1,\$2,\$3}' > ${prefix}_raw.txt
cat ${bedpe} | awk '{OFS="\t"; print \$1,\$2,\$4}' > ${prefix}_balanced.txt

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    cooler: \$(awk --version | head -1 | cut -f1 -d, | sed -e 's/GNU Awk //')
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
"""
26
27
28
29
30
31
32
33
34
35
36
37
38
"""
cp ${cool} ${prefix}.${extension}

cooler balance \\
    $args \\
    -p ${task.cpus} \\
    ${prefix}.${extension}${suffix}

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    cooler: \$(cooler --version 2>&1 | sed 's/cooler, version //')
END_VERSIONS
"""
26
27
28
29
30
31
32
33
34
35
36
37
38
"""
cooler cload \\
    $args \\
    $nproc \\
    ${chromsizes}:${cool_bin} \\
    $pairs \\
    ${prefix}.cool

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    cooler: \$(cooler --version 2>&1 | sed 's/cooler, version //')
END_VERSIONS
"""
24
25
26
27
28
29
30
31
32
33
34
"""
cooler dump \\
    $args \\
    -o ${prefix}.bedpe \\
    $cool$suffix

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    cooler: \$(cooler --version 2>&1 | sed 's/cooler, version //')
END_VERSIONS
"""
23
24
25
26
27
28
29
30
31
32
33
"""
cooler makebins \\
    $args \\
    ${chromsizes} \\
    ${cool_bin} > ${prefix}.bed

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    cooler: \$(cooler --version 2>&1 | sed 's/cooler, version //')
END_VERSIONS
"""
23
24
25
26
27
28
29
30
31
32
33
34
"""
cooler zoomify \\
    $args \\
    -n $task.cpus \\
    -o ${prefix}.mcool \\
    $cool

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    cooler: \$(cooler --version 2>&1 | sed 's/cooler, version //')
END_VERSIONS
"""
24
25
26
27
28
29
30
31
32
"""
samtools faidx $fasta
cut -f 1,2 ${fasta}.fai > ${fasta}.sizes

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    getchromsizes: \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//')
END_VERSIONS
"""
35
36
37
38
39
40
41
42
43
"""
touch ${fasta}.fai
touch ${fasta}.sizes

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    getchromsizes: \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//')
END_VERSIONS
"""
28
29
30
31
32
33
34
35
36
37
38
"""
printf "%s %s\\n" $rename_to | while read old_name new_name; do
    [ -f "\${new_name}" ] || ln -s \$old_name \$new_name
done
fastqc $args --threads $task.cpus $renamed_files

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    fastqc: \$( fastqc --version | sed -e "s/FastQC v//g" )
END_VERSIONS
"""
42
43
44
45
46
47
48
49
50
"""
touch ${prefix}.html
touch ${prefix}.zip

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    fastqc: \$( fastqc --version | sed -e "s/FastQC v//g" )
END_VERSIONS
"""
ShowHide 22 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/hic
Name: hic
Version: 2.1.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 ...