README.md 8.95 KB
Newer Older
Rachel  LEGENDRE's avatar
Rachel LEGENDRE committed
1
# ChIPflow: from raw data to epigenomic dynamics
Rachel  LEGENDRE's avatar
Rachel LEGENDRE committed
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

[![Snakemake](https://img.shields.io/badge/snakemake-≥5.2.1-brightgreen.svg)](https://snakemake.readthedocs.io/en/stable/) [![Python 3.6](https://img.shields.io/badge/python-3.6-blue.svg)](https://www.python.org/downloads/release/python-360/)


## Authors

* Rachel Legendre (@rlegendr)
* Maelle Daunesse
* Adrien Pain
* Hugo Varet
* Claudia Chica


## What is ChIPflow ?

Rachel  LEGENDRE's avatar
Rachel LEGENDRE committed
17
ChIPflow is a snakemake-based workflow for the analysis of ChIP-seq data from the raw fastq files to the differential analysis of transcription factor binding or histone modification marking. It streamlines critical steps like the quality assessment of the immunoprecipitation using the cross correlation and the replicate comparison for both narrow and broad peaks. For the differential analysis ChIPflow provides linear and non linear methods for normalisation between samples as well as conservative and stringent models for estimating the variance and testing the significance of the observed differences (see [chipflowr](https://gitlab.pasteur.fr/hub/chipflowr)).
Rachel  LEGENDRE's avatar
Rachel LEGENDRE committed
18
19
20
21
22
23
24
25
26
27
28
29

## How to install ChIPflow ?

### Installation with singularity

You need to install:
- python >= 3.8
- snakemake >=4.8.0
- pandas
- pysam
- singularity

Rachel  LEGENDRE's avatar
Rachel LEGENDRE committed
30
A basic tutorial to create a conda environment with all dependencies is available here : [env.sh](https://gitlab.pasteur.fr/hub/chipflow/-/blob/master/env.sh)
Rachel  LEGENDRE's avatar
Rachel LEGENDRE committed
31
32
33
    
Download the singularity container:
 
Rachel  LEGENDRE's avatar
Rachel LEGENDRE committed
34
` singularity pull --arch amd64 library://rlegendre/default/chipflow:latest ` 
Rachel  LEGENDRE's avatar
Rachel LEGENDRE committed
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51

### Manual installation 

In addition to above tools, you need to install pipeline-related tools:

- cutadapt >= 3.2
- fastqc == 0.11.9
- samtools >= 1.10
- bowtie2 >= 2.3.5
- macs2 >= 2.2.7
- picard >= 2.18.25
- featureCounts (from subread) >= 2.0.0
- bedtools >= 2.27.1
- idr == 2.0.3
- R >= 4.0.3
- spp == 1.15.2
    - need following cran packages: snow, snowfail, bitops, caTools, RCurl, Rcpp, and bioconductor packages: GenomeInfoDB, genomicRanges, Rsamtools.
Rachel  LEGENDRE's avatar
Rachel LEGENDRE committed
52
- [chipflowr](https://gitlab.pasteur.fr/hub/chipflowr)
Rachel  LEGENDRE's avatar
Rachel LEGENDRE committed
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69


# How to run ChIPflow ?

## Usage

* Step 1: Install workflow

If you simply want to use this workflow, download and extract the latest release.

`git clone https://gitlab.pasteur.fr/hub/chipflow.git`

In any case, if you use this workflow in a paper, don't forget to give credits to the authors by citing the URL of this repository and, if available, its DOI (see above).


*  Step 2: Configure workflow

70
Configure the workflow according to your needs via editing the [config.yaml](https://gitlab.pasteur.fr/hub/chipflow/-/tree/master#how-to-fill-the-config-file), [design.txt](https://gitlab.pasteur.fr/hub/chipflow/-/tree/master#how-to-fill-the-design) and  [multiqc_config.yaml](https://gitlab.pasteur.fr/hub/chipflow/-/edit/master/README.md#how-to-fill-the-multiqc-config) files in the `config/` directory.
Rachel  LEGENDRE's avatar
Rachel LEGENDRE committed
71

Rachel  LEGENDRE's avatar
Rachel LEGENDRE committed
72
You need to copy the singularity image in the cloned ChIPflow directory and rename it as "chipflow.img".
Rachel  LEGENDRE's avatar
Rachel LEGENDRE committed
73

74
75
76
`mv chipflow_latest.sif chipflow/chipflow.img`


Rachel  LEGENDRE's avatar
Rachel LEGENDRE committed
77
78
79
80
*  Step 3: Execute workflow

Test your configuration by performing a dry-run via

Rachel  LEGENDRE's avatar
Rachel LEGENDRE committed
81
`snakemake --use-singularity -n --cores 1`
Rachel  LEGENDRE's avatar
Rachel LEGENDRE committed
82
83
84

Execute the workflow locally via

Rachel  LEGENDRE's avatar
Rachel LEGENDRE committed
85
`snakemake --use-singularity --singularity-args "-B '/home/login/'" --cores $N`
Rachel  LEGENDRE's avatar
Rachel LEGENDRE committed
86
87
88

using $N cores or run it in a cluster environment via

Rachel  LEGENDRE's avatar
Rachel LEGENDRE committed
89
`snakemake --use-singularity --singularity-args "-B '$HOME'" --cluster-config config/cluster_config.json --cluster "sbatch --mem={cluster.ram} --cpus-per-task={threads} " -j 200 --nolock --cores $SLURM_JOB_CPUS_PER_NODE`
Rachel  LEGENDRE's avatar
Rachel LEGENDRE committed
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111


Visualize how the rules are connected via 

`snakemake -s Snakefile --rulegraph --nolock | dot -Tsvg > rulegraph.svg`

or how the files are processed via

`snakemake -s Snakefile -j 10 --dag --nolock | dot -Tsvg > dag.svg`

### Pipeline overview

<img src="images/chipflow_pipeline.svg" width="700">


### Rename FASTQ files

All FASTQ files have to observe the following name nomenclature: `MARK_COND_REP_MATE.fastq.gz`. For FASTQ files with only one mate (single-end sequencing), or if no replicates are available, set MATE to R1 or REP to Rep1, respectively.

| Wildcard |                          Description                                |
|----------|---------------------------------------------------------------------|
|   MARK   | Histone mark or Transcription Factor (TF) name (i.e. H3K4me1, Klf4) |
112
|   COND   | Biological condition name (i.e. Normal, Cancer, Cells)                     |
Rachel  LEGENDRE's avatar
Rachel LEGENDRE committed
113
114
115
116
117
|   REP    | Replicate number (i.e. Rep1 or Rep2)                                |
|   MATE   | Identification of mate pair sequencing (i.e. R1 or R2)              |

All the FASTQ files must be stored in the same directory.

118
119
120
121
122
123
Example of FASTQ file names:

- `H3K27ac_shCtrl_Rep1_R1.fastq.gz` and its corresponding INPUT file: `INPUT_shCtrl_Rep1_R1.fastq.gz`
- `TF4_HeLa_rep1_R1.fastq.gz` and its corresponding INPUT file: `Input_HeLa_rep1_R1.fastq.gz`
- `CTCF_WT_REP1_R1.fastq.gz` and its corresponding INPUT file: `INPUT_WT_REP1_R1.fastq.gz`

Rachel  LEGENDRE's avatar
Rachel LEGENDRE committed
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
### How to fill the design

The experimental analysis design is summarise in a tabulated design file that the user have to fill before running the pipeline.

Design columns:

|    Column    |                          Description                          |
|--------------|---------------------------------------------------------------|
|   IP_NAME    | IP FASTQ files prefix  (i.e. MARK_COND1)                      |
|   INPUT_NAME | INPUT FASTQ files prefix (i.e. INPUT_COND1)                   |
|   NB_IP      | Number of replicates of the histone mark or TFs (i.e. 1 or 2) |
|   NB_INPUT   | Number of replicates of INPUT files (i.e. 1 or 2)             |

Link to an Example: [design.txt](https://gitlab.pasteur.fr/hub/chipflow/-/blob/master/test/design.txt)


### How to fill the config file

All the parameters to run the pipeline are gathered in a YAML config file that the user has to fill before running the pipeline. Here is an filled example: [config.yaml](https://gitlab.pasteur.fr/hub/chipflow/-/blob/master/test/config.yaml)

This config file is divided in 2 sections:

1. Section 1: Running pipeline chunks

This first chunk provides input information and assigns working directories. 
`input_dir` path to FASTQ files directory. 
`input_mate` mate pair format (i.e. `_R[12]` for *MATE* = R1 or R2) , must match the *MATE* parameter in FASTQ files.
`input_extension` filename extension format (i.e. `fastq.gz` or `fq.gz`).
`analysis_dir` path to analysis directory.
`tmpdir` path to temporary directory (i.e. `/tmp/` or `/local/scratch/`)

```
input_dir: /path/to/raw_data
input_mate: '_R[12]'
input_extension: '.fastq.gz'
analysis_dir: /path/to/directory/analysis
tmpdir: "/tmp/"
```

The design chunk aims to check that the FASTQ files name match the design file information. The `marks`, `conditions` and `replicates` parameters must respectively match the *MARK*, *COND* and *REP* parameters of the FASTQ files name and the design file. 
For spike-in data, set `spike` on "True" and provide the spike-in genome FASTA file path through the `spike_genome_file` parameter.

```
design:
    design_file: /path/to/directory/analysis/config/design.txt    
    marks: K4Me3
    condition: C, U
    replicates: Rep
    spike: false
    spike_genome_file: /path/to/genome/directory/dmel9.fa
```

2. Section 2: Rule parameters chunks

Each step has it proper setting in independent chunk.
The second section of the configuration file is divided in multiple chunks. Each chunk gather the parameters of one step of the pipeline: `adapters`, `bowtie2_mapping`, `mark_duplicates`, `remove_blacklist`, `peak_calling`, `compute_idr` and `differential_analysis`. 

The `options` parameter present in `adapters`, `bowtie2_mapping` and `peak_calling` allows you to provide any parameter recognised by cutadapt, bowtie2 and macs2 respectively. For example for the `bowtie2_mapping` chunk, `options` can be fill with "--very-sensitive".

```
bowtie2_mapping:
    options: "--very-sensitive"
    threads: 4
```

189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
### How to fill the multiqc config

At the beginning of `config/multiqc_config.yaml` file, you have the possibility to customize header of MultiQC report according to your experiment as you can see below: 

```
# Title to use for the report.
title: "ChIP-seq analysis"
subtitle: "ChIP-seq analysis of CTCF factor in breast tumor cells"                  # Set your own text
intro_text: "MultiQC reports summarise analysis results produced from ChIPflow"     

# Add generic information to the top of reports
report_header_info:
    - Contact E-mail: 'rlegendre@pasteur.fr'                                        # Set your own text
    - Application Type: 'ChIP-seq'                                                  # Set your own text
    - Project Type: 'Differential peak expression'                                  # Set your own text
    - Sequencing Platform: 'NextSeq2000'                                            # Set your own text
    - Sequencing Setup: 'PE75'                                                      # Set your own text
```
<img src="images/multiqc_header.png" width="600">

Rachel  LEGENDRE's avatar
Rachel LEGENDRE committed
209
210
## How to cite ChIPflow ?

Claudia  CHICA's avatar
Claudia CHICA committed
211
https://doi.org/10.1101/2021.02.02.429342
Rachel  LEGENDRE's avatar
Rachel LEGENDRE committed
212
213