sliding.median {Ringo} | R Documentation |
Compute median score over a sliding window.
sliding.median(positions, scores, half.width, return.counts = TRUE)
positions |
numeric; sorted vector of (genomic) positions of scores |
scores |
numeric; scores to be smoothed associated to the
positions |
half.width |
numeric, half the window size of the sliding window |
return.counts |
logical; should the number of points, e.g. probes, that were used for computing the median in each sliding window also returned? |
For each position of argument positions
, the median score over
a window of size 2*half.width
is computed as a smoothed score.
For the smoothed score at position i, scores at adjacent positions j are
included in the median computation as long as
they are not further than half.width
away from positions[i]
.
Matrix with two columns:
median |
medians over running window centered at the
positions that were specified in argument positions . |
count |
number of points that were considerd for computing the median at each position |
These positions are given as row.names
of the resulting vector.
If argument return.counts
is FALSE
, only a vector
of the medians is returned, with the positions as names
.
Oleg Sklyar and Joern Toedling
sampleSize <- 1000 ap <- cumsum(1+round(runif(sampleSize)*10)) as <- c(rnorm(floor(sampleSize/3)), rnorm(ceiling(sampleSize/3),mean=1.5), rnorm(floor(sampleSize/3))) arm <- sliding.median(ap, as, 20) plot(ap, as, pch=20, xlab="position",ylab="level") points(ap, arm[,1], type="l", col="red", lwd=2)