Title: | Gets feasible taxon samples on a tree |
---|---|
Description: | Often you want to pick species at random, but don't have access to all the possible species, and your group might be a nonrandom set. However, you might have a taxonomy, perhaps a bad one, for all the species. This will let you pick species at random on that full taxonomy and then pick a species out of the possible set closest to this. You could still have a biased sample, but way less biased. |
Authors: | Brian C. O'Meara |
Maintainer: | Brian C. O'Meara <[email protected]> |
License: | GPL 3.0 |
Version: | 1.0 |
Built: | 2024-11-16 06:22:21 UTC |
Source: | https://github.com/bomeara/closesamples |
Get the closest taxon to the focal taxon
GetClosest(focal_taxon, similarity_matrix)
GetClosest(focal_taxon, similarity_matrix)
focal_taxon |
String with taxon name to find closest match to |
similarity |
matrix Matrix from GetSimilarity function |
The taxon closest to it
Get n samples
GetClosestSamples( n, phy_full, taxa_feasible, replace_full = TRUE, replace_feasible = FALSE, truncate_full_to_mrca = FALSE, less_memory = FALSE, descendant_labeled = FALSE, fast_ultrametric = FALSE, verbose = TRUE )
GetClosestSamples( n, phy_full, taxa_feasible, replace_full = TRUE, replace_feasible = FALSE, truncate_full_to_mrca = FALSE, less_memory = FALSE, descendant_labeled = FALSE, fast_ultrametric = FALSE, verbose = TRUE )
n |
How many taxa to sample |
phy_full |
A phylo object with all feasible taxa to sample from |
taxa_feasible |
A vector of taxon names that are feasible to study (often on another tree) |
replace_full |
If TRUE, will allow selecting the same taxon from the full tree more than once. If FALSE, forbids this. Both cases return n taxa |
replace_feasible |
If TRUE, will allow selecting the same taxon from the set of feasible taxa more than once (returning a smaller than desired tree). If FALSE, forbids this. |
truncate_full_to_mrca |
If TRUE, prune the full tree to the node that is the MRCA of the |
less_memory |
If TRUE, uses a much slower approach that will not create giant matrices |
descendant_labeled |
If TRUE, assumes the phy_full has been labeled with LabelNodesWithFeasibleDescendants |
fast_ultrametric |
If TRUE, uses a fast algorithm for ultrametric trees |
verbose |
If TRUE, all the output will print to the screen |
A data.frame of chosen taxa, closest feasible match, and distance between them
If you don't have a taxonomy tree for the feasible tree, this will find one
GetEnclosingTaxonomy(phy_feasible)
GetEnclosingTaxonomy(phy_feasible)
tips |
A vetor of taxon names |
A phylogeny of the enclosing taxonomy
Get similarity Uses ape's cophenetic.phylo to get patristic distances between pairs of taxa, then makes the diagonals Inf. If the tree has no branch lengths, makes every edge length 1.
GetSimilarity(phy_full, taxa_feasible, truncate_full_to_mrca = FALSE)
GetSimilarity(phy_full, taxa_feasible, truncate_full_to_mrca = FALSE)
phy_full |
A phylo object with all feasible taxa to sammple from |
taxa_feasible |
A vector of taxon names that are feasible to study (often on another tree) |
truncate_full_to_mrca |
If TRUE, prune the full tree to the node that is the MRCA of the |
A matrix with tips on the rows and columns and patristic distances in the cells. Rows are tips on the phy_full tree, columns are taxa in the taxa_feasible vector
Include descendant taxon ids in node labels
LabelNodesWithChosenDescendants(node, phy, clean = FALSE, sep = ", ")
LabelNodesWithChosenDescendants(node, phy, clean = FALSE, sep = ", ")
node |
node number, typically a tip |
phy |
phylo object |
clean |
wipe existing node labels |
sep |
Separator |
A phylogeny with terminal node numbers as node.labels. Unfortunately, each will start with NA.
Include descendant taxon ids in node labels
LabelNodesWithFeasibleDescendants(taxa_feasible, phy)
LabelNodesWithFeasibleDescendants(taxa_feasible, phy)
taxa_feasible |
vector of taxon names that are feasible for later suse |
phy |
phylo object |
A phylogeny with terminal node numbers as node.labels.
Return a sampled tree
SubsampleTree( phy_feasible, n, phy_full = NULL, replace_full = TRUE, replace_feasible = FALSE, truncate_full_to_mrca = FALSE, less_memory = FALSE, verbose = TRUE )
SubsampleTree( phy_feasible, n, phy_full = NULL, replace_full = TRUE, replace_feasible = FALSE, truncate_full_to_mrca = FALSE, less_memory = FALSE, verbose = TRUE )
phy_feasible |
The tree to subsample |
n |
The number of taxa to include |
phy_full |
The larger tree giving relationships |
replace_full |
If TRUE, will allow selecting the same taxon from the full tree more than once. If FALSE, forbids this. Both cases return n taxa |
replace_feasible |
If TRUE, will allow selecting the same taxon from the set of feasible taxa more than once (returning a smaller than desired tree). If FALSE, forbids this. |
truncate_full_to_mrca |
If TRUE, prune the full tree to the node that is the MRCA of the feasible tree |
less_memory |
If TRUE, uses a much slower approach that will not create giant matrices |
verbose |
If TRUE, all the output will print to the screen |
A phylo object where taxa are sampled based on representing flat sampling from taxonomy