-
Notifications
You must be signed in to change notification settings - Fork 0
/
prep_sqlite_db.R
executable file
·42 lines (36 loc) · 1.28 KB
/
prep_sqlite_db.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env Rscript
library(DBI)
library(feather)
library(RSQLite)
library(dplyr)
db_file <- "data/geno_data.db"
con <- dbConnect(RSQLite::SQLite(), dbname = db_file)
df <- read_feather("data/Japonica_GEA.feather")
df <- df %>%
mutate(
FDR_01 = ifelse(FDR < 0.01, 1, 0),
FDR_005 = ifelse(FDR < 0.005, 1, 0),
FDR_001 = ifelse(FDR < 0.001, 1, 0)
)
dbWriteTable(con, "japonica", df, overwrite=TRUE)
query <- "CREATE INDEX idx_FDR_01_Locus_japonica ON japonica(FDR_01, Locus_ID);"
dbExecute(con, query)
query <- "CREATE INDEX idx_FDR_005_Locus_japonica ON japonica(FDR_005, Locus_ID);"
dbExecute(con, query)
query <- "CREATE INDEX idx_FDR_001_Locus_japonica ON japonica(FDR_001, Locus_ID);"
dbExecute(con, query)
df <- read_feather("data/Indica_GEA.feather")
df <- df %>%
mutate(
FDR_01 = ifelse(FDR < 0.01, 1, 0),
FDR_005 = ifelse(FDR < 0.005, 1, 0),
FDR_001 = ifelse(FDR < 0.001, 1, 0)
)
dbWriteTable(con, "indica", df, overwrite=TRUE)
query <- "CREATE INDEX idx_FDR_01_Locus_indica ON indica(FDR_01, Locus_ID);"
dbExecute(con, query)
query <- "CREATE INDEX idx_FDR_005_Locus_indica ON indica(FDR_005, Locus_ID);"
dbExecute(con, query)
query <- "CREATE INDEX idx_FDR_001_Locus_indica ON indica(FDR_001, Locus_ID);"
dbExecute(con, query)
dbDisconnect(con)