Skip to content
This repository has been archived by the owner. It is now read-only.

Commit

Permalink
Fixed incorrect sorting of bound/unbound; Removed heatmap comparison …
Browse files Browse the repository at this point in the history
…within conditions
  • Loading branch information
msbentsen committed Jan 4, 2019
1 parent a6fb466 commit 80bf5e4
Show file tree
Hide file tree
Showing 10 changed files with 11,490 additions and 11,509 deletions.
27 changes: 5 additions & 22 deletions snakemake_pipeline/TOBIAS.snake
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ for file in files:
TF_IDS = list(MOTIF_FILES.keys())


#---------------------------- OUTPUT PER CONDITION -----------------------------#
#----------------------------------- OUTPUT -----------------------------------#

id2bam = {condition:{} for condition in CONDITION_IDS}

Expand All @@ -124,13 +124,12 @@ for condition in CONDITION_IDS:
id2bam[condition] = {sampleids[i]:config_bams[i] for i in range(len(sampleids))} # Link sample ids to bams


PLOTNAMES = expand("{condition}_{plotname}", condition=CONDITION_IDS, plotname=["heatmap", "aggregate"])
PLOTNAMES = expand("{condition}_{plotname}", condition=CONDITION_IDS, plotname=["aggregate"])
if len(CONDITION_IDS) > 1:
PLOTNAMES.extend(["heatmap_comparison", "aggregate_comparison"])
PLOTNAMES.extend(["heatmap_comparison", "aggregate_comparison_all", "aggregate_comparison_bound"])

output_files.append(expand(os.path.join(OUTPUTDIR, "footprinting", "{condition}_footprints.bw"), condition=CONDITION_IDS))

#output_files.append(os.path.join(OUTPUTDIR, "overview", "TFBS_distance.txt"))
output_files.append(os.path.join(OUTPUTDIR, "TFBS", "bindetect_results.txt"))
output_files.append(os.path.join(OUTPUTDIR, "overview", "bindetect_results.txt"))

