R/Methods.R
, R/functions-EnsDb.R
global-filters.Rd
These methods allow to set, delete or show globally defined
filters on an EnsDb
object.
addFilter
: adds an annotation filter to the EnsDb
object.
dropFilter
deletes all globally set filters from the
EnsDb
object.
activeFilter
returns the globally set filter from an
EnsDb
object.
filter
filters an EnsDb
object. filter
is
an alias for the addFilter
function.
# S4 method for EnsDb
addFilter(x, filter = AnnotationFilterList())
# S4 method for EnsDb
dropFilter(x)
# S4 method for EnsDb
activeFilter(x)
filter(x, filter = AnnotationFilterList())
The EnsDb
object to which the filter should be
added.
The filter as an
AnnotationFilter
,
AnnotationFilterList
or filter
expression. See
addFilter
and filter
return an EnsDb
object
with the specified filter added.
activeFilter
returns an
AnnotationFilterList
object being the
active global filter or NA
if no filter was added.
dropFilter
returns an EnsDb
object with all eventually
present global filters removed.
Adding a filter to an EnsDb
object causes this filter to be
permanently active. The filter will be used for all queries to the
database and is added to all additional filters passed to the methods
such as genes
.
Filter-classes
for a list of all supported filters.
library(EnsDb.Hsapiens.v86)
edb <- EnsDb.Hsapiens.v86
## Add a global SeqNameFilter to the database such that all subsequent
## queries will be applied on the filtered database.
edb_y <- addFilter(edb, SeqNameFilter("Y"))
## Note: using the filter function is equivalent to a call to addFilter.
## Each call returns now only features encoded on chromosome Y
gns <- genes(edb_y)
seqlevels(gns)
#> [1] "Y"
## Get all lincRNA gene transcripts on chromosome Y
transcripts(edb_y, filter = ~ gene_biotype == "lincRNA")
#> GRanges object with 73 ranges and 7 metadata columns:
#> seqnames ranges strand | tx_id
#> <Rle> <IRanges> <Rle> | <character>
#> ENST00000611750 Y 2934406-2934771 - | ENST00000611750
#> ENST00000444263 Y 3002912-3097217 + | ENST00000444263
#> ENST00000425031 Y 3002998-3102272 + | ENST00000425031
#> ENST00000426699 Y 4036497-4100320 + | ENST00000426699
#> ENST00000622595 Y 4993858-4997719 - | ENST00000622595
#> ... ... ... ... . ...
#> ENST00000421387 Y 25183643-25184773 - | ENST00000421387
#> ENST00000427373 Y 25378300-25394719 - | ENST00000427373
#> ENST00000611754 Y 25378671-25391610 - | ENST00000611754
#> ENST00000306641 Y 25482908-25486705 + | ENST00000306641
#> ENST00000417334 Y 25728490-25733388 + | ENST00000417334
#> tx_biotype tx_cds_seq_start tx_cds_seq_end gene_id
#> <character> <integer> <integer> <character>
#> ENST00000611750 lincRNA <NA> <NA> ENSG00000278847
#> ENST00000444263 lincRNA <NA> <NA> ENSG00000231535
#> ENST00000425031 lincRNA <NA> <NA> ENSG00000231535
#> ENST00000426699 lincRNA <NA> <NA> ENSG00000229308
#> ENST00000622595 lincRNA <NA> <NA> ENSG00000277930
#> ... ... ... ... ...
#> ENST00000421387 lincRNA <NA> <NA> ENSG00000223641
#> ENST00000427373 lincRNA <NA> <NA> ENSG00000228786
#> ENST00000611754 lincRNA <NA> <NA> ENSG00000228786
#> ENST00000306641 lincRNA <NA> <NA> ENSG00000240450
#> ENST00000417334 lincRNA <NA> <NA> ENSG00000231141
#> tx_name gene_biotype
#> <character> <character>
#> ENST00000611750 ENST00000611750 lincRNA
#> ENST00000444263 ENST00000444263 lincRNA
#> ENST00000425031 ENST00000425031 lincRNA
#> ENST00000426699 ENST00000426699 lincRNA
#> ENST00000622595 ENST00000622595 lincRNA
#> ... ... ...
#> ENST00000421387 ENST00000421387 lincRNA
#> ENST00000427373 ENST00000427373 lincRNA
#> ENST00000611754 ENST00000611754 lincRNA
#> ENST00000306641 ENST00000306641 lincRNA
#> ENST00000417334 ENST00000417334 lincRNA
#> -------
#> seqinfo: 1 sequence from GRCh38 genome
## Get the currently active global filter:
activeFilter(edb_y)
#> AnnotationFilterList of length 1
#> seq_name == 'Y'
## Delete this filter again.
edb_y <- dropFilter(edb_y)
activeFilter(edb_y)
#> [1] NA