# Efficient Phylogenetics on Large Trees

## Documentation for package ‘castor’ version 1.8.6

- DESCRIPTION file

## Help Pages

A C D E F G H I J L M P R S T W

castor-package | Efficient computations on large phylogenetic trees.

## -- A --

asr_empirical_probabilities | Empirical ancestral state probabilities.
asr_independent_contrasts | Ancestral state reconstruction via phylogenetic independent contrasts.
asr_max_parsimony | Maximum-parsimony ancestral state reconstruction.
asr_mk_model | Ancestral state reconstruction with Mk models and rerooting
asr_squared_change_parsimony | Squared-change parsimony ancestral state reconstruction.
asr_subtree_averaging | Ancestral state reconstruction via subtree averaging.

## -- C --

castor | Efficient computations on large phylogenetic trees.
clade_densities | Estimate the density of tips & nodes in a timetree.
collapse_monofurcations | Remove monofurcations from a tree.
collapse_tree_at_resolution | Collapse nodes of a tree at a phylogenetic resolution.
congruent_divergence_times | Extract dating anchors for a target tree, using a dated reference tree
congruent_hbds_model | Generate a congruent homogenous-birth-death-sampling model.
consensus_taxonomies | Compute consensus taxonomies across a tree.
consentrait_depth | Calculate phylogenetic depth of a binary trait using the consenTRAIT metric.
correlate_discrete_traits | Correlations between discrete traits on trees.
correlate_phylo_geodistances | Correlations between phylogenetic & geographic distances.
count_lineages_through_time | Count number of lineages through time (LTT).
count_tips_per_node | Count descending tips.
count_transitions_between_clades | Count the number of state transitions between tips or nodes.

## -- D --

date_tree_red | Date a tree based on relative evolutionary divergences.
discrete_trait_depth | Calculate phylogenetic depth of a discrete trait.

## -- E --

evaluate_spline | Evaluate a scalar spline at arbitrary locations.
expanded_tree_from_jplace | Place queries on a tree from a jplace file.
expected_distances_sbm | Expected distances traversed by a Spherical Brownian Motion.
exponentiate_matrix | Exponentiate a matrix.
extend_tree_to_height | Extend a rooted tree up to a specific height.
extract_deep_frame | Extract tips representing a tree's deep splits.
extract_fasttree_constraints | Extract tree constraints in FastTree alignment format.
extract_tip_neighborhood | Extract a subtree spanning tips within a certain neighborhood.
extract_tip_radius | Extract a subtree spanning tips within a certain radius.

## -- F --

find_farthest_tips | Find farthest tip to each tip & node of a tree.
find_farthest_tip_pair | Find the two most distant tips in a tree.
find_nearest_tips | Find nearest tip to each tip & node of a tree.
find_root | Find the root of a tree.
find_root_of_monophyletic_tips | Find the node or tip that, as root, would make a set of target tips monophyletic.
fit_and_compare_bm_models | Fit and compare Brownian Motion models for multivariate trait evolution between two data sets.
fit_and_compare_sbm_const | Fit and compare Spherical Brownian Motion models for diffusive geographic dispersal between two data sets.
fit_bm_model | Fit a Brownian Motion model for multivariate trait evolution.
fit_hbds_model_on_grid | Fit a homogenous birth-death-sampling model on a discrete time grid.
fit_hbds_model_parametric | Fit a parametric homogenous birth-death-sampling model to a timetree.
fit_hbd_model_on_grid | Fit a homogenous birth-death model on a discrete time grid.
fit_hbd_model_parametric | Fit a parametric homogenous birth-death model to a timetree.
fit_hbd_pdr_on_best_grid_size | Fit pulled diversification rates of birth-death models on a time grid with optimal size.
fit_hbd_pdr_on_grid | Fit pulled diversification rates of birth-death models on a time grid.
fit_hbd_pdr_parametric | Fit parameterized pulled diversification rates of birth-death models.
fit_hbd_psr_on_best_grid_size | Fit pulled speciation rates of birth-death models on a time grid with optimal size.
fit_hbd_psr_on_grid | Fit pulled speciation rates of birth-death models on a time grid.
fit_hbd_psr_parametric | Fit parameterized pulled speciation rates of birth-death models.
fit_mk | Fit a Markov (Mk) model for discrete trait evolution.
fit_musse | Fit a discrete-state-dependent diversification model via maximum-likelihood.
fit_sbm_const | Fit a phylogeographic Spherical Brownian Motion model.
fit_sbm_geobiased_const | Fit a phylogeographic Spherical Brownian Motion model with geographic sampling bias.
fit_sbm_linear | Fit a phylogeographic Spherical Brownian Motion model with linearly varying diffusivity.
fit_sbm_on_grid | Fit a phylogeographic Spherical Brownian Motion model with piecewise-linear diffusivity.
fit_sbm_parametric | Fit a time-dependent phylogeographic Spherical Brownian Motion model.
fit_tree_model | Fit a cladogenic model to an existing tree.

