S4Vectors (version 0.10.1)

Hits-comparison: Comparing and ordering hits

Description

==, !=, <=< code="">, >=, <, >, match(), %in%, order(), sort(), and rank() can be used on Hits objects to compare and order hits.

Note that only the "pcompare", "match", and "order" methods are actually defined for Hits objects. This is all what is needed to make all the other comparing and ordering operations (i.e. ==, !=, <=< code="">, >=, <, >, %in%, sort(), and rank()) work on these objects (see ?`Vector-comparison` for more information about this).

Usage

## S3 method for class 'Hits,Hits':
pcompare(x, y)

## S3 method for class 'Hits,Hits': match(x, table, nomatch=NA_integer_, incomparables=NULL, method=c("auto", "quick", "hash"))

## S3 method for class 'Hits': order(..., na.last=TRUE, decreasing=FALSE, method=c("shell", "radix"))

Arguments

x, y, table
Compatible Hits objects, that is, Hits objects with the same subject and query lengths.
nomatch
The value to be returned in the case when no match is found. It is coerced to an integer.
incomparables
Not supported.
method
For match: Use a Quicksort-based (method="quick") or a hash-based (method="hash") algorithm. The latter tends to give better performance, except maybe for some pathological input that we've not encountered so far. When method="auto" is specified, the most efficient algorithm will be used, that is, the hash-based algorithm if length(x) <= 2^29<="" code="">, otherwise the Quicksort-based algorithm.

For order: The method argument is ignored.

...
One or more Hits objects. The additional Hits objects are used to break ties.
na.last
Ignored.
decreasing
TRUE or FALSE.

Details

Only hits that belong to Hits objects with same subject and query lengths can be compared.

Hits are ordered by query hit first, and then by subject hit. On a Hits object, order, sort, and rank are consistent with this order.

[object Object],[object Object],[object Object]

See Also

  • Hitsobjects.
  • Vector-comparisonfor general information about comparing, ordering, and tabulating vector-like objects.

Examples

Run this code
## ---------------------------------------------------------------------
## A. ELEMENT-WISE (AKA "PARALLEL") COMPARISON OF 2 Hits OBJECTS
## ---------------------------------------------------------------------
hits <- Hits(c(2, 4, 4, 4, 5, 5), c(3, 1, 3, 2, 3, 2), 6, 3)
hits

pcompare(hits, hits[3])
pcompare(hits[3], hits)

hits == hits[3]
hits != hits[3]
hits >= hits[3]
hits < hits[3]

## ---------------------------------------------------------------------
## B. match(), %in%
## ---------------------------------------------------------------------
table <- hits[-c(1, 3)]
match(hits, table)

hits %in% table

## ---------------------------------------------------------------------
## C. order(), sort(), rank()
## ---------------------------------------------------------------------
order(hits)
sort(hits)
rank(hits)

Run the code above in your browser using DataLab