Learn R Programming

regioneR (version 1.4.0)

subtractRegions: Subtract Regions

Description

Function for subtracting a region set from another region set.

Usage

subtractRegions(A, B)

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...)

Value

A GenomicRanges object

Details

This function returns the regions in A minus the parts of them overlapping the regions in B. Overlapping regions in the result will be fused.

The implementation relies completely in the setdiff function from IRanges package.

Examples

Run this code
A <- data.frame(chr=1, start=c(1, 15, 24, 31), end=c(10, 20, 30, 35))

B <- data.frame(chr=1, start=c(2, 12, 24, 35), end=c(5, 25, 29, 40))

subtract <- subtractRegions(A, B)

plotRegions(list(A, B, subtract), chromosome=1, regions.labels=c("A", "B", "subtract"), regions.colors=3:1)

Run the code above in your browser using DataLab