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:

     ##############################################################
     if (require("AffymetrixDataTestFiles")) {            # START #
     ##############################################################

     # Search for some available Calvin CEL files
     path <- system.file("rawData", package="AffymetrixDataTestFiles")
     files <- findFiles(pattern="[.](cel|CEL)$", path=path, recursive=TRUE, firstOnly=FALSE)
     files <- grep("FusionSDK_Test3", files, value=TRUE)
     files <- grep("Calvin", files, value=TRUE)
     file <- files[1]

     # Convert to an XDA CEL file
     pathname <- file.path(tempdir(), basename(file))
     if (file.exists(pathname))
       file.remove(pathname)
     convertCel(file, pathname)



     # Check for the CDF file
     hdr <- readCelHeader(pathname)
     cdfFile <- findCdf(hdr$chiptype)

     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")
     }

     ##############################################################
     }                                                     # STOP #
     ##############################################################

