boundingBox {InteractionSet} | R Documentation

## Get the bounding box

### Description

Computing a minimum bounding box for groups of pairwise interactions.

### Usage

    ## S4 method for signature 'GInteractions'
    boundingBox(x, f)

    # Note, the same call is used for the InteractionSet method.

### Arguments

`x` | A GInteractions or InteractionSet object.
`f` | A factor or vector of length equal to that of `x`, indicating the group to which each pairwise interaction belongs.

### Details

For any group of pairwise interactions, the minimum bounding box is the smallest rectangle in the interaction space that contains all interactions in the group. Each side of the box has coordinates spanning the most extreme anchor regions on the corresponding chromosome. This is often useful for summarizing clusters of interactions.

Grouping of interactions is specified using `f`, where interactions in `x` with the same level of `f` are considered to be in the same group. If `f` is not specified, all interactions in `x` are assumed to be in a single group (named as “1”). An error will be raised if a group spans multiple chromosomes for either the first or second anchor regions.

The function returns a GInteractions object containing the coordinates of the bounding boxes for all groups. Each interaction represents a bounding box for a group, where the anchor regions represent the sides of the box. Entries are named according to the levels of `f`, in order to specify which bounding box corresponds to which group.

It is recommended to run `swapAnchors` prior to computing the bounding box for intra-chromosomal groups. If all `anchor1 >= anchor2` or all `anchor1 <= anchor2`, all interactions will lie on one side of the diagonal of the intra-chromosomal interaction space. This results in the smallest possible minimum bounding box, which will only increase in size if interactions are placed on the other side of the diagonal. Alternatively, users can specify a StrictGInteractions object as an input into `x`, in which `anchor1 <= anchor2` is enforced automatically.

### Value

A GInteractions object containing the coordinates of each bounding box.

### Author(s)

Aaron Lun

### See Also

`GInteractions-class`, `InteractionSet-class`

### Examples

    example(GInteractions, echo=FALSE)

    # Making up a sensible grouping.
    gi <- sort(gi)
    all.chrs <- as.character(seqnames(regions(gi)))
    f <- paste0(all.chrs[anchors(gi, type="first", id=TRUE)], ".",
                all.chrs[anchors(gi, type="second", id=TRUE)])

    boundingBox(gi, f)
    boundingBox(swapAnchors(gi), f)

    # Fails for multiple chromosomes
    try(out <- boundingBox(gi))
    in.A <- f=="chrA.chrA"
    out <- boundingBox(gi[in.A])

[Package InteractionSet version 1.15.3 Index]