sliding.median             package:Ringo             R Documentation

_C_o_m_p_u_t_e _m_e_d_i_a_n _s_c_o_r_e _o_v_e_r _a _r_u_n_n_i_n_g _w_i_n_d_o_w

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

     Compute median score over a sliding window.

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

     sliding.median(positions, scores, half.width, 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

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:

     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]'.

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

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

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

     Oleg Sklyar and Joern Toedling

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

     'median','sliding.quantile'

_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.median(ap, as, 20)
       plot(ap, as, pch=20, xlab="position",ylab="level")
       points(ap, arm[,1], type="l", col="red", lwd=2)

