forked from hkawaji/dpi1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
identify_tss_peaks.smk
72 lines (62 loc) · 2.6 KB
/
identify_tss_peaks.smk
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
from snakemake.utils import validate, min_version
import itertools
import pandas as pd
##### set minimum snakemake version #####
min_version("5.20.0")
##### load config and sample sheets #####
configfile: "config/config.yaml"
validate(config, schema="schemas/config.schema.yaml")
samples = pd.read_table(config["samples"],sep="\t")
##### target rules #####
def get_input(wildcards):
if config["analysis"] == "spi":
robust = "{pdir}/outPooled/tc.spi.merged.ctssMaxCounts{robust}.ctssMaxTpm{tpm}.bed.gz".format(
pdir=config['directory'],
robust=config['cutoff']['robust'],
tpm=config['cutoff']['tpm'])
permissive = "{pdir}/outPooled/tc.spi.merged.ctssMaxCounts{permissive}.bed.gz".format(
pdir=config['directory'],
permissive=config['cutoff']['permissive'])
return [robust, permissive]
elif config["analysis"] == "dpi":
robust = "{pdir}/outPooled/tc.decompose_smoothing_merged.ctssMaxCounts{robust}.ctssMaxTpm{tpm}.bed.gz".format(
pdir=config['directory'],
robust=config['cutoff']['robust'],
tpm=config['cutoff']['tpm'])
permissive = "{pdir}/outPooled/tc.decompose_smoothing_merged.ctssMaxCounts{permissive}.bed.gz".format(
pdir=config['directory'],
permissive=config['cutoff']['permissive'])
allout = expand("{pdir}/outPooled/tc.long.decompose_smoothing.component{n}_ctss.{strand}.bedGraph.gz",
pdir=config['directory'],
strand=['fwd', 'rev'],
n=range(1, config['split']['n_comp_upper_bound'] + 1))
allout.append(robust)
allout.append(permissive)
return allout
else:
raise ValueError("config['analysis'] should be 'spi' or 'dpi'; provided {}".format(config['analysis']))
rule all:
input:
get_input
#"_test/snakemake/outPooled/tc.long/aaaaa"
##### setup report #####
#report: "report/workflow.rst"
##### load rules #####
### prepare bigWig files for individual samples
include: "rules/bigwig.smk"
### pool ctss across samples: total counts, max counts and tpm
include: "rules/pool.smk"
### prepare tag clusters
include: "rules/tagcluster.smk"
### split tag cluster into long and short for decomposition
include: "rules/split_tagclusters.smk"
if config["analysis"] == 'spi':
### simple smoothing without decomposition
include: "rules/smoothing_simple.smk"
### thresholding
include: "rules/thresholding_simple.smk"
if config["analysis"] == 'dpi':
### decomposition and smoothing
include: "rules/smoothing.smk"
### thresholding
include: "rules/thresholding.smk"