interaction-subset: Interaction subsetting and combining

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

Description

Methods to subset or combine InteractionSet or GInteractions objects.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
## S4 method for signature 'InteractionSet,ANY,ANY'
x[i, j, ..., drop=TRUE]

## S4 replacement method for signature 'InteractionSet,ANY,ANY,InteractionSet'
x[i, j] <- value

## S4 method for signature 'InteractionSet'
subset(x, i, j)

## S4 replacement method for signature 'GInteractions,ANY,GInteractions'
x[i] <- value

Arguments

x

A GInteractions or InteractionSet object.

i, j

A vector of logical or integer subscripts. For InteractionSet objects, these indicate the rows and columns to be subsetted for i and j, respectively. Rows correspond to pairwise interactions while columns correspond to samples. For GInteractions objects, i indicates the genomic interactions to be retained. j is ignored as there is no concept of samples in this class.

..., drop

Additional arguments that are ignored.

value

A GInteractions or InteractionSet object with length or number of rows equal to length of i (or that of x, if i is not specified). For InteractionSet objects, the number of columns must be equal to the length of j (or number of columns in x, if j is not specified).

Value

A subsetted object of the same class as x.

Details for GInteractions

Subsetting operations are not explicitly listed above as they inherit from the Vector class. They will return a GInteractions object containing the specified interactions. Values of the anchor1 and anchor2 slots will be appropriately subsetted in the returned object, along with any metadata in mcols. However, note that the value of regions will not be modified by subsetting.

For short index vectors, subsetting a GInteractions object prior to calling anchors may be much faster than the reverse procedure. This is because the anchors getter will construct a GRanges(List) containing the genomic loci for all pairwise interactions. Subsetting beforehand ensures that only loci for the desired interactions are included. This avoids constructing the entire object just to subset it later.

Subset assignment will check if the regions are identical between x and value. If not, the regions slot in the output object will be set to a sorted union of all regions from x and value. Indices are refactored appropriately to point to the entries in the new regions.

Details for InteractionSet

Subsetting behaves in much the same way as that for the SummarizedExperiment class. Interactions are treated as rows and will be subsetted as such. All subsetting operations will return an InteractionSet with the specified interactions (rows) or samples (columns). Again, note that the value of regions will not be modified by subsetting.

Author(s)

Aaron Lun

See Also

InteractionSet-class GInteractions-class

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
example(GInteractions, echo=FALSE)

# Subsetting:    
gi[1,]
gi[1:2,]
gi[3]
gi[3:4]

temp.gi <- gi
temp.gi[3:4] <- gi[1:2]

# Splitting:
f <- sample(4, length(gi), replace=TRUE)
out <- split(gi, f)
out[[1]]

#################
# Same can be done for an InteractionSet object:

example(InteractionSet, echo=FALSE)

# Subsetting:    
iset[1,]
iset[1:2,]
iset[,1]
iset[,1:2]
iset[3,3]
iset[3:4,3:4]

# Splitting:
out <- split(iset, f)
out[[1]]

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