-
Notifications
You must be signed in to change notification settings - Fork 12
/
Snakefile_fastq_multilane.alt_splicing
executable file
·500 lines (438 loc) · 20.7 KB
/
Snakefile_fastq_multilane.alt_splicing
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
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
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
include:
#'configs/config_HuR.human.Penalva_L_01182017.py'
#'configs/config_HuR.mouse.py',
'configs/config_Feb_02_2017_Radiation_GBM.py'
#'configs/config_Penalva_L_01182017.human.py'
#'configs/config_Musashi1_Penalva_L_12212016.human.py'
workdir: OUT_DIR
from itertools import chain, combinations
from os.path import join
import glob
import re
"""
The idea behind this section is to get sample names and the corresponding lanes,
here I do it for filenames which look like this:
HepG2_Control_1_S7_L001_R1_001.fastq.gz
HepG2_Control_1_S7_L001_R2_001.fastq.gz
HepG2_Control_1_S7_L002_R1_001.fastq.gz
HepG2_Control_1_S7_L002_R2_001.fastq.gz
HepG2_Control_1_S7_L003_R1_001.fastq.gz
HepG2_Control_1_S7_L003_R2_001.fastq.gz
HepG2_Control_1_S7_L004_R1_001.fastq.gz
HepG2_Control_1_S7_L004_R2_001.fastq.gz
So the SAMPLE_NAME here is HepG2_Control_1_S7 which was sequenced(paired-end) in 4 lanes: L001-L004.
"""
SAMPLES = glob.glob('{}**/*.fastq.gz'.format(RAWDATA_DIR), recursive=True)
SAMPLE_LANE = []
for sample in SAMPLES:
sample = sample.replace('{}/'.format(RAWDATA_DIR),'')
sample_name = re.split(r'_L\d\d\d_', sample)[0]
lane_name = re.search(r'L\d\d\d', sample).group()
SAMPLE_LANE.append((sample_name, lane_name))
SAMPLE_LANE = set(SAMPLE_LANE)
SAMPLE_LANE = sorted(SAMPLE_LANE, key=lambda tup: tup[0])
SAMPLE_NAMES, LANE_NAMES = zip(*SAMPLE_LANE)
PLOT_PREFIXES = list(combinations(set(SAMPLE_NAMES), 2))
PLOT_PREFIXES_1 = [x[0] for x in PLOT_PREFIXES]
PLOT_PREFIXES_2 = [x[1] for x in PLOT_PREFIXES]
T24_SAMPLES = list(filter(lambda x: 'T24' in x, SAMPLE_NAMES))
T1_SAMPLES = list(filter(lambda x: 'T1' in x, SAMPLE_NAMES))
T0_SAMPLES = list(filter(lambda x: 'T0' in x, SAMPLE_NAMES))
rule all:
input:
STAR_INDEX,
expand('qc/{sample_name}_{lane}_R1_001_fastqc.html', zip, sample_name=SAMPLE_NAMES, lane=LANE_NAMES),
expand('qc/{sample_name}_{lane}_R2_001_fastqc.html', zip, sample_name=SAMPLE_NAMES, lane=LANE_NAMES),
expand('preprocessed/{sample_name}/{sample_name}_{lane}_R1_001_val_1.fq.gz', zip, sample_name=SAMPLE_NAMES, lane=LANE_NAMES),
expand('preprocessed/{sample_name}/{sample_name}_{lane}_R2_001_val_2.fq.gz', zip, sample_name=SAMPLE_NAMES, lane=LANE_NAMES),
expand('mapped/bams/{sample_name}/{sample_name}_{lane}.bam', zip, sample_name=SAMPLE_NAMES, lane=LANE_NAMES),
expand('mapped/merged_bams/{sample_name}.bam', sample_name=SAMPLE_NAMES),
#expand('mapped/plots/tpm_scatter/{sample1}_VS_{sample2}.png', sample1=PLOT_PREFIXES_1, sample2=PLOT_PREFIXES_2),
#expand('mapped/HTSeq-counts/{sample}.counts.tsv', sample=SAMPLE_NAMES),
#expand('mapped/intergenic_reads/{sample}.intergenic.bam', sample=SAMPLE_NAMES),
expand('inferred_experiment/{sample}.txt', sample=SAMPLE_NAMES),
#expand('mapped/counts_DEXSeq/{sample}.DEXSeq.counts.tsv', sample=SAMPLE_NAMES),
#expand('mapped/fpkm/{sample}.FPKM.xls', sample=SAMPLE_NAMES),
#'mapped/plots/tpm_scatter/',
#'mapped/tpm/HTSeq/masterTPM.tsv',
#'mapped/tpm/featureCounts/masterTPM.tsv',
#'mapped/DE_analysis/featureCounts/'+GENOME_BUILD+'.featureCounts.DESeq2.sig.tsv',
#'mapped/DE_analysis/HTSeq/'+GENOME_BUILD+'.HTSeq.DESeq2.all.tsv',
expand('mapped/HTSeq-counts/byCDS/{sample}.CDS.counts.tsv', sample=SAMPLE_NAMES),
expand('mapped/HTSeq-counts/byExon/{sample}.exon.counts.tsv', sample=SAMPLE_NAMES),
expand('mapped/dexseq/{sample}.dexseq.counts.tsv', sample=SAMPLE_NAMES),
#expand('mapped/rsem_bams/{sample_name}.bam', sample_name=SAMPLE_NAMES),
#expand('mapped/rsem-counts/{sample}.isoforms.results', sample=SAMPLE_NAMES),
'mapped/featureCounts/byCDS/fcounts.CDS.tsv',
'mapped/featureCounts/byExon/fcounts.exon.tsv',
'multiqc_report/multiqc_report.html',
'alternative_splicing_rMATS/All_T1_vs_T0/MATS_output/AS_Event.MATS.JunctionCountOnly.txt',
'alternative_splicing_rMATS/All_T24_vs_T0/MATS_output/AS_Event.MATS.JunctionCountOnly.txt',
'alternative_splicing_rMATS/All_T24_vs_T1/MATS_output/AS_Event.MATS.JunctionCountOnly.txt'
rule perform_qc:
input:
R1=RAWDATA_DIR+'/{sample_name}_{lane}_R1_001.fastq.gz',
R2=RAWDATA_DIR+'/{sample_name}_{lane}_R2_001.fastq.gz'
params:
out_dir = 'qc'
output:
'qc/{sample_name}_{lane}_R1_001_fastqc.html',
'qc/{sample_name}_{lane}_R1_001_fastqc.zip',
'qc/{sample_name}_{lane}_R2_001_fastqc.html',
'qc/{sample_name}_{lane}_R2_001_fastqc.zip',
shell:
r'''
fastqc -o {params.out_dir} -f fastq {input.R1} {input.R2}
'''
## rMATs requires the final read lengths to be same. So we take a simple strategy, rather than trimming
## only reads with adapters, we trim all reads for upto 13bp towards the 3' end (-13 and not 13).
## The other thing that needs to be done is to disable soft-clipping at the STAR mapping step by doing alignEndToEnd.
rule perfom_trimming:
input:
R1=RAWDATA_DIR+'/{sample_name}_{lane}_R1_001.fastq.gz',
R2=RAWDATA_DIR+'/{sample_name}_{lane}_R2_001.fastq.gz'
params:
out_dir='preprocessed/{sample_name}',
phred_cutoff=5
output:
'preprocessed/{sample_name}/{sample_name}_{lane}_R1_001_val_1.fq.gz',
'preprocessed/{sample_name}/{sample_name}_{lane}_R2_001_val_2.fq.gz',
shell:
r'''
cutadapt -u -13 -U -13 -o {output[0]} -p {output[1]} {input.R1} {input.R2}
'''
"""
shell:
r'''
trim_galore --paired -o {params.out_dir} -q {params.phred_cutoff} {input.R1} {input.R2}
'''
"""
"""This is optimised for >150bp reads:
--outFilterMultimapScoreRange 20 : the score range below the maximum score for multimapping alignments
--outFilterScoreMinOverLread 0 : alignment will output only if score is ghier than or equal to this value normalised for read length
--outFilterMatchNminOverLread 0.66 : alignment will output only if number of matched bases is higher than or equal to his value normalised for read length
--outFilterMismatchNmax 100 : increases the number of allowed mismatches to 100 - need to allow more mismatches for longer reads
--winAnchorMultimapNmax 200 : Maximum number of loci anchors are allowed to map
--seedPerReadNmax 100000 --seedPerWindowNmax 100 : increase the number of allowed seeds for each read and alignment window - need to store more seeds for longer reads
## Not used
--seedSearchStartLmax 30 : increases the number of seed search start position in the read - important for reads with high error rate
--seedSearchLmax 30 : similar to the above, limits the maximum length of the seeds. Presently, I do not recommend changing this parameter
--alignTranscriptsPerReadNmax 100000 --alignTranscriptsPerWindowNmax 10000 : increase the number of allowed alignments for each read and alignment window - need to store more putative alignments for longer reads
"""
rule map_starlong:
input:
R1='preprocessed/{sample_name}/{sample_name}_{lane}_R1_001_val_1.fq.gz',
R2='preprocessed/{sample_name}/{sample_name}_{lane}_R2_001_val_2.fq.gz',
index=STAR_INDEX
output: 'mapped/bams/{sample_name}/{sample_name}_{lane}.bam'
params:
prefix = 'mapped/bams/{sample_name}_{lane}',
unmapped = 'unmapped/fastq/{sample_name}_{lane}',
starlogs = 'mapped/starlogs'
threads: 16
shell:
r'''
STARlong --runThreadN {threads}\
--genomeDir {input.index}\
--outFileNamePrefix {params.prefix} --readFilesIn {input.R1} {input.R2}\
--outSAMtype BAM SortedByCoordinate\
--readFilesCommand zcat\
--outReadsUnmapped {params.unmapped}\
--outFilterMultimapScoreRange 20\
--outFilterScoreMinOverLread 0\
--outFilterMatchNminOverLread 0.66\
--outFilterMismatchNmax 100\
--winAnchorMultimapNmax 200\
--alignEndsType EndToEnd\
--seedPerReadNmax 100000 --seedPerWindowNmax 100\
&& mv {params.prefix}Aligned.sortedByCoord.out.bam {output} &&\
mkdir -p {params.starlogs} && mv {params.prefix}Log.final.out\
{params.prefix}Log.out {params.prefix}Log.progress.out {params.starlogs}
'''
## See: https://software.broadinstitute.org/gatk/guide/article?id=3060
## Merging should happen post alignment
rule merge_bams:
input: expand('mapped/bams/{{sample_name}}/{{sample_name}}_{lane}.bam', lane=set(LANE_NAMES))
output: 'mapped/merged_bams/{sample_name}.bam'
run:
cmd = ' -in '.join(input)
shell(r'''bamtools merge -in {cmd} -out {output}''')
rule sort_by_name:
input: 'mapped/merged_bams/{sample}.bam'
output: 'mapped/merged_bams/{sample}.sortedByName.bam'
shell:
r'''
samtools sort -on {input} -T /tmp/ -o {output}
'''
rule count:
input: 'mapped/merged_bams/{sample}.sortedByName.bam'
params:
annotation=GTF,
phred_cutoff=5
output: 'mapped/HTSeq-counts/byExon/{sample}.exon.counts.tsv'
shell:
r'''
source activate python2 && htseq-count --order=name --format=bam --mode=intersection-strict --stranded={HTSEQ_STRANDED} --minaqual={params.phred_cutoff} --type=exon --idattr=gene_id {input} {params.annotation} > {output}
'''
rule count_byCDS:
input: 'mapped/merged_bams/{sample}.sortedByName.bam'
params:
annotation=GTF,
phred_cutoff=5
output: 'mapped/HTSeq-counts/byCDS/{sample}.CDS.counts.tsv'
shell:
r'''
source activate python2 && htseq-count --order=name --format=bam --mode=intersection-strict --stranded={HTSEQ_STRANDED} --minaqual={params.phred_cutoff} --type=CDS --idattr=gene_id {input} {params.annotation} > {output}
'''
rule format_counts:
input: 'mapped/HTSeq-counts/{sample}.counts.tsv'
output: 'mapped/HTSeq-counts/{sample}.counts.noversion.tsv'
shell:
r'''
cat {input} | sed -E 's/\.[0-9]+//' > {output}
'''
rule infer_experiment:
input: 'mapped/merged_bams/{sample}.bam'
output: 'inferred_experiment/{sample}.txt'
shell:
r'''
source activate python2 && infer_experiment.py -r {GENE_BED_TSV} -i {input} 2>&1 > {output}
'''
rule run_deseq:
input: expand('mapped/HTSeq-counts/{sample}.counts.noversion.tsv', sample=SAMPLE_NAMES)
output:
'mapped/DE_analysis/HTSeq/'+GENOME_BUILD+'.HTSeq.DESeq2.all.tsv',
'mapped/DE_analysis/HTSeq/'+GENOME_BUILD+'.HTSeq.DESeq2.sig.tsv'
params:
basedir = 'mapped/HTSeq-counts/',
inprefix = 'counts.noversion',
gene_annotations = GENE_NAMES,
outprefix = 'mapped/DE_analysis/HTSeq/'+GENOME_BUILD+'.HTSeq'
shell:
r'''
Rscript {SRC_DIR}/do_DE_analysis.R --basedir={params.basedir} \
--gene_annotations={params.gene_annotations} \
--design_file={DESIGN_FILE} \
--outprefix={params.outprefix} \
--inprefix={params.inprefix}
'''
rule featurecounts:
input: expand('mapped/merged_bams/{sample}.sortedByName.bam', sample=set(SAMPLE_NAMES))
params:
annotation=GTF
output: 'mapped/featureCounts/byExon/fcounts.exon.tsv'
threads: 16
shell:
r'''featureCounts {FEATURECOUNTS_S} -a {params.annotation} -o {output} -t exon -g gene_id -Q 4 -T {threads} {input}'''
rule featurecounts_cds:
input: expand('mapped/merged_bams/{sample}.sortedByName.bam', sample=set(SAMPLE_NAMES))
params:
annotation=GTF
output: 'mapped/featureCounts/byCDS/fcounts.CDS.tsv'
threads: 16
shell:
r'''featureCounts {FEATURECOUNTS_S} -a {params.annotation} -o {output} -t CDS -g gene_id -Q 4 -T {threads} {input}'''
rule format_fcounts:
input: 'mapped/featureCounts/fcounts.tsv'
output: 'mapped/featureCounts/fcounts.noversion.tsv'
shell:
r'''
cat {input} | sed -E 's/\.[0-9]+//' > {output}
'''
output: 'mapped/featureCounts/fcounts.noversion.tsv'
rule run_deseq_featureCounts:
input: 'mapped/featureCounts/fcounts.noversion.tsv'
output:
'mapped/DE_analysis/featureCounts/'+GENOME_BUILD+'.featureCounts.DESeq2.all.tsv',
'mapped/DE_analysis/featureCounts/'+GENOME_BUILD+'.featureCounts.DESeq2.sig.tsv'
params:
gene_annotations = GENE_NAMES,
outprefix = 'mapped/DE_analysis/featureCounts/'+GENOME_BUILD+'.featureCounts'
shell:
r'''
Rscript {SRC_DIR}/do_DE_analysis_featureCounts.R --counts={input} \
--gene_annotations={params.gene_annotations} \
--design_file={DESIGN_FILE} \
--outprefix={params.outprefix}
'''
rule run_picardmetrics:
input: 'mapped/merged_bams/{sample}.bam'
output: 'mapped/bam_metrics/{sample}.metrics'
shell:
r'''
picard CollectInsertSizeMetrics I={input} H={output}.insertsize.pdf O={output}
'''
rule create_insertsize_tsv:
input: 'mapped/bam_metrics/{sample}.metrics'
output: 'mapped/bam_metrics/{sample}.insertsizes.tsv'
shell:
r'''
python {SRC_DIR}/collect_picard_metrics.py {input} {output}
'''
rule counts_to_tpm:
input:
count = expand('mapped/HTSeq-counts/{sample}.counts.noversion.tsv', sample=SAMPLE_NAMES),
insert_size = expand('mapped/bam_metrics/{sample}.insertsizes.tsv', sample=SAMPLE_NAMES),
output: 'mapped/tpm/HTSeq/masterTPM.tsv'
params:
gene_lengths=GENE_LENGTHS,
name=expand('{sample}', sample=set(SAMPLE_NAMES)),
outprefix='mapped/tpm/HTSeq',
gene_map=GENE_NAMES
run:
counts_input = (',').join(input.count)
sizes_input = (',').join(input.insert_size)
names = (',').join(params.name)
shell('Rscript {SRC_DIR}/counts_to_tpm.R --counts={counts_input} --insert_sizes={sizes_input} --gene_lengths={params.gene_lengths} --inprefix={names} --gene_map={params.gene_map} --outprefix={params.outprefix}')
rule featurecounts_to_tpm:
input:
insert_size = expand('mapped/bam_metrics/{sample}.insertsizes.tsv', sample=set(SAMPLE_NAMES)),
fcounts = 'mapped/featureCounts/fcounts.noversion.tsv'
output: 'mapped/tpm/featureCounts/masterTPM.tsv'
params:
gene_lengths=GENE_LENGTHS,
name=expand('{sample}', sample=set(SAMPLE_NAMES)),
outprefix='mapped/tpm/featureCounts',
gene_map=GENE_NAMES
run:
sizes_input = (',').join(input.insert_size)
names = (',').join(params.name)
shell('Rscript {SRC_DIR}/featurecounts_to_tpm.R --counts={input.fcounts} --insert_sizes={sizes_input} --gene_lengths={params.gene_lengths} --inprefix={names} --gene_map={params.gene_map} --outprefix={params.outprefix}')
rule plot_tpm:
input: 'mapped/tpm/HTSeq/masterTPM.tsv'
output: 'mapped/plots/tpm_scatter/'
params:
prefix = 'mapped/plots/tpm_scatter/'
shell:
r'''
export LC_ALL=en_US.UTF-8 && python {SRC_DIR}/plot_tpm_scatter.py --master {input} --outprefix {params.prefix}
'''
rule perform_qualimap_qc:
input: 'mapped/merged_bams/{sample}.bam',
output: 'mapped/post_mapping_qualimap/{sample}/qualimapReport.html',
params:
outdir='mapped/post_mapping_qualimap/{sample}',
gtf=GTF
shell:
r'''
qualimap rnaseq -bam {input} -gtf {params.gtf} --outdir {params.outdir} --java-mem-size=8G
'''
rule get_duplication_estimate:
input: 'mapped/merged_bams/{sample}.bam'
output: 'mapped/post_mapping_deduplication/{sample}/output.DupRate_plot.r'
params:
outprefix='mapped/post_mapping_deduplication/{sample}/output'
shell:
r'''
source activate python2 && read_duplication.py -i {input} -o {params.outprefix}
'''
rule run_multiqc:
input:
expand('qc/{sample_name}_{lane}_R1_001_fastqc.html', zip, sample_name=SAMPLE_NAMES, lane=LANE_NAMES),
expand('qc/{sample_name}_{lane}_R2_001_fastqc.html', zip, sample_name=SAMPLE_NAMES, lane=LANE_NAMES),
expand('mapped/bam_metrics/{sample}.metrics', sample=SAMPLE_NAMES),
expand('mapped/post_mapping_deduplication/{sample}/output.DupRate_plot.r', sample=SAMPLE_NAMES),
expand('mapped/post_mapping_qualimap/{sample}/qualimapReport.html', sample=SAMPLE_NAMES),
expand('mapped/merged_bams/{sample}.bam', sample=SAMPLE_NAMES),
#'mapped/DE_analysis/HTSeq/'+GENOME_BUILD+'.HTSeq.DESeq2.sig.tsv',
#'mapped/DE_analysis/featureCounts/'+GENOME_BUILD+'.featureCounts.DESeq2.sig.tsv',
output:
'multiqc_report/multiqc_report.html'
shell:
'export LC_ALL=en_US.UTF-8 && multiqc -f --outdir multiqc_report .'
rule extract_intergenic_reads:
input:
bam='mapped/merged_bams/{sample}.bam'
output: 'mapped/intergenic_reads/{sample}.intergenic.bam'
shell:
r'''
samtools index {input.bam} && samtools view -bhL {INTERGENIC_BED} > {output}
'''
rule count_dexseq:
input: 'mapped/merged_bams/{sample}.sortedByName.bam'
output: 'mapped/counts_DEXSeq/{sample}.DEXSeq.counts.tsv'
shell:
r'''
source activate python2 && python {SRC_DIR}/external/DEXSeq/dexseq_count.py -p yes -s {HTSEQ_STRANDED} -r name -f bam {DEXSeq_GFF} {input} {output}
'''
rule calc_fpkm:
input: 'mapped/merged_bams/{sample}.bam'
output: 'mapped/fpkm/{sample}.FPKM.xls'
params:
prefix='mapped/fpkm/{sample}'
shell:
r'''
source activate python2 && FPKM_count.py -i {input} -o {params.prefix} -r {GENE_BED}
'''
rule alt_t1t0:
input:
t1 = expand('mapped/merged_bams/{sample}.bam', sample=T1_SAMPLES),
t0 = expand('mapped/merged_bams/{sample}.bam', sample=T0_SAMPLES)
params:
outdir = 'alternative_splicing_rMATS/All_T1_vs_T0'
output: 'alternative_splicing_rMATS/All_T1_vs_T0/MATS_output/AS_Event.MATS.JunctionCountOnly.txt'
run:
b1 = ','.join(input.t0),
b2 = ','.join(input.t1)
gtf = GTF
star_index = STAR_INDEX
shell(r'''source activate python2 && python /home/cmb-panasas2/skchoudh/software_frozen/rMATS.3.2.5/RNASeq-MATS.py -b1 {b1} -b2 {b2} -t paired -len 138 -gtf {gtf} -bi {star_index} -o {params.outdir} 1>&2''')
rule alt_t24t0:
input:
t24 = expand('mapped/merged_bams/{sample}.bam', sample=T24_SAMPLES),
t0 = expand('mapped/merged_bams/{sample}.bam', sample=T0_SAMPLES)
params:
outdir = 'alternative_splicing_rMATS/All_T24_vs_T0'
output: 'alternative_splicing_rMATS/All_T24_vs_T0/MATS_output/AS_Event.MATS.JunctionCountOnly.txt'
run:
b1 = ','.join(input.t0),
b2 = ','.join(input.t24)
gtf = GTF
star_index = STAR_INDEX
shell(r'''source activate python2 && python /home/cmb-panasas2/skchoudh/software_frozen/rMATS.3.2.5/RNASeq-MATS.py -b1 {b1} -b2 {b2} -t paired -len 138 -gtf {gtf} -bi {star_index} -o {params.outdir} 1>&2''')
rule alt_t24t1:
input:
t1 = expand('mapped/merged_bams/{sample}.bam', sample=T1_SAMPLES),
t24 = expand('mapped/merged_bams/{sample}.bam', sample=T24_SAMPLES)
params:
outdir = 'alternative_splicing_rMATS/All_T24_vs_T1'
output: 'alternative_splicing_rMATS/All_T24_vs_T1/MATS_output/AS_Event.MATS.JunctionCountOnly.txt'
run:
b1 = ','.join(input.t1),
b2 = ','.join(input.t24)
gtf = GTF
star_index = STAR_INDEX
shell(r'''source activate python2 && python /home/cmb-panasas2/skchoudh/software_frozen/rMATS.3.2.5/RNASeq-MATS.py -b1 {b1} -b2 {b2} -t paired -len 138 -gtf {gtf} -bi {star_index} -o {params.outdir} 1>&2''')
rule rsem_bams:
input: 'mapped/merged_bams/{sample}.bam'
output: 'mapped/rsem_bams/{sample}.bam'
params:
prefix = 'mapped/rsem_bams/{sample}'
shell:
r'''convert-sam-for-rsem {input} {params.prefix}'''
rule rsem_counts:
input: 'mapped/rsem_bams/{sample}.bam'
params:
annotation=GTF,
prefix='mapped/rsem-counts/{sample}'
output: 'mapped/rsem-counts/{sample}.isoforms.results'
threads: 16
shell:
r'''
rsem-calculate-expression --paired-end --bam -p {threads} {input} {RSEM_INDEX} {params.prefix}
'''
rule prepare_annotation_for_dexseq:
input: GTF
output: 'mapped/dexseq/gencode.v25.annotation.DEXSeq.gff'
shell:
r'''source activate python2 && python /panfs/cmb-panasas2/skchoudh/software_frozen/anaconda27/envs/python2/lib/R/library/DEXSeq/python_scripts/dexseq_prepare_annotation.py {input} {output}
'''
rule run_dexseq:
input:
bam='mapped/merged_bams/{sample}.bam',
gff='mapped/dexseq/gencode.v25.annotation.DEXSeq.gff'
output:
'mapped/dexseq/{sample}.dexseq.counts.tsv'
shell:
r'''source activate python2 && python /panfs/cmb-panasas2/skchoudh/software_frozen/anaconda27/envs/python2/lib/R/library/DEXSeq/python_scripts/dexseq_count.py -f bam -s no -p yes -r name {input.gff} {input.bam} {output}
'''