AtomicList {IRanges}R Documentation

Lists of Atomic Vectors in Natural and Rle Form

Description

An extension of Sequence 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 = FALSE): Concatenates the run-length encoded atomic vectors in ... into a new RleList. If compress, the internal storage of the data is compressed.

Coercion

as.vector(x), as(from, "vector"): Creates a vector based on the values contained in x.
as.logical(x), as(from, "logical"): Creates a logical vector based on the values contained in x.
as.integer(x), as(from, "integer"): Creates an integer vector based on the values contained in x.
as.numeric(x), as(from, "numeric"): Creates a numeric vector based on the values contained in x.
as.complex(x), as(from, "complex"): Creates a complex vector based on the values contained in x.
as.character(x), as(from, "character"): Creates a character vector based on the values contained in x.
as.raw(x), as(from, "raw"): Creates a raw vector based on the values contained in x.
as.factor(x), as(from, "factor"): Creates a factor object based on the values contained in x.
as.data.frame(x, row.names = NULL, optional = FALSE), as(from, "data.frame"): Creates a data.frame object based on the values contained in x. Essentially the same as calling data.frame(space=rep(names(x), elementLengths(x)), as.vector(x)).
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.

Group Generics

AtomicList objects have support for S4 group generic functionality to operate within elements across objects:

Arith
"+", "-", "*", "^", "%%", "%/%", "/"
Compare
"==", ">", "<", "!=", "<=", ">="
Logic
"&", "|"
Ops
"Arith", "Compare", "Logic"
Math
"abs", "sign", "sqrt", "ceiling", "floor", "trunc", "cummax", "cummin", "cumprod", "cumsum", "log", "log10", "log2", "log1p", "acos", "acosh", "asin", "asinh", "atan", "atanh", "exp", "expm1", "cos", "cosh", "sin", "sinh", "tan", "tanh", "gamma", "lgamma", "digamma", "trigamma"
Math2
"round", "signif"
Summary
"max", "min", "range", "prod", "sum", "any", "all"
Complex
"Arg", "Conj", "Im", "Mod", "Re"
See S4groupGeneric for more details.

Fixed Width Running Window Summaries

RleList objects have support for the following fixed width running window summary methods:

runmean(x, k, endrule = c("drop", "constant")): Calculates the means for fixed width running windows across x.
x
An RleList object containing integer or numeric Rle elements.
k
An integer indicating the fixed width of the running window. Must be odd when endrule == "constant".
endrule
A character string indicating how the values at the beginning and the end (of the data) should be treated.
"drop"
do not extend the running statistics to be the same length as the underlying vectors;
"constant"
copies running statistic to the first values and analogously for the last ones making the smoothed ends constant;
runmed(x, k, endrule = c("median", "keep", "constant")): Calculates the medians for fixed width running windows across x.
x
An RleList object containing integer or numeric Rle elements.
k
An integer indicating the fixed width of the running window. Must be odd when endrule != "drop".
endrule
A character string indicating how the values at the beginning and the end (of the data) should be treated.
"drop"
do not extend the running statistics to be the same length as the underlying vectors;
"keep"
keeps the first and last k2 values at both ends, where k2 is the half-bandwidth k2 = k %/% 2, i.e., y[[i]][j] = x[[i]][j] for j \in \{1,\ldots,k_2; n-k_2+1,\ldots,n\} j = 1,..,k2 and (n-k2+1),..,n;
"constant"
copies the running statistic to the first values and analogously for the last ones making the smoothed ends constant;
"median"
the default, smooths the ends by using symmetrical medians of subsequently smaller bandwidth, but for the very first and last value where Tukey's robust end-point rule is applied, see smoothEnds.
runsum(x, k, endrule = c("drop", "constant")): Calculates the sums for fixed width running windows across x.
x
An RleList object containing integer or numeric Rle elements.
k
An integer indicating the fixed width of the running window. Must be odd when endrule == "constant".
endrule
A character string indicating how the values at the beginning and the end (of the data) should be treated.
"drop"
do not extend the running statistics to be the same length as the underlying vectors;
"constant"
copies running statistic to the first values and analogously for the last ones making the smoothed ends constant;
runwtsum(x, k, wt, endrule = c("drop", "constant")): Calculates the sums for fixed width running windows across x.
x
An RleList object containing integer or numeric Rle elements.
k
An integer indicating the fixed width of the running window. Must be odd when endrule == "constant".
wt
A numeric vector of length k that provides the weights to use.
endrule
A character string indicating how the values at the beginning and the end (of the data) should be treated.
"drop"
do not extend the running statistics to be the same length as the underlying vectors;
"constant"
copies running statistic to the first values and analogously for the last ones making the smoothed ends constant;
runq(x, k, i, endrule = c("drop", "constant")): Calculates the order statistic for fixed width running windows across x.
x
An RleList object containing integer or numeric Rle elements.
k
An integer indicating the fixed width of the running window. Must be odd when endrule == "constant".
i
An integer indicating which order statistic to calculate.
endrule
A character string indicating how the values at the beginning and the end (of the data) should be treated.
"drop"
do not extend the running statistics to be the same length as the underlying vectors;
"constant"
copies running statistic to the first values and analogously for the last ones making the smoothed ends constant;

Author(s)

P. Aboyoun

See Also

Sequence for the applicable methods.

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

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

  ## group generics
  2 * col1
  col1 + col1
  col1 > 2
  log(col1)
  sum(col1)

  ## get the mean for each element
  sapply(col1, mean)

[Package IRanges version 1.4.16 Index]