diff --git a/Snakefile b/Snakefile index c7b515fb81f88366ea70ccda169d8e529b16078e..a559229fed6bb47eea119b975bd8f9a65425f163 100644 --- a/Snakefile +++ b/Snakefile @@ -168,17 +168,35 @@ rule plot_mosaic_counts: {params.plot_command} {input.counts} {input.info} {output} > {log} 2>&1 """ +ruleorder: plot_SV_calls_simulated > plot_SV_calls + rule plot_SV_calls: input: counts = "counts/{sample}/{windows}.txt.gz", - calls = "sv_calls/{sample}/{windows}.{bpdens}/{method}.txt" + calls = "sv_calls/{sample}/{windows}.{bpdens}/{method}.txt", + segments = "segmentation2/{sample}/{windows}.{bpdens}.txt" output: "sv_calls/{sample}/{windows}.{bpdens}/{method}.{chrom}.pdf" shell: """ - Rscript utils/chrom.R calls={input.calls} {input.counts} {wildcards.chrom} {output} + Rscript utils/chrom.R segments={input.segments} calls={input.calls} {input.counts} {wildcards.chrom} {output} """ +rule plot_SV_calls_simulated: + input: + counts = "counts/simulation{seed}-{window}/{window}_fixed.txt.gz", + calls = "sv_calls/simulation{seed}-{window}/{window}_fixed.{bpdens}/{method}.txt", + segments = "segmentation2/simulation{seed}-{window}/{window}_fixed.{bpdens}.txt", + truth = "simulation/variants/genome{seed}-{window}.txt" + output: + "sv_calls/simulation{seed}-{window}/{window}_fixed.{bpdens}/{method}.{chrom}.pdf" + shell: + """ + Rscript utils/chrom.R segments={input.segments} truth={input.truth} calls={input.calls} {input.counts} {wildcards.chrom} {output} + """ + + + ################################################################################ # Read counting # diff --git a/utils/chrom.R b/utils/chrom.R index e13a821d5b25b9c0144988b91e87077cd3cc7842..c364cfdb5d3346e8548fea65b2df60aea6a70766 100644 --- a/utils/chrom.R +++ b/utils/chrom.R @@ -43,6 +43,7 @@ manual_colors = c( simul_inv_dup = "darkgoldenrod2", idup_h1 = muted("darkgoldenrod2", 80, 70), idup_h2 = muted("darkgoldenrod2", 80, 70), + complex = "grey", # background bg1 = "#ffffff", bg2 = "khaki2") @@ -157,7 +158,10 @@ if (!is.null(f_calls)) { "end" %in% colnames(svs), "sample" %in% colnames(svs), "cell" %in% colnames(svs), - "SV_class" %in% colnames(svs)) %>% invisible + ("SV_class" %in% colnames(svs) | "sv_call_name" %in% colnames(svs) )) %>% invisible + if(!("SV_class" %in% colnames(svs))) { + svs[, SV_class := sv_call_name] + } assert_that(all(svs$SV_class %in% names(manual_colors))) %>% invisible svs[, sample_cell := paste(sample, "-", cell)] assert_that(all(unique(svs$sample_cell) %in% unique(counts$sample_cell))) %>% invisible