Skip to content

Commit

Permalink
Fix missing rule all for PIQ and motif dictionary
Browse files Browse the repository at this point in the history
  • Loading branch information
rdalbanus committed Sep 26, 2019
1 parent f67d36f commit 1c1cb02
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 22 deletions.
19 changes: 17 additions & 2 deletions analyses/1e_bmo/Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,21 @@ VERSION_DIR = join(RESULTS, "versions")
# will be used to determine the output files for each sample
subsample_depths = {x: subsampled_depths_from_sample(x) for x in get_samples()}

# Number of motifs and motif-number dictionary - used for PIQ
# e.g. 9-CTCFknown2, 20-NFKBknown10
# Wildcards
motifs = get_motifs()
motifs = list(set(motifs)) # remove duplicates
motifs.sort()
nmotifs = len(motifs)
motif_dic = {}
motif_handle_dic = {}
for i in range(0, nmotifs):
motif = motifs[i]
handle = "{}-{}".format(i + 1, motifs[i].replace("_", "").replace(".", ""))
motif_dic[motif] = str(i + 1)
motif_handle_dic[motif] = handle


rule all:
input:
Expand Down Expand Up @@ -180,7 +195,7 @@ rule all:
),
sample=sample,
depth=depths,
motif=get_motifs()
motif=motifs
) for sample, depths in subsample_depths.items()],
# PIQ - scores files
[expand(
Expand All @@ -190,7 +205,7 @@ rule all:
),
sample=sample,
depth=depths,
motif=get_motifs()
motif=motifs
) for sample, depths in subsample_depths.items()],

# Motifs in peaks (binary)
Expand Down
17 changes: 3 additions & 14 deletions analyses/1e_bmo/rules/tf-binding_piq.smk
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ rule gather_motifs:
input:
expand(
os.path.join(PIQ_DIR, "motifs", "{motif}.jaspar"),
motif=get_motifs()
motif=motifs
)
output:
mat = os.path.join(PIQ_DIR, "motifs", "matrices.txt")
Expand All @@ -42,19 +42,8 @@ rule gather_motifs:
cat {input} > {output.mat}
"""

rule pwm_key:
input:
rules.gather_motifs.output,
output:
os.path.join(PIQ_DIR, "motifs", "key.txt")
shell:
"""
grep "^>" {input} | sed 's/^>//g' > tmp.keys.txt
sed 's/_//g' tmp.keys.txt > tmp.keys2.txt
paste tmp.keys.txt tmp.keys2.txt | cat -n > {output} && \
rm tmp.keys*txt
"""

# Note that variable i is defined in rule piq, but snakemake
# is able to propagate it bottom-up
rule pwm_scan:
input:
mat = os.path.join(PIQ_DIR, "motifs", "matrices.txt"),
Expand Down
31 changes: 26 additions & 5 deletions analyses/1e_bmo/rules_hepg2/Snakefile.smk
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,15 @@ subsample_depths = {x: subsampled_depths_from_sample(x) for x in get_samples()}

# Number of motifs and motif-number dictionary - used for PIQ
# e.g. 9-CTCFknown2, 20-NFKBknown10
all_motifs = [x for x in get_motifs()]
all_motifs.sort()
nmotifs = len(all_motifs)
motifs = get_motifs()
motifs = list(set(motifs)) # remove duplicates
motifs.sort()
nmotifs = len(motifs)
motif_dic = {}
motif_handle_dic = {}
for i in range(0, nmotifs):
motif = all_motifs[i]
handle = "{}-{}".format(i + 1, all_motifs[i].replace("_", ""))
motif = motifs[i]
handle = "{}-{}".format(i + 1, motifs[i].replace("_", "").replace(".", ""))
motif_dic[motif] = str(i + 1)
motif_handle_dic[motif] = handle

Expand Down Expand Up @@ -240,6 +241,26 @@ rule all:
depth=depths,
motif=get_motifs()
) for sample, depths in subsample_depths.items()],
# PIQ - binarized files
[expand(
os.path.join(
PIQ_DIR,
"processed_output_binary", "{sample}", "{depth}M.{motif}.bed"
),
sample=sample,
depth=depths,
motif=motifs
) for sample, depths in subsample_depths.items()],
# PIQ - scores files
[expand(
os.path.join(
PIQ_DIR,
"processed_output_scores", "{sample}", "{depth}M.{motif}.bed"
),
sample=sample,
depth=depths,
motif=motifs
) for sample, depths in subsample_depths.items()],
# Motifs in peaks
[expand(
os.path.join(PEAKS_DIR, "{sample}", "{motif}.{depth}.bed"),
Expand Down
4 changes: 3 additions & 1 deletion analyses/1e_bmo/rules_hepg2/tf-binding_piq.smk
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ rule gather_motifs:
input:
expand(
os.path.join(PIQ_DIR, "motifs", "{motif}.jaspar"),
motif=get_motifs()
motif=motifs
)
output:
mat = os.path.join(PIQ_DIR, "motifs", "matrices.txt")
Expand All @@ -55,6 +55,8 @@ rule pwm_key:
rm tmp.keys*txt
"""

# Note that variable i is defined in rule piq, but snakemake
# is able to propagate it bottom-up
rule pwm_scan:
input:
mat = os.path.join(PIQ_DIR, "motifs", "matrices.txt"),
Expand Down

0 comments on commit 1c1cb02

Please sign in to comment.