ensembldb (version 1.4.6)

select: Integration into the AnnotationDbi framework

Description

Several of the methods available for AnnotationDbi objects are also implemented for EnsDb objects. This enables to extract data from EnsDb objects in a similar fashion than from objects inheriting from the base annotation package class AnnotationDbi. In addition to the standard usage, the select and mapIds for EnsDb objects support also the filter framework of the ensembdb package and thus allow to perform more fine-grained queries to retrieve data.

Usage

## S3 method for class 'EnsDb':
columns(x)
## S3 method for class 'EnsDb':
keys(x, keytype, filter,...)
## S3 method for class 'EnsDb':
keytypes(x)
## S3 method for class 'EnsDb':
mapIds(x, keys, column, keytype, ..., multiVals)
## S3 method for class 'EnsDb':
select(x, keys, columns, keytype, ...)

Arguments

column
For mapIds: the column to search on, i.e. from which values should be retrieved.
columns
For select: the columns from which values should be retrieved. Use the columns method to list all possible columns.
keys
The keys/ids for which data should be retrieved from the database. This can be either a character vector of keys/IDs, a single filter object extending BasicFilter or a list of such objects.
keytype
For mapIds and select: the type (column) that matches the provided keys. This argument does not have to be specified if argument keys is a filter object extending BasicFilter or a list of such objects.

For keys: which keys should be returned from the database.

filter
For keys: either a single object extending BasicFilter or a list of such object to retrieve only specific keys from the database.
multiVals
What should mapIds do when there are multiple values that could be returned? Options are: "first", "list", "filter", "asNA". See mapIds for a detailed description.
x
The EnsDb object.
...
Not used.

Value

  • See method description above.

See Also

BasicFilter listColumns transcripts

Examples

Run this code
library(EnsDb.Hsapiens.v75)
edb <- EnsDb.Hsapiens.v75

## List all supported keytypes.
keytypes(edb)

## List all supported columns for the select and mapIds methods.
columns(edb)

## List /real/ database column names.
listColumns(edb)

## Retrieve all keys corresponding to transcript ids.
txids <- keys(edb, keytype="TXID")
length(txids)
head(txids)

## Retrieve all keys corresponding to gene names of genes encoded on chromosome X
gids <- keys(edb, keytype="GENENAME", filter=SeqnameFilter("X"))
length(gids)
head(gids)

## Get a mapping of the genes BCL2 and BCL2L11 to all of their
## transcript ids and return the result as list
maps <- mapIds(edb, keys=c("BCL2", "BCL2L11"), column="TXID",
               keytype="GENENAME", multiVals="list")
maps

## Perform the same query using a combination of a GenenameFilter and a TxbiotypeFilter
## to just retrieve protein coding transcripts for these two genes.
mapIds(edb, keys=list(GenenameFilter(c("BCL2", "BCL2L11")),
                      TxbiotypeFilter("protein_coding")), column="TXID",
       multiVals="list")

## select:
## Retrieve all transcript and gene related information for the above example.
select(edb, keys=list(GenenameFilter(c("BCL2", "BCL2L11")),
                      TxbiotypeFilter("protein_coding")),
       columns=c("GENEID", "GENENAME", "TXID", "TXBIOTYPE", "TXSEQSTART", "TXSEQEND",
                 "SEQNAME", "SEQSTRAND"))

## Get all data for genes encoded on chromosome Y
Y <- select(edb, keys="Y", keytype="SEQNAME")
head(Y)
nrow(Y)

## Get selected columns for all lincRNAs encoded on chromosome Y
Y <- select(edb, keys=list(SeqnameFilter("Y"), GenebiotypeFilter("lincRNA")),
            columns=c("GENEID", "GENEBIOTYPE", "TXID", "GENENAME"))
head(Y)
nrow(Y)

Run the code above in your browser using DataLab