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 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600
|
\name{exonsBy}
\Rdversion{1.1}
\docType{class}
\alias{disjointExons,EnsDb-method}
\alias{cdsBy}
\alias{cdsBy,EnsDb-method}
\alias{fiveUTRsByTranscript,EnsDb-method}
\alias{threeUTRsByTranscript,EnsDb-method}
\alias{exons}
\alias{exons,EnsDb-method}
\alias{exonsBy}
\alias{exonsBy,EnsDb-method}
\alias{intronsByTranscript,EnsDb-method}
\alias{exonsByOverlaps,EnsDb-method}
\alias{genes}
\alias{genes,EnsDb-method}
\alias{toSAF}
\alias{toSAF,GRangesList-method}
\alias{transcripts}
\alias{transcripts,EnsDb-method}
\alias{transcriptsBy}
\alias{transcriptsBy,EnsDb-method}
\alias{transcriptsByOverlaps,EnsDb-method}
\alias{promoters}
\alias{promoters,EnsDb-method}
\title{Retrieve annotation data from an Ensembl based package}
\description{
Retrieve gene/transcript/exons annotations stored in an Ensembl based
database package generated with the \code{\link{makeEnsembldbPackage}}
function. Parameter \code{filter} enables to define filters to
retrieve only specific data. Alternatively, a global filter might be
added to the \code{EnsDb} object using the \code{\link{addFilter}}
method.
}
\usage{
\S4method{exons}{EnsDb}(x, columns = listColumns(x,"exon"),
filter = AnnotationFilterList(), order.by,
order.type = "asc", return.type = "GRanges")
\S4method{exonsBy}{EnsDb}(x, by = c("tx", "gene"),
columns = listColumns(x, "exon"), filter =
AnnotationFilterList(), use.names = FALSE)
\S4method{intronsByTranscript}{EnsDb}(x, ..., use.names = FALSE)
\S4method{exonsByOverlaps}{EnsDb}(x, ranges, maxgap = -1L, minoverlap = 0L,
type = c("any", "start", "end"), columns = listColumns(x, "exon"),
filter = AnnotationFilterList())
\S4method{transcripts}{EnsDb}(x, columns = listColumns(x, "tx"),
filter = AnnotationFilterList(), order.by, order.type = "asc",
return.type = "GRanges")
\S4method{transcriptsBy}{EnsDb}(x, by = c("gene", "exon"),
columns = listColumns(x, "tx"), filter = AnnotationFilterList())
\S4method{transcriptsByOverlaps}{EnsDb}(x, ranges, maxgap = -1L,
minoverlap = 0L, type = c("any", "start", "end"),
columns = listColumns(x, "tx"), filter = AnnotationFilterList())
\S4method{promoters}{EnsDb}(x, upstream = 2000, downstream = 200,
use.names = TRUE, ...)
\S4method{genes}{EnsDb}(x, columns = c(listColumns(x, "gene"), "entrezid"),
filter = AnnotationFilterList(), order.by, order.type = "asc",
return.type = "GRanges")
\S4method{disjointExons}{EnsDb}(x, aggregateGenes = FALSE,
includeTranscripts = TRUE, filter = AnnotationFilterList(), ...)
\S4method{cdsBy}{EnsDb}(x, by = c("tx", "gene"), columns = NULL,
filter = AnnotationFilterList(), use.names = FALSE)
\S4method{fiveUTRsByTranscript}{EnsDb}(x, columns = NULL,
filter = AnnotationFilterList())
\S4method{threeUTRsByTranscript}{EnsDb}(x, columns = NULL,
filter = AnnotationFilterList())
\S4method{toSAF}{GRangesList}(x, ...)
}
\arguments{
(In alphabetic order)
\item{...}{
For \code{promoters}: additional arguments to be passed to the
\code{transcripts} method. For \code{intronsByTranscript}:
additional arguments such as \code{filter}.
}
\item{aggregateGenes}{
For \code{disjointExons}: When \code{FALSE} (default) exon fragments
that overlap multiple genes are dropped. When \code{TRUE}, all
fragments are kept and the \code{gene_id} metadata column includes
all gene IDs that overlap the exon fragment.
}
\item{by}{
For \code{exonsBy}: wheter exons sould be fetched by genes
or by transcripts; as in the corresponding function of the
\code{GenomicFeatures} package.
For \code{transcriptsBy}: whether
transcripts should be fetched by genes or by exons; fetching
transcripts by cds as supported by the
\code{\link[GenomicFeatures]{transcriptsBy}} method in the
\code{GenomicFeatures} package is currently not implemented.
For \code{cdsBy}: whether cds should be fetched by transcript of by
gene.
}
\item{columns}{
Columns to be retrieved from the database tables.
Default values for \code{genes} are all columns from the \code{gene}
database table, for \code{exons} and \code{exonsBy} the column names of
the \code{exon} database table table and for \code{transcript} and
\code{transcriptBy} the columns of the \code{tx} data base table
(see details below for more information).
Note that any of the column names of the database tables can be
submitted to any of the methods (use \code{\link{listTables}} or
\code{\link{listColumns}} methods for a complete list of allowed
column names).
For \code{cdsBy}: this argument is only supported for for
\code{by="tx"}.
}
\item{downstream}{
For method \code{promoters}: the number of nucleotides downstream of
the transcription start site that should be included in the promoter region.
}
\item{filter}{
A filter describing which results to retrieve from the database. Can
be a single object extending
\code{\link[AnnotationFilter]{AnnotationFilter}}, an
\code{\link[AnnotationFilter]{AnnotationFilterList}} object
combining several such objects or a \code{formula} representing a
filter expression (see examples below or
\code{\link[AnnotationFilter]{AnnotationFilter}} for more
details). Use the \code{\link{supportedFilters}} method to get an
overview of supported filter classes and related fields.
}
\item{includeTranscripts}{
For \code{disjointExons}: When \code{TRUE} (default) a
\code{tx_name} metadata column is included that lists all transcript
IDs that overlap the exon fragment. Note: this is different to the
\code{\link[GenomicFeatures]{disjointExons}} function in the
\code{GenomicFeatures} package, that lists the transcript names, not
IDs.
}
\item{maxgap}{
For \code{exonsByOverlaps} and \code{transcriptsByOverlaps}: see
\code{exonsByOverlaps} in \code{GenomicFeatures} for more
information.
}
\item{minoverlap}{
For \code{exonsByOverlaps} and \code{transcriptsByOverlaps}: see
\code{exonsByOverlaps} in \code{GenomicFeatures} for more
information.
}
\item{order.by}{
Character vector specifying the column(s) by which the result should
be ordered. This can be either in the form of
\code{"gene_id, seq_name"} or \code{c("gene_id", "seq_name")}.
}
\item{order.type}{
If the results should be ordered ascending
(\code{asc}, default) or descending (\code{desc}).
}
\item{ranges}{
For \code{exonsByOverlaps} and \code{transcriptsByOverlaps}: a
\code{GRanges} object specifying the genomic regions.
}
\item{return.type}{
Type of the returned object. Can be either
\code{"data.frame"}, \code{"DataFrame"} or \code{"GRanges"}. In the
latter case the return object will be a \code{GRanges} object with
the GRanges specifying the chromosomal start and end coordinates of
the feature (gene, transcript or exon, depending whether \code{genes},
\code{transcripts} or \code{exons} was called). All additional
columns are added as metadata columns to the GRanges object.
}
\item{type}{
For \code{exonsByOverlaps} and \code{transcriptsByOverlaps}: see
\code{exonsByOverlaps} in \code{GenomicFeatures} for more
information.
}
\item{upstream}{
For method \code{promoters}: the number of nucleotides upstream of
the transcription start site that should be included in the promoter region.
}
\item{use.names}{
For \code{cdsBy} and \code{exonsBy}: only for \code{by="gene"}: use
the names of the genes instead of their IDs as names of the resulting
\code{GRangesList}.
}
\item{x}{
For \code{toSAF} a \code{GRangesList} object.
For all other methods an \code{EnsDb} instance.
}
}
\section{Methods and Functions}{
\describe{
\item{exons}{
Retrieve exon information from the database. Additional
columns from transcripts or genes associated with the exons can be specified
and are added to the respective exon annotation.
}
\item{exonsBy}{
Retrieve exons grouped by transcript or by gene. This
function returns a \code{GRangesList} as does the analogous function
in the \code{GenomicFeatures} package. Using the \code{columns}
parameter it is possible to determine which additional values should
be retrieved from the database. These will be included in the
\code{GRanges} object for the exons as metadata columns.
The exons in the inner \code{GRanges} are ordered by the exon
index within the transcript (if \code{by="tx"}), or increasingly by the
chromosomal start position of the exon or decreasingly by the chromosomal end
position of the exon depending whether the gene is encoded on the
+ or - strand (for \code{by="gene"}).
The \code{GRanges} in the \code{GRangesList} will be ordered by
the name of the gene or transcript.
}
\item{intronsByTranscript}{
Retrieve introns by transcripts. Filters can also be passed to the
function. For more information see the \code{intronsByTranscript}
method in the \code{GenomicFeatures} package.
}
\item{exonsByOverlaps}{
Retrieve exons overlapping specified genomic ranges. For
more information see the
\code{exonsByOverlaps} method in the
\code{GenomicFeatures} package. The functionality is to some
extent similar and redundant to the \code{exons} method in
combination with \code{\link{GRangesFilter}} filter.
}
\item{transcripts}{
Retrieve transcript information from the database. Additional
columns from genes or exons associated with the transcripts can be specified
and are added to the respective transcript annotation.
}
\item{transcriptsBy}{
Retrieve transcripts grouped by gene or exon. This
function returns a \code{GRangesList} as does the analogous function
in the \code{GenomicFeatures} package. Using the \code{columns}
parameter it is possible to determine which additional values should
be retrieved from the database. These will be included in the
\code{GRanges} object for the transcripts as metadata columns.
The transcripts in the inner \code{GRanges} are ordered increasingly by the
chromosomal start position of the transcript for genes encoded on
the + strand and in a decreasing manner by the chromosomal end
position of the transcript for genes encoded on the - strand.
The \code{GRanges} in the \code{GRangesList} will be ordered by
the name of the gene or exon.
}
\item{transcriptsByOverlaps}{
Retrieve transcripts overlapping specified genomic ranges. For
more information see
\code{\link[GenomicFeatures]{transcriptsByOverlaps}} method in the
\code{GenomicFeatures} package. The functionality is to some
extent similar and redundant to the \code{transcripts} method in
combination with \code{\link{GRangesFilter}} filter.
}
\item{promoters}{
Retrieve promoter information from the database. Additional
columns from genes or exons associated with the promoters can be specified
and are added to the respective promoter annotation.
}
\item{genes}{
Retrieve gene information from the database. Additional columns
from transcripts or exons associated with the genes can be
specified and are added to the respective gene annotation. Note
that column \code{"entrezid"} is a \code{list} of Entrezgene
identifiers to accomodate the potential 1:n mapping between
Ensembl genes and Entrezgene IDs.
}
\item{disjointExons}{
This method is identical to
\code{\link[GenomicFeatures]{disjointExons}} defined in the
\code{GenomicFeatures} package. It creates a \code{GRanges} of
non-overlapping exon parts with metadata columns of \code{gene_id}
and \code{exonic_part}. Exon parts that overlap more than one gene
can be dropped with \code{aggregateGenes=FALSE}.
}
\item{cdsBy}{
Returns the coding region grouped either by transcript or by
gene. Each element in the \code{GRangesList} represents the cds
for one transcript or gene, with the individual ranges
corresponding to the coding part of its exons.
For \code{by="tx"} additional annotation columns can be added to
the individual \code{GRanges} (in addition to the default columns
\code{exon_id} and \code{exon_rank}).
Note that the \code{GRangesList} is sorted by its names.
}
\item{fiveUTRsByTranscript}{
Returns the 5' untranslated region for protein coding
transcripts.
}
\item{threeUTRsByTranscript}{
Returns the 3' untranslated region for protein coding
transcripts.
}
\item{toSAF}{
Reformats a \code{GRangesList} object into a
\code{data.frame} corresponding to a standard SAF (Simplified
Annotation Format) file (i.e. with column names \code{"GeneID"},
\code{"Chr"}, \code{"Start"}, \code{"End"} and
\code{"Strand"}). Note: this method makes only sense on a
\code{GRangesList} that groups features (exons, transcripts) by gene.
}
}
}
\details{
A detailed description of all database tables and the associated
attributes/column names is also given in the vignette of this package.
An overview of the columns is given below:
\describe{
\item{gene_id}{the Ensembl gene ID of the gene.}
\item{gene_name}{the name of the gene (in most cases its official symbol).}
\item{entrezid}{the NCBI Entrezgene ID of the gene. Note that this
column contains a \code{list} of Entrezgene identifiers to
accommodate the potential 1:n mapping between Ensembl genes and
Entrezgene IDs.}
\item{gene_biotype}{the biotype of the gene.}
\item{gene_seq_start}{the start coordinate of the gene on the
sequence (usually a chromosome).}
\item{gene_seq_end}{the end coordinate of the gene.}
\item{seq_name}{the name of the sequence the gene is encoded
(usually a chromosome).}
\item{seq_strand}{the strand on which the gene is encoded}
\item{seq_coord_system}{the coordinate system of the sequence.}
\item{tx_id}{the Ensembl transcript ID.}
\item{tx_biotype}{the biotype of the transcript.}
\item{tx_seq_start}{the chromosomal start coordinate of the transcript.}
\item{tx_seq_end}{the chromosomal end coordinate of the transcript.}
\item{tx_cds_seq_start}{the start coordinate of the coding region of
the transcript (NULL for non-coding transcripts).}
\item{tx_cds_seq_end}{the end coordinate of the coding region.}
\item{gc_content}{the G and C nucleotide content of the transcript's
sequence expressed as a percentage (i.e. between 0 and 100).}
\item{exon_id}{the ID of the exon. In Ensembl, each exon specified
by a unique chromosomal start and end position has its own
ID. Thus, the same exon might be part of several transcripts.}
\item{exon_seq_start}{the chromosomal start coordinate of the exon.}
\item{exon_seq_end}{the chromosomal end coordinate of the exon.}
\item{exon_idx}{the index of the exon in the transcript model. As
noted above, an exon can be part of several transcripts and thus
its position inside these transcript might differ.}
}
Many \code{EnsDb} databases provide also protein related
annotations. See \code{\link{listProteinColumns}} for more information.
}
\note{
Ensembl defines genes not only on standard chromosomes, but also on
patched chromosomes and chromosome variants. Thus it might be
advisable to restrict the queries to just those chromosomes of
interest (e.g. by specifying a \code{SeqNameFilter(c(1:22, "X", "Y"))}).
In addition, also so called LRG genes (Locus Reference Genomic) are defined in
Ensembl. Their gene id starts with LRG instead of ENS for Ensembl
genes, thus, a filter can be applied to specifically select those
genes or exclude those genes (see examples below).
Depending on the value of the global option
\code{"ucscChromosomeNames"} (use
\code{getOption(ucscChromosomeNames, FALSE)} to get its value or
\code{option(ucscChromosomeNames=TRUE)} to change its value)
the sequence/chromosome names of the returned \code{GRanges} objects
or provided in the returned \code{data.frame} or \code{DataFrame}
correspond to Ensembl chromosome names (if value is \code{FALSE}) or
UCSC chromosome names (if \code{TRUE}). This ensures a better
integration with the \code{Gviz} package, in which this option is set
by default to \code{TRUE}.
}
\value{
For \code{exons}, \code{transcripts} and \code{genes},
a \code{data.frame}, \code{DataFrame}
or a \code{GRanges}, depending on the value of the
\code{return.type} parameter. The result is ordered as specified by
the parameter \code{order.by} or, if not provided, by \code{seq_name}
and chromosomal start coordinate, but NOT by any ordering of values in
eventually submitted filter objects.
For \code{exonsBy}, \code{transcriptsBy}:
a \code{GRangesList}, depending on the value of the
\code{return.type} parameter. The results are ordered by the value of the
\code{by} parameter.
For \code{exonsByOverlaps} and \code{transcriptsByOverlaps}: a
\code{GRanges} with the exons or transcripts overlapping the specified
regions.
For \code{toSAF}: a \code{data.frame} with column names
\code{"GeneID"} (the group name from the \code{GRangesList}, i.e. the
ID by which the \code{GRanges} are split), \code{"Chr"} (the seqnames
from the \code{GRanges}), \code{"Start"} (the start coordinate),
\code{"End"} (the end coordinate) and \code{"Strand"} (the strand).
For \code{disjointExons}: a \code{GRanges} of non-overlapping exon
parts.
For \code{cdsBy}: a \code{GRangesList} with \code{GRanges} per either
transcript or exon specifying the start and end coordinates of the
coding region of the transcript or gene.
For \code{fiveUTRsByTranscript}: a \code{GRangesList} with
\code{GRanges} for each protein coding transcript representing the
start and end coordinates of full or partial exons that constitute the
5' untranslated region of the transcript.
For \code{threeUTRsByTranscript}: a \code{GRangesList} with
\code{GRanges} for each protein coding transcript representing the
start and end coordinates of full or partial exons that constitute the
3' untranslated region of the transcript.
}
\note{
While it is possible to request values from a column \code{"tx_name"}
(with the \code{columns} argument), no such column is present in the
database. The returned values correspond to the ID of the transcripts.
}
\author{
Johannes Rainer, Tim Triche
}
\seealso{
\code{\link{supportedFilters}} to get an overview of supported filters.
\code{\link{makeEnsembldbPackage}},
\code{\link{listColumns}}, \code{\link{lengthOf}}
\code{\link{addFilter}} for globally adding filters to an \code{EnsDb}
object.
}
\examples{
library(EnsDb.Hsapiens.v86)
edb <- EnsDb.Hsapiens.v86
###### genes
##
## Get all genes encoded on chromosome Y
AllY <- genes(edb, filter = SeqNameFilter("Y"))
AllY
## Return the result as a DataFrame; also, we use a filter expression here
## to define which features to extract from the database.
AllY.granges <- genes(edb,
filter = ~ seq_name == "Y",
return.type="DataFrame")
AllY.granges
## Include all transcripts of the gene and their chromosomal
## coordinates, sort by chrom start of transcripts and return as
## GRanges.
AllY.granges.tx <- genes(edb,
filter = SeqNameFilter("Y"),
columns = c("gene_id", "seq_name",
"seq_strand", "tx_id", "tx_biotype",
"tx_seq_start", "tx_seq_end"),
order.by = "tx_seq_start")
AllY.granges.tx
###### transcripts
##
## Get all transcripts of a gene
Tx <- transcripts(edb,
filter = GeneIdFilter("ENSG00000184895"),
order.by = "tx_seq_start")
Tx
## Get all transcripts of two genes along with some information on the
## gene and transcript
Tx <- transcripts(edb,
filter = GeneIdFilter(c("ENSG00000184895",
"ENSG00000092377")),
columns = c("gene_id", "gene_seq_start", "gene_seq_end",
"gene_biotype", "tx_biotype"))
Tx
###### promoters
##
## Get the bona-fide promoters (2k up- to 200nt downstream of TSS)
promoters(edb, filter = GeneIdFilter(c("ENSG00000184895",
"ENSG00000092377")))
###### exons
##
## Get all exons of protein coding transcript for the gene ENSG00000184895
Exon <- exons(edb,
filter = ~ gene_id == "ENSG00000184895" &
tx_biotype == "protein_coding",
columns = c("gene_id", "gene_seq_start", "gene_seq_end",
"tx_biotype", "gene_biotype"))
Exon
##### exonsBy
##
## Get all exons for transcripts encoded on chromosomes X and Y.
ETx <- exonsBy(edb, by = "tx",
filter = SeqNameFilter(c("X", "Y")))
ETx
## Get all exons for genes encoded on chromosome 1 to 22, X and Y and
## include additional annotation columns in the result
EGenes <- exonsBy(edb, by = "gene",
filter = SeqNameFilter(c("X", "Y")),
columns = c("gene_biotype", "gene_name"))
EGenes
## Note that this might also contain "LRG" genes.
length(grep(names(EGenes), pattern="LRG"))
## to fetch just Ensemblgenes, use an GeneIdFilter with value
## "ENS%" and condition "like"
eg <- exonsBy(edb, by = "gene",
filter = AnnotationFilterList(SeqNameFilter(c("X", "Y")),
GeneIdFilter("ENS", "startsWith")),
columns = c("gene_biotype", "gene_name"))
eg
length(grep(names(eg), pattern="LRG"))
##### transcriptsBy
##
TGenes <- transcriptsBy(edb, by = "gene",
filter = SeqNameFilter(c("X", "Y")))
TGenes
## convert this to a SAF formatted data.frame that can be used by the
## featureCounts function from the Rsubreader package.
head(toSAF(TGenes))
##### transcriptsByOverlaps
##
ir <- IRanges(start = c(2654890, 2709520, 28111770),
end = c(2654900, 2709550, 28111790))
gr <- GRanges(rep("Y", length(ir)), ir)
## Retrieve all transcripts overlapping any of the regions.
txs <- transcriptsByOverlaps(edb, gr)
txs
## Alternatively, use a GRangesFilter
grf <- GRangesFilter(gr, type = "any")
txs <- transcripts(edb, filter = grf)
txs
#### cdsBy
## Get the coding region for all transcripts on chromosome Y.
## Specifying also additional annotation columns (in addition to the default
## exon_id and exon_rank).
cds <- cdsBy(edb, by = "tx", filter = SeqNameFilter("Y"),
columns = c("tx_biotype", "gene_name"))
#### the 5' untranslated regions:
fUTRs <- fiveUTRsByTranscript(edb, filter = SeqNameFilter("Y"))
#### the 3' untranslated regions with additional column gene_name.
tUTRs <- threeUTRsByTranscript(edb, filter = SeqNameFilter("Y"),
columns = "gene_name")
}
\keyword{classes}
|