Permalink
Switch branches/tags
Nothing to show
Find file Copy path
2e022d0 May 14, 2018
1 contributor

Users who have contributed to this file

46 lines (27 sloc) 872 Bytes

title: "Example Query of Prediction db" output: html_document


install.packages("RSQLite")
library("RSQLite")
sqlite <- dbDriver("SQLite")
dbname <- "DGN-WB_0.5.db" ## add full path if db file not in current directory

## connect to db

db = dbConnect(sqlite,dbname)

## list tables

dbListTables(db)
dbListFields(db, "weights")
dbListFields(db, "extra")

## convenience query function

query <- function(...) dbGetQuery(db, ...)

## example queries

query('select count(*) from weights')
query('select * from weights where gene = "GATA6" ')
query('select * from weights limit 10')

## select genes with R2>0.01 (this is cor>0.1)

high.h2.genes <- query('select * from extra where R2 > 0.01')

## how many genes are available for given tissue?
## dbname should be the name of the sqlite database for the tissue
query('select count(*) from extra')