updateCelUnits          package:affxparser          R Documentation

_U_p_d_a_t_e_s _a _C_E_L _f_i_l_e _u_n_i_t _b_y _u_n_i_t

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

     Updates a CEL file unit by unit.

     _Please note that, contrary to 'readCelUnits'(), this method can
     only update a single CEL file at the time._

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

     updateCelUnits(filename, cdf=NULL, data, ..., verbose=0)

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

filename: The filename of the CEL file.

     cdf: A (optional) CDF 'list' structure either with field 'indices'
          or fields 'x' and 'y'. If 'NULL', the unit names (and from
          there the cell indices) are inferred from the names of the
          elements in 'data'. 

    data: A 'list' structure in a format similar to what is returned by
          'readCelUnits'() for _a single CEL file only_.

     ...: Optional arguments passed to 'readCdfCellIndices'(), which is
          called if 'cdf' is not given.

 verbose: An 'integer' specifying how much verbose details are
          outputted.

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

     Returns what 'updateCel'() returns.

_W_o_r_k_i_n_g _w_i_t_h _r_e-_a_r_r_a_n_g_e_d _C_D_F _s_t_r_u_c_t_u_r_e_s:

     Note that if the 'cdf' structure is specified the CDF file is
     _not_ queried, but all information about cell x and y locations,
     that is, cell indices is expected to be in this structure.  This
     can be very useful when one work with a cdf structure that
     originates from the underlying CDF file, but has been restructured
     for instance through the 'applyCdfGroups'() method, and 'data'
     correspondingly.  This update method knows how to update such
     structures too.

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

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

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

     Internally, 'updateCel'() is used.

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

     for (zzz in 0) {

     # CEL file to use in this demostration
     pathname <- "tmp.cel"
     if (!file.exists(pathname)) {
       # Scan current directory for a CEL file
       file <- findFiles(pattern="[.](c|C)(e|E)(l|L)$")
       if (is.null(file))
         break

       # Work on a copy of the CEL file
       cat("Copying CEL file: ", file, "\n", sep="");
       if (!file.copy(file, pathname))
         stop("Failed to copy CEL file: ", file);
       rm(file)
     }

     # Check for the CDF file
     hdr <- readCelHeader(pathname)
     cdfFile <- findCdf(hdr$chiptype)
     if (is.null(cdfFile))
       break

     hdr <- readCdfHeader(cdfFile)
     nbrOfUnits <- hdr$nunits
     print(nbrOfUnits);

     # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     # Example: Read and re-write the same data
     # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     units <- c(101, 51)
     data1 <- readCelUnits(pathname, units=units, readStdvs=TRUE)
     cat("Original data:\n")
     str(data1)
     updateCelUnits(pathname, data=data1)
     data2 <- readCelUnits(pathname, units=units, readStdvs=TRUE)
     cat("Updated data:\n")
     str(data2)
     stopifnot(identical(data1, data2))

     # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     # Example: Random read and re-write "stress test"
     # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     for (kk in 1:10) {
       nunits <- sample(min(1000,nbrOfUnits), size=1)
       units <- sample(nbrOfUnits, size=nunits)
       cat(sprintf("%02d. Selected %d random units: reading", kk, nunits));
       t <- system.time({
         data1 <- readCelUnits(pathname, units=units, readStdvs=TRUE)
       }, gcFirst=TRUE)[3]
       cat(sprintf(" [%.2fs=%.2fs/unit], updating", t, t/nunits))
       t <- system.time({
         updateCelUnits(pathname, data=data1)
       }, gcFirst=TRUE)[3]
       cat(sprintf(" [%.2fs=%.2fs/unit], validating", t, t/nunits))
       data2 <- readCelUnits(pathname, units=units, readStdvs=TRUE)
       stopifnot(identical(data1, data2))
       cat(". done\n")
     }

     } # for (zzz in 0)

