movbin                  package:reb                  R Documentation

_m_o_v_b_i_n

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

     This function analyzes ordered data series to identify regional
     biases using an moving (running) approximated binomial test.

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

     movbin(v,span=NULL,summarize=mean)

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

       v: data vector

    span: numeric vector. Each element is used to define the number of
          points to include when the approximated binomial test is
          applied to 'v'. While mixed for the defaults, the span can be
          specified as fraction of the observation or actual sizes, but
          _not_ a mixture - defaults to: seq(25,length(v)*.3,by=5)

summarize: function that is used to summarize the results from multiple
          spans. if NULL, a matrix with 'length(span)' rows and
          'length(v)' columns is returned.

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

     'movbin' applies a moving binomial test to sequential windows of
     elements of 'v'. Within each span a z-score from an approximated
     binomial is computed such that 'z=(2*r - n)/sqrt(n)' where 'r' is
     the number of positive relative gene expression values and 'n' is
     the number of non-zero values within each window.

     For convenience, this function allows for the specification of
     multiple window sizes using the 'span' argument. The result of a
     'movbin' call will generate a matrix with 'length(span)' rows and
     'length(v)' columns. Each row of the matrix represents the data
     generated from each span. This matrix can be returned or the
     matrix from can be condensed to a single vector of length v by
     applying a summary function 'summarize' to the matrix columns.

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

     Either a matrix or a vector containing the summarized z-scores
     from the applied binomial test.

_N_o_t_e:

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

     Kyle A. Furge, Ph.D., kyle.furge@vai.org and Karl J. Dykema,
     karl.dykema@vai.org

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

     x <- c(rnorm(50,mean=1),rnorm(50,mean=-1),rnorm(100))
     layout(1:2)
     plot(x,type="h",ylim=c(-5,5))

     ## apply the approximated binomial with a single span
     mb <- movbin(x,span=25,summarize=NULL)
     lines(mb[1,])

     ## try a few different span ranges
     mb <- movbin(x,span=c(10,25,50),summarize=NULL)
     lines(mb[1,])  ## span of 10
     lines(mb[2,])  ## span of 25
     lines(mb[3,])  ## span of 50

     ## average the results from the different spans
     plot(x,type="h",ylim=c(-5,5))

     mb <- movbin(x,span=c(10,25,50),summarize=mean)
     lines(mb,col="blue")

     mb <- movbin(x,span=c(10,25,50),summarize=median)
     lines(mb,col="red")  

