|
a |
|
b/exseek/snakefiles/differential_expression.snakemake |
|
|
1 |
include: 'common.snakemake' |
|
|
2 |
|
|
|
3 |
compare_groups = config['compare_groups'] |
|
|
4 |
|
|
|
5 |
def get_all_inputs(wildcards): |
|
|
6 |
inputs = [] |
|
|
7 |
inputs += expand('{output_dir}/differential_expression/{count_method}/{compare_group}/{diffexp_method}.txt', |
|
|
8 |
output_dir=output_dir, count_method=config['count_method'], compare_group=compare_groups, diffexp_method=config['diffexp_method']) |
|
|
9 |
if has_batch_info: |
|
|
10 |
inputs += expand('{output_dir}/differential_expression_with_batch/{batch_index}/{count_method}/{compare_group}/{diffexp_method}.txt', |
|
|
11 |
output_dir=output_dir, batch_index=config['batch_index'], count_method=config['count_method'], compare_group=compare_groups, diffexp_method=config['diffexp_method']) |
|
|
12 |
return inputs |
|
|
13 |
|
|
|
14 |
rule all: |
|
|
15 |
input: |
|
|
16 |
get_all_inputs |
|
|
17 |
|
|
|
18 |
rule differential_expression: |
|
|
19 |
input: |
|
|
20 |
matrix='{output_dir}/matrix_processing/filter.{count_method}.txt', |
|
|
21 |
classes=data_dir + '/sample_classes.txt' |
|
|
22 |
output: |
|
|
23 |
'{output_dir}/differential_expression/{count_method}/{compare_group}/{diffexp_method}.txt' |
|
|
24 |
params: |
|
|
25 |
positive_class=lambda wildcards: compare_groups[wildcards.compare_group][1], |
|
|
26 |
negative_class=lambda wildcards: compare_groups[wildcards.compare_group][0] |
|
|
27 |
shell: |
|
|
28 |
'''{bin_dir}/differential_expression.R \ |
|
|
29 |
-i {input.matrix} --classes {input.classes} \ |
|
|
30 |
--method {wildcards.diffexp_method} \ |
|
|
31 |
--positive-class "{params.positive_class}" \ |
|
|
32 |
--negative-class "{params.negative_class}" \ |
|
|
33 |
-o {output} |
|
|
34 |
''' |
|
|
35 |
|
|
|
36 |
rule differential_expression_with_batch: |
|
|
37 |
input: |
|
|
38 |
matrix='{output_dir}/matrix_processing/filter.{count_method}.txt', |
|
|
39 |
classes=data_dir + '/sample_classes.txt', |
|
|
40 |
batch_info=data_dir + '/batch_info.txt' |
|
|
41 |
output: |
|
|
42 |
'{output_dir}/differential_expression_with_batch/{batch_index}/{count_method}/{compare_group}/{diffexp_method}.txt' |
|
|
43 |
params: |
|
|
44 |
positive_class=lambda wildcards: compare_groups[wildcards.compare_group][1], |
|
|
45 |
negative_class=lambda wildcards: compare_groups[wildcards.compare_group][0], |
|
|
46 |
batch_index=config['batch_index'] |
|
|
47 |
shell: |
|
|
48 |
'''{bin_dir}/differential_expression.R \ |
|
|
49 |
-i {input.matrix} --classes {input.classes} \ |
|
|
50 |
--method {wildcards.diffexp_method} \ |
|
|
51 |
--positive-class "{params.positive_class}" \ |
|
|
52 |
--negative-class "{params.negative_class}" \ |
|
|
53 |
--batch {input.batch_info} --batch-index {wildcards.batch_index} \ |
|
|
54 |
-o {output} |
|
|
55 |
''' |