makeWiggleVector         package:HilbertVis         R Documentation

_g_e_n_e_r_a_t_e _a "_w_i_g_g_l_e _v_e_c_t_o_r" _f_r_o_m _s_t_a_r_t/_e_n_d/_v_a_l_u_e _d_a_t_a

_D_e_s_c_r_i_p_t_i_o_n:

     Given intervals in the form of a "start" and an "end" vectors and
     corresponding values, generate a "wiggle vector" of a given length
     that contains the specified values in the vector elements
     indicated by the intervals.

_U_s_a_g_e:

     makeWiggleVector(start, end, value, chrlength )

_A_r_g_u_m_e_n_t_s:

   start: The start coordinates of the intervals. As usual in R, these
          ar 1-based. 

     end: The end coordinates of the intervals. As usual, the end
          points are included 

   value: The values to be put in the wiggle vector. Where intervals
          overlap, the values are added. 

chrlength: The desired length of the returned vector. 

_V_a_l_u_e:

     A vector as described above.

_A_u_t_h_o_r(_s):

     Simon Anders, EMBL-EBI, sanders\@fs.tum.de

_S_e_e _A_l_s_o:

     For a value vector containing only ones, this function acts
     similar as the 'pileup' function in the ShortRead package.

_E_x_a_m_p_l_e_s:

        intervalStarts <- c(3,10,17,22)
        intervalEnds <- c(7,13,20,26)
        values <- c(2, 1.5, .3, 4)
        chrlength <- 30
        wig <- makeWiggleVector( intervalStarts, intervalEnds, values, chrlength )
        # The same effect can be achieved with the following R code, which, however
        # is much slower:
        wig2 <- numeric(chrlength)
        for( i in 1:length(values) )
           wig2[ intervalStarts[i]:intervalEnds[i] ] <- 
              wig2[ intervalStarts[i]:intervalEnds[i] ] + values[i]
        # Let's check that we got the same:
        all( wig == wig2 )      

