ContactMatrix accessors | R Documentation |
Methods to get and set fields in an ContactMatrix object.
## S4 method for signature 'ContactMatrix'
anchors(x, type="both", id=FALSE)
## S4 method for signature 'ContactMatrix'
anchorIds(x, type="both")
## S4 replacement method for signature 'ContactMatrix'
anchorIds(x, type="both") <- value
## S4 method for signature 'ContactMatrix'
regions(x)
## S4 replacement method for signature 'ContactMatrix'
regions(x) <- value
## S4 replacement method for signature 'ContactMatrix'
replaceRegions(x) <- value
## S4 replacement method for signature 'ContactMatrix'
appendRegions(x) <- value
## S4 method for signature 'ContactMatrix'
reduceRegions(x)
## S4 method for signature 'ContactMatrix'
show(x)
## S4 method for signature 'ContactMatrix'
as.matrix(x)
## S4 replacement method for signature 'ContactMatrix'
as.matrix(x) <- value
## S4 method for signature 'ContactMatrix'
t(x)
## S4 method for signature 'ContactMatrix'
dim(x)
## S4 method for signature 'ContactMatrix'
dimnames(x)
## S4 replacement method for signature 'ContactMatrix'
dimnames(x) <- value
## S4 method for signature 'ContactMatrix'
length(x)
x |
A ContactMatrix object. |
type |
a string specifying which anchors are to be extracted or replaced. |
id |
a scalar logical indicating whether indices or GRanges should be returned. |
value |
For For For For |
The return value of anchors
varies depending on type
and id
:
If id=FALSE
, a GRanges object is returned containing the regions specified by the anchor1
or anchor2
slots in x
,
for type=="row"
or "column"
, respectively.
If id=FALSE
and type="both"
, a list is returned with two entries row
and column
, containing regions specified by anchor1
and anchor2
respectively.
If id=TRUE
, the integer vectors in the anchor1
or anchor2
slots of x
are returned directly, depending on type
.
A list of length two is returned for type="both"
, containing both of these vectors.
Note that anchorIds
is equivalent to calling anchors
with id=TRUE
.
Replacement in anchorIds<-
can only be performed using anchor indices.
If type="both"
, a list of two integer vectors is required in value
, specifying the indices of the row- and column-wise interacting regions in x
.
If type="row"
or "column"
, an integer vector is required to replace the existing row- or column-wise indices in the anchor1
or anchor2
slot, respectively.
For regions
, a GRanges is returned equal to the regions
slot in x
.
For regions<-
, the GRanges in value
is used to replace the regions
slot.
Resorting of the replacement GRanges is performed automatically, along with re-indexing of the anchors.
In addition, the input GRanges must be of the same length as the existing object in the regions
slot.
The newRegions
replacement method can take variable length GRanges, but requires that the replacement contain (at least) all ranges contained in anchors(x)
.
The appendRegions
replacement method appends extra intervals to the existing regions
slot of x
.
The reduceRegions
method removes unused entries in the regions
slot, to save memory – see reduceRegions,GInteractions-method
for more details.
The show
method will print out various details of the object, such as the dimensions of the matrix
slot and the length of the regions
slot.
The as.matrix
method will return the value of the matrix
slot, containing a matrix-like object of interaction data.
Replacement with a matrix-like object of the same dimensions can be performed using the as.matrix<-
function.
The t
method will transpose the matrix, i.e., switch the rows and columns (and switch the vectors in the anchor1
and anchor2
slots).
The dim
method will return a vector of length 2, containing the dimensions of the matrix
slot.
The dimnames
method will return a list of length 2, containing the row and column names of matrix
(these can be modified with the dimnames<-
method).
The length
method will return an integer scalar corresponding to the total number of entries in the matrix
slot.
As the ContactMatrix class inherits from the Annotated
class, additional metadata can be stored in the metadata
slot.
This can be accessed or modified with metadata,Annotated-method
.
For the getters, values in various slots of x
are returned, while for the setters, the slots of x
are modified accordingly – see Details.
Aaron Lun
ContactMatrix-class
example(ContactMatrix, echo=FALSE) # Generate a nice object.
show(x)
# Various matrix methods:
as.matrix(x)
t(x)
nrow(x)
ncol(x)
length(x)
# Accessing anchor ranges or indices:
anchors(x)
anchors(x, type="row")
anchors(x, id=TRUE)
anchors(x, id=TRUE, type="row")
anchors(x, id=TRUE, type="column")
# Modifying anchor indices:
nregs <- length(regions(x))
anchorIds(x) <- list(sample(nregs, nrow(x), replace=TRUE),
sample(nregs, ncol(x), replace=TRUE))
anchors(x, id=TRUE, type="row")
anchors(x, id=TRUE, type="column")
# Accessing or modifying regions:
regions(x)
regions(x)$score <- runif(length(regions(x)))
new.ranges <- c(regions(x), resize(regions(x), fix="center", width=50))
try(regions(x) <- new.ranges) # Fails
replaceRegions(x) <- new.ranges # Succeeds
length(regions(x))
appendRegions(x) <- GRanges("chrA", IRanges(5:10+1000, 1100+5:10), score=runif(6))
length(regions(x))
reduceRegions(x)
# Setting metadata
metadata(x)$name <- "I am a contact matrix"
metadata(x)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.