From c5a71767ae479d8bf0fb90d6ef834df365a0e0d4 Mon Sep 17 00:00:00 2001 From: Petr Smirnov Date: Fri, 26 May 2023 11:22:32 +0200 Subject: [PATCH 1/2] implementing small indexing bug fixes for reading in segment file --- workflow/scripts/plotting/plot-sv-calls_dev.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/workflow/scripts/plotting/plot-sv-calls_dev.R b/workflow/scripts/plotting/plot-sv-calls_dev.R index 72204acf..0dc8620c 100644 --- a/workflow/scripts/plotting/plot-sv-calls_dev.R +++ b/workflow/scripts/plotting/plot-sv-calls_dev.R @@ -363,7 +363,7 @@ if (!is.null(f_segments)) { seg <- - merge(seg, bins[, .N, by = chrom][, .(chrom, N = c(0, cumsum(N))[1:(.N - 1)])], by = "chrom") + merge(seg, bins[, .N, by = chrom][, .(chrom, N = c(0, cumsum(N)[1:(.N - 1)]))], by = "chrom") # print(c(1, bps[1:(.N - 1)] + 1)) # print(bps) @@ -372,7 +372,7 @@ if (!is.null(f_segments)) { # stop() - seg[, `:=`(from = c(1, bps[1:(.N - 1)] + 1), to = bps), by = chrom] + seg[, `:=`(from = c(1, bps[-length(bps)] + 1), to = bps), by = chrom] # print(seg) From 1bca921d74b01967cd04f575adcf0de1c77c341d Mon Sep 17 00:00:00 2001 From: Petr Smirnov Date: Fri, 26 May 2023 13:13:50 +0200 Subject: [PATCH 2/2] avoiding making same indexing mistake as I jusst fixed a few lines below (1:0) --- workflow/scripts/plotting/plot-sv-calls_dev.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workflow/scripts/plotting/plot-sv-calls_dev.R b/workflow/scripts/plotting/plot-sv-calls_dev.R index 0dc8620c..c600d20f 100644 --- a/workflow/scripts/plotting/plot-sv-calls_dev.R +++ b/workflow/scripts/plotting/plot-sv-calls_dev.R @@ -363,7 +363,7 @@ if (!is.null(f_segments)) { seg <- - merge(seg, bins[, .N, by = chrom][, .(chrom, N = c(0, cumsum(N)[1:(.N - 1)]))], by = "chrom") + merge(seg, bins[, .N, by = chrom][, .(chrom, N = c(0, cumsum(N)[- .N]))], by = "chrom") # print(c(1, bps[1:(.N - 1)] + 1)) # print(bps)