1
- from snakemake .logging import logger
2
-
3
1
if config ["peak_calling_perl" ]["run" ]:
4
2
fdr = config ["peak_calling_perl" ]["fdr" ]
5
3
rule peak_calling_perl :
@@ -71,7 +69,7 @@ if config["peak_calling_macs2"]["run"]:
71
69
resources :
72
70
runtime = config ["resources" ]["deeptools" ]["time" ]
73
71
log :
74
- "logs/consensus_peaks_macs2_narrow_fdr {fdr}/{bg_sample}.log"
72
+ "logs/consensus_peaks_macs2_narrow/fdr {fdr}/{bg_sample}.log"
75
73
conda :
76
74
"../envs/peak_calling.yaml"
77
75
shell :
@@ -113,7 +111,7 @@ if config["peak_calling_macs2"]["run"]:
113
111
resources :
114
112
runtime = config ["resources" ]["plotting" ]["time" ]
115
113
log :
116
- "logs/plotting/macs2_narrow_peak_annotation_plots_fdr {fdr}.log"
114
+ "logs/plotting/macs2_narrow_peak_annotation_plots/fdr {fdr}.log"
117
115
conda :
118
116
"../envs/R.yaml"
119
117
script :
@@ -130,7 +128,7 @@ if config["peak_calling_macs2"]["run"]:
130
128
params :
131
129
extra = ""
132
130
log :
133
- "logs/annotate_peaks_macs2_narrow_fdr {fdr}/{bg_sample}.log"
131
+ "logs/annotate_peaks_macs2_narrow/fdr {fdr}/{bg_sample}.log"
134
132
threads : config ["resources" ]["deeptools" ]["cpu" ]
135
133
resources :
136
134
runtime = config ["resources" ]["deeptools" ]["time" ]
@@ -293,7 +291,7 @@ if config["peak_calling_macs2"]["run"]:
293
291
resources :
294
292
runtime = config ["resources" ]["deeptools" ]["time" ]
295
293
log :
296
- "logs/consensus_peaks_macs2_broad_fdr {fdr}/{bg_sample}.log"
294
+ "logs/consensus_peaks_macs2_broad/fdr {fdr}/{bg_sample}.log"
297
295
conda :
298
296
"../envs/peak_calling.yaml"
299
297
shell :
@@ -421,55 +419,55 @@ if config["peak_calling_macs2"]["run"]:
421
419
"../scripts/plot_enrichment.R"
422
420
423
421
424
- rule count_reads_in_peaks :
425
- # Adapted from https://www.biostars.org/p/337872/#337890
426
- input :
427
- bam = "results/bam/{dir}/{bg_sample}.bam" ,
428
- b = "results/macs2_broad/fdr{fdr}/{dir}/{bg_sample}_peaks.broadPeak" ,
429
- output :
430
- total_read_count = "results/macs2_broad/fdr{fdr}/read_counts/{dir}/{bg_sample}.total.count" ,
431
- peak_read_count = "results/macs2_broad/fdr{fdr}/read_counts/{dir}/{bg_sample}.peak.count" ,
432
- params :
433
- extra = "" ,
434
- threads : config ["resources" ]["deeptools" ]["cpu" ]
435
- resources :
436
- runtime = config ["resources" ]["deeptools" ]["time" ]
437
- log :
438
- "logs/bedtools_intersect/fdr{fdr}/{dir}/{bg_sample}.log"
439
- conda :
440
- "../envs/peak_calling.yaml"
441
- shell :
442
- "bedtools bamtobed "
443
- "{params.extra} "
444
- "-i {input.bam} | "
445
- "sort -k1,1 -k2,2n | "
446
- "tee >(wc -l > {output.total_read_count}) | "
447
- "bedtools intersect "
448
- "{params.extra} "
449
- "-sorted "
450
- "-c "
451
- "-a {input.b} "
452
- "-b stdin | "
453
- "awk '{{i+=$NF}}END{{print i}}' > "
454
- "{output.peak_read_count} "
455
- "{log}"
456
-
422
+ rule count_reads_in_peaks :
423
+ # Adapted from https://www.biostars.org/p/337872/#337890
424
+ input :
425
+ bam = "results/bam/{dir}/{bg_sample}.bam" ,
426
+ b = "results/macs2_broad/fdr{fdr}/{dir}/{bg_sample}_peaks.broadPeak" ,
427
+ output :
428
+ total_read_count = "results/macs2_broad/fdr{fdr}/read_counts/{dir}/{bg_sample}.total.count" ,
429
+ peak_read_count = "results/macs2_broad/fdr{fdr}/read_counts/{dir}/{bg_sample}.peak.count" ,
430
+ params :
431
+ extra = "" ,
432
+ threads : config ["resources" ]["deeptools" ]["cpu" ]
433
+ resources :
434
+ runtime = config ["resources" ]["deeptools" ]["time" ]
435
+ log :
436
+ "logs/bedtools_intersect/fdr{fdr}/{dir}/{bg_sample}.log"
437
+ conda :
438
+ "../envs/peak_calling.yaml"
439
+ shell :
440
+ "bedtools bamtobed "
441
+ "{params.extra} "
442
+ "-i {input.bam} | "
443
+ "sort -k1,1 -k2,2n | "
444
+ "tee >(wc -l > {output.total_read_count}) | "
445
+ "bedtools intersect "
446
+ "{params.extra} "
447
+ "-sorted "
448
+ "-c "
449
+ "-a {input.b} "
450
+ "-b stdin | "
451
+ "awk '{{i+=$NF}}END{{print i}}' > "
452
+ "{output.peak_read_count} "
453
+ # "{log}"
454
+
457
455
458
- rule plot_fraction_of_reads_in_peaks :
459
- input :
460
- total_read_count = expand ("results/macs2_broad/fdr{fdr}/read_counts/{dir}/{bg_sample}.total.count" , dir = DIRS , fdr = fdr , bg_sample = BG_SAMPLES ),
461
- peak_read_count = expand ("results/macs2_broad/fdr{fdr}/read_counts/{dir}/{bg_sample}.peak.count" , dir = DIRS , fdr = fdr , bg_sample = BG_SAMPLES ),
462
- output :
463
- plot = "results/plots/macs2_broad/fdr{fdr}/frip.pdf" ,
464
- csv = "results/macs2_broad/fdr{fdr}/frip.csv" ,
465
- params :
466
- extra = "" ,
467
- threads : config ["resources" ]["plotting" ]["cpu" ]
468
- resources :
469
- runtime = config ["resources" ]["plotting" ]["time" ]
470
- log :
471
- "logs/plot_frip/fdr{fdr}.log"
472
- conda :
473
- "../envs/R.yaml"
474
- script :
475
- "../scripts/plot_frip.R"
456
+ rule plot_fraction_of_reads_in_peaks :
457
+ input :
458
+ total_read_count = expand ("results/macs2_broad/fdr{fdr}/read_counts/{dir}/{bg_sample}.total.count" , dir = DIRS , fdr = fdr , bg_sample = BG_SAMPLES ),
459
+ peak_read_count = expand ("results/macs2_broad/fdr{fdr}/read_counts/{dir}/{bg_sample}.peak.count" , dir = DIRS , fdr = fdr , bg_sample = BG_SAMPLES ),
460
+ output :
461
+ plot = "results/plots/macs2_broad/fdr{fdr}/frip.pdf" ,
462
+ csv = "results/macs2_broad/fdr{fdr}/frip.csv" ,
463
+ params :
464
+ extra = "" ,
465
+ threads : config ["resources" ]["plotting" ]["cpu" ]
466
+ resources :
467
+ runtime = config ["resources" ]["plotting" ]["time" ]
468
+ log :
469
+ "logs/plot_frip/fdr{fdr}.log"
470
+ conda :
471
+ "../envs/R.yaml"
472
+ script :
473
+ "../scripts/plot_frip.R"
0 commit comments