/usr/lib/R/site-library/AnnotationDbi/unitTests/test_select_reactome.R is in r-bioc-annotationdbi 1.26.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | ## unit tests for methods associated with reactome.db
require(reactome.db)
r <- reactome.db
test_cols <- function(){
res <- columns(r)
checkTrue(length(res) >4)
checkTrue("ENTREZID" %in% res)
checkTrue("GO" %in% res)
checkTrue("PATHNAME" %in% res)
checkTrue("REACTOMEID" %in% res)
}
test_keytypes <- function(){
res <- keytypes(r)
checkTrue(length(res) >4)
checkTrue("ENTREZID" %in% res)
checkTrue("GO" %in% res)
checkTrue("PATHNAME" %in% res)
checkTrue("REACTOMEID" %in% res)
}
test_keys <- function(){
res <- head(keys(r, keytype="ENTREZID"))
checkTrue(length(res) > 0)
checkTrue(length(res) == length(unique(res)))
res2 <- head(keys(r, keytype="PATHNAME"))
checkTrue(is.character(res2))
checkTrue(length(res2) == length(unique(res2)))
}
## test function that gets table names
test_getTables <- function(){
c <- c("ENTREZID", "PATHNAME")
res <- AnnotationDbi:::.getTables(c, retVal="table") ##default for retVal
checkTrue(length(res) ==2)
checkIdentical(res, c("pathway2gene","pathway2name"))
res2 <- AnnotationDbi:::.getTables(c, retVal="colname")
checkTrue(length(res2) ==2)
checkIdentical(res2, c("gene_id","path_name"))
}
## Tests ability to get one table/query out.
test_extractWithSimpleQuery <- function(){
table <- "pathway2gene" ## a table (in this case). (Could also be subquery)
colType <- "gene_id" ## column we are interested in.
k <- head(keys(r, keytype="ENTREZID"), n=2)
res <- AnnotationDbi:::.extractWithSimpleQuery(r, table, colType, k)
checkTrue(dim(res)[1]>0)
checkTrue(dim(res)[2]==2)
checkIdentical(c("DB_ID","gene_id"), colnames(res))
}
## Test ability to pull data out in vectorized fashion
test_collateQueryResults <- function(){
tables <- c("pathway2gene", "reactome2go", "pathway2name")
colType <- "gene_id"
k <- head(keys(r, keytype="ENTREZID"), n=2)
mergeID = "DB_ID"
res <- AnnotationDbi:::.collateQueryResults(r, tables, colType, k, mergeID)
checkTrue(dim(res)[1]>0)
checkTrue(dim(res)[2]==4)
checkIdentical(c("DB_ID","gene_id","go_id","path_name"), colnames(res))
}
## and tests for select:
test_select_TYPICAL <- function(){
k <- head(keys(r, keytype="ENTREZID"))
c <- c("ENTREZID","PATHNAME","GO","REACTOMEID")
res <- select(r, keys=k, columns=c, keytype="ENTREZID")
checkTrue(dim(res)[1]>0)
checkTrue(dim(res)[2]==4)
checkIdentical(c("ENTREZID","PATHNAME","GO","REACTOMEID"), colnames(res))
}
test_select_MISSING_EG <- function(){
k <- head(keys(r, keytype="ENTREZID"))
c <- c("PATHNAME","GO")
res <- select(r, keys=k, columns=c, keytype="ENTREZID")
checkTrue(dim(res)[1]>0)
checkTrue(dim(res)[2]==3)
checkIdentical(c("ENTREZID","PATHNAME","GO"), colnames(res))
}
test_select_ONE_COL <- function(){
k <- head(keys(r, keytype="ENTREZID"))
c <- c("ENTREZID")
res <- select(r, keys=k, columns=c, keytype="ENTREZID") ## Boom no warning
checkTrue(dim(res)[1]>0)
checkTrue(dim(res)[2]==1)
checkIdentical(c("ENTREZID"), colnames(res))
}
test_select_OTHERKEYTYPE <- function(){
## This also checks if that we handle "BS keys" OK
k <- head(keys(r, keytype="REACTOMEID"))
k <- c(k[1:4], "109688")
c <- c("ENTREZID","PATHNAME","GO")
res <- select(r, keys=k, columns=c, keytype="REACTOMEID")
checkTrue(dim(res)[1]>0)
checkTrue(dim(res)[2]==4)
checkIdentical(c("REACTOMEID","ENTREZID","PATHNAME","GO"), colnames(res))
}
test_select_PATHNAME <- function(){
k <- head(keys(r, "PATHNAME"))
suppressWarnings(res <- select(r, k, "ENTREZID", "PATHNAME"))
checkTrue(dim(res)[1]>0)
checkTrue(dim(res)[2]==2)
checkIdentical(c("PATHNAME","ENTREZID"), colnames(res))
}
## for convenience...
## debug(AnnotationDbi:::.selectReact)
## debug(AnnotationDbi:::.collateQueryResults)
## debug(AnnotationDbi:::.extractWithSimpleQuery)
|