overlap: overlap function

Description Usage Arguments Details Value Author(s) Examples

View source: R/refGenome.R

Description

Overlaps query ranges with reference ranges. The function assumes that there is no overlap between reference ranges.

Usage

1
overlap(qry, ref)

Arguments

qry

data.frame with query ranges. qry should have columns 'id','start' and 'end'. The routine assumes that the table is ascending sorted by column 'start'.

ref

data.frame with reference ranges. ref should have columns 'id','start' and 'end'. The routine assumes that the table is ascending sorted by column 'start'.

Details

The routine assumes that qry and ref tables are ascending sorted by column 'start'. Otherwise the result will be incorrect (i.e. missing hits). The function assumes that there is no overlap between reference ranges. It will otherwise return only one, possibly arbitrary, hit per query range.

Value

The function returns a data.frame

overlap

Factor which encodes type of overlap between query and reference range. Levels no (no overlap; refid is set to 0), l (qry left overhangs ref), n (qry is contained in ref ), r (qry right overhangs ref)

leftDiff

Distance on left side between margins of query and reference.

rightDiff

Distance on right side between margins of query and reference.

queryid

id from qry table.

refid

id from ref table.

Author(s)

Wolfgang Kaisers

Examples

1
2
3
qry <- data.frame(id=1:6, start=c(10,18,61,78,82,110), end=c(15,22,63,87,90,120))
ref <- data.frame(id=1:5, start=c(20,40,60,80,100), end=c(25,45,65,85,105))
overlap(qry, ref)

Example output

Loading required package: doBy
Loading required package: RSQLite
  overlap leftDiff rightDiff queryid refid
0      no        0         5       1     0
1       l        2         3       2     1
2       n        1         2       3     3
3       b        2         2       4     4
4       r        2         5       5     4
5      no        5         0       6     0

refGenome documentation built on May 23, 2019, 1:03 a.m.