shrinkVector {HilbertVis}R Documentation

shrink a vector by partitioning it into bins and taking the maxima in the bins

Description

Given a (potentially very long) vector, the vector is partitioned into a given number of (up to rounding errors) equally long parts, and a vector of the maxima within each of the parts it returned.

Usage

shrinkVector(vec, newLength)

Arguments

vec The vector to be shrunk. May be numeric or integer.
newLength The desired size of the return vector, i.e., the number of partitions

Details

This function is useful when plotting a very long vector such as those returned by ShortRead::pileup. For a sufficiently long vector x, the two commands plot( x, type="h" ) and plot( shrinkVector( x, 10000 ), type="h" ) produce essential the same plot (up to a rescaling of the x axis) but the former takes much longer to execute because R plots many needles on top of each other. The function plotLongVector is a simple wrapper around this function.

Value

A vector of length newLength with the maxima of each of the partitions of vector.

Note

Note that, as the maximum is returned, the result may mot be what you want if negative numbers are present. Note further that NAs may not be handles correctly.

Author(s)

Simon Anders, EMBL-EBI (sanders@fs.tum.de)

See Also

plotLongVector, ShortRead::pileup, HilbertVisGui::simpleLinPlot

Examples

   shrinkVector( 100000 + 1:1000, 17 )

[Package HilbertVis version 1.0.2 Index]