ContactMatrix subsetting {InteractionSet} | R Documentation

## ContactMatrix subsetting and combining

### Description

Methods to subset or combine ContactMatrix objects.

### Usage

    ### Subsetting

    ## S4 method for signature 'ContactMatrix,ANY,ANY'
    x[i, j, ..., drop=TRUE]
    ## S4 replacement method for signature 'ContactMatrix,ANY,ANY,ContactMatrix'
    x[i, j] <- value
    ## S4 method for signature 'ContactMatrix'
    subset(x, i, j)

    ### Combining

    ## S4 method for signature 'ContactMatrix'
    cbind(..., deparse.level=1)
    ## S4 method for signature 'ContactMatrix'
    rbind(..., deparse.level=1)

### Arguments

`x` | A ContactMatrix object.
`i, j` | A vector of subscripts, indicating the rows and columns to be subsetted for `i` and `j`, respectively.
`...` | For `cbind`, `rbind` and `c`, `...` contains ContactMatrix objects to be combined. Otherwise, this argument is ignored during subsetting.
`drop` | A logical scalar, ignored by `[,ContactMatrix,ANY,ANY-method`.
`value` | A ContactMatrix object with dimensions equal to the length of the two subscripts (or the corresponding dimensions of `x`, if either subscript is missing.
`deparse.level` | An integer scalar; see `?base::cbind` for a description of this argument.

### Details

Subsetting of ContactMatrix objects behaves like that for standard matrices. Rows and columns can be selected and rearranged, with concomitant changes to the `anchor1` and `anchor2` slots. All subsetting operations will return an ContactMatrix with the specified rows and columns. However, note that the value of `regions` will not be modified by subsetting.

`cbind` will combines objects with the same rows but different columns. Errors will occur if the row regions are not identical between objects (i.e., must have same values in the slots for `regions` and `anchor1`). Conversely, `rbind` will combines objects with the same columns but different rows. Again, errors will occur if the columns are not identical (i.e., must have same values in the slots for `regions` and `anchor2`).

If subsetted anchors are required, see `?"interaction-subset"` for why subsetting should be done before calling the `anchors` method.

### Value

A subsetted or combined ContactMatrix object.

### Author(s)

Aaron Lun

### See Also

`ContactMatrix-class`

### Examples

    example(ContactMatrix, echo=FALSE)

    # Subsetting:
    x[1:5,]
    x[,10:15]
    x[1:5,10:15]

    x2 <- x
    x2[1:5,] <- x[6:10,]
    as.matrix(x2[,1]) <- 20

    # Combining
    cbind(x, x)
    rbind(x, x)

[Package InteractionSet version 1.22.0 Index]