Learn R Programming

bedr (version 1.1.3)

in.region: checks if regions in object a are found in object b

Description

checks if regions in object a are found in object b

Usage

in.region(
	x,
	y,
	proportion.overlap = 1e-09,
	method = "natural",
	reciprocal.overlap = FALSE,
	check.zero.based = TRUE,
	check.chr = TRUE,
	check.valid = TRUE,
	check.sort = TRUE,
	check.merge = TRUE,
	verbose = FALSE
	)

Value

Returns a logical vector the length of x.

Arguments

x

first region index in the form chr:start-stop. regions in this index will be checked for intersection in the values of the second index.

y

second region index.

proportion.overlap

Defaults 1e-9 which is 1 bp. See details below for the different interpretation between 0 and 1 based overlap

method

Sorting method ("natural" by default)

reciprocal.overlap

Should the proportion.overlap be reciprocal

check.zero.based

should 0 based coordinates be checked

check.chr

should chr prefix be checked

check.valid

check if region is valid

check.sort

check if region is sorted

check.merge

check if overlapping regions are merged

verbose

prints some debugging information. currently it just checks if the input regions are overlapping

Author

Daryl Waggott

Details

The function can also be called using syntax similar to the %in% operator, for example "region1 %in.region% region2"

The default is to report TRUE if there is 1bp overlap in zero based bed format. That means that region chr1:10-20 and chr1:20-30 would not overlap. To switch to one based intuitive interpretation set proportion.overlap = 0.

References

http://bedtools.readthedocs.io/en/latest/content/tools/intersect.html

Examples

Run this code
if (check.binary("bedtools")) {

index <- get.example.regions();

a <- index[[1]];
b <- index[[2]];
a <- bedr(engine = "bedtools", input = list(i = a), method = "sort", params = "");
b <- bedr(engine = "bedtools", input = list(i = b), method = "sort", params = "");

d <- in.region(a,b);

# alternative calling
d <- a %in.region% b

}

Run the code above in your browser using DataLab