# Efficient Phylogenetics on Large Trees

## Documentation for package ‘castor’ version 1.6.2

- DESCRIPTION file.

## Help Pages

A C D E F G H I 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.
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
count_lineages_through_time | Count number of lineages through time (LTT).
count_tips_per_node | Count descending tips.

## -- D --

date_tree_red | Date a tree based on relative evolutionary divergences.

## -- E --

evaluate_spline | Evaluate a scalar spline at arbitrary locations.
exponentiate_matrix | Exponentiate a matrix.
extend_tree_to_height | Extend a rooted tree up to a specific height.
extract_fasttree_constraints | Extract tree constraints in FastTree alignment format.

## -- F --

find_farthest_tips | Find farthest tip to each tip & node of 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_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_grid | Fit pulled speciation rates of birth-death models on a time grid.
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 Spherical Brownian Motion model on a tree.
fit_sbm_linear | Fit a Spherical Brownian Motion model with linearly varying diffusivity on a tree.
fit_sbm_parametric | Fit a time-dependent Spherical Brownian Motion model on a tree.
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_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_clade_list | Get a representation of a tree as a table listing tips/nodes.
get_independent_contrasts | Phylogenetic independent contrasts for continuous traits.
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_depth | Calculate depth of phylogenetic conservatism for a binary 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_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 --

is_monophyletic | Determine if a set of tips is monophyletic.

## -- 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.
merge_short_edges | Eliminate short edges in a tree by merging nodes into multifurcations.
multifurcations_to_bifurcations | Expand multifurcations to bifurcations.

## -- P --

pick_random_tips | Pick random subsets of tips on a tree.

## -- R --

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 or re-root a tree at the midpoint node.
root_at_node | Root or re-root a tree at a specific node.
root_in_edge | Root or re-root a tree in the middle of an edge.
root_via_outgroup | Root or re-root a tree based on an outgroup tip.

## -- S --

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.
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_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.