Skip to content

Commit 1f28992

Browse files
committed
feat: automatically infer symmetrical = FALSE and limits when plotting only trans contacts
1 parent 723d6cb commit 1f28992

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

R/plotting.R

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,12 @@ setMethod("plotMatrix", "GInteractions", function(
183183
) {
184184
`%over%` <- IRanges::`%over%`
185185

186-
## -- Extract scores
186+
## -- Switch `symmetrical` to FALSE if only trans interactions
187187
gis <- x
188+
onlyTRANS <- !any(S4Vectors::first(gis) == S4Vectors::second(gis))
189+
if (onlyTRANS & symmetrical) symmetrical <- FALSE
190+
191+
## -- Extract scores
188192
if (!is.null(use.scores)) {
189193
gis$score <- S4Vectors::mcols(gis)[, use.scores]
190194
}
@@ -220,7 +224,12 @@ setMethod("plotMatrix", "GInteractions", function(
220224
M <- limits[2]
221225
}
222226
else {
223-
.scores <- gis$score[pairdist(gis) != 0 & !is.na(pairdist(gis) != 0)]
227+
if (onlyTRANS) {
228+
.scores <- gis$score
229+
}
230+
else {
231+
.scores <- gis$score[pairdist(gis) != 0 & !is.na(pairdist(gis) != 0)]
232+
}
224233
.scores <- .scores[!is.na(.scores)]
225234
.scores <- .scores[!is.infinite(.scores)]
226235
M <- max(.scores)
@@ -340,7 +349,7 @@ setMethod("plotMatrix", "GInteractions", function(
340349
GenomicRanges::seqnames(InteractionSet::anchors(gis, "second"))
341350
)}) { ## SINGLE CHROMOSOME MAP or 2 CHROMOSOMES TRANS INTERSECTION
342351

343-
if (is.null(maxDistance)) { ##### REGULAR SQUARE MATRIX
352+
if (is.null(maxDistance)) { ##### REGULAR SQUARE/RECTANGULAR (IF TRANS ONLY) MATRIX
344353
## -- Convert gis to table and extract x/y
345354
mat <- gis |>
346355
tibble::as_tibble() |>

0 commit comments

Comments
 (0)