sliding.quantile            package:Ringo            R Documentation

_C_o_m_p_u_t_e _q_u_a_n_t_i_l_e _o_f _s_c_o_r_e_s _i_n _a _s_l_i_d_i_n_g _w_i_n_d_o_w

_D_e_s_c_r_i_p_t_i_o_n:

     This functions is used to slide a window of specified size over
     scores at given positions. Computed is the quantile over the
     scores in the window.

_U_s_a_g_e:

     sliding.quantile(positions, scores, half.width, prob = 0.5,
                      return.counts = TRUE)

_A_r_g_u_m_e_n_t_s:

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

    prob: numeric specifying which quantile is to be computed over the
          scores in the window; default 0.5 means compute the median
          over the scores.

return.counts: logical; should the number of points, e.g. probes, that
          were used for computing the median in each sliding window
          also returned?

_D_e_t_a_i_l_s:

     This function is meant as a more general alternative to the
     'sliding.median' function. In most, but not in all, situations, we
     found it to outperform 'sliding.median'.

_V_a_l_u_e:

     Matrix with two columns: 

quantile: 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'.

_A_u_t_h_o_r(_s):

     Oleg Sklyar and Joern Toedling

_S_e_e _A_l_s_o:

     'quantile','sliding.median'

_E_x_a_m_p_l_e_s:

       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.quantile(ap, as, 20)
       arq <- sliding.quantile(ap, as, 20, prob=0.25)
       plot(ap, as, pch=20, xlab="position",ylab="level")
       points(ap, arm[,1], type="l", col="red", lwd=2)
       points(ap, arq[,1], type="l", col="green", lwd=2)
       legend(x="topleft", legend=c("median","1st quartile"),
              col=c("red","green"), lty=1, lwd=2)

