get_ott_children: Use this instead of 'rotl::tol_subtree()' when taxa are not...

View source: R/opentree_taxonomy.R

get_ott_childrenR Documentation

Use this instead of rotl::tol_subtree() when taxa are not in synthesis tree and you still need to get all species or an induced OpenTree subtree

Description

Use this instead of rotl::tol_subtree() when taxa are not in synthesis tree and you still need to get all species or an induced OpenTree subtree

Usage

get_ott_children(input = NULL, ott_ids = NULL, ott_rank = "species", ...)

Arguments

input

Optional. A character vector of names.

ott_ids

If not NULL, it takes this argument and ignores input. A numeric vector of ott ids obtained with rotl::taxonomy_taxon_info() or rotl::tnrs_match_names() or tnrs_match().

ott_rank

A character vector with the ranks you wanna get lineage children from.

...

Other arguments to pass to get_valid_children().

Value

A data.frame object.

Examples

# An example with the dog genus:

# It is currently not possible to get an OpenTree subtree of a taxon that is
#  missing from the OpenTree synthetic tree.
# The dog genus is not monophyletic in the OpenTree synthetic tree, so in
#  practice, it has no node to extract a subtree from.
# Get the Open Tree Taxonomy identifier (OTT id) for "Canis":
tnrs <- tnrs_match("Canis")

## Not run: 
rotl::tol_subtree(tnrs$ott_id[1])
#> Error: HTTP failure: 400
#> [/v3/tree_of_life/subtree] Error: node_id was not found (broken taxon).

## End(Not run) # end dontrun


ids <- tnrs$ott_id[1]
names(ids) <- tnrs$unique_name
children <- get_ott_children(ott_ids = ids) # or
# children <- get_ott_children(input = "Canis")
str(children)
ids <- children$Canis$ott_id
names(ids) <- rownames(children$Canis)
tree_children <- rotl::tol_induced_subtree(ott_ids = ids)
plot(tree_children, cex = 0.3)

# An example with flowering plants:

# orders <- get_ott_children(input = "magnoliophyta", ott_rank = "order")
# Get the number of orders of flowering plants that we have
# sum(orders$Magnoliophyta$rank == "order")

 # end donttest

OpenTreeChronograms documentation built on June 22, 2022, 9:08 a.m.