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).