R/Methods-Filter.R
convertFilter.Rd
convertFilter
converts an AnnotationFilter::AnnotationFilter
or AnnotationFilter::AnnotationFilterList
to an SQL where condition
for an EnsDb
database.
# S4 method for AnnotationFilter,EnsDb
convertFilter(object, db, with.tables = character())
# S4 method for AnnotationFilterList,EnsDb
convertFilter(object, db, with.tables = character())
AnnotationFilter
or AnnotationFilterList
objects (or
objects extending these classes).
EnsDb
object.
optional character
vector specifying the names of the
database tables that are being queried.
A character(1)
with the SQL where condition.
This function might be used in direct SQL queries on the SQLite
database underlying an EnsDb
but is more thought to illustrate the
use of AnnotationFilter
objects in combination with SQL databases.
This method is used internally to create the SQL calls to the database.
library(EnsDb.Hsapiens.v86)
edb <- EnsDb.Hsapiens.v86
## Define a filter
flt <- AnnotationFilter(~ gene_name == "BCL2")
## Use the method from the AnnotationFilter package:
convertFilter(flt)
#> [1] "gene_name == 'BCL2'"
## Create a combination of filters
flt_list <- AnnotationFilter(~ gene_name %in% c("BCL2", "BCL2L11") &
tx_biotype == "protein_coding")
flt_list
#> AnnotationFilterList of length 2
#> gene_name %in% c('BCL2', 'BCL2L11') & tx_biotype == 'protein_coding'
convertFilter(flt_list)
#> [1] "gene_name %in% c('BCL2', 'BCL2L11') & tx_biotype == 'protein_coding'"
## Use the filters in the context of an EnsDb database:
convertFilter(flt, edb)
#> [1] "gene.gene_name = 'BCL2'"
convertFilter(flt_list, edb)
#> [1] "(gene.gene_name in ('BCL2','BCL2L11') and tx.tx_biotype = 'protein_coding')"