Description Usage Arguments Details Value Author(s) References See Also Examples
Subtracts one set of ranges from another, either by position or range.
1 2 3 4 5 6 7  bedtools_subtract(cmd = "help")
R_bedtools_subtract(a, b, f = 1e09, F = 1e09, r = FALSE, e = FALSE,
s = FALSE, S = FALSE, A = FALSE, N = FALSE,
g = NA_character_)
do_bedtools_subtract(a, b, f = 1e09, F = 1e09, r = FALSE, e = FALSE,
s = FALSE, S = FALSE, A = FALSE, N = FALSE,
g = NA_character_)

cmd 
String of bedtools command line arguments, as they would be entered at the shell. There are a few incompatibilities between the docopt parser and the bedtools style. See argument parsing. 
a 
Path to a BAM/BED/GFF/VCF/etc file, a BED stream, a file object, or
a ranged data structure, such as a GRanges. Each feature in 
b 
Like 
f 
Minimum overlap required as a fraction of 
F 
Minimum overlap required as a fraction of 
r 
Require that the fraction of overlap be reciprocal for 
e 
Require that the minimum fraction be satisfied for 
s 
Require same strandedness. That is, find the subtract feature in

S 
Require opposite strandedness. That is, find the subtract feature in

A 
Remove entire feature if any overlap. If a feature in 
N 
Same as 
g 
A genome file, identifier or Seqinfo object that defines the order and size of the sequences. 
As with all commands, there are three interfaces to the
subtract
command:
bedtools_subtract
Parses the bedtools command line and compiles it to the equivalent R code.
R_bedtools_subtract
Accepts R arguments corresponding to the command line arguments and compiles the equivalent R code.
do_bedtools_subtract
Evaluates the result of
R_bedtools_subtract
. Recommended only for
demonstration and testing. It is best to integrate the compiled
code into an R script, after studying it.
We typically subtract sets of ranges using
setdiff
; however, that will not work
here, because we cannot merge the ranges in a
.
The algorithm has two modes: by position (where ranges are clipped)
and by range (where ranges are discarded entirely). The position mode
is the default. We find overlaps, optionally restrict them, and for
each range in a
, we subtract all of the qualifying
intersections in b
.
When A
or N
are TRUE
, we use the second mode. In
the simplest case, that is just
subsetByOverlaps
with invert=TRUE
,
but fractional overlap restrictions and N
make that more
complicated.
A language object containing the compiled R code, evaluating to a
GRanges object, except when A
or N
are TRUE
,
where the value might be a GRanges, GAlignments or VCF object,
depending on the input.
Michael Lawrence
http://bedtools.readthedocs.io/en/latest/content/tools/subtract.html
setopsmethods for set operations including setdiff, findOverlapsmethods for different ways to detect overlaps.
1 2 3 4 5 6 7 8 9 10 11  ## Not run:
setwd(system.file("unitTests", "data", "subtract", package="HelloRanges"))
## End(Not run)
## simple case, positionwise subtraction
bedtools_subtract("a a.bed b b.bed")
## fractional overlap restriction
bedtools_subtract("a a.bed b b.bed f 0.5")
## rangewise subtraction
bedtools_subtract("a a.bed b b.bed A f 0.5")

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.
Please suggest features or report bugs in the GitHub issue tracker.
All documentation is copyright its authors; we didn't write any of that.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.