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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339
|
\name{RangedSummarizedExperiment-class}
\docType{class}
% Class
\alias{class:RangedSummarizedExperiment}
\alias{RangedSummarizedExperiment-class}
\alias{RangedSummarizedExperiment}
% Constructor
\alias{SummarizedExperiment}
\alias{SummarizedExperiment,SimpleList-method}
\alias{SummarizedExperiment,ANY-method}
\alias{SummarizedExperiment,list-method}
\alias{SummarizedExperiment,missing-method}
% Coercion
\alias{coerce,RangedSummarizedExperiment,SummarizedExperiment-method}
\alias{coerce,SummarizedExperiment,RangedSummarizedExperiment-method}
% Accessors
\alias{rowRanges}
\alias{rowRanges,SummarizedExperiment-method}
\alias{rowRanges,RangedSummarizedExperiment-method}
\alias{rowRanges<-}
\alias{rowRanges<-,SummarizedExperiment,NULL-method}
\alias{rowRanges<-,RangedSummarizedExperiment,NULL-method}
\alias{rowRanges<-,SummarizedExperiment,GenomicRanges-method}
\alias{rowRanges<-,SummarizedExperiment,GRangesList-method}
\alias{names,RangedSummarizedExperiment-method}
\alias{names<-,RangedSummarizedExperiment-method}
\alias{dimnames,RangedSummarizedExperiment-method}
\alias{dimnames<-,RangedSummarizedExperiment,list-method}
% GenomicRanges compatibility methods
\alias{Compare,ANY,RangedSummarizedExperiment-method}
\alias{Compare,RangedSummarizedExperiment,ANY-method}
\alias{Compare,RangedSummarizedExperiment,RangedSummarizedExperiment-method}
\alias{pcompare,ANY,RangedSummarizedExperiment-method}
\alias{pcompare,RangedSummarizedExperiment,ANY-method}
\alias{pcompare,RangedSummarizedExperiment,RangedSummarizedExperiment-method}
\alias{duplicated,RangedSummarizedExperiment-method}
\alias{elementMetadata,RangedSummarizedExperiment-method}
\alias{elementMetadata<-,RangedSummarizedExperiment-method}
\alias{end,RangedSummarizedExperiment-method}
\alias{end<-,RangedSummarizedExperiment-method}
\alias{granges,RangedSummarizedExperiment-method}
\alias{is.unsorted,RangedSummarizedExperiment-method}
\alias{mcols,RangedSummarizedExperiment-method}
\alias{mcols<-,RangedSummarizedExperiment-method}
\alias{order,RangedSummarizedExperiment-method}
\alias{ranges,RangedSummarizedExperiment-method}
\alias{ranges<-,RangedSummarizedExperiment-method}
\alias{rank,RangedSummarizedExperiment-method}
\alias{seqinfo,RangedSummarizedExperiment-method}
\alias{seqinfo<-,RangedSummarizedExperiment-method}
\alias{seqnames,RangedSummarizedExperiment-method}
\alias{sort,RangedSummarizedExperiment-method}
\alias{split,RangedSummarizedExperiment-method}
\alias{split,RangedSummarizedExperiment,ANY-method}
\alias{start,RangedSummarizedExperiment-method}
\alias{start<-,RangedSummarizedExperiment-method}
\alias{strand,RangedSummarizedExperiment-method}
\alias{strand<-,RangedSummarizedExperiment,ANY-method}
\alias{subset,RangedSummarizedExperiment-method}
\alias{width,RangedSummarizedExperiment-method}
\alias{width<-,RangedSummarizedExperiment-method}
% updateObject
\alias{updateObject,RangedSummarizedExperiment-method}
\title{RangedSummarizedExperiment objects}
\description{
The RangedSummarizedExperiment class is a matrix-like container where rows
represent ranges of interest (as a \link{GRanges} or \link{GRangesList}
object) and columns represent samples (with sample data summarized as a
\link{DataFrame}). A RangedSummarizedExperiment contains one or more
assays, each represented by a matrix-like object of numeric or other mode.
RangedSummarizedExperiment is a subclass of \link{SummarizedExperiment} and,
as such, all the methods documented in \code{?\link{SummarizedExperiment}}
also work on a RangedSummarizedExperiment object. The methods documented
below are additional methods that are specific to RangedSummarizedExperiment
objects.
}
\usage{
## Constructor
SummarizedExperiment(assays, ...)
\S4method{SummarizedExperiment}{SimpleList}(assays, rowData=NULL, rowRanges=GRangesList(),
colData=DataFrame(), metadata=list())
\S4method{SummarizedExperiment}{ANY}(assays, ...)
\S4method{SummarizedExperiment}{list}(assays, ...)
\S4method{SummarizedExperiment}{missing}(assays, ...)
## Accessors
rowRanges(x, ...)
rowRanges(x, ...) <- value
## Subsetting
\S4method{subset}{RangedSummarizedExperiment}(x, subset, select, ...)
## rowRanges access
## see 'GRanges compatibility', below
}
\arguments{
\item{assays}{A \code{list} or \code{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 \code{rowRanges} and
\code{colData}.}
\item{rowData}{A \link[S4Vectors]{DataFrame} object describing
the rows. Row names, if present, become the row names of the
SummarizedExperiment object. The number of rows of the
\link[S4Vectors]{DataFrame} must equal the number of rows of the
matrices in \code{assays}.}
\item{rowRanges}{A \link[GenomicRanges]{GRanges} or
\link[GenomicRanges]{GRangesList} object describing the ranges of
interest. Names, if present, become the row names of the
SummarizedExperiment object. The length of the
\link[GenomicRanges]{GRanges} or \link[GenomicRanges]{GRangesList}
must equal the number of rows of the matrices in \code{assays}.
If \code{rowRanges} is missing, a \link{SummarizedExperiment}
instance is returned.}
\item{colData}{An optional \link{DataFrame} describing the
samples. Row names, if present, become the column names of the
RangedSummarizedExperiment.}
\item{metadata}{An optional \code{list} of arbitrary content
describing the overall experiment.}
\item{...}{For \code{SummarizedExperiment}, S4 methods \code{list}
and \code{matrix}, arguments identical to those of the
\code{SimpleList} method.
For \code{rowRanges}, ignored.
}
\item{x}{A RangedSummarizedExperiment object. The \code{rowRanges} setter
will also accept a \link{SummarizedExperiment} object and will first
coerce it to RangedSummarizedExperiment before it sets \code{value} on
it.}
\item{value}{A \link[GenomicRanges]{GRanges} or
\link[GenomicRanges]{GRangesList} object.}
\item{subset}{An expression which, when evaluated in the
context of \code{rowRanges(x)}, is a logical vector indicating
elements or rows to keep: missing values are taken as false.}
\item{select}{An expression which, when evaluated in the
context of \code{colData(x)}, is a logical vector indicating
elements or rows to keep: missing values are taken as false.}
}
\details{
The rows of a RangedSummarizedExperiment object represent ranges
(in genomic coordinates) of interest. The ranges of interest are
described by a \link{GRanges} or a \link{GRangesList} object, accessible
using the \code{rowRanges} function, described below. The \link{GRanges}
and \link{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.
}
\section{Constructor}{
RangedSummarizedExperiment instances are constructed using the
\code{SummarizedExperiment} function with arguments outlined above.
}
\section{Accessors}{
In the following code snippets, \code{x} is a RangedSummarizedExperiment
object.
\describe{
\item{\code{rowRanges(x)}, \code{rowRanges(x) <- value}:}{Get or set the
row data. \code{value} is a \code{GenomicRanges} object. Row
names of \code{value} must be NULL or consistent with the existing
row names of \code{x}.}
}
}
\section{GRanges compatibility (rowRanges access)}{
Many \link{GRanges} and \link{GRangesList} operations are supported on
RangedSummarizedExperiment objects, using \code{rowRanges}.
Supported operations include: \code{\link{pcompare}},
\code{\link{duplicated}}, \code{\link{end}}, \code{\link{end<-}},
\code{\link{granges}}, \code{\link{is.unsorted}}, \code{\link{match}},
\code{\link{mcols}}, \code{\link{mcols<-}}, \code{\link{order}},
\code{\link{ranges}}, \code{\link{ranges<-}}, \code{\link{rank}},
\code{\link{seqinfo}}, \code{\link{seqinfo<-}}, \code{\link{seqnames}},
\code{\link{sort}}, \code{\link{start}}, \code{\link{start<-}},
\code{\link{strand}}, \code{\link{strand<-}},
\code{\link{width}}, \code{\link{width<-}}.
See also \code{?\link[SummarizedExperiment]{shift}},
\code{?\link[SummarizedExperiment]{isDisjoint}},
\code{?\link[SummarizedExperiment]{coverage}},
\code{?\link[SummarizedExperiment]{findOverlaps}}, and
\code{?\link[SummarizedExperiment]{nearest}} for more
\emph{GRanges compatibility methods}.
Not all \link{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<-).
}
\section{Subsetting}{
In the code snippets below, \code{x} is a RangedSummarizedExperiment
object.
\describe{
\item{\code{subset(x, subset, select)}:}{Create a subset of \code{x}
using an expression \code{subset} referring to columns of
\code{rowRanges(x)} (including \sQuote{seqnames}, \sQuote{start},
\sQuote{end}, \sQuote{width}, \sQuote{strand}, and
\code{names(rowData(x))}) and / or \code{select} referring to
column names of \code{colData(x)}.}
}
}
\section{Extension}{
RangedSummarizedExperiment is implemented as an S4 class, and can be
extended in the usual way, using \code{contains="RangedSummarizedExperiment"}
in the new class definition.
}
\author{Martin Morgan, \url{mtmorgan@fhcrc.org}}
\seealso{
\itemize{
\item \link{SummarizedExperiment-class}
\item \link[SummarizedExperiment]{shift},
\link[SummarizedExperiment]{isDisjoint},
\link[SummarizedExperiment]{coverage},
\link[SummarizedExperiment]{findOverlaps}, and
\link[SummarizedExperiment]{nearest} for more
\emph{GRanges compatibility methods}.
\item \link[GenomicRanges]{GRanges} objects in the \pkg{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)))
}
|