GRanges methods {InteractionSet} | R Documentation

## Equivalents of GRanges methods

### Description

Methods for GInteractions, InteractionSet and ContactMatrix that operate on the internal GenomicRanges.

### Usage

    ## S4 method for signature 'GInteractions'
    shift(x, shift=0L, use.names=TRUE)
    ## S4 method for signature 'InteractionSet'
    shift(x, shift=0L, use.names=TRUE)
    ## S4 method for signature 'ContactMatrix'
    shift(x, shift=0L, use.names=TRUE)

    ## S4 method for signature 'GInteractions'
    narrow(x, start=NA, end=NA, width=NA, use.names=TRUE)
    ## S4 method for signature 'InteractionSet'
    narrow(x, start=NA, end=NA, width=NA, use.names=TRUE)
    ## S4 method for signature 'ContactMatrix'
    narrow(x, start=NA, end=NA, width=NA, use.names=TRUE)

    ## S4 method for signature 'GInteractions'
    resize(x, width, fix="start", use.names=TRUE, ...)
    ## S4 method for signature 'InteractionSet'
    resize(x, width, fix="start", use.names=TRUE, ...)
    ## S4 method for signature 'ContactMatrix'
    resize(x, width, fix="start", use.names=TRUE, ...)

    ## S4 method for signature 'GInteractions'
    flank(x, width, start=TRUE, both=FALSE, use.names=TRUE, ignore.strand=FALSE)
    ## S4 method for signature 'InteractionSet'
    flank(x, width, start=TRUE, both=FALSE, use.names=TRUE, ignore.strand=FALSE)
    ## S4 method for signature 'ContactMatrix'
    flank(x, width, start=TRUE, both=FALSE, use.names=TRUE, ignore.strand=FALSE)

    ## S4 method for signature 'GInteractions'
    trim(x, use.names=FALSE)
    ## S4 method for signature 'InteractionSet'
    trim(x, use.names=FALSE)
    ## S4 method for signature 'ContactMatrix'
    trim(x, use.names=FALSE)

    ## S4 method for signature 'GInteractions'
    width(x)
    ## S4 method for signature 'InteractionSet'
    width(x)
    ## S4 method for signature 'ContactMatrix'
    width(x)

### Arguments

`x` | A GInteractions, InteractionSet or ContactMatrix object.
`shift, start, end, width, fix, both` | Further interaction-specific arguments to pass to the relevant GenomicRanges methods, see details.
`use.names, ignore.strand, ...` | Further overall arguments to pass to the relevant GenomicRanges methods.

### Details

The `trim`, `resize`, `narrow` and `shift` methods will apply the GenomicRanges methods with the same name to the anchor regions of `x`. For example, `resize(x, width)` will produce an object that is equivalent to running `resize` on the first and second anchor regions directly. This is not the same as running the methods on the `regions` slot of `x`, which is an important distinction when the arguments are vectors.

The interaction-specific arguments can be scalars, vectors or a list of two scalars/vectors. Scalars and vectors will be recycled across the length of the first and second anchor regions. For lists, the first element will be applied to the first anchor regions, and the second element will be applied to the second anchor regions.

After any modifications are applied, resorting may be performed to ensure that the entries in the `regions` slot of the output object are ordered. This means that the order of the ranges in the `regions` slot may change between the input and output object. However, the number and order of the interactions will not change.

For GInteractions and InteractionSet objects, the `width` method will return a list with two integer vectors `first` and `second` with the same length as `x`. These contain the widths of the first or second anchor regions corresponding to each interaction. For ContactMatrix objects, the method will return a list with the vectors `row` and `column`, with lengths equal to the number of rows and column respectively.

### Value

Depending on the method, an object of the same class as `x`, or information regarding the genomic regions – see Details.

### Author(s)

Aaron Lun, based on suggestions from Liz Ing-Simmons.

### See Also

`trim,GenomicRanges-method`, `resize,GenomicRanges-method`, `narrow,GenomicRanges-method`, `shift,GenomicRanges-method`, `flank,GenomicRanges-method`, `width,IRanges-method`

### Examples

    example(GInteractions, echo=FALSE)

    trim(gi)
    width(gi)

    # Functions are applied along the length of 'gi':
    new.sizes <- round(runif(length(gi), 10, 50))
    gi2 <- resize(gi, width=new.sizes)
    gi2
    resize(first(gi), width=new.sizes)
    resize(second(gi), width=new.sizes)

    # ... not along the length of 'regions(gi)': note the difference!
    mod.regions <- suppressWarnings(resize(regions(gi), width=new.sizes))
    mod.regions[anchors(gi, type="first", id=TRUE)] # not the same as first(gi2)!
    mod.regions[anchors(gi, type="second", id=TRUE)] # not the same second(gi2)!

    example(ContactMatrix, echo=FALSE)
    trim(x)
    width(x)

[Package InteractionSet version 1.8.0 Index]