Browse code

Fixed issue with shifted read ends and deletions.

Robert Ivánek authored on 05/01/2022 20:55:28
Showing 1 changed files

... ...
@@ -2412,7 +2412,7 @@ setMethod("drawGD", signature("AlignmentsTrack"), function(GdObject, minBase, ma
2412 2412
         sh <- max(0, min(h, .dpOrDefault(GdObject, "stackHeight", 0.75))) / 2
2413 2413
         boxOnly <- res > 10
2414 2414
         if (boxOnly) {
2415
-            x <- c(start(readInfo), rep(end(readInfo), 2), start(readInfo))
2415
+            x <- c(start(readInfo), rep(end(readInfo)+1, 2), start(readInfo))
2416 2416
             y <- c(rep(readInfo$stack + sh, 2), rep(readInfo$stack - sh, 2))
2417 2417
             id <- rep(readInfo$uid, 4)
2418 2418
         } else {
... ...
@@ -2426,20 +2426,20 @@ setMethod("drawGD", signature("AlignmentsTrack"), function(GdObject, minBase, ma
2426 2426
             readInfo$arrow[match(names(arrowMap), readInfo$uid)] <- arrowMap
2427 2427
             ## The parts that don't need arrow heads
2428 2428
             sel <- is.na(readInfo$arrow) | readInfo$arrow == "*"
2429
-            x <- c(start(readInfo)[sel], rep(end(readInfo)[sel], 2), start(readInfo)[sel])
2429
+            x <- c(start(readInfo)[sel], rep(end(readInfo)[sel]+1, 2), start(readInfo)[sel])
2430 2430
             y <- c(rep(readInfo$stack[sel] + sh, 2), rep(readInfo$stack[sel] - sh, 2))
2431 2431
             id <- rep(readInfo$uid[sel], 4)
2432 2432
             ## The arrow heads facing right
2433 2433
             w <- Gviz:::.pxResolution(coord = "x", 5)
2434 2434
             sel <- readInfo$arrow == "+"
2435
-            ah <- pmax(start(readInfo)[sel], end(readInfo)[sel] - w)
2436
-            x <- c(x, start(readInfo)[sel], ah, end(readInfo)[sel], ah, start(readInfo)[sel])
2435
+            ah <- pmax(start(readInfo)[sel], end(readInfo)[sel]+1 - w)
2436
+            x <- c(x, start(readInfo)[sel], ah, end(readInfo)[sel]+1, ah, start(readInfo)[sel])
2437 2437
             y <- c(y, rep(readInfo$stack[sel] + sh, 2), readInfo$stack[sel], rep(readInfo$stack[sel] - sh, 2))
2438 2438
             id <- c(id, rep(readInfo$uid[sel], 5))
2439 2439
             ## The arrow heads facing left
2440 2440
             sel <- readInfo$arrow == "-"
2441 2441
             ah <- pmin(end(readInfo)[sel], start(readInfo)[sel] + w)
2442
-            x <- c(x, start(readInfo)[sel], ah, rep(end(readInfo)[sel], 2), ah)
2442
+            x <- c(x, start(readInfo)[sel], ah, rep(end(readInfo)[sel]+1, 2), ah)
2443 2443
             y <- c(y, readInfo$stack[sel], rep(readInfo$stack[sel] + sh, 2), rep(readInfo$stack[sel] - sh, 2))
2444 2444
             id <- c(id, rep(readInfo$uid[sel], 5))
2445 2445
         }
... ...
@@ -2463,7 +2463,7 @@ setMethod("drawGD", signature("AlignmentsTrack"), function(GdObject, minBase, ma
2463 2463
             mateGaps <- mateGaps[start(rmap) <= start(mateGaps) & end(rmap) >= end(mateGaps)]
2464 2464
             gy <- readInfo$stack[match(as.character(seqnames(mateGaps)), readInfo$entityId)]
2465 2465
             lineCoords <- data.frame(
2466
-                x1 = start(mateGaps) - 1, y1 = gy, x2 = end(mateGaps) + 1, y2 = gy,
2466
+                x1 = start(mateGaps), y1 = gy, x2 = end(mateGaps) + 1, y2 = gy,
2467 2467
                 col = .dpOrDefault(GdObject, c("col.gap", "col"), .DEFAULT_SHADED_COL),
2468 2468
                 lwd = .dpOrDefault(GdObject, c("lwd.gap", "lwd"), 1),
2469 2469
                 lty = .dpOrDefault(GdObject, c("lty.gap", "lty"), 1),
... ...
@@ -2505,7 +2505,7 @@ setMethod("drawGD", signature("AlignmentsTrack"), function(GdObject, minBase, ma
2505 2505
             gy <- readInfo$stack[match(names(delGaps), readInfo$entityId)]
2506 2506
             if (length(delGaps)) {
2507 2507
                 delCoords <- data.frame(
2508
-                    x1 = start(delGaps) - 1, y1 = gy, x2 = end(delGaps) + 1, y2 = gy,
2508
+                    x1 = start(delGaps)+1, y1 = gy, x2 = end(delGaps) + 1, y2 = gy,
2509 2509
                     col = .dpOrDefault(GdObject, c("col.deletion", "col"), .DEFAULT_BRIGHT_SHADED_COL),
2510 2510
                     lwd = .dpOrDefault(GdObject, c("lwd.deletion", "lwd"), 1),
2511 2511
                     lty = .dpOrDefault(GdObject, c("lty.deletion", "lty"), 1),
... ...
@@ -2625,6 +2625,7 @@ setMethod("drawGD", signature("AlignmentsTrack"), function(GdObject, minBase, ma
2625 2625
     }
2626 2626
     return(switch(as.character(exponent),
2627 2627
         "0" = sprintf("%i", as.integer(tckText)),
2628
+        #"0" = sprintf("%s bp", tckText),
2628 2629
         "3" = sprintf("%s kb", tckText),
2629 2630
         "6" = sprintf("%s mb", tckText),
2630 2631
         "9" = sprintf("%s gb", tckText),