Hits-setops {S4Vectors} | R Documentation |
Perform set operations on Hits objects.
## S4 method for signature 'Hits,Hits' union(x, y) ## S4 method for signature 'Hits,Hits' intersect(x, y) ## S4 method for signature 'Hits,Hits' setdiff(x, y)
x, y |
Compatible Hits objects, that is, Hits objects with the same subject and query lengths. |
The union
, intersect
, and setdiff
methods for
Hits objects return a Hits object containing respectively
the union, intersection, and (asymmetric!) difference of the sets of hits
in x
and y
.
These methods only work if x
and y
are compatible
Hits objects, that is, if they have the same subject and query
lengths.
union
returns a Hits object obtained by appending to x
the hits in y
that are not already in x
. The original metadata
columns are dropped.
intersect
returns a Hits object obtained by keeping only
the hits in x
that are also in y
.
setdiff
returns a Hits object obtained by dropping from
x
the hits that are in y
.
Both intersect
and setdiff
propagate the metadata columns
from x
.
H. Pages and Michael Lawrence
Hits objects.
Hits-comparison for comparing and ordering hits.
BiocGenerics::union
,
BiocGenerics::intersect
,
and BiocGenerics::setdiff
in the BiocGenerics package for general information about
these generic functions.
x <- Hits(c(2, 4, 4, 4, 5, 5), c(3, 1, 3, 2, 3, 2), 6, 3) x y <- Hits(c(1, 3, 4, 4, 5, 5, 5), c(3, 3, 2, 1, 2, 1, 3), 6, 3) y union(x, y) union(y, x) # same hits as in union(x, y), but in different order intersect(x, y) intersect(y, x) # same hits as in intersect(x, y), but in # different order setdiff(x, y) setdiff(y, x)