Expand All @@ -139,21 +138,6 @@ output_files.extend(expand(os.path.join(OUTPUTDIR, "TFBS", "{TF}", "plots", "{TF
output_files.extend(expand(os.path.join(OUTPUTDIR, "overview", "all_{plotname}.pdf"), plotname=PLOTNAMES))


#-------------------------- OUTPUT ACROSS CONDITIONS ---------------------------#

"""
COMPARE_COND = 0
if len(CONDITION_IDS) > 1:
COMPARE_COND = 1 # flag
output_files.extend(expand(os.path.join(OUTPUTDIR, "TFBS", "{TF}", "plots", "{TF}_heatmap_comparison.pdf"), TF=TF_IDS))
output_files.extend(expand(os.path.join(OUTPUTDIR, "TFBS", "{TF}", "plots", "{TF}_aggregate_comparison.pdf"), TF=TF_IDS))
#output_files.extend([os.path.join(OUTPUTDIR, "overview", "diff_bind_plot.pdf")])

"""
#-------------------------------- OTHER OUTPUT ---------------------------------#




#-------------------------------------------------------------------------------#
#--------------------- WHICH SNAKE MODULES SHOULD BE USED? ---------------------#
Expand All @@ -164,12 +148,11 @@ include: "snakefiles/footprinting.snake"
include: "snakefiles/visualization.snake"



#-------------------------------------------------------------------------------#
#------------------------ DEAL WITH SPECIAL ENVIRONMENTS -----------------------#
#-------------------------------------------------------------------------------#

"""

sys_env = subprocess.check_output(['conda', 'env', 'list'], universal_newlines=True)
env_list = [line.split()[0] for line in sys_env.split("\n") if len(line.split()) > 0]

Expand All @@ -183,7 +166,7 @@ if "MACS_ENV" not in env_list:
print("Creating macs environment for the first time")
subprocess.call(["conda", "env", "create", "--file", "environments/macs.yaml"])

"""

#-------------------------------------------------------------------------------#
#---------------------------------- RUN :-) ------------------------------------#
#-------------------------------------------------------------------------------#
Expand Down
18 changes: 8 additions & 10 deletions snakemake_pipeline/snakefiles/visualization.snake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#----------------------------------------------------------------#
#---------------------------- Heatmaps --------------------------#
#----------------------------------------------------------------#

"""
#Heatmaps split in bound/unbound within conditions
rule plot_heatmaps_within:
input:
Expand All @@ -16,7 +16,7 @@ rule plot_heatmaps_within:
"--title '{TF} heatmap'",
shell:
"TOBIAS PlotHeatmap --TFBS {input.beds} --signals {input.tracks} --output {output.heatmap} {params} >/dev/null"

"""

#Heatmaps across conditions
rule plot_heatmaps_across:
Expand Down Expand Up @@ -44,8 +44,7 @@ rule plot_heatmaps_across:
rule plot_aggregate_within:
input:
TFBS = [os.path.join(OUTPUTDIR, "TFBS", "{TF}", "beds", "{TF}_all.bed")] + [os.path.join(OUTPUTDIR, "TFBS", "{TF}", "beds", "{TF}_{condition}_" + state + ".bed") for state in ["bound", "unbound"]],
signals = [os.path.join(OUTPUTDIR, "bias_correction", "{condition}_" + state + ".bw") for state in ["uncorrected", "bias", "expected", "corrected"]],
#whitelist = os.path.join(OUTPUTDIR, "peaks", condition + "_union.bed")
signals = [os.path.join(OUTPUTDIR, "bias_correction", "{condition}_" + state + ".bw") for state in ["uncorrected", "expected", "corrected"]],
output:
os.path.join(OUTPUTDIR, "TFBS", "{TF}", "plots", "{TF}_{condition}_aggregate.pdf")
message: "Plotting split between bound/unbound around TFBS for TF \"{wildcards.TF}\" in condition \"{wildcards.condition}\""
Expand All @@ -57,25 +56,24 @@ rule plot_aggregate_within:
"TOBIAS PlotAggregate --TFBS {input.TFBS} --signals {input.signals} --output {output} {params} >/dev/null "


#Aggregates across conditions
#Aggregates across conditions for all and for bound subsets
rule plot_aggregate_across:
input:
TFBS_all = os.path.join(OUTPUTDIR, "TFBS", "{TF}", "beds", "{TF}_all.bed"),
TFBS_bound = expand(os.path.join(OUTPUTDIR, "TFBS", "{{TF}}", "beds", "{{TF}}_{condition}_bound.bed"), condition=CONDITION_IDS),
signals = expand(os.path.join(OUTPUTDIR, "bias_correction", "{condition}_corrected.bw"), condition=CONDITION_IDS),
#regions = os.path.join(OUTPUTDIR, "peaks", condition + "_union.bed") #[os.path.join(OUTPUTDIR, "peaks", condition + "_union.bed") for condition in CONDITION_IDS]
output:
all_compare = os.path.join(OUTPUTDIR, "TFBS", "{TF}", "plots", "{TF}_aggregate_comparison.pdf"),
#bound_compare = os.path.join(OUTPUTDIR, "TFBS", "{TF}", "plots", "{TF}_aggregate_comparison_bound.pdf")
all_compare = os.path.join(OUTPUTDIR, "TFBS", "{TF}", "plots", "{TF}_aggregate_comparison_all.pdf"),
bound_compare = os.path.join(OUTPUTDIR, "TFBS", "{TF}", "plots", "{TF}_aggregate_comparison_bound.pdf")
priority: 2
params:
"--title {0}".format("{TF}"),
"--plot_boundaries",
"--share_y both",
message: "Plotting comparison of cutsite signals for \"{wildcards.TF}\" between conditions"
shell:
"TOBIAS PlotAggregate --TFBS {input.TFBS_all} {input.TFBS_bound} --signals {input.signals} --output {output.all_compare} {params} >/dev/null"
#"TOBIAS PlotAggregate --TFBS {input.TFBS_bound} --signals {input.signals} --output {output.bound_compare} {params};"
"TOBIAS PlotAggregate --TFBS {input.TFBS_all} --signals {input.signals} --output {output.all_compare} {params} >/dev/null; "
"TOBIAS PlotAggregate --TFBS {input.TFBS_bound} --signals {input.signals} --output {output.bound_compare} {params} >/dev/null;"


#----------------------------------------------------------------#
Expand Down
Loading

0 comments on commit 80bf5e4

Please sign in to comment.