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
          are 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 )      

