ContactMatrix-sorting: ContactMatrix sorting and ordering

Description Usage Arguments Details Value Author(s) See Also Examples

Description

Methods to sort and order ContactMatrix objects, based on the anchor indices. Also, methods to remove duplicate rows or columns in each ContactMatrix.

Usage

1
2
3
4
5
6
7
8
## S4 method for signature 'ContactMatrix'
order(..., na.last=TRUE, decreasing=FALSE)
## S4 method for signature 'ContactMatrix'
sort(x, decreasing=FALSE, ...)
## S4 method for signature 'ContactMatrix'
duplicated(x, incomparables=FALSE, fromLast=FALSE, ...)
## S4 method for signature 'ContactMatrix'
unique(x, incomparables=FALSE, fromLast=FALSE, ...)

Arguments

...

For sort,ContactMatrix-method, one or more ContactMatrix objects with the same dimensions. Otherwise, ignored in all other methods.

x

A ContactMatrix object.

na.last

A logical scalar indicating whether NA values should be ordered last. This should not be relevant as anchor indices should be finite.

decreasing

A logical scalar indicating whether sorting should be performed in decreasing order.

incomparables

A logical scalar, ignored.

fromLast

A logical scalar indicating whether the last entry of a repeated set in x should be considered as a non-duplicate.

Details

Sorting is performed based on the anchor indices of the ContactMatrix object. Rows are ordered for increasing values of the anchor1 slot, while columns are ordered for increasing values of the anchor2 slot. This equates to ordering by the coordinates directly, as the GRanges in the regions slot is always sorted. Based on this, sort,ContactMatrix-method will return a sorted copy of x with permuted rows/columns in increasing order. This can be set to decreasing order by specifying decreasing=TRUE.

order,ContactMatrix-method returns a list of 2 integer vectors. The first vector contains the permutation to rearrange the rows of x in increasing order, while the second vector does the same for the columns of x. If multiple objects are supplied to order, ordering will be computed using anchor indices from successive objects. In other words, ordering will be performed using anchor indices from the first object; any rows with the same anchor1 or columns with the same anchor2 will be split using the corresponding indices in the second object; and so on.

duplicated,ContactMatrix-method returns a list of two logical vectors. The first vector indicates whether rows are duplicated, based on identical values in the anchor1 slot. The second does the same for columns based on the anchor2 slot. For a set of duplicated rows or columns, the first occurrence of that row/column is marked as the non-duplicate if fromLast=FALSE, and the last entry otherwise.

unique,ContactMatrix-method returns an ContactMatrix object where all duplicate rows and columns have been removed from x. This is equivalent to subsetting based on the non-duplicate rows and columns defined in duplicated,ContactMatrix-method.

Note that sorting and duplicate identification only use the anchor indices. The values of the matrix slot are not used in distinguishing between rows or columns with the same index.

Value

For sort and unique, a ContactMatrix object is returned with sorted or unique rows/columns, respectively.

For order, a list of two integer vectors is returned containing row/column permutations.

For duplicated, a list of logical vectors is returned specifying which rows/columns are duplicated.

Author(s)

Aaron Lun

See Also

ContactMatrix-class

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
example(ContactMatrix, echo=FALSE)

anchors(x)
x2 <- sort(x)
x2
anchors(x2)

# Can also order them.
o <- order(x)
o
stopifnot(all.equal(x[o$row,o$column], x2))

# Checking duplication.
duplicated(x)
duplicated(rbind(x, x))
stopifnot(all.equal(unique(x), unique(rbind(x, x))))

InteractionSet documentation built on April 17, 2021, 6 p.m.