README.md 11.2 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

[![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)
Rachel  LEGENDRE's avatar
Rachel LEGENDRE committed
9
* Maëlle Daunesse
Rachel  LEGENDRE's avatar
Rachel LEGENDRE committed
10
11
12
13
14
15
16
* 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
`mv chipflow_latest.sif chipflow/chipflow.img`

76
77
**Note that you can use public datasets to test the pipeline as described [here](https://gitlab.pasteur.fr/hub/chipflow/-/edit/master/README.md#run-the-pipeline-on-test-data)**

78

Rachel  LEGENDRE's avatar
Rachel LEGENDRE committed
79
80
81
82
*  Step 3: Execute workflow

Test your configuration by performing a dry-run via

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

Execute the workflow locally via

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

Rachel  LEGENDRE's avatar
Rachel LEGENDRE committed
89
using $N cores or run it in a cluster environment via this standard command line :
Rachel  LEGENDRE's avatar
Rachel LEGENDRE committed
90

91
`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 1`
Rachel  LEGENDRE's avatar
Rachel LEGENDRE committed
92

Rachel  LEGENDRE's avatar
Rachel LEGENDRE committed
93
94
95
96
97
98
99
100
Or specifically on Slurm cluster:

`sbatch 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`

or on SGE cluster:

`snakemake --use-singularity --singularity-args "-B '$HOME'" --cluster-config config/cluster_config.json --cluster "qsub -cwd -V -b y -l h_vmem={cluster.ram} -pe [PE] {threads}" -j 200 --nolock --cores 1`

Rachel  LEGENDRE's avatar
Rachel LEGENDRE committed
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121

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) |
122
|   COND   | Biological condition name (i.e. Normal, Cancer, Cells)                     |
Rachel  LEGENDRE's avatar
Rachel LEGENDRE committed
123
124
125
126
127
|   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.

128
129
130
131
132
133
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
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
189
190
191
192
193
194
195
196
197
198
### 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
```

199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
### 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">

219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264


### Run the pipeline on test data 

You need to have sra-toolkit installed before to download test data.


```
# Download genome references
wget https://ftp.ncbi.nlm.nih.gov/genomes/all/GCF/000/001/635/GCF_000001635.26_GRCm38.p6/GCF_000001635.26_GRCm38.p6_genomic.fna.gz
gunzip GCF_000001635.26_GRCm38.p6_genomic.fna.gz


# get blacklisted regions
wget http://mitra.stanford.edu/kundaje/akundaje/release/blacklists/mm10-mouse/mm10.blacklist.bed.gz
gunzip mm10.blacklist.bed.gz

# create genome directory
mkdir genome
mv GCF_000001635.26_GRCm38.p6_genomic.fna genome/mm10.fa
mv mm10.blacklist.bed genome/mm10.blacklist.bed

# copy config file
cp test/config.yaml config/config.yaml
cp test/design.txt config/design.txt

# Download FastQ files from GEO (GSE99009) https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSE99009
# Only include the H3K27ac histone mark and Klf4 transcription factor with their associated inputs for the shUbc9 and shCtrl conditions
SRR=("SRR5572646" "SRR5572647" "SRR5572658" "SRR5572659" "SRR5572668" "SRR5572669" "SRR5572676" "SRR5572677" "SRR5572652" "SRR5572653" "SRR5572664" "SRR5572665")
sample=("H3K27ac_shCtrl_Rep1_R1" "H3K27ac_shCtrl_Rep2_R1" "H3K27ac_shUbc9_Rep1_R1" "H3K27ac_shUbc9_Rep2_R1" "Klf4_shCtrl_Rep1_R1" "Klf4_shCtrl_Rep2_R1" "Klf4_shUbc9_Rep1_R1" "Klf4_shUbc9_Rep2_R1" "INPUT_shCtrl_Rep1_R1" "INPUT_shCtrl_Rep2_R1" "INPUT_shUbc9_Rep1_R1" "INPUT_shUbc9_Rep2_R1")

mkdir data
cd data
for i in  ${!SRR[*]} ; do
    echo ${SRR[$i]}, ${sample[$i]}
    prefetch ${SRR[$i]} -o ${sample[$i]}.sra
    fastq-dump ${sample[$i]}.sra
done

rm *.sra 
for file in *.fastq ; do 
    pigz $file ; 
done
```


Rachel  LEGENDRE's avatar
Rachel LEGENDRE committed
265
## Q&A
266

Rachel  LEGENDRE's avatar
Rachel LEGENDRE committed
267
268
## How to cite ChIPflow ?

Claudia  CHICA's avatar
Claudia CHICA committed
269
https://doi.org/10.1101/2021.02.02.429342
Rachel  LEGENDRE's avatar
Rachel LEGENDRE committed
270
271