-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathexpr_core.R
54 lines (41 loc) · 1.39 KB
/
expr_core.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
43
44
45
46
47
48
49
50
51
52
53
54
source("./expr_utils.R")
get_exprs <- function()
{
exprs <- c("emtab", "gene_atlas", "rnaseq_atlas", "hpa", "hpa_all")
return(exprs)
}
is_core <- function(expr_name="hpa")
{
# load the ts/hk summary data from the database
source("sql_config.R")
con <- get_sql_conn()
query <- paste("SELECT COUNT(DISTINCT Gene) FROM ", expr_name)
gene_count <- dbGetQuery(con, query)
query <- paste("SELECT COUNT(DISTINCT Type) FROM ", expr_name)
tissue_count <- dbGetQuery(con, query)
query <- paste("SELECT Gene, COUNT(DISTINCT Type) as cnt FROM ",
expr_name, " GROUP BY Gene HAVING cnt != ",
tissue_count)
incompl_genes <- dbGetQuery(con, query)
query <- paste("SELECT Type, COUNT(DISTINCT Gene) as cnt FROM ",
expr_name, " GROUP BY Type HAVING cnt != ",
gene_count)
incompl_tissues <- dbGetQuery(con, query)
return(list(genes=incompl_genes, tissues=incompl_tissues))
}
all_is_core <- function()
{
for (e in get_exprs())
{
incompl <- is_core(e)
ngenes <- dim(incompl$genes)[1]
ntissues <- dim(incompl$tissues)[1]
if (ngenes == 0 && ntissues == 0)
{
print(paste(e, " is complete"))
} else {
print(paste(e, " is incomplete with genes=", ngenes,
", tissues=", ntissues))
}
}
}