-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathannotation_hub.R
More file actions
106 lines (71 loc) · 1.97 KB
/
annotation_hub.R
File metadata and controls
106 lines (71 loc) · 1.97 KB
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
# 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")
pissy <- query(ah, "Aphis gossypii")
# extract information
cicer$dataprovider
cicer$genome
cicer$maintainer
pissy$dataprovider
pissy$genome
pissy$maintainer
# "AnnotationHub" object
class(cicer)
class(pissy)
# retrieve (=download) the element
cicer <- cicer[[1]]
pissy <- pissy[[1]]
#OrgDb object
class(cicer)
cicer
class(pissy)
pissy
# accessing data :
## method columns
columns(cicer)
columns(pissy)
#### method keytypes
keytypes(cicer)
keytypes(pissy)
## method keys
head(keys(cicer, keytype = "GENENAME"))
head(keys(cicer, keytype = "ENTREZID"))
head(keys(cicer, keytype = "SYMBOL"))
head(keys(cicer, keytype = "SYMBOL", pattern = "ARF"))
head(keys(pissy, keytype = "ENTREZID"))
head(keys(pissy, keytype = "SYMBOL"))
# method select
select(cicer, keys = "101509359", keytype = "ENTREZID",
columns = c("GO", "ONTOLOGY", "SYMBOL"))
select(cicer, keys = "LOC101509359", keytype = "ALIAS",
columns = c("GO", "CHR", "GENENAME"))
select(pissy, keys = c("114118904", "114118905", "114118906"),
keytype = "ENTREZID",
columns = c("GO", "SYMBOL"))
library(dplyr)
select(cicer, keys = "101509359", keytype = "ENTREZID",
columns = columns(cicer)) %>%
display()