read_tree: Somewhat flexible tree-import function

Description Usage Arguments Value See Also Examples

View source: R/IO-methods.R

Description

This function is a convenience wrapper around the read.tree (Newick-format) and read.nexus (Nexus-format) importers provided by the ape-package. This function attempts to return a valid tree if possible using either format importer. If it fails, it silently returns NULL by default, rather than throwing a show-stopping error.

Usage

1
read_tree(treefile, errorIfNULL=FALSE, ...)

Arguments

treefile

(Required). A character string implying a file connection (like a path or URL), or an actual connection. Must be a Newick- or Nexus-formatted tree.

errorIfNULL

(Optional). Logical. Should an error be thrown if no tree can be extracted from the connection? Default is FALSE, indicating that NULL will be SILENTLY returned, rather than an error. Be cautious about this behavior. Useful for phyloseq internals, but might be hard to track in your own code if you're not aware of this “no error by default” setting. If this is a problem, change this value to TRUE, and you can still use the function.

...

(Optional). Additional parameter(s) passed to the relevant tree-importing function.

Value

If successful, returns a phylo-class object as defined in the ape-package. Returns NULL if neither tree-reading function worked.

See Also

read_tree_greengenes

phylo

read.tree

read.nexus

Examples

1
2
read_tree(system.file("extdata", "esophagus.tree.gz", package="phyloseq"))
read_tree(system.file("extdata", "GP_tree_rand_short.newick.gz", package="phyloseq"))

Example output

Phylogenetic tree with 677 tips and 675 internal nodes.

Tip labels:
	9_6_14, 9_6_25, 9_1_26, 9_4_14, 9_7_28, 9_3_24, ...

Unrooted; includes branch lengths.

Phylogenetic tree with 500 tips and 499 internal nodes.

Tip labels:
	153762, 175045, 71074, 525569, 557121, 560734, ...
Node labels:
	, 0.858.4, 0.943.7, 0.985.6, 0.695, 0.692.78, ...

Rooted; includes branch lengths.

phyloseq documentation built on Nov. 8, 2020, 6:41 p.m.