pairs {InteractionSet} | R Documentation

## Extract paired ranges

### Description

Represent interactions in a GInteractions or Interaction object as a Pairs, SelfHits or GRangesList object.

### Usage

    ## S4 method for signature 'GInteractions'
    pairs(x, id=FALSE, as.grlist=FALSE)

    # Equivalent call for InteractionSet to above.

    makeGInteractionsFromGRangesPairs(x)

### Arguments

`x` | For `pairs`, a GInteractions or InteractionSet object. For `makeGInteractionsFromGRangesPairs`, a Pairs object containing two parallel GRanges.
`id` | A logical scalar specifying whether indices should be returned instead of regions.
`as.grlist` | A logical scalar specifying whether a GRangesList should be returned.

### Details

Recall that the GInteractions object stores anchor regions for each interaction in two parallel GRanges, where corresponding entries between the two GRanges constitute the pair of regions for one interaction. These parallel ranges can be extracted and stored as a Pairs object for further manipulation. This is similar to the GRangesList reported by `anchors` with `type="both"` and `id=FALSE`. The reverse conversion is performed using `makeGInteractionsFromGRangesPairs`.

An alternative representation involves storing the two anchors for each interaction in a single GRanges of length 2. Multiple interactions are then stored as a GRangesList, along with any metadata and sequence information. This is returned if `as.grlist=FALSE`, may be more useful in some applications where the two interacting regions must be in the same GRanges. Finally, if `id=TRUE`, the anchor indices are extracted and returned as a SelfHits object. This may be useful for graph construction.

### Value

For `pairs`, if `id=TRUE`, a SelfHits object is returned. Otherwise, if `as.grlist=TRUE`, a GRangesList object is returned. Otherwise, a Pairs object is returned.

For `makeGInteractionsFromGRangesPairs`, a GInteractions object is returned.

### Author(s)

Aaron Lun

### See Also

`GInteractions`, `Pairs`, `SelfHits`, `GRangesList`

### Examples

    example(GInteractions, echo=FALSE)
    y <- pairs(gi)
    y
    makeGInteractionsFromGRangesPairs(y)

    pairs(gi, id=TRUE)
    pairs(gi, as.grlist=TRUE)

    example(InteractionSet, echo=FALSE)
    pairs(iset)
    pairs(iset, id=TRUE)
    pairs(iset, as.grlist=TRUE)

[Package InteractionSet version 1.10.0 Index]