overlapRegions {regioneR} | R Documentation

## Overlap Regions

### Description

return overlap between 2 regios set A and B

### Usage

    overlapRegions(A, B, colA=NULL, colB=NULL, type="any", min.bases=1, min.pctA=NULL, min.pctB=NULL, get.pctA=FALSE, get.pctB=FALSE, get.bases=FALSE, only.boolean=FALSE, only.count=FALSE, ...)

### Arguments

`A` | a region set in any of the accepted formats by `toGRanges` (`GenomicRanges`, `data.frame`, etc...)
`B` | a region set in any of the accepted formats by `toGRanges` (`GenomicRanges`, `data.frame`, etc...)
`colA` | numeric vector indicating which columns of A the results will contain (default NULL)
`colB` | numeric vector indicating which columns of B the results will contain (default NULL)
`type` | `AinB`: the region in A is contained in a region in B `BinA`: the region in B is contained in A `within`: the region in A or B is contained in a region in the other region set `equal`: the region in A has the same chromosome, start and end as a region in B `AleftB`: the end of the region from A overlaps the beginning of a region in B `ArightB`: the start of a region from A overlaps the end of a region in B `any`: any kind of overlap is returned
`min.bases` | numeric minimun number of bp accepted to define a overlap (default 1)
`min.pctA` | numeric minimun percentage of bases of A accepted to define a overlap (default NULL)
`min.pctB` | numeric minimun percentage of bases of B accepted to define a overlap (default NULL)
`get.pctA` | boolean if TRUE add a column in the results indicating the number percentage of A are involved in the overlap (default FALSE)
`get.pctB` | boolean if TRUE add a column in the results indicating the number percentage of B are involved in the overlap (default FALSE)
`get.bases` | boolean if TRUE add in the results the number of overlapped bases (default FALSE)
`only.boolean` | boolean if TRUE devolve as result a boolean vector containing the overlap state of each regions of A (default FALSE)
`only.count` | boolean if TRUE devolve as result the number of regions of A overlapping with B
`...` | any additional parameter (are there any left?)

### Value

the default results is a `data.frame` with at least 5 columns "chr" indicating the chromosome of the appartenence of each overlap, "startA", "endA", "startB", "endB", indicating the coordinates of the region A and B for each overlap "type" that describe the nature of the overlap (see arguments "type") eventually other columns can be added (see see arguments "colA", "colB", "get.pctA", "get.pctB", "get.bases")

### Note

The implementation uses when possible the `countOverlaps` function from `IRanges` package.

### See Also

`plotRegions`, `toDataframe`, `toGRanges`, `subtractRegions`, `splitRegions`, `extendRegions`, `commonRegions`, `mergeRegions`, `joinRegions`

### Examples

    A <- data.frame("chr1", c(1, 5, 20, 30), c(8, 13, 28, 40), x=c(1,2,3,4), y=c("a", "b", "c", "d"))

    B <- data.frame("chr1", 25, 35)

    overlapRegions(A, B)

[Package regioneR version 1.19.2 Index]