## -- G --

gamma_statistic | Calculate the gamma-statistic of a tree.
generate_gene_tree_msc | Generate a gene tree based on the multi-species coalescent model.
generate_gene_tree_msc_hgt_dl | Generate gene trees based on the multi-species coalescent, horizontal gene transfers and duplications/losses.
generate_random_tree | Generate a tree using a Poissonian speciation/extinction model.
generate_tree_hbds | Generate a tree from a birth-death-sampling model in forward time.
generate_tree_hbd_reverse | Generate a tree from a birth-death model in reverse time.
generate_tree_with_evolving_rates | Generate a random tree with evolving speciation/extinction rates.
geographic_acf | Phylogenetic autocorrelation function of geographic locations.
get_all_distances_to_root | Get distances of all tips and nodes to the root.
get_all_distances_to_tip | Get distances of all tips/nodes to a focal tip.
get_all_node_depths | Get the phylogenetic depth of each node in a tree.
get_all_pairwise_distances | Get distances between all pairs of tips and/or nodes.
get_ancestral_nodes | Compute ancestral nodes.
get_clade_list | Get a representation of a tree as a table listing tips/nodes.
get_independent_contrasts | Phylogenetic independent contrasts for continuous traits.
get_independent_sister_tips | Extract disjoint tip pairs with independent relationships.
get_mrca_of_set | Most recent common ancestor of a set of tips/nodes.
get_pairwise_distances | Get distances between pairs of tips or nodes.
get_pairwise_mrcas | Get most recent common ancestors of tip/node pairs.
get_random_diffusivity_matrix | Create a random diffusivity matrix for a Brownian motion model.
get_random_mk_transition_matrix | Create a random transition matrix for an Mk model.
get_reds | Calculate relative evolutionary divergences in a tree.
get_stationary_distribution | Stationary distribution of Markov transition matrix.
get_subtrees_at_nodes | Extract subtrees descending from specific nodes.
get_subtree_at_node | Extract a subtree descending from a specific node.
get_subtree_with_tips | Extract a subtree spanning a specific subset of tips.
get_tips_for_mrcas | Find tips with specific most recent common ancestors.
get_trait_acf | Phylogenetic autocorrelation function of a numeric trait.
get_trait_stats_over_time | Calculate mean & standard deviation of a numeric trait on a dated tree over time.
get_transition_index_matrix | Create an index matrix for a Markov transition model.
get_tree_span | Get min and max distance of any tip to the root.
get_tree_traversal_root_to_tips | Traverse tree from root to tips.

## -- H --

