RangedSummarizedExperiment-class function - RDocumentation (original) (raw)
RangedSummarizedExperiment-class: RangedSummarizedExperiment objects
Description
The RangedSummarizedExperiment class is a matrix-like container where rows represent ranges of interest (as a GRanges or GRangesList object) and columns represent samples (with sample data summarized as aDataFrame). A RangedSummarizedExperiment contains one or more assays, each represented by a matrix-like object of numeric or other mode.
RangedSummarizedExperiment is a subclass of SummarizedExperiment and, as such, all the methods documented in ?[SummarizedExperiment](/link/SummarizedExperiment?package=SummarizedExperiment&version=1.2.3)
also work on a RangedSummarizedExperiment object. The methods documented below are additional methods that are specific to RangedSummarizedExperiment objects.
Usage
Constructor
SummarizedExperiment(assays, ...) "SummarizedExperiment"(assays, rowData=NULL, rowRanges=GRangesList(), colData=DataFrame(), metadata=list()) "SummarizedExperiment"(assays, ...) "SummarizedExperiment"(assays, ...) "SummarizedExperiment"(assays, ...)
Accessors
rowRanges(x, ...) rowRanges(x, ...) <- value
Subsetting
"subset"(x, subset, select, ...)
rowRanges access
see 'GRanges compatibility', below
Arguments
assays
A list
or SimpleList
of matrix-like elements, or a matrix-like object. All elements of the list must have the same dimensions, and dimension names (if present) must be consistent across elements and with the row names of rowRanges
andcolData
.
rowData
A DataFrame object describing the rows. Row names, if present, become the row names of the SummarizedExperiment object. The number of rows of theDataFrame must equal the number of rows of the matrices in assays
.
rowRanges
A GRanges orGRangesList object describing the ranges of interest. Names, if present, become the row names of the SummarizedExperiment object. The length of theGRanges or GRangesList must equal the number of rows of the matrices in assays
. If rowRanges
is missing, a SummarizedExperiment instance is returned.
colData
An optional DataFrame describing the samples. Row names, if present, become the column names of the RangedSummarizedExperiment.
metadata
An optional list
of arbitrary content describing the overall experiment.
...
For SummarizedExperiment
, S4 methods list
and matrix
, arguments identical to those of theSimpleList
method.
For rowRanges
, ignored.
x
A RangedSummarizedExperiment object. The rowRanges
setter will also accept a SummarizedExperiment object and will first coerce it to RangedSummarizedExperiment before it sets value
on it.
subset
An expression which, when evaluated in the context of rowRanges(x)
, is a logical vector indicating elements or rows to keep: missing values are taken as false.
select
An expression which, when evaluated in the context of colData(x)
, is a logical vector indicating elements or rows to keep: missing values are taken as false.
Constructor
RangedSummarizedExperiment instances are constructed using theSummarizedExperiment
function with arguments outlined above.
Accessors
In the following code snippets, x
is a RangedSummarizedExperiment object.
rowRanges(x)
, rowRanges(x) <- value
:
Get or set the row data. value
is a GenomicRanges
object. Row names of value
must be NULL or consistent with the existing row names of x
.
GRanges compatibility (rowRanges access)
Many GRanges and GRangesList operations are supported on RangedSummarizedExperiment objects, using rowRanges
. Supported operations include: [pcompare](/link/pcompare?package=SummarizedExperiment&version=1.2.3)
,[duplicated](/link/duplicated?package=SummarizedExperiment&version=1.2.3)
, [end](/link/end?package=SummarizedExperiment&version=1.2.3)
, [end<-](/link/end%26lt%3B-?package=SummarizedExperiment&version=1.2.3)
, [granges](/link/granges?package=SummarizedExperiment&version=1.2.3)
, [is.unsorted](/link/is.unsorted?package=SummarizedExperiment&version=1.2.3)
, [match](/link/match?package=SummarizedExperiment&version=1.2.3)
,[mcols](/link/mcols?package=SummarizedExperiment&version=1.2.3)
, [mcols<-](/link/mcols%26lt%3B-?package=SummarizedExperiment&version=1.2.3)
, [order](/link/order?package=SummarizedExperiment&version=1.2.3)
,[ranges](/link/ranges?package=SummarizedExperiment&version=1.2.3)
, [ranges<-](/link/ranges%26lt%3B-?package=SummarizedExperiment&version=1.2.3)
, [rank](/link/rank?package=SummarizedExperiment&version=1.2.3)
,[seqinfo](/link/seqinfo?package=SummarizedExperiment&version=1.2.3)
, [seqinfo<-](/link/seqinfo%26lt%3B-?package=SummarizedExperiment&version=1.2.3)
, [seqnames](/link/seqnames?package=SummarizedExperiment&version=1.2.3)
,[sort](/link/sort?package=SummarizedExperiment&version=1.2.3)
, [start](/link/start?package=SummarizedExperiment&version=1.2.3)
, [start<-](/link/start%26lt%3B-?package=SummarizedExperiment&version=1.2.3)
,[strand](/link/strand?package=SummarizedExperiment&version=1.2.3)
, [strand<-](/link/strand%26lt%3B-?package=SummarizedExperiment&version=1.2.3)
,[width](/link/width?package=SummarizedExperiment&version=1.2.3)
, [width<-](/link/width%26lt%3B-?package=SummarizedExperiment&version=1.2.3)
. See also ?[shift](/link/shift?package=SummarizedExperiment&version=1.2.3&to=SummarizedExperiment)
,?[isDisjoint](/link/isDisjoint?package=SummarizedExperiment&version=1.2.3&to=SummarizedExperiment)
,?[coverage](/link/coverage?package=SummarizedExperiment&version=1.2.3&to=SummarizedExperiment)
,?[findOverlaps](/link/findOverlaps?package=SummarizedExperiment&version=1.2.3&to=SummarizedExperiment)
, and?[nearest](/link/nearest?package=SummarizedExperiment&version=1.2.3&to=SummarizedExperiment)
for more_GRanges compatibility methods_. Not all GRanges operations are supported, because they do not make sense for RangedSummarizedExperiment objects (e.g., length, name, as.data.frame, c, splitAsList), involve non-trivial combination or splitting of rows (e.g., disjoin, gaps, reduce, unique), or have not yet been implemented (Ops, map, window, window<-).
Subsetting
In the code snippets below, x
is a RangedSummarizedExperiment object.
subset(x, subset, select)
:
Create a subset of x
using an expression subset
referring to columns ofrowRanges(x)
(including ‘seqnames’, ‘start’, ‘end’, ‘width’, ‘strand’, andnames(rowData(x))
) and / or select
referring to column names of colData(x)
.
Extension
RangedSummarizedExperiment is implemented as an S4 class, and can be extended in the usual way, using contains="RangedSummarizedExperiment"
in the new class definition.
Details
The rows of a RangedSummarizedExperiment object represent ranges (in genomic coordinates) of interest. The ranges of interest are described by a GRanges or a GRangesList object, accessible using the rowRanges
function, described below. The GRanges and GRangesList classes contains sequence (e.g., chromosome) name, genomic coordinates, and strand information. Each range can be annotated with additional data; this data might be used to describe the range or to summarize results (e.g., statistics of differential abundance) relevant to the range. Rows may or may not have row names; they often will not.
See Also
- SummarizedExperiment objects.
- shift,isDisjoint,coverage,findOverlaps, andnearest for more_GRanges compatibility methods_.
- GRanges objects in the GenomicRanges package.
Examples
nrows <- 200; ncols <- 6
counts <- matrix(runif(nrows * ncols, 1, 1e4), nrows)
rowRanges <- GRanges(rep(c("chr1", "chr2"), c(50, 150)),
IRanges(floor(runif(200, 1e5, 1e6)), width=100),
strand=sample(c("+", "-"), 200, TRUE),
feature_id=sprintf("ID%03d", 1:200))
colData <- DataFrame(Treatment=rep(c("ChIP", "Input"), 3),
row.names=LETTERS[1:6])
rse <- SummarizedExperiment(assays=SimpleList(counts=counts),
rowRanges=rowRanges, colData=colData)
rse
dim(rse)
dimnames(rse)
assayNames(rse)
head(assay(rse))
assays(rse) <- endoapply(assays(rse), asinh)
head(assay(rse))
rowRanges(rse)
rowData(rse) # same as 'mcols(rowRanges(rse))'
colData(rse)
rse[, rse$Treatment == "ChIP"]
## cbind() combines objects with the same ranges but different samples:
rse1 <- rse
rse2 <- rse1[,1:3]
colnames(rse2) <- letters[1:ncol(rse2)]
cmb1 <- cbind(rse1, rse2)
dim(cmb1)
dimnames(cmb1)
## rbind() combines objects with the same samples but different ranges:
rse1 <- rse
rse2 <- rse1[1:50,]
rownames(rse2) <- letters[1:nrow(rse2)]
cmb2 <- rbind(rse1, rse2)
dim(cmb2)
dimnames(cmb2)
## Coercion to/from SummarizedExperiment:
se0 <- as(rse, "SummarizedExperiment")
se0
as(se0, "RangedSummarizedExperiment")
## Setting rowRanges on a SummarizedExperiment object turns it into a
## RangedSummarizedExperiment object:
se <- se0
rowRanges(se) <- rowRanges
se # RangedSummarizedExperiment
## Sanity checks:
stopifnot(identical(assays(se0), assays(rse)))
stopifnot(identical(dim(se0), dim(rse)))
stopifnot(identical(dimnames(se0), dimnames(rse)))
stopifnot(identical(rowData(se0), rowData(rse)))
stopifnot(identical(colData(se0), colData(rse)))
Run the code above in your browser using DataLab