-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSnakefile
145 lines (138 loc) · 5.69 KB
/
Snakefile
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
Samples=["SRX7080612","SRX7080613","SRX7080614","SRX7080615","SRX7080616","SRX7080617"]
reference_suffixes = ["1", "2", "3", "4", "rev.1", "rev.2"]
rule all:
input:
"results/07_Final_results/DESeq2_Results/MA_plot.png",
"results/07_Final_results/DESeq2_Results/MA_plot_translation1.png",
"results/07_Final_results/DESeq2_Results/MA_plot_translation2.png",
"results/07_Final_results/DESeq2_Results/Volcano_plot.png",
"results/07_Final_results/Supplementary_results/Supplementary_analysis.pdf"
# Rule that downloads the FASTQ files.
rule fasterq_dump:
output:
"results/01_raw_data/{SRA_id}.fastq.gz"
container:
"https://zenodo.org/records/13994690/files/fasterq-dump.img?download=1"
log:
"logs/fasterq-dump/{SRA_id}.log"
threads: 5
shell:
"""
fasterq-dump --threads {threads} --progress {wildcards.SRA_id} -O results/01_raw_data/ &> {log}
gzip -f results/01_raw_data/{wildcards.SRA_id}.fastq
"""
# Rule that performs the trimming of FASTQ files.
rule cutadapt:
input:
"results/01_raw_data/{SRA_id}.fastq.gz"
output:
trimmed_fastq="results/02_Trimming_results/{SRA_id}_trimmed.fastq.gz",
container:
"https://zenodo.org/records/13994994/files/cutadapt_v1.11.img?download=1"
log:
"logs/cutadapt/{SRA_id}_trimmed.log"
threads: 5
shell:
"""
cutadapt -o results/02_Trimming_results/{wildcards.SRA_id}_trimmed.fastq.gz {input} -a AGATCGGAAGAGC -q 20 -m 25 > results/02_Trimming_results/{wildcards.SRA_id}_trimming_report.txt
"""
# Rule that downloads the reference genome in FASTA format.
rule reference_genome:
output:
"results/03_Reference_Genome/reference.fasta"
shell:
"""
wget -q -O results/03_Reference_Genome/reference.fasta "https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=nuccore&id=CP000253.1&rettype=fasta"
"""
# Rule that downloads the genome annotation.
rule genome_annotation :
output:
"results/04_Genome_Annotation/reference.gff"
log:
"logs/Genome_Annotation"
shell:
"""
wget -O {output} "https://www.ncbi.nlm.nih.gov/sviewer/viewer.cgi?db=nuccore&report=gff3&id=CP000253.1" &> {log}
"""
# Rule that creates the genome index
rule genome_index:
input:
"results/03_Reference_Genome/reference.fasta"
output:
"results/03_Reference_Genome/reference.{suffixe}.ebwt"
container:
"https://zenodo.org/records/13994994/files/bowtie_v0.12.7_samtools.img?download=1"
shell:
"""
bowtie-build {input} results/03_Reference_Genome/reference
"""
# Rule that maps the genome and creates an index
rule mapping:
input:
index = expand("results/03_Reference_Genome/reference.{suffixe}.ebwt", suffixe=reference_suffixes),
fastq_files = "results/02_Trimming_results/{SRA_id}_trimmed.fastq.gz"
output:
bam = "results/05_Mapping_results/{SRA_id}.bam",
bai = "results/05_Mapping_results/{SRA_id}.bai"
container:
"https://zenodo.org/records/13994994/files/bowtie_v0.12.7_samtools.img?download=1"
threads: 4
shell:
"""
bowtie -p {threads} -S results/03_Reference_Genome/reference <(gunzip -c {input.fastq_files}) | samtools sort -@ {threads} -o {output.bam}
samtools index -@ {threads} -o {output.bai} {output.bam}
"""
# Rule that counts the number of reads mapped on each gene.
rule counting:
input:
bamf = expand("results/05_Mapping_results/{SRA_id}.bam", SRA_id=Samples),
genome_annotation = "results/04_Genome_Annotation/reference.gff"
output:
"results/06_Counting_results/counts.txt"
container:
"https://zenodo.org/records/13994994/files/featureCounts_v1.4.6-p3.img?download=1"
log:
"logs/counting.log"
threads: 2
shell:
"""
featureCounts -t gene -g ID -s 1 -T {threads} -a {input.genome_annotation} -o {output} {input.bamf}
"""
rule Download_KEGG_Genes:
output:
"assets/tRNA_synthetases_genes.txt",
"assets/translation_genes.txt"
container:
"https://zenodo.org/records/14288479/files/RStudio_version4.3.1_FactoMiner_Factoextra_ggplot2.img?download=1"
shell:
"""
Rscript bin/Download_KEGG_Genes.R
"""
rule DESeq2_analysis:
input:
counts="results/06_Counting_results/counts.txt",
translation_genes="assets/translation_genes.txt",
tRNA_genes="assets/tRNA_synthetases_genes.txt",
correspondance_genes="assets/GeneSpecificInformation_NCTC8325.txt"
output:
ma_plot="results/07_Final_results/DESeq2_Results/MA_plot.png",
ma_plot_translation1="results/07_Final_results/DESeq2_Results/MA_plot_translation1.png",
ma_plot_translation2="results/07_Final_results/DESeq2_Results/MA_plot_translation2.png",
volcano_plot="results/07_Final_results/DESeq2_Results/Volcano_plot.png",
container:
"https://zenodo.org/records/14288479/files/RStudio_v3.4.1_DESeq2_v1.16.1.img?download=1"
shell:
"""
Rscript bin/DESeq2_analysis.R {input.counts} {input.translation_genes} {input.tRNA_genes} {input.correspondance_genes} results/07_Final_results/DESeq2_Results/
"""
rule PCA_analysis:
input :
counts="results/06_Counting_results/counts.txt",
output:
"results/07_Final_results/Supplementary_results/Supplementary_analysis.pdf"
container:
"https://zenodo.org/records/14288479/files/RStudio_version4.3.1_FactoMiner_Factoextra_ggplot2.img?download=1"
shell:
"""
Rscript bin/PCA_analysis.R {input.counts} results/07_Final_results/Supplementary_results/
"""