Views-utils {IRanges}R Documentation

Utility functions and numeric summary of Views of numerics

Description

The slice function creates a Views object that contains the indices where the data are within the specified bounds.

The viewMins, viewMaxs, viewSums, viewMeans functions calculate the minima, maxima, sums, and means on views respectively.

Usage

  viewApply(X, FUN, ..., simplify = TRUE)

  slice(x, lower=-Inf, upper=Inf, ...)
  ## S4 method for signature 'Rle':
slice(x, lower=-Inf, upper=Inf,
                        includeLower=TRUE, includeUpper=TRUE,
                        rangesOnly = FALSE)

  viewMins(x, na.rm=FALSE)
  viewMaxs(x, na.rm=FALSE)
  viewSums(x, na.rm=FALSE)
  viewMeans(x, na.rm=FALSE)

  viewWhichMins(x, na.rm=FALSE)
  viewWhichMaxs(x, na.rm=FALSE)

  viewRangeMins(x, na.rm=FALSE)
  viewRangeMaxs(x, na.rm=FALSE)

Arguments

X A Views object.
FUN The function to be applied to each view in X.
... Additional arguments to be passed on.
simplify A logical value specifying whether or not the result should be simplified to a vector or matrix if possible.
x An Rle, RleList, XInteger object or an integer vector for slice.

An RleViews, RleViewsList, XIntegerViews object for viewMins, viewMaxs, viewSums, and viewMeans.

An Rle, RleViewsList, XIntegerViews object for viewWhichMins and viewWhichMaxs.

lower, upper The lower and upper bounds for the slice.
includeLower, includeUpper Logical indicating whether or not the specified boundary is open or closed.
rangesOnly For Rle and RleList objects, a logical indicating whether or not to drop the original data from the output.
na.rm Logical indicating whether or not to include missing values in the results.

Details

The slice function is useful for finding areas of absolute maxima (peaks), absolute minima (troughs), or fluctuations within specified limits.

The viewMins, viewMaxs, viewSums, and viewMeans functions provide efficient methods for calculating the specified numeric summary by performing the looping in compiled code.

The viewWhichMins, viewWhichMaxs, viewRangeMins, and viewRangeMaxs functions provide efficient methods for finding the locations of the minima and maxima.

Value

An RleViews object for Rle or an RleViewsList for RleList containing the views when using slice with rangesOnly = FALSE. An IRanges object for Rle or a CompressedIRangesList for RleList containing the ranges when using slice with rangesOnly = TRUE. An XIntegerViews for an XInteger object when using slice.

A vector of length(x) for RleViews and XIntegerViews objects or a SimpleList object of length(x) for RleViewsList objects containing the numeric summaries for the views for viewMins, viewMaxs, viewSums, viewMeans, viewWhichMins, and viewWhichMaxs.

An IRanges object for RleViews objects or a SimpleIRangesList for RleViewsList objects containing the location ranges for viewRangeMins and viewRangeMaxs.

Author(s)

P. Aboyoun

See Also

RleViews-class, RleViewsList-class, XIntegerViews-class, which.min, colSums

Examples

  ## Views derived from vector
  vec <- as.integer(c(19, 5, 0, 8, 5))
  slice(vec, lower=5, upper=8)

  set.seed(0)
  vec <- sample(24)
  vecViews <- slice(vec, lower=4, upper=16)
  vecViews
  viewApply(vecViews, function(x) diff(as.integer(x)))
  viewMins(vecViews)
  viewMaxs(vecViews)
  viewSums(vecViews)
  viewMeans(vecViews)
  viewWhichMins(vecViews)
  viewWhichMaxs(vecViews)

  ## Views derived from coverage
  x <- IRanges(start=c(1L, 9L, 4L, 1L, 5L, 10L),
               width=c(5L, 6L, 3L, 4L, 3L,  3L))
  slice(coverage(x), lower=2)
  slice(coverage(x), lower=2, rangesOnly = TRUE)

[Package IRanges version 1.6.16 Index]