invertMap             package:affxparser             R Documentation

_I_n_v_e_r_t_s _a _r_e_a_d _o_r _a _w_r_i_t_e _m_a_p

_D_e_s_c_r_i_p_t_i_o_n:

     Inverts a read or a write map.

_U_s_a_g_e:

     invertMap(map, ...)

_A_r_g_u_m_e_n_t_s:

     map: An 'integer' 'vector'.

     ...: Not used.

_D_e_t_a_i_l_s:

     An map is defined to be a 'vector' of _n_ with unique finite
     values in [1,n].  Finding the inverse of a map is the same as
     finding the rank of each element, cf. 'order'().  However, this
     method is much faster, because it utilizes the fact that all
     values are unique and in [1,n].  Moreover, for any map it holds
     that taking the inverse twice will result in the same map.

_V_a_l_u_e:

     Returns an 'integer' 'vector'.

_A_u_t_h_o_r(_s):

     Henrik Bengtsson (<URL: http://www.braju.com/R/>)

_S_e_e _A_l_s_o:

     To generate an optimized write map for a CDF file, see
     'readCdfUnitsWriteMap'().

_E_x_a_m_p_l_e_s:

     # Simulate a read map for a chip with 2.6 million cells
     nbrOfCells <- 2600000
     readMap <- sample(nbrOfCells)

     # Get the corresponding write map
     writeMap <- invertMap(readMap)

     # A map inverted twice should be equal itself
     stopifnot(identical(invertMap(writeMap), readMap))

     # Another example illustrating that the write map is the
     # inverse of the read map
     idx <- sample(nbrOfCells, size=1000)
     stopifnot(identical(writeMap[readMap[idx]], idx))

     # invertMap() is much faster than order()
     t1 <- system.time(invertMap(readMap))[3]
     cat(sprintf("invertMap()  : %5.2fs [ 1.00x]\n", t1))

     t2 <- system.time(writeMap2 <- sort.list(readMap, na.last=NA, method="quick"))[3]
     cat(sprintf("'quick sort' : %5.2fs [%5.2fx]\n", t2, t2/t1))
     stopifnot(identical(writeMap, writeMap2))

     t3 <- system.time(writeMap2 <- order(readMap))[3]
     cat(sprintf("order()      : %5.2fs [%5.2fx]\n", t3, t3/t1))
     stopifnot(identical(writeMap, writeMap2))

     # Clean up
     rm(nbrOfCells, idx, readMap, writeMap, writeMap2)