hsp_binomial | Hidden state prediction for a binary trait based on the binomial distribution.
hsp_empirical_probabilities | Hidden state prediction via empirical probabilities.
hsp_independent_contrasts | Hidden state prediction via phylogenetic independent contrasts.
hsp_max_parsimony | Hidden state prediction via maximum parsimony.
hsp_mk_model | Hidden state prediction with Mk models and rerooting
hsp_naive | Naive hidden state prediction.
hsp_nearest_neighbor | Hidden state prediction based on nearest neighbor.
hsp_squared_change_parsimony | Hidden state prediction via squared-change parsimony.
hsp_subtree_averaging | Hidden state prediction via subtree averaging.

## -- I --

inherit_taxonomies | Inherit ancestral taxonomies from a phylogeny.
is_bifurcating | Determine if a tree is bifurcating.
is_monophyletic | Determine if a set of tips is monophyletic.

## -- J --

join_rooted_trees | Join two rooted trees.

## -- L --

loglikelihood_hbd | Galculate the log-likelihood of a homogenous birth-death model.

## -- M --

map_to_state_space | Map states of a discrete trait to integers.
mean_abs_change_scalar_ou | Compute the expected absolute change of an Ornstein-Uhlenbeck process.
merge_nodes_to_multifurcations | Merge specific nodes into multifurcations.
merge_short_edges | Eliminate short edges in a tree by merging nodes into multifurcations.
model_adequacy_hbd | Check if a birth-death model adequately explains a timetree.
model_adequacy_hbds | Check if a birth-death-sampling model adequately explains a timetree.
multifurcations_to_bifurcations | Expand multifurcations to bifurcations.

## -- P --

pick_random_tips | Pick random subsets of tips on a tree.
place_tips_taxonomically | Place queries on a tree based on taxonomic identities.
plot_tree_radial | Plot a tree in radial layout.

## -- R --

read_fasta | Load a fasta file.
read_fastq | Load a fastq file.
read_tree | Load a tree from a string or file in Newick (parenthetic) format.
reconstruct_past_diversification | Reconstruct past diversification dynamics from a diversity time series.
reorder_tree_edges | Reorder tree edges in preorder or postorder.
root_at_midpoint | Root a tree at the midpoint node.
root_at_node | Root a tree at a specific node.
root_in_edge | Root a tree in the middle of an edge.
root_via_outgroup | Root a tree based on an outgroup tip.
root_via_rtt | Root a tree via root-to-tip regression.

## -- S --

shift_clade_times | Shift the time of specific nodes & tips.
simulate_bm_model | Simulate a Brownian motion model for multivariate trait co-evolution.
simulate_deterministic_hbd | Simulate a deterministic homogenous birth-death model.
simulate_deterministic_hbds | Simulate a deterministic homogenous birth-death-sampling model.
simulate_diversification_model | Simulate a deterministic uniform speciation/extinction model.
simulate_dsse | Simulate a Discrete-State Speciation and Extinction (dSSE) model.
simulate_mk_model | Simulate an Mk model for discrete trait evolution.
simulate_musse | Simulate a Discrete-State Speciation and Extinction (dSSE) model.
simulate_ou_model | Simulate an Ornstein-Uhlenbeck model for continuous trait evolution.
simulate_rou_model | Simulate a reflected Ornstein-Uhlenbeck model for continuous trait evolution.
simulate_sbm | Simulate Spherical Brownian Motion on a tree.
simulate_tdsse | Simulate a time-dependent Discrete-State Speciation and Extinction (tdSSE) model.
spline_coefficients | Get the polynomial coefficients of a spline.
split_tree_at_height | Split a tree into subtrees at a specific height.

## -- T --

tree_distance | Calculate the distance between two trees.
tree_from_branching_ages | Generate a random timetree with specific branching ages.
tree_from_sampling_branching_ages | Generate a random timetree with specific tip/sampling and node/branching ages.
tree_from_taxa | Construct a rooted tree from lists of taxa.
tree_imbalance | Calculate various imbalance statistics for a tree.
trim_tree_at_height | Trim a rooted tree down to a specific height.

## -- W --

write_tree | Write a tree in Newick (parenthetic) format.