Methods for manipulating the keys of a Bimap object
#length(x) isNA(x) mappedkeys(x) count.mappedkeys(x) keys(x) <- value #x[i]
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.
- A character vector containing the new keys (must be a subset of the current keys).
- A character vector containing the keys of the map elements to extract.
keys(x) returns the set of all valid keys for map
keys(hgu95av2GO) is the set of all probe set IDs
for chip hgu95av2 from Affymetrix.
Please Note that in addition to
will also work for
AnnotationDb objects and related 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.
?`Bimap-envirAPI` for more information
about this operator.)
length(x) is equivalent to (but more efficient than)
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
TRUE value is used to mark keys that are NOT mapped
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)
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
more information about this).
A character vector for
mappedkeys.A single non-negative integer for
count.mappedkeys.A logical vector for
isNA.A Bimap object of the same subtype as
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)