getElement               package:prada               R Documentation

_F_u_n_c_t_i_o_n_s _t_o _e_x_t_r_a_c_t _a_t_o_m_i_c _d_a_t_a _t_y_p_e_s (_n_u_m_e_r_i_c, _c_h_a_r_a_c_t_e_r)
_a_n_d _v_e_c_t_o_r_s _f_r_o_m _a_n _X_M_L _t_r_e_e

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

     Functions to extract atomic data types (numeric, character) and
     vectors from an XML tree that was generated by Urban Liebel's
     Labview image analysis  program

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

       getElement(node, name, type="numeric")
       getVector(node, name, elementnames, elementtypes)

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

    node: XMLNode. A node of an XML tree

    name: character. The expected name of the node. Maybe NULL for
          'getVector', is mandatory for 'getElement'. If
          'xmlName(node)' is not the same as 'name', an error message
          is generated.

    type: Character. Should be either 'numeric' or 'character'.

elementnames: list. The list may be nested, thus describing a tree.
          This tree must correspond to the XML subtree starting at
          'node'. The leaves of 'elementnames' should be of class
          'character' and contain the names of the leave nodes of the
          XML subtree.

elementtypes: list. Same form as 'elementnames'. The leaves of
          'elementtypes' should be of class 'character' and contain the
          types of the leave nodes of the XML subtree.

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

     'getVector' descends into the XML subtree starting at 'node'
     recursively. The atomic elements of the nested lists
     'elementnames' and 'elementtypes' are used as the arguments 'name'
     and 'type' of the call to 'getElement' for the corresponding leave
     nodes.

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

     A flat list (the result of 'unlist') with the values from the XML
     subtree and names 'unlist(elementnames)'.

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

     Wolfgang Huber <URL: http://www.ebi.ac.uk/huber>

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

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

      
       exfile = file.path(.path.package("prada"), "extdata", "dorit13_2c-1-2--13-Ytrail=3143937171.xml")
       z      = xmlTreeParse(exfile)
       r      = xmlRoot(z)[[2]]
       getElement(r[[3]], name="current clone", type="character")

       thenames = list("Area (pixels)", "Perimeter", "Projection x", "Projection y",
           "Longest Segment Length",
           list("x1Left", "y1Top", "x2Right", "y2Bottom"),
           "Number of Holes", "Hole's Area (pixels)", "Dapi mean",
           "Brdu mean", "transfection mean")
       thetypes = c(rep("numeric", 5), list(rep("numeric", 4)), rep("numeric", 5))

       getVector(r[[4]][[6]], name=NULL, elementnames=thenames, elementtypes=thetypes)
       getElement(r[[4]][[6]][[3]], "Area (pixels)")

