From 84ae4dbd624ecc43ab069fed58a5e8d8798bd82d Mon Sep 17 00:00:00 2001 From: js2264 Date: Thu, 16 Nov 2023 18:19:48 +0100 Subject: [PATCH] fix: 4C with multiple loci in `viewpoint` --- R/4C.R | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/R/4C.R b/R/4C.R index a8b698e..81deb02 100644 --- a/R/4C.R +++ b/R/4C.R @@ -39,16 +39,19 @@ virtual4C <- function(x, viewpoint, use.scores = 'balanced') { else { score <- cm[, regions_in_viewpoint] } - GenomicRanges::GRanges( + gr <- GenomicRanges::GRanges( seqnames = as.vector(GenomicRanges::seqnames(regions)), IRanges::IRanges( GenomicRanges::start(regions), GenomicRanges::end(regions) ), score = score, - viewpoint = as.character(viewpoint), center = GenomicRanges::start(regions) + (GenomicRanges::end(regions) - GenomicRanges::start(regions))/2, in_viewpoint = regions_in_viewpoint ) + if (length(as.character(viewpoint)) == 1) { + gr$viewpoint <- as.character(viewpoint) + } + return(gr) }