addFilter,EnsDb-method {ensembldb} | R Documentation

## Globally add filters to an EnsDb database

### Description

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.

### Usage

    ## S4 method for signature 'EnsDb'
    addFilter(x, filter = AnnotationFilterList())

    ## S4 method for signature 'EnsDb'
    dropFilter(x)

    ## S4 method for signature 'EnsDb'
    activeFilter(x)

    filter(x, filter = AnnotationFilterList())

### Arguments

`x` | The `EnsDb` object to which the filter should be added.
`filter` | The filter as an `AnnotationFilter`, `AnnotationFilterList` or filter expression. See

### Details

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`.

### Value

`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.

### Author(s)

Johannes Rainer

### See Also

`Filter-classes` for a list of all supported filters.

### Examples

    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)

    ## Get all lincRNA gene transcripts on chromosome Y
    transcripts(edb_y, filter = ~ gene_biotype == "lincRNA")

    ## Get the currently active global filter:
    activeFilter(edb_y)

    ## Delete this filter again.
    edb_y <- dropFilter(edb_y)

    activeFilter(edb_y)

[Package ensembldb version 2.6.8 Index]