-
Notifications
You must be signed in to change notification settings - Fork 0
/
00_workshop_code.sh
93 lines (80 loc) · 4.3 KB
/
00_workshop_code.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
################################
## ChIP-seq Analysis Workflow ##
################################
## Mireia Ramos-Rodríguez ##
## 14th of March 2019 ##
################################
#########################################################################
# Set up your working environment and necessary files
#########################################################################
# Open the virtual machine, log in to the VPN and connect to `ironwomen`.
# There, you will need to create the following directory structure.
#--------------------------------------------------------------------
# 1) Generate directory structure:
#--------------------------------------------------------------------
# yourpersonalfolder
# |-- ChIP-seq
# |-- fastq
# |-- BAM
# |-- peaks
cd yourpersonalfolder
mkdir ChIP-seq
cd ChIP-seq
mkdir fastq
mkdir BAM
mkdir peaks
#--------------------------------------------------------------------
# 2) Copy sample file: NL1_h3k27ac.fastq.gz
#--------------------------------------------------------------------
cp ~/workshop_ChIPseq/ChIP-seq_sample/fastq/NL1_h3k27ac_sample.fastq.gz ~/yourpersonalfolder/ChIP-seq/fastq/.
#########################################################################
## Quality control with FastQC
#########################################################################
# First, we are going to check the quality of the sequenced reads using FastQC.
# The otuput is an html file with a summary of the tests performed and if your
# reads are passing or not the quality control thresholds.
#--------------------------------------------------------------------
# 1) Run FastQC on the sample file
#--------------------------------------------------------------------
cd ~/yourpersonalfolder/ChIP-seq # Make sure you are here
mkdir FastQC # Make directory for output
fastqc fastq/NL1_h3k27ac_sample.fastq.gz -o FastQC # 15 seconds
#--------------------------------------------------------------------
# 2) To see the results, copy the output html to the virtual machine
#--------------------------------------------------------------------
# Open a terminal in the virtual machine
scp msuser@ironwomen:/home/labs/mslab/msuser/yourpersonalfolder/ChIP-seq/FastQC/NL1_h3k27ac_sample_fastqc.html .
# Now open the hmtl from your virtual machine and explore the results
#########################################################################
## Alignment with Bowtie2
#########################################################################
#--------------------------------------------------------------------
# 1) Align the sample file to the reference genome
#--------------------------------------------------------------------
bowtie2 -t -x ~/workshop_ChIPseq/reference_genome/hg19 -U fastq/NL1_h3k27ac_sample.fastq.gz
-S BAM/NL1_h3K27ac_sample.sam
#########################################################################
## Post-processing with Samtools
#########################################################################
#--------------------------------------------------------------------
# 1) Convert to BAM and sort
#--------------------------------------------------------------------
samtools view BAM/NL1_h3K27ac_sample.sam -b | samtools sort - -o BAM/NL1_h3K27ac_sample.srtd.bam
#--------------------------------------------------------------------
# 2) Remove duplicates
#--------------------------------------------------------------------
markdup BAM/NL1_h3K27ac_sample.srtd.bam BAM/NL1_h3K27ac_sample.rmdup.bam -r -s
#--------------------------------------------------------------------
# 3) Index bam files
#--------------------------------------------------------------------
samtools index BAM/NL1_h3K27ac_sample.srtd.bam
samtools index BAM/NL1_h3K27ac_sample.rmdup.bam
#########################################################################
## Peak calling with MACS2
#########################################################################
activate-macs-git-2017.5.15 # Activate MACS2
mkdir tmp/ # Create folder for temporary files
#--------------------------------------------------------------------
# Run peak calling with MACS2
#--------------------------------------------------------------------
macs2 callpeak -f BAM -t BAM/NL1_h3K27ac_sample.rmdup.bam -c ~/workshop_ChIPseq/ChIP-seq/BAM/NL1_input.rmdup.bam -g hs -n peaks/NL1_h3K27ac --tempdir tmp/ --broad --nomodel