Verified Commit dfd2bd7d authored by Aurélien Ginolhac's avatar Aurélien Ginolhac 🚴
Browse files

bugfixes in individual peak type

parent a97de040
...@@ -99,11 +99,16 @@ def get_sample_control_peak_combinations_list(): ...@@ -99,11 +99,16 @@ def get_sample_control_peak_combinations_list():
return sam_contr return sam_contr
def get_peak_combinations_list(): def get_peak_combinations_list():
peak_contr = [] peak_type = []
for sample in samples.index: for peak_file in get_sample_control_peak_combinations_list():
if not is_control(sample): try:
sam_contr.extend(expand(["{peak}"], peak = samples.loc[sample]["peak-analysis"])) found = re.search('\.(.+?)_peaks', peak_file).group(1)
return peak_contr peak_type.append(found)
except AttributeError:
found = ''
finally:
peak_type.append(found)
return peak_type
def get_peaks_count_plot_input(): def get_peaks_count_plot_input():
return expand( return expand(
...@@ -117,11 +122,11 @@ def get_peaks_output(): ...@@ -117,11 +122,11 @@ def get_peaks_output():
if not is_control(sample): if not is_control(sample):
if samples.loc[sample]["peak-analysis"] == "broad": if samples.loc[sample]["peak-analysis"] == "broad":
peak_out.extend(expand(["results/macs2_callpeak/{sample}-{control}.{peak}_peaks.gappedPeak"], sample = sample, control = samples.loc[sample]["control"], peak = samples.loc[sample]["peak-analysis"])) peak_out.extend(expand(["results/macs2_callpeak/{sample}-{control}.{peak}_peaks.gappedPeak"], sample = sample, control = samples.loc[sample]["control"], peak = samples.loc[sample]["peak-analysis"]))
if samples.loc[sample]["peak-analysis"] == "nrrow": elif samples.loc[sample]["peak-analysis"] == "narrow":
peak_out.extend(expand(["results/macs2_callpeak/{sample}-{control}.{peak}_summits.bed"], sample = sample, control = samples.loc[sample]["control"], peak = samples.loc[sample]["peak-analysis"])) peak_out.extend(expand(["results/macs2_callpeak/{sample}-{control}.{peak}_summits.bed"], sample = sample, control = samples.loc[sample]["control"], peak = samples.loc[sample]["peak-analysis"]))
else: else:
raise ValueError( raise ValueError(
f"for {sample}, peak-analysis must be either narrow or broad (not {samples.loc[sample]["peak-analysis"]}\n" f"for {sample}, peak-analysis must be either narrow or broad (not {samples.loc[sample]['peak-analysis']})\n"
) )
return peak_out return peak_out
...@@ -132,10 +137,11 @@ def get_frip_score_input(): ...@@ -132,10 +137,11 @@ def get_frip_score_input():
) )
def get_macs2_peaks(): def get_macs2_peaks():
return expand( sam_contr = []
"results/macs2_callpeak/{sam_contr_peak}_peaks.{peak}Peak", for sample in samples.index:
sam_contr_peak = get_sample_control_peak_combinations_list(), peak = get_peak_combinations_list() if not is_control(sample):
) sam_contr.extend(expand(["results/macs2_callpeak/{sample}-{control}.{peak}_peaks.{peak}Peak"], sample = sample, control = samples.loc[sample]["control"], peak = samples.loc[sample]["peak-analysis"]))
return sam_contr
def get_plot_homer_annotatepeaks_input(): def get_plot_homer_annotatepeaks_input():
return expand("results/homer/annotate_peaks/{sam_contr_peak}_peaks.annotatePeaks.txt", return expand("results/homer/annotate_peaks/{sam_contr_peak}_peaks.annotatePeaks.txt",
...@@ -225,7 +231,7 @@ def get_files_for_igv(): ...@@ -225,7 +231,7 @@ def get_files_for_igv():
"results/macs2_merged_expand/{antibody}.consensus_{peak}-peaks.boolean.bed" "results/macs2_merged_expand/{antibody}.consensus_{peak}-peaks.boolean.bed"
], ],
sample_control_peak=get_sample_control_peak_combinations_list(), sample_control_peak=get_sample_control_peak_combinations_list(),
peak=get_peak_combinations_list() peak=get_peak_combinations_list(),
antibody=get_unique_antibodies() antibody=get_unique_antibodies()
) )
) )
...@@ -351,8 +357,7 @@ def all_input(wildcards): ...@@ -351,8 +357,7 @@ def all_input(wildcards):
# QC with fastQC and multiQC, igv session # QC with fastQC and multiQC, igv session
wanted_input.extend([ wanted_input.extend([
"results/qc/multiqc/multiqc.html", "results/qc/multiqc/multiqc.html"
"results/IGV/igv_session.xml"
]) ])
# trimming reads # trimming reads
...@@ -461,7 +466,7 @@ def all_input(wildcards): ...@@ -461,7 +466,7 @@ def all_input(wildcards):
"results/macs2_callpeak/{sample}-{control}.{peak}_control_lambda.bdg", "results/macs2_callpeak/{sample}-{control}.{peak}_control_lambda.bdg",
"results/macs2_callpeak/{sample}-{control}.{peak}_peaks.{peak}Peak", "results/macs2_callpeak/{sample}-{control}.{peak}_peaks.{peak}Peak",
"results/macs2_callpeak/plots/plot_{peak}_peaks_count.pdf", "results/macs2_callpeak/plots/plot_{peak}_peaks_count.pdf",
"results/macs2_callpeak/plots/plot_{peak}_peaks_frip_score.pdf", #"results/macs2_callpeak/plots/plot_{peak}_peaks_frip_score.pdf",
"results/macs2_callpeak/plots/plot_{peak}_peaks_macs2.pdf" "results/macs2_callpeak/plots/plot_{peak}_peaks_macs2.pdf"
], ],
sample = sample, sample = sample,
...@@ -470,5 +475,5 @@ def all_input(wildcards): ...@@ -470,5 +475,5 @@ def all_input(wildcards):
antibody = samples.loc[sample]["antibody"] antibody = samples.loc[sample]["antibody"]
) )
) )
wanted_input.extend(get_peaks_output())samples.loc[sample]["peak-analysis"] wanted_input.extend(get_peaks_output())
return wanted_input return wanted_input
...@@ -38,6 +38,7 @@ rule mark_merged_duplicates: ...@@ -38,6 +38,7 @@ rule mark_merged_duplicates:
metrics="results/picard_dedup/{sample}.metrics.txt" metrics="results/picard_dedup/{sample}.metrics.txt"
log: log:
"logs/picard/picard_dedup/{sample}.log" "logs/picard/picard_dedup/{sample}.log"
threads: 2
params: params:
"REMOVE_DUPLICATES=false ASSUME_SORTED=true VALIDATION_STRINGENCY=LENIENT" "REMOVE_DUPLICATES=false ASSUME_SORTED=true VALIDATION_STRINGENCY=LENIENT"
wrapper: wrapper:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment