Learn R Programming

S4Vectors (version 0.8.0)

Hits-setops: Set operations on Hits objects

Description

Perform set operations on Hits objects.

Usage

"union"(x, y)
"intersect"(x, y)
"setdiff"(x, y)

Arguments

x, y
Compatible Hits objects, that is, Hits objects with the same subject and query lengths.

Value

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.

Details

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.

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

Run this code
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)

Run the code above in your browser using DataLab