applyCdfGroups          package:affxparser          R Documentation

_A_p_p_l_i_e_s _a _f_u_n_c_t_i_o_n _o_v_e_r _t_h_e _g_r_o_u_p_s _i_n _a _C_D_F _s_t_r_u_c_t_u_r_e

_D_e_s_c_r_i_p_t_i_o_n:

     Applies a function over the groups in a CDF structure.

_U_s_a_g_e:

     applyCdfGroups(cdf, fcn, ...)

_A_r_g_u_m_e_n_t_s:

     cdf: A CDF 'list' structure.

     fcn: A 'function' that takes a 'list' structure of group elements
          and returns an updated 'list' of groups.

     ...: Arguments passed to the 'fcn' function.

_V_a_l_u_e:

     Returns an updated CDF 'list' structure.

_P_r_e-_d_e_f_i_n_e_d _r_e_s_t_r_u_c_t_u_r_i_n_g _f_u_n_c_t_i_o_n_s:

           *  'cdfGetFields'() - Gets a subset of groups fields in a
              CDF structure.

           *  'cdfGetGroups'() - Gets a subset of groups in a CDF
              structure.

           *  'cdfOrderBy'() - Orders the fields according to the value
              of another field in the same CDF group.

           *  'cdfOrderColumnsBy'() - Orders the columns of fields
              according to the values in a certain row of another field
              in the same CDF group.

           *  'cdfAddBaseMmCounts'() - Adds the number of allele A and
              allele B mismatching nucleotides of the probes in a CDF
              structure.

           *  'cdfAddProbeOffsets'() - Adds probe offsets to the groups
              in a CDF structure.

           *  'cdfGtypeCelToPQ'() - Function to immitate Affymetrix'
              'gtype_cel_to_pq' software.

           *  'cdfMergeAlleles'() - Function to join CDF allele A and
              allele B groups strand by strand.

           *  'cdfMergeStrands'() - Function to join CDF groups with
              the same names.

     We appreciate contributions.

_A_u_t_h_o_r(_s):

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

_E_x_a_m_p_l_e_s:

     for (zzz in 0) {

     # Find the CDF file for the Mapping 100K Xba array
     chipType <- "Mapping50K_Xba240";
     cdfFile <- findCdf(chipType)
     if (is.null(cdfFile))
       break;

     # Probeset SNP_A-1658298 (dbSNP rs7034018) has equal number of
     # sense and anti-sense probes, but for the latter group the
     # SNP "interrogating" probe pair has been excluded in
     # Affymetrix' probe selection process when designing the
     # Mapping 100K Xba array.

     # Identify the unit index from the unit name
     probeset <- "SNP_A-1658298"
     unit <- which(readCdfUnitNames(cdfFile) == probeset)
     rm(probeset)

     # Read the CDF file
     cdf0 <- readCdfUnits(cdfFile, units=unit, stratifyBy="pmmm")
     cat("Default CDF structure:\n")
     print(cdf0)

     # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     # Tabulate the information in each group
     # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     cdf <- readCdfUnits(cdfFile, units=unit)
     cdf <- applyCdfGroups(cdf, lapply, as.data.frame)
     print(cdf)

     # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     # Infer the (true or the relative) offset for probe quartets.
     # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     cdf <- applyCdfGroups(cdf0, cdfAddProbeOffsets)
     cat("Probe offsets:\n")
     print(cdf)

     # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     # Identify the number of nucleotides that mismatch the
     # allele A and the allele B sequences, respectively.
     # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     cdf <- applyCdfGroups(cdf, cdfAddBaseMmCounts)
     cat("Allele A & B target sequence mismatch counts:\n")
     print(cdf)


     # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     # Combine the signals from  the sense and the anti-sense
     # strands in a SNP CEL files.
     # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     # First, join the strands in the CDF structure.
     cdf <- applyCdfGroups(cdf, cdfMergeStrands)
     cat("Joined CDF structure:\n")
     print(cdf)

     # Then, read the CEL file using this new structure
     # celFile <- "NA06985_Hind_B5_3005533.CEL"
     # cel <- readCelUnits(celFile, cdf=cdf)
     # cat("Joined CEL intensities:\n")
     # print(cel)

     # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     # Rearrange values of group fields into quartets.  This
     # requires that the values are already arranged as PMs and MMs.
     # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     cdf <- applyCdfGroups(cdf0, cdfMergeAlleles)
     cat("Probe quartets:\n")
     print(cdf)

     # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     # Get the x and y cell locations
     # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     x <- unlist(applyCdfGroups(cdf, cdfGetFields, "x"), use.names=FALSE)
     y <- unlist(applyCdfGroups(cdf, cdfGetFields, "y"), use.names=FALSE)

     # Clean up
     rm(chipType, cdfFile, unit, cdf0, cdf, x, y)
     } # for (zzz in 0)
     rm(zzz)

