Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

Hits-setops

Set operations on Hits objects


Description

Perform set operations on Hits objects.

Details

union(x, y), intersect(x, y), setdiff(x, y), and setequal(x, y) work on Hits objects x and y only if the objects are compatible Hits objects, that is, if they have the same subject and query lengths. These operations return respectively the union, intersection, (asymmetric!) difference, and equality of the sets of hits in x and y.

Value

union returns a Hits object obtained by appending to x the hits in y that are not already in x.

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.

setequal returns TRUE if x and y contain the same sets of hits and FALSE otherwise.

union, intersect, and setdiff propagate the names and metadata columns of their first argument (x).

Author(s)

Hervé Pagès and Michael Lawrence

See Also

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

Examples

x <- Hits(c(2, 4, 4, 4, 5, 5), c(3, 1, 3, 2, 3, 2), 6, 3,
          score=11:16)
x

y <- Hits(c(1, 3, 4, 4, 5, 5, 5), c(3, 3, 2, 1, 2, 1, 3), 6, 3,
          score=21:27)
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)

setequal(x, y)

S4Vectors

Foundation of vector-like and list-like containers in Bioconductor

v0.28.1
Artistic-2.0
Authors
H. Pagès, M. Lawrence and P. Aboyoun
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.