AtomicList-class: Lists of Atomic Vectors in Natural and Rle Form

AtomicListR Documentation

Lists of Atomic Vectors in Natural and Rle Form

Description

An extension of List that holds only atomic vectors in either a natural or run-length encoded form.

Details

The lists of atomic vectors are LogicalList, IntegerList, NumericList, ComplexList, CharacterList, and RawList. There is also an RleList class for run-length encoded versions of these atomic vector types.

Each of the above mentioned classes is virtual with Compressed* and Simple* non-virtual representations.

Constructors

LogicalList(..., compress = TRUE):

Concatenates the logical vectors in ... into a new LogicalList. If compress, the internal storage of the data is compressed.

IntegerList(..., compress = TRUE):

Concatenates the integer vectors in ... into a new IntegerList. If compress, the internal storage of the data is compressed.

NumericList(..., compress = TRUE):

Concatenates the numeric vectors in ... into a new NumericList. If compress, the internal storage of the data is compressed.

ComplexList(..., compress = TRUE):

Concatenates the complex vectors in ... into a new ComplexList. If compress, the internal storage of the data is compressed.

CharacterList(..., compress = TRUE):

Concatenates the character vectors in ... into a new CharacterList. If compress, the internal storage of the data is compressed.

RawList(..., compress = TRUE):

Concatenates the raw vectors in ... into a new RawList. If compress, the internal storage of the data is compressed.

RleList(..., compress = TRUE):

Concatenates the run-length encoded atomic vectors in ... into a new RleList. If compress, the internal storage of the data is compressed.

FactorList(..., compress = TRUE):

Concatenates the factor objects in ... into a new FactorList. If compress, the internal storage of the data is compressed.

Coercion

as(from, "CompressedSplitDataFrameList"), as(from, "SimpleSplitDataFrameList"):

Creates a CompressedSplitDataFrameList/SimpleSplitDataFrameList instance from an AtomicList instance.

as(from, "IRangesList"), as(from, "CompressedIRangesList"), as(from, "SimpleIRangesList"):

Creates a CompressedIRangesList/SimpleIRangesList instance from a LogicalList or logical RleList instance. Note that the elements of this instance are guaranteed to be normal.

as(from, "NormalIRangesList"), as(from, "CompressedNormalIRangesList"), as(from, "SimpleNormalIRangesList"):

Creates a CompressedNormalIRangesList/SimpleNormalIRangesList instance from a LogicalList or logical RleList instance.

as(from, "CharacterList"), as(from, "ComplexList"), as(from, "IntegerList"), as(from, "LogicalList"), as(from, "NumericList"), as(from, "RawList"), as(from, "RleList"):

Coerces an AtomicList from to another derivative of AtomicList.

as(from, "AtomicList"):

If from is a vector, converts it to an AtomicList of the appropriate type.

drop(x):

Checks if every element of x is of length one, and, if so, unlists x. Otherwise, an error is thrown.

as(from, "RleViews"):

Creates an RleViews where each view corresponds to an element of from. The subject is unlist(from).

as.matrix(x, col.names=NULL):

Maps the elements of the list to rows of a matrix. The column mapping depends on whether there are inner names (either on the object or provided via col.names as a List object). If there are no inner names, each row is padded with NAs to reach the length of the longest element. If there are inner names, there is a column for each unique name and the mapping is by name. To provide inner names, the col.names argument should be a List, usually a CharacterList or FactorList (which is particularly efficient). If col.names is a character vector, it names the columns of the result, but does not imply inner names.

Compare, Order, Tabulate

The following methods are provided for element-wise comparison of 2 AtomicList objects, and ordering or tabulating of each list element of an AtomicList object: is.na, duplicated, unique, match, %in%, table, order, sort.

RleList Methods

RleList has a number of methods that are not shared by other AtomicList derivatives.

runLength(x):

Gets the run lengths of each element of the list, as an IntegerList.

runValue(x), runValue(x) <- value:

Gets or sets the run values of each element of the list, as an AtomicList.

ranges(x):

Gets the run ranges as a IntegerRangesList.

Author(s)

P. Aboyoun

See Also

  • AtomicList-utils for common operations on AtomicList objects.

  • List objects in the S4Vectors package for the parent class.

Examples

int1 <- c(1L,2L,3L,5L,2L,8L)
int2 <- c(15L,45L,20L,1L,15L,100L,80L,5L)
collection <- IntegerList(int1, int2)

## names
names(collection) <- c("one", "two")
names(collection)
names(collection) <- NULL # clear names
names(collection)
names(collection) <- "one"
names(collection) # c("one", NA)

## extraction
collection[[1]] # range1
collection[["1"]] # NULL, does not exist
collection[["one"]] # range1
collection[[NA_integer_]] # NULL

## subsetting
collection[numeric()] # empty
collection[NULL] # empty
collection[] # identity
collection[c(TRUE, FALSE)] # first element
collection[2] # second element
collection[c(2,1)] # reversed
collection[-1] # drop first
collection$one

## replacement
collection$one <- int2
collection[[2]] <- int1

## concatenating
col1 <- IntegerList(one = int1, int2)
col2 <- IntegerList(two = int2, one = int1)
col3 <- IntegerList(int2)
append(col1, col2)
append(col1, col2, 0)
col123 <- c(col1, col2, col3)
col123

## revElements
revElements(col123)
revElements(col123, 4:5)

Bioconductor/IRanges documentation built on Dec. 7, 2024, 1:19 p.m.