Bimap-toTable         package:AnnotationDbi         R Documentation

_M_e_t_h_o_d_s _f_o_r _m_a_n_i_p_u_l_a_t_i_n_g _a _B_i_m_a_p _o_b_j_e_c_t _i_n _a _d_a_t_a-_f_r_a_m_e _s_t_y_l_e

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

     These methods are part of the Bimap interface (see '?Bimap' for a
     quick overview of the Bimap objects and their interface).

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

       ## Extract all the columns of the map (links + right attributes)
       toTable(x)
       nrow(x)
       ncol(x)
       #dim(x)
       head(x, ...)
       tail(x, ...)

       ## Extract only the links of the map
       links(x)
       count.links(x)
       nhit(x)

       ## Col names and col metanames
       colnames(x, do.NULL=TRUE, prefix="col")
       colmetanames(x)
       Lkeyname(x)
       Rkeyname(x)
       keyname(x)
       tagname(x)
       Rattribnames(x)
       Rattribnames(x) <- value

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

       x: A Bimap object (or a list or an environment for 'nhit'). 

     ...: Further arguments to be passed to or from other methods (see
          'head' or 'tail' for the details). 

 do.NULL: Ignored. 

  prefix: Ignored. 

   value: A character vector containing the names of the new right
          attributes (must be a subset of the current right attribute
          names) or NULL. 

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

     'toTable(x)' turns Bimap object 'x' into a data frame (see section
     "Flat representation of a bimap" in '?Bimap' for a short
     introduction to this concept). For simple maps (i.e. no tags and
     no right attributes), the resulting data frame has only 2 columns,
     one for the left keys and one for the right keys, and each row in
     the data frame represents a link (or edge) between a left and a
     right key. For maps with tagged links (i.e. a tag is associated to
     each link), 'toTable(x)' has one additional colmun for the tags
     and there is still one row per link. For maps with right
     attributes (i.e. a set of attributes is associated to each right
     key), 'toTable(x)' has one additional colmun per attribute. So for
     example if 'x' has tagged links and 2 right attributes,
     'toTable(x)' will have 5 columns: one for the left keys, one for
     the right keys, one for the tags, and one for each right attribute
     (always the rightmost columns). Note that if at least one of the
     right attributes is multivalued then more than 1 row can be needed
     to represent the same link so the number of rows in 'toTable(x)'
     can be strictly greater than the number of links in the map.

     'nrow(x)' is equivalent to (but more efficient than)
     'nrow(toTable(x))'.

     'ncol(x)' is equivalent to (but more efficient than)
     'ncol(toTable(x))'.

     'colnames(x)' is equivalent to (but more efficient than)
     'colnames(toTable(x))'. Columns are named accordingly to the names
     of the SQL columns where the data are coming from. An important
     consequence of this that they are not necessarily unique.

     'colmetanames(x)' returns the metanames for the column of 'x' that
     are not right attributes. Valid column metanames are '"Lkeyname"',
     '"Rkeyname"' and '"tagname"'.

     'Lkeyname', 'Rkeyname', 'tagname' and 'Rattribnames' return the
     name of the column (or columns) containing the left keys, the
     right keys, the tags and the right attributes, respectively.

     Like 'toTable(x)', 'links(x)' turns 'x' into a data frame but the
     right attributes (if any) are dropped. Note that dropping the
     right attributes produces a data frame that has eventually less
     columns than 'toTable(x)' and also eventually less rows because
     now exactly 1 row is needed to represent 1 link.

     'count.links(x)' is equivalent to (but more efficient than)
     'nrow(links(x))'.

     'nhit(x)' returns a named integer vector indicating the number of
     "hits" for each key in 'x' i.e. the number of links that start
     from each key.

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

     A data frame for 'toTable' and 'links'.

     A single integer for 'nrow', 'ncol' and 'count.links'.

     A character vector for 'colnames', 'colmetanames' and
     'Rattribnames'.

     A character string for 'Lkeyname', 'Rkeyname' and 'tagname'.

     A named integer vector for 'nhit'.

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

     H. Pages

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

     Bimap, BimapFormatting, AnnDbBimap-envirAPI

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

       library(GO.db)
       x <- GOSYNONYM
       x
       toTable(x)[1:4, ]
       toTable(x["GO:0007322"])
       links(x)[1:4, ]
       links(x["GO:0007322"])

       nrow(x)
       ncol(x)
       dim(x)
       colnames(x)
       colmetanames(x)
       Lkeyname(x)
       Rkeyname(x)
       tagname(x)
       Rattribnames(x)

       links(x)[1:4, ]
       count.links(x)

       y <- GOBPCHILDREN
       nhy <- nhit(y) # 'nhy' is a named integer vector
       identical(names(nhy), keys(y)) # TRUE
       table(nhy)
       sum(nhy == 0) # number of GO IDs with no children
       names(nhy)[nhy == max(nhy)] # the GO ID(s) with the most direct children

       ## Some sanity check
       sum(nhy) == count.links(y) # TRUE

       ## Changing the right attributes of the GOSYNONYM map (advanced
       ## users only)
       class(x) # GOTermsAnnDbBimap
       as.list(x)[1:3]
       colnames(x)
       colmetanames(x)
       tagname(x) # untagged map
       Rattribnames(x)
       Rattribnames(x) <- Rattribnames(x)[3:1]
       colnames(x)
       class(x) # AnnDbBimap
       as.list(x)[1:3]

