shrinkVector {HilbertVis} | R Documentation |
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.
shrinkVector(vec, newLength)
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 |
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.
A vector of length newLength
with the maxima of each of the partitions
of vector
.
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.
Simon Anders, EMBL-EBI (sanders@fs.tum.de)
plotLongVector
,
ShortRead::pileup
,
HilbertVisGui::simpleLinPlot
shrinkVector( 100000 + 1:1000, 17 )