1
#' Get the desired element from the nexml object
3
#' Get the desired element from the nexml object
4
#' @aliases nexml_get get_item
5
#' @param nexml a nexml object (from read_nexml)
6
#' @param element the kind of object desired, see details.
7
#' @param ... additional arguments, if applicable to certain elements
11
#' \item{"tree"}{ an ape::phylo tree, if only one tree is represented. Otherwise returns a list of lists of multiphylo trees. To consistently recieve the list of lists format (preserving the heriarchical nature of the nexml), use \code{trees} instead.}
12
#' \item{"trees"}{ returns a list of lists of multiphylo trees, even if all trees are in the same `trees` node (and hence the outer list will be of length 1) or if there is only a single tree (and hence the inner list will also be of length 1. This guarentees a consistent return type regardless of the number of trees present in the nexml file, and also preserves any heirarchy/grouping of trees. }
13
#' \item{"flat_trees"}{ a multiPhylo object (list of ape::phylo objects) Note that this method collapses any heirachical structure that may have been present as multiple `trees` nodes in the original nexml (though such a feature is rarely used). To preserve that structure, use `trees` instead.}
14
#' \item{"metadata"}{Get metadata from the specified level (default is top/nexml level) }
15
#' \item{"otu"}{ returns a named character vector containing all available metadata. names indicate \code{property} (or \code{rel} in the case of links/resourceMeta), while values indicate the \code{content} (or \code{href} for links). }
16
#' \item{"taxa"}{ alias for otu }
18
#' For a slightly cleaner interface, each of these elements is also defined as an S4 method
19
#' for a nexml object. So in place of `get_item(nexml, "tree")`, one could use `get_tree(nexml)`,
20
#' and so forth for each element type.
21
#' @return return type depends on the element requested. See details.
23
#' @seealso \code{\link{get_trees}}
26
#' comp_analysis <- system.file("examples", "comp_analysis.xml", package="RNeXML")
27
#' nex <- nexml_read(comp_analysis)
28
#' nexml_get(nex, "trees")
29
#' nexml_get(nex, "characters_list")
30
nexml_get <- function(nexml,
41
element <- match.arg(element)
44
trees = get_trees(nexml), # will warn if more than one tree is available
45
trees_list = get_trees_list(nexml),
46
flat_trees = get_flat_trees(nexml),
47
metadata = get_metadata(nexml, ...),
48
otu = get_taxa(nexml),
49
taxa = get_taxa(nexml),
50
characters = get_characters(nexml),
51
characters_list = get_characters_list(nexml),
52
namespaces = get_namespaces(nexml))