This page documents the S4 generics and methods defined for objects inheriting of the IdVector class. The IdVector class directly extends Vector and thus inherits of all methods defined for the parent class. In the usage below, object and x represent an object of class inheriting from IdVector, and value is an object of a class specified in the S4 method signature or as outlined in 'Accessors'.

ids(object) <- value

# S4 method for IdVector
ids(object)

# S4 method for IdVector
ids(object) <- value

# S4 method for IdVector
names(x)

# S4 method for IdVector,ANY
names(x) <- value

# S4 method for IdVector
length(x)

# S4 method for IdVector
duplicated(x, incomparables = FALSE, ...)

# S4 method for IdVector,ANY,ANY,ANY
[(x, i, j, ..., drop = TRUE)

# S3 method for IdVector
as.vector(x, mode = "character")

# S3 method for IdVector
as.character(x, ...)

as.IdVector.default(ids, ...)

Arguments

object, x

An object of class inheriting from IdVector.

value

An object of a class specified in the S4 method signature.

incomparables

Ignored.

i

index specifying elements to extract or replace.

j, ..., drop

Ignored.

mode

Atomic type of the vector() returned. character string naming an atomic mode or "list" or "expression" or (except for vector) "any".

ids

An atomic vector of identifiers.

Accessors

ids(object) returns a character vector of element identifiers. names(object) is a synonym for compatibility with S4 methods such as mcols(object, use.names = TRUE, ...) .

Dimensions

length(x) returns the number of elements in x.

Subsetting

x[i] returns new IdVector object of the same class as x made of the elements selected by i. i can be missing; an NA-free logical, numeric, or character vector or factor (as ordinary vector or Rle object); or an IntegerRanges object.

Coercion

as(x, "vector") and as.vector(x) return an atomic vector of identifiers contained in x.

as(x, "vector") and as.vector(x) return a character vector of identifiers contained in x.

as(object, "IdVector") and as.IdVector(object) return an IdVector from the given atomic vector of identifiers.

See also

IdVector, Vector, Vector-setops.

Examples

# Constructor ---- iv <- IdVector(ids=head(LETTERS, 6)) mcols(iv) <- DataFrame(row.names = ids(iv), field1=runif(length(iv))) iv
#> IdVector of length 6 with 6 unique identifiers #> Ids: A, B, C, D, ... #> Metadata: field1 (1 column)
# Accessors ---- ids(iv)
#> [1] "A" "B" "C" "D" "E" "F"
iv1 <- iv ids(iv1)[1] <- "gene1" names(iv)
#> [1] "A" "B" "C" "D" "E" "F"
iv1 <- iv names(iv1)[1] <- "GENE001" # Dimensions ---- length(iv)
#> [1] 6
# Duplication ---- iv1 <- iv[c(1, 1, 2, 2)] duplicated(iv1)
#> [1] FALSE TRUE FALSE TRUE
unique(iv1)
#> IdVector of length 2 with 2 unique identifiers #> Ids: A, B #> Metadata: field1 (1 column)
iv1 <- iv[1:3] iv2 <- iv[2:4] union(iv1, iv2)
#> IdVector of length 4 with 4 unique identifiers #> Ids: A, B, C, D #> Metadata: field1 (1 column)
# Subsetting ---- iv1 <- iv[1:5] iv1
#> IdVector of length 5 with 5 unique identifiers #> Ids: A, B, C, D, ... #> Metadata: field1 (1 column)
# Coercion from IdVector ---- v1 <- as(iv, "vector") c1 <- as(iv, "character")