Description Usage Arguments Details Value Examples
View source: R/create_variant_query_func.R
Create a function that will connect to a SQLite database of founder variant information and return a data frame with variants for a selected region.
1 2 3 | create_variant_query_func(dbfile = NULL, db = NULL,
table_name = "variants", chr_field = "chr", pos_field = "pos",
filter = NULL)
|
dbfile |
Name of database file |
db |
Optional database connection (provide one of |
table_name |
Name of table in the database |
chr_field |
Name of chromosome field |
pos_field |
Name of position field |
filter |
Additional SQL filter (as a character string) |
Note that this function assumes that the database has a
pos
field that is in basepairs, but the selection uses
start
and end
positions in Mbp, and the output
data frame should have pos
in Mbp.
Function with three arguments, chr
, start
,
and end
, which returns a data frame with the variants in
that region, with start
and end
being in Mbp. The
output should contain at least the columns chr
and
pos
, the latter being position in Mbp.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | # create query function by connecting to file
dbfile <- system.file("extdata", "cc_variants_small.sqlite", package="qtl2db")
query_variants <- create_variant_query_func(dbfile)
# query_variants will connect and disconnect each time
variants <- query_variants("2", 97.0, 98.0)
# create query function to just grab SNPs
query_snps <- create_variant_query_func(dbfile, filter="type=='snp'")
# query_variants will connect and disconnect each time
snps <- query_snps("2", 97.0, 98.0)
# connect and disconnect separately
library(RSQLite)
db <- dbConnect(SQLite(), dbfile)
query_variants <- create_variant_query_func(db=db)
variants <- query_variants("2", 97.0, 98.0)
dbDisconnect(db)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.