This function searches for intervals in y that overlaps with x, and remove the overlapping portion of x.

subtract_bed(
  x,
  y,
  min_overlap = 1,
  min_overlap_type = c("bp", "frac1", "frac2")
)

Arguments

x

A GRanges object.

y

A GRanges object.

min_overlap

See intersect_bed().

min_overlap_type

intersect_bed().

Value

A GRanges after subtracting y from x

References

Manual page of bedtools subtract: https://bedtools.readthedocs.io/en/latest/content/tools/subtract.html

See also

Examples

# Load BED tables
tbl_x <- read_bed(system.file("extdata", "example_merge.bed", package = "bedtorch"), use_gr = FALSE)
tbl_y <- read_bed(system.file("extdata", "example_intersect_y.bed", package = "bedtorch"), use_gr = FALSE)

# Basic usage
result <- subtract_bed(tbl_x, tbl_y)
head(result)
#>    chrom start end score
#> 1:    21     3   6     8
#> 2:    21    10  16     5
#> 3:    21    12  17     4
#> 4:    21    15  22     5
#> 5:    21    36  47     1
#> 6:    21    45  47     2
#> -------
#> genome: unspecified.

# Perform the mapping, requiring the minimum overlapping of 5bp
result <- subtract_bed(tbl_x, tbl_y, min_overlap = 5, min_overlap_type = "bp")
head(result)
#>    chrom start end score
#> 1:    21     3   6     8
#> 2:    21    10  16     5
#> 3:    21    12  17     4
#> 4:    21    15  22     5
#> 5:    21    22  25     7
#> 6:    21    26  30     7
#> -------
#> genome: unspecified.