R: Methods for manipulating the keys of a Bimap object
Bimap-keys
R Documentation
Methods for manipulating the keys of a Bimap object
Description
These methods are part of the Bimap interface
(see ?Bimap for a quick overview of the Bimap
objects and their interface).
Usage
#length(x)
isNA(x)
mappedkeys(x)
count.mappedkeys(x)
keys(x) <- value
#x[i]
Arguments
x
A Bimap object. If the method being caled is
keys(x), then x can also be a AnnotationDb object or one of
that objects progeny.
value
A character vector containing the new keys (must be a subset of the
current keys).
i
A character vector containing the keys of the map elements to extract.
Details
keys(x) returns the set of all valid keys for map x.
For example, keys(hgu95av2GO) is the set of all probe set IDs
for chip hgu95av2 from Affymetrix.
Please Note that in addition to Bimap objest, keys(x)
will also work for AnnotationDb objects and related objects
such as OrgDb and ChipDb objects.
Note also that the double bracket operator [[ for Bimap
objects is guaranteed to work only with a valid key and will raise
an error if the key is invalid.
(See ?`Bimap-envirAPI` for more information
about this operator.)
length(x) is equivalent to (but more efficient than)
length(keys(x)).
A valid key is not necessarily mapped ([[ will return an
NA on an unmapped key).
isNA(x) returns a logical vector of the same length as x
where the TRUE value is used to mark keys that are NOT mapped
and the FALSE value to mark keys that ARE mapped.
mappedkeys(x) returns the subset of keys(x) where only
mapped keys were kept.
count.mappedkeys(x) is equivalent to (but more efficient than)
length(mappedkeys(x)).
Two (almost) equivalent forms of subsetting a Bimap object
are provided: (1) by setting the keys explicitely and (2) by using
the single bracket operator [ for Bimap objects.
Let's say the user wants to restrict the mapping to the subset of
valid keys stored in character vector mykeys. This can be
done either with keys(x) <- mykeys (form (1)) or with
y <- x[mykeys] (form (2)).
Please note that form (1) alters object x in an irreversible
way (the original keys are lost) so form (2) should be preferred.
All the methods described on this pages are "directed methods"
i.e. what they return DOES depend on the direction of the Bimap
object that they are applied to (see ?direction for
more information about this).
Value
A character vector for keys and mappedkeys.
A single non-negative integer for length and
count.mappedkeys.
library(hgu95av2.db)
x <- hgu95av2GO
x
length(x)
count.mappedkeys(x)
x[1:3]
links(x[1:3])
## Keep only the mapped keys
keys(x) <- mappedkeys(x)
length(x)
count.mappedkeys(x)
x # now it is a submap
## The above subsetting can also be achieved with
x <- hgu95av2GO[mappedkeys(hgu95av2GO)]
## mappedkeys() and count.mappedkeys() also work with an environment
## or a list
z <- list(k1=NA, k2=letters[1:4], k3="x")
mappedkeys(z)
count.mappedkeys(z)
## retrieve the set of primary keys for the ChipDb object named 'hgu95av2.db'
keys <- keys(hgu95av2.db)
head(keys)
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(AnnotationDbi)
Loading required package: stats4
Loading required package: BiocGenerics
Loading required package: parallel
Attaching package: 'BiocGenerics'
The following objects are masked from 'package:parallel':
clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
clusterExport, clusterMap, parApply, parCapply, parLapply,
parLapplyLB, parRapply, parSapply, parSapplyLB
The following objects are masked from 'package:stats':
IQR, mad, xtabs
The following objects are masked from 'package:base':
Filter, Find, Map, Position, Reduce, anyDuplicated, append,
as.data.frame, cbind, colnames, do.call, duplicated, eval, evalq,
get, grep, grepl, intersect, is.unsorted, lapply, lengths, mapply,
match, mget, order, paste, pmax, pmax.int, pmin, pmin.int, rank,
rbind, rownames, sapply, setdiff, sort, table, tapply, union,
unique, unsplit
Loading required package: Biobase
Welcome to Bioconductor
Vignettes contain introductory material; view with
'browseVignettes()'. To cite Bioconductor, see
'citation("Biobase")', and for packages 'citation("pkgname")'.
Loading required package: IRanges
Loading required package: S4Vectors
Attaching package: 'S4Vectors'
The following objects are masked from 'package:base':
colMeans, colSums, expand.grid, rowMeans, rowSums
> png(filename="/home/ddbj/snapshot/RGM3/R_BC/result/AnnotationDbi/Bimap-keys.Rd_%03d_medium.png", width=480, height=480)
> ### Name: Bimap-keys
> ### Title: Methods for manipulating the keys of a Bimap object
> ### Aliases: Bimap-keys keys,Bimap-method length,Bimap-method mappedkeys
> ### mappedkeys,Bimap-method mappedkeys,environment-method
> ### mappedkeys,vector-method count.mappedkeys
> ### count.mappedkeys,Bimap-method count.mappedkeys,ANY-method isNA
> ### isNA,Bimap-method isNA,environment-method isNA,ANY-method keys<-
> ### keys<-,Bimap-method [,Bimap-method show,AnnDbTable-method
> ### Keywords: methods
>
> ### ** Examples
>
> library(hgu95av2.db)
Loading required package: org.Hs.eg.db
> x <- hgu95av2GO
> x
GO map for chip hgu95av2 (object of class "ProbeGo3AnnDbBimap")
> length(x)
[1] 12625
> count.mappedkeys(x)
[1] 11242
> x[1:3]
GO submap for chip hgu95av2 (object of class "ProbeGo3AnnDbBimap")
> links(x[1:3])
probe_id go_id Evidence
1 1000_at GO:0000165 NAS
2 1000_at GO:0000165 TAS
3 1000_at GO:0000186 TAS
4 1000_at GO:0000187 TAS
5 1000_at GO:0000189 IEA
6 1000_at GO:0001934 IMP
7 1000_at GO:0002224 TAS
8 1000_at GO:0002755 TAS
9 1000_at GO:0002756 TAS
10 1000_at GO:0006360 TAS
11 1000_at GO:0006361 TAS
12 1000_at GO:0006461 IEA
13 1000_at GO:0006468 IDA
14 1000_at GO:0006915 IEA
15 1000_at GO:0006975 IDA
16 1000_at GO:0007049 IEA
17 1000_at GO:0007173 TAS
18 1000_at GO:0007264 TAS
19 1000_at GO:0007265 TAS
20 1000_at GO:0007411 TAS
21 1000_at GO:0007596 TAS
22 1000_at GO:0008286 TAS
23 1000_at GO:0008543 TAS
24 1000_at GO:0009636 IEA
25 1000_at GO:0010467 TAS
26 1000_at GO:0016032 IEA
27 1000_at GO:0016310 IDA
28 1000_at GO:0018105 IEA
29 1000_at GO:0019221 TAS
30 1000_at GO:0019233 IEA
31 1000_at GO:0019369 IEA
32 1000_at GO:0030168 TAS
33 1000_at GO:0030509 IMP
34 1000_at GO:0030878 IEA
35 1000_at GO:0031281 IMP
36 1000_at GO:0031663 IEA
37 1000_at GO:0032212 IMP
38 1000_at GO:0032872 TAS
39 1000_at GO:0033129 IMP
40 1000_at GO:0034134 TAS
41 1000_at GO:0034138 TAS
42 1000_at GO:0034142 TAS
43 1000_at GO:0034146 TAS
44 1000_at GO:0034162 TAS
45 1000_at GO:0034166 TAS
46 1000_at GO:0034605 TAS
47 1000_at GO:0035066 IMP
48 1000_at GO:0035666 TAS
49 1000_at GO:0038083 IDA
50 1000_at GO:0038095 TAS
51 1000_at GO:0038096 TAS
52 1000_at GO:0038123 TAS
53 1000_at GO:0038124 TAS
54 1000_at GO:0042473 IEA
55 1000_at GO:0043330 IEA
56 1000_at GO:0045087 TAS
57 1000_at GO:0045727 IEA
58 1000_at GO:0045944 IMP
59 1000_at GO:0048010 TAS
60 1000_at GO:0048011 TAS
61 1000_at GO:0048538 IEA
62 1000_at GO:0051090 TAS
63 1000_at GO:0051216 IEA
64 1000_at GO:0051403 TAS
65 1000_at GO:0051493 TAS
66 1000_at GO:0051973 IMP
67 1000_at GO:0060020 IEA
68 1000_at GO:0060324 IEA
69 1000_at GO:0060397 TAS
70 1000_at GO:0060425 IEA
71 1000_at GO:0060440 IEA
72 1000_at GO:0061308 IEA
73 1000_at GO:0070371 IEA
74 1000_at GO:0070374 IMP
75 1000_at GO:0070498 IMP
76 1000_at GO:0070849 IDA
77 1000_at GO:0071260 IEP
78 1000_at GO:0072584 TAS
79 1000_at GO:0090170 TAS
80 1000_at GO:1900034 TAS
81 1000_at GO:1904355 IMP
82 1000_at GO:2000641 TAS
83 1000_at GO:2000657 IEA
84 1001_at GO:0001525 IEA
85 1001_at GO:0001570 IEA
86 1001_at GO:0001701 IEA
87 1001_at GO:0007165 TAS
88 1001_at GO:0007498 TAS
89 1001_at GO:0016525 IEA
90 1001_at GO:0018108 IEA
91 1001_at GO:0018108 TAS
92 1001_at GO:0030336 IEA
93 1001_at GO:0032526 IEA
94 1001_at GO:0045026 IEA
95 1002_f_at GO:0006805 TAS
96 1002_f_at GO:0008202 IMP
97 1002_f_at GO:0016098 IDA
98 1002_f_at GO:0017144 IDA
99 1002_f_at GO:0019369 TAS
100 1002_f_at GO:0019373 IBA
101 1002_f_at GO:0019373 TAS
102 1002_f_at GO:0042738 IDA
103 1002_f_at GO:0044281 TAS
104 1002_f_at GO:0046483 IDA
105 1002_f_at GO:0055114 IDA
106 1002_f_at GO:0097267 TAS
107 1000_at GO:0005634 TAS
108 1000_at GO:0005635 IDA
109 1000_at GO:0005654 IDA
110 1000_at GO:0005654 TAS
111 1000_at GO:0005739 TAS
112 1000_at GO:0005769 TAS
113 1000_at GO:0005770 TAS
114 1000_at GO:0005794 TAS
115 1000_at GO:0005829 TAS
116 1000_at GO:0005856 TAS
117 1000_at GO:0005901 TAS
118 1000_at GO:0005925 TAS
119 1000_at GO:0015630 IDA
120 1000_at GO:0031143 IEA
121 1000_at GO:0043234 IEA
122 1000_at GO:0070062 IDA
123 1001_at GO:0005887 TAS
124 1002_f_at GO:0005789 TAS
125 1002_f_at GO:0043231 TAS
126 1000_at GO:0001784 IEA
127 1000_at GO:0004707 IDA
128 1000_at GO:0004707 NAS
129 1000_at GO:0004707 TAS
130 1000_at GO:0005515 IPI
131 1000_at GO:0005524 IEA
132 1000_at GO:0019902 IPI
133 1000_at GO:0097110 IEA
134 1001_at GO:0004714 IEA
135 1001_at GO:0005515 IPI
136 1001_at GO:0005524 IEA
137 1002_f_at GO:0004497 IDA
138 1002_f_at GO:0005506 IEA
139 1002_f_at GO:0008392 IBA
140 1002_f_at GO:0008395 IMP
141 1002_f_at GO:0016491 IDA
142 1002_f_at GO:0018675 IEA
143 1002_f_at GO:0018676 IEA
144 1002_f_at GO:0019825 TAS
145 1002_f_at GO:0019899 IPI
146 1002_f_at GO:0020037 IDA
147 1002_f_at GO:0052741 IEA
>
> ## Keep only the mapped keys
> keys(x) <- mappedkeys(x)
> length(x)
[1] 11242
> count.mappedkeys(x)
[1] 11242
> x # now it is a submap
GO submap for chip hgu95av2 (object of class "ProbeGo3AnnDbBimap")
>
> ## The above subsetting can also be achieved with
> x <- hgu95av2GO[mappedkeys(hgu95av2GO)]
>
> ## mappedkeys() and count.mappedkeys() also work with an environment
> ## or a list
> z <- list(k1=NA, k2=letters[1:4], k3="x")
> mappedkeys(z)
[1] "k2" "k3"
> count.mappedkeys(z)
[1] 2
>
> ## retrieve the set of primary keys for the ChipDb object named 'hgu95av2.db'
> keys <- keys(hgu95av2.db)
> head(keys)
[1] "1000_at" "1001_at" "1002_f_at" "1003_s_at" "1004_at" "1005_at"
>
>
>
>
>
> dev.off()
null device
1
>