Hits-setops {S4Vectors}R Documentation

Set operations on Hits objects

Description

Perform set operations on Hits objects.

Usage

## 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)

Arguments

x, y

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

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.

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.

Author(s)

H. Pages and Michael Lawrence

See Also

Examples

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)

[Package S4Vectors version 0.6.1 Index]