-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSnakefile
180 lines (157 loc) · 4.47 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
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
configfile: "config.json"
rule decompress_fastq:
input:
config["fastq_path"] + "/{sample}_L002_R1_001.fastq.gz"
output:
temp("output/FASTQ/{sample}.fastq")
shell:
"gzcat {input} > {output}"
rule align:
input:
"output/FASTQ/{sample}.fastq"
output:
temp("output/SAM/{sample}_Aligned.out.sam")
threads: 4
shell:
"star --runThreadN {threads} --genomeDir " + config["star_index"] + " --readFilesIn {input} --outFileNamePrefix output/SAM/{wildcards.sample}_"
rule bam:
input:
"output/SAM/{sample}_Aligned.out.sam"
output:
config["bam_path"] + "/{sample}.sorted.bam"
threads: 4
shell:
"samtools sort -@ 3 -m 4G {input} > {output}"
rule bam_index:
input:
config["bam_path"] + "/{sample}.sorted.bam"
output:
config["bam_path"] + "/{sample}.sorted.bam.bai"
shell:
"samtools index {input}"
def get_bam_files():
IDS, = glob_wildcards(config["bam_path"] + "/{id}.bam")
bamfiles = [base + ".bam" for base in IDS]
return bamfiles
rule bam_links:
input:
[config["bam_path"] + "/" + bam for bam in get_bam_files()]
output:
["data/BAM/" + bam for bam in get_bam_files()]
run:
for bam in get_bam_files():
shell("ln -s " + config["bam_path"] + "/" + bam + " data/BAM/" + bam)
rule featurecounts:
input:
["data/BAM/" + bam for bam in get_bam_files()]
output:
report="reports/featureCounts.report.txt",
counts="data/gene_counts.tsv"
threads: 4
script:
"scripts/featureCounts.R"
rule dds:
input:
counts="data/gene_counts.tsv"
output:
rds="data/RData/dds.rds"
script:
"scripts/make_dds.R"
rule normalized_counts:
input:
rds="data/RData/dds.rds"
output:
counts="output/normalized_counts.tsv"
script:
"scripts/normalized_counts.R"
rule size_factor_plot:
input:
dds="data/RData/dds.rds",
Rmd="scripts/SizeFactors.Rmd"
output:
html="output/SizeFactors.html"
script:
"scripts/SizeFactors.Rmd"
rule DE_single:
input:
dds="data/RData/dds.rds"
output:
dds="data/RData/dds-{comparison}.rds",
rds="data/RData/DE-{comparison}.rds"
script:
"scripts/DifferentialExpression.R"
rule DE_report_single:
input:
dds="data/RData/dds-{comparison}.rds",
rds="data/RData/DE-{comparison}.rds",
Rmd="scripts/DifferentialExpression.Rmd"
output:
html="output/DifferentialExpression/DiffExp-{comparison}.html"
script:
"scripts/DifferentialExpression.Rmd"
rule DE_reports:
input:
["output/DifferentialExpression/DiffExp-" + comparison + ".html" for comparison in config['comparisons'].keys()]
rule PCA_vsd:
input:
dds="data/RData/dds.rds"
output:
vsd="data/RData/vsd-{pca}.rds"
script:
"scripts/PCA_vsd.R"
rule PCA_plot:
input:
dds="data/RData/dds.rds",
Rmd="scripts/PCA.Rmd",
vsd="data/RData/vsd-{pca}.rds"
output:
"output/PCA/PCA-{pca}.html"
script:
"scripts/PCA.Rmd"
rule PCA_plots:
input:
["output/PCA/PCA-" + pca + ".html" for pca in config['PCA_plots'].keys()]
rule heatmap_vsd:
input:
dds="data/RData/dds.rds"
output:
vsd="data/RData/heatmap-vsd-{heatmap}.rds"
script:
"scripts/heatmap_vsd.R"
rule heatmap:
input:
vsd="data/RData/heatmap-vsd-{heatmap}.rds",
Rmd="scripts/Heatmap.Rmd"
output:
"output/Heatmaps/Heatmap-{heatmap}.html"
script:
"scripts/Heatmap.Rmd"
rule heatmaps:
input:
["output/Heatmaps/Heatmap-" + heatmap + ".html" for heatmap in config['heatmaps'].keys()]
rule plots:
input:
dds="data/RData/dds.rds",
Rmd="scripts/Plots.Rmd"
output:
html="output/Heatmap_PCA.html"
script:
"scripts/Plots.Rmd"
rule fgsea_rds_single:
input:
rds="data/RData/DE-{comparison}.rds"
output:
fgsea="data/RData/fgsea-{comparison}.rds"
script:
"scripts/fgsea.R"
rule fgsea_html:
input:
rds="data/RData/fgsea-{comparison}.rds",
Rmd="scripts/fgsea.Rmd"
output:
html="output/fgsea/fgsea-{comparison}.html"
script:
"scripts/fgsea.Rmd"
rule fgsea:
input:
["output/fgsea/fgsea-" + comparison + ".html" for comparison in config['comparisons'].keys() if config['comparisons'][comparison]['do_fgsea']]