-
Notifications
You must be signed in to change notification settings - Fork 0
/
annotation_hub.R
84 lines (56 loc) · 1.59 KB
/
annotation_hub.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
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
# Install from Bioconductor
if (!requireNamespace("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install("AnnotationHub", version = "3.8")
# Load library
library(AnnotationHub)
help("AnnotationHub")
## create an AnnotationHub object
ah = AnnotationHub()
## Summary of available records
ah
## Detail for a single record
ah[1]
## and what is the date we are using?
snapshotDate(ah)
## how many resources?
length(ah)
## from which resources, is data available?
head(sort(table(ah$dataprovider), decreasing=TRUE))
## from which species, is data available ?
head(sort(table(ah$species),decreasing=TRUE))
## what web service and local cache does this AnnotationHub point to?
hubUrl(ah)
hubCache(ah)
## search the hub
cicer <- query(ah, "Cicer arietinum")
# extract information
cicer$dataprovider
cicer$genome
cicer$maintainer
# "AnnotationHub" object
class(cicer)
# retrieve (=download) the element
cicer <- cicer[[1]]
#OrgDb object
class(cicer)
cicer
# accessing data :
## method columns
columns(cicer)
#### method keytypes
keytypes(cicer)
## method keys
head(keys(cicer, keytype = "GENENAME"))
head(keys(cicer, keytype = "ENTREZID"))
head(keys(cicer, keytype = "SYMBOL"))
head(keys(cicer, keytype = "SYMBOL", pattern = "ARF"))
# method select
select(cicer, keys = "101509359", keytype = "ENTREZID",
columns = c("GO", "ONTOLOGY", "SYMBOL"))
select(cicer, keys = "LOC101509359", keytype = "ALIAS",
columns = c("GO", "CHR", "GENENAME"))
library(dplyr)
select(cicer, keys = "101509359", keytype = "ENTREZID",
columns = columns(cicer)) %>%
display()