R/AllGenerics.R
, R/bestOverlap.R
bestOverlap-methods.Rd
Find the best overlap between ranges
bestOverlap(x, y, ...)
# S4 method for class 'GRanges,GRanges'
bestOverlap(
x,
y,
var = NULL,
ignore.strand = FALSE,
missing = NA_character_,
min_prop = 0.01,
...
)
# S4 method for class 'GRanges,GRangesList'
bestOverlap(
x,
y,
ignore.strand = FALSE,
missing = NA_character_,
min_prop = 0.01,
...
)
a GRanges object
a named GRangesList or GRanges object with mcol as reference category
Not used
The variable to use as the category. Not required if y
is a
GRangesList
logical(1) Passed to findOverlaps
Value to assign to ranges with no overlap
Threshold below which overlaps are discarded
Character vector the same length as the supplied GRanges object
This finds the category in the subject GRanges (y) which has the best overlap with the query GRanges (x). The aim is to produce a character vector for best classifying the query GRanges using an external set of features (e.g. promoters, enhancers etc). If the subject (y) is a GRanges object, the values in the specified column will be used as the category. If the subject (y) is a GRangesList, the names of the list will be used to provide the best match
gr <- GRanges("chr1:1-10")
gr_cat <- GRanges(c("chr1:2-10", "chr1:5-10"))
gr_cat$category <- c("a", "b")
propOverlap(gr, gr_cat)
#> [1] 0.9
bestOverlap(gr, gr_cat, var = "category")
#> [1] "a"
grl <- splitAsList(gr_cat, gr_cat$category)
lapply(grl, function(x) propOverlap(gr, x))
#> $a
#> [1] 0.9
#>
#> $b
#> [1] 0.6
#>
bestOverlap(gr, grl)
#> [1] "a"