coerce                package:convert                R Documentation

_C_o_n_v_e_r_t _D_a_t_a _O_b_j_e_c_t_s

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

     Convert between limma, marray and Biobase data objects.

_D_e_t_a_i_l_s:

     Objects can be converted (coerced) from one class to another using
     'as(object, Class)' where 'object' is an object to convert and
     'Class' is the name of the class to convert to.  The following
     conversions are provided:

       From:         To:
       'RGList'      'marrayRaw'
       'marrayRaw'   'RGList'
       'MAList'      'marrayNorm'
       'marrayNorm'  'MAList'
       'RGList'      'exprSet'
       'MAList'      'exprSet'
       'MAList'      'ExpressionSet'
       'marrayRaw'   'exprSet'
       'marrayNorm'  'ExpressionSet'

     Note that 'RGList' and 'marrayRaw' objects are coerced to
     'exprSet's in such a way that green and  red channel intensities
     are  stored in alternate columns of the 'exprs' slot expression
     matrix.   This means that the resulting object has twice as many
     columns as the original object. There is intentionally no such
     conversion to the 'ExpressionSet' class, as it is intended for
     expression values, not intensities. On the other hand, 'MAList'
     and 'marrayNorm' are coerced so that the resulting 'exprs' slot
     contains log-ratios (M-values) and the 'exprSet' or
     'ExpressionSet' object has the same number  of columns as the
     original object. In this case, information on the A-values is
     lost.

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

     Gordon Smyth

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

     'as' in the 'methods' package.

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

     ##first set up some fake intensity matrices
     testRed = matrix(rnorm(5*2),5,2, 
       dimnames=list(paste("gene",1:5, sep=""), c("S1", "S2")))
     testGreen = matrix(rnorm(5*2),5,2, 
       dimnames=list(paste("gene",1:5, sep=""), c("S1", "S2")))

     ##some sample/target info
     testTarget = data.frame(slide=c("S1", "S2"), Cy3=c("T", "C"),
       Cy5=c("C", "T"), row.names=c("S1", "S2"))

     maT = new("marrayInfo", maLabels=c("S1", "S2"),
       maInfo= testTarget)

     ##now create instances and convert
     x <- new("RGList")
     x$R = testRed
     x$G = testGreen
     y <- as(x,"marrayRaw")

     x <- new("marrayRaw")
     x@maGf <- testGreen
     x@maRf <- testRed
     x@maTargets = maT
     y <- as(x,"RGList")
     y <- as(x,"exprSet")

     x <- new("MAList")
     y <- as(x,"marrayNorm")

     ##we construct a reasonably complete fake, small 
     ##instance of the marrayNorm class
     x <- new("marrayNorm")
     x@maM <- testRed
     x@maA <- testGreen
     maTargets(x) = maT
     y <- as(x,"MAList")
     y <- as(x,"exprSet")

     x <- new("MAList")
     x$M <- testRed
     x$A <- testGreen
     x$targets = testTarget
     y <- as(x,"ExpressionSet")

