Count the number of overlaps between two Ranges objects

count_overlaps(x, y, maxgap, minoverlap)

# S3 method for IntegerRanges
count_overlaps(x, y, maxgap = -1L, minoverlap = 0L)

# S3 method for GenomicRanges
count_overlaps(x, y, maxgap = -1L, minoverlap = 0L)

count_overlaps_within(x, y, maxgap, minoverlap)

# S3 method for IntegerRanges
count_overlaps_within(x, y, maxgap = 0L, minoverlap = 1L)

# S3 method for GenomicRanges
count_overlaps_within(x, y, maxgap = 0L, minoverlap = 1L)

count_overlaps_directed(x, y, maxgap, minoverlap)

# S3 method for GenomicRanges
count_overlaps_directed(x, y, maxgap = -1L, minoverlap = 0L)

count_overlaps_within_directed(x, y, maxgap, minoverlap)

# S3 method for GenomicRanges
count_overlaps_within_directed(x, y, maxgap = -1L, minoverlap = 0L)

Arguments

x, y

Objects representing ranges

maxgap, minoverlap

The maximimum gap between intervals as an integer greater than or equal to zero. The minimum amount of overlap between intervals as an integer greater than zero, accounting for the maximum gap.

Value

An integer vector of same length as x.

Examples

query <- data.frame(start = c(5,10, 15,20), width = 5, gc = runif(4)) %>%
             as_iranges()
subject <- data.frame(start = 2:6, width = 3:7, label = letters[1:5]) %>%
             as_iranges()
query %>% mutate(n_olap = count_overlaps(., subject),
                 n_olap_within = count_overlaps_within(., subject))
#> Error in (function (classes, fdef, mtable) {    methods <- .findInheritedMethods(classes, fdef, mtable)    if (length(methods) == 1L)         return(methods[[1L]])    else if (length(methods) == 0L) {        cnames <- paste0("\"", vapply(classes, as.character,             ""), "\"", collapse = ", ")        stop(gettextf("unable to find an inherited method for function %s for signature %s",             sQuote(fdef@generic), sQuote(cnames)), domain = NA)    }    else stop("Internal error in finding inherited methods; didn't return a unique method",         domain = NA)})(list(structure("IRanges", package = "IRanges"), structure("standardGeneric", package = "methods")),     new("standardGeneric", .Data = function (query, subject,         maxgap = -1L, minoverlap = 0L, type = c("any", "start",             "end", "within", "equal"), ...)     standardGeneric("countOverlaps"), generic = structure("countOverlaps", package = "IRanges"),         package = "IRanges", group = list(), valueClass = character(0),         signature = c("query", "subject"), default = NULL, skeleton = (function (query,             subject, maxgap = -1L, minoverlap = 0L, type = c("any",                 "start", "end", "within", "equal"), ...)         stop(gettextf("invalid call in method dispatch to '%s' (no default method)",             "countOverlaps"), domain = NA))(query, subject, maxgap,             minoverlap, type, ...)), <environment>): unable to find an inherited method for function ‘countOverlaps’ for signature ‘"IRanges", "standardGeneric"’