Take model parameters and the data and calculate the log-likelihood
define_BioGeoBEARS_model_object
Define a BioGeoBEARS_model class and object
For each tip, get a text string of the areas in a tipranges object.
get_indices_of_branches_under_tips
Get the indices of the branches (row number in edge matrix) below each tip
An object of class BioGeoBEARS_run holding the model inputs
Conditionally format a number (mostly)
bears_2param_standard_fast_symOnly_simp
2-parameter model, no cladogenesis model (as in BayArea or other purely continuous-time model)
LGcpp_splits_fn_to_table2
Get the ML splits per node, from Python LAGRANGE output
get_MLsplitprobs_from_results
Extract the ML probs for the base of each branch above a split
BioGeoBEARS_model_object_to_params_upper
Produce the upper limit on the parameters from a BioGeoBEARS model object
Get rownum of named model
BioGeoBEARS_model_object_to_init_params
Produce initial parameters from a BioGeoBEARS model object
Order LAGRANGE-numbered nodes so that they can be plotted in R
bears_3param_standard_fast_fixnode
3-parameter model, adding j (founder-event speciation)
areas_list_to_states_list_new
Convert a list of areas to a list of geographic ranges (states); R version
BioGeoBEARS_model_defaults
Set up a default BioGeoBEARS model object
prob_of_states_from_prior_prob_areas
Calculate probability of detection data for each OTU at each range in a list of states/geographic ranges
BioGeoBEARS_model_object_to_est_params
Extract estimated parameters from a BioGeoBEARS model object
Get the ML splits per node, from Python LAGRANGE output
Get the ML states per node, from a states table
bears_2param_standard_fast
2-parameter model, fixed cladogenesis model (as in LAGRANGE)
bears_3param_standard_fast_noJ
3-parameter model, adding v (vicariance proportion), but no j (founder-event speciation)
Calculate posterior probability of presence, given count data and parameters
Calculate all the AIC and LRT stats between two models
calc_linked_params_BioGeoBEARS_model_object
Update parameters that are deterministic functions of free parameters
bears_3param_standard_fast
3-parameter model, adding j (founder-event speciation)
binary_range_to_letter_code_txt
Convert binary presence/absence codes (1/0) to text area names
Iterate up through a plotted tree, getting the coordinates of the corners
Get the ages of all the nodes in the tree (above the root)
Get the class for each column in a list
bears_4param_standard_fast
4-parameter model, adding j (founder-event speciation) and v (vicariance proportion)
calc_loglike_for_optim_stratified
Take model parameters and the data and calculate the log-likelihood -- stratified version
Get the ML splits per node, from C++ LAGRANGE output
BioGeoBEARS_model_object_to_params_lower
Produce the lower limit on the parameters from a BioGeoBEARS model object
binary_ranges_to_letter_codes
Convert binary presence/absence codes (1/0) to a list of text area names
get_Akaike_weights_from_rel_likes
Calculate the Akaike Weights, from the relative likelihoods of the models
Calculate likelihood of count data given true presence/absence and parameters
Calculate AICc
Calculate probability of detection data given a true geographic range and a detection probability
Get R internal node numbers
Convert to data.frame, without factors
An object of class BioGeoBEARS_model holding the model inputs
Convert to data.frame, without factors
Get a node's level in the tree
Get TRUE/FALSE for nodes being tips
Convert a specified null range code to NA
Get the corner coordinates
Calculate Z (part of equation 6.4 of Harte 2011)
get_Akaike_weight_ratio_from_Akaike_pairwise_weights
Get the ratio between the pairwise Akaike Weights
Extract the indices for the ML states at each node, given a row of relative probabilities
Get the class for each column in a list
calc_loglike_sp_stratified
Calculate log-likelihood with a transition matrix and speciation events, and with stratification
get_ML_states_from_relprobs
Extract the ML states at each node, from a table of relative probabilities -- old version
get_indices_where_list1_occurs_in_list2
Return (first!) indices in second list matching the first list
calc_prob_forward_onebranch_dense
Dense matrix exponentiation forward on a branch, with rexpokit
bears_2param_standard_fast_fixnode
2-parameter model, fixed cladogenesis model (as in LAGRANGE)
divide_probs_by_number_of_options_txt
Divide each type of event by its frequency
bears_9param_standard_fast_ys_v_cb
6-parameter model, adding j (founder-event speciation), v (vicariance proportion), and both maxent_constraint_01 and maxent_constraint_01v
Calculate AICc values for a list of models
getranges_from_LagrangePHYLIP
Read a LAGRANGE PHYLIP-style file containing geographic ranges into a tipranges
object
get_edge_times_before_present
Get the times of the top and bottom of each edge
BioGeography with Bayesian (and likelihood) Evolutionary Analysis of RangeS
bears_5param_standard_fast_diffstart
5-parameter model, with different starting points for optimization
Get the ML splits per node, from a splits table
normalizePath shortcut
infprobs_to_probs_of_each_area_from_relprobs
Convert relative probabilities matrix to the probabilities of presence in each area
Calculate AICc values for a list of models
Mapply version of calc_obs_like()
Average the heights of (non-fossil) tips to make ultrametric-ish.
Make pie charts for plotting ranges on corners
Define a tipranges class and object
AkaikeWeights_and_Ratios_pairwise_on_summary_table_compared_to_ref
Get the ratio between the pairwise Akaike Weights
Order the tipranges in a tipranges object so they match the order of tips in a tree
binary_range_to_letter_code_list
Convert binary presence/absence codes (1/0) to a list of text area names
infprobs_to_probs_of_each_area
Convert probabilities of each state, to the probabilities of presence in each area
Run ML search from BioGeoBEARS_run
object
Saw a tree off at a particular time before present
bears_6param_standard_fast_ys_v
6-parameter model, adding j (founder-event speciation), v (vicariance proportion), and both maxent_constraint_01 and maxent_constraint_01v
Iterate up and down a tree in C++ LAGRANGE downpass order
Make labels for plotting ranges on corners
expokit_dgpadm_Qmat2_prebyte
A version of expokit_dgpadm_Qmat to byte-compile
bears_2param_standard_fast_fortest
2-parameter model, fixed cladogenesis model (as in LAGRANGE) -- older test version
Default input for a states_list
Plot a colors legend for geographic ranges
Calculate log-likelihood with a transition matrix and speciation events -- pre-byte-compiled
get_Akaike_weights_from_rel_likes_pairwise
Calculate the Akaike Weights, from the relative likelihoods of the models
axisPhylo with more flexibility in labeling
Get the ML states per node, from C++ LAGRANGE output
bears_5param_standard_fast_v
5-parameter model, adding j (founder-event speciation), v (vicariance proportion), and maxent_constraint_01v (vicariance daughter sizes)
Get indices of all matches to a list
divide_probs_by_number_of_options_nums
Divide each type of event by its frequency, return calculated probabilities
Calculate Z (equation 6.3 of Harte 2011)
parse_lagrange_output_old
Parse the output file from python LAGRANGE
-- older version
Calculate AICs for a list of models
Get TRUE/FALSE for nodes being tips
getareas_from_tipranges_object
Get the names of the areas in a tipranges object
Get the inferred parameters from a results object (utility function)
prt_tree_to_phylo4
check_if_state_is_allowed
Check if a geographic range/state is allowed, given an areas-allowed matrix.
Conditionally format the numbers (mostly) in a table
Get the inferred parameters from an ML optimization
get_indices_where_list1_occurs_in_list2_noNA
Return (first!) indices in second list matching the first list, excluding NAs
Extract just the numbers from a string, including decimal points
Get the unique node numbers in a tree
Get the direct parent node of a node
simstates_to_probs_of_each_area
Convert simulated states to probabilities of each area
Check for not NA
get_AICweight_ratio_model1_over_model2
Calculate ratio of Akaike Weights
calc_prob_forward_onebranch_sparse
Sparse matrix exponentiation forward on a branch, with rexpokit
Get all the direct daughters nodes of a node
Get the probability of the ML state for each node, from a BioGeoBEARS model results list
An even faster version of expand.grid
Get the text that comes after the last slash
Get internal node numbers in LAGRANGE's downpass order
get_relative_prob_model1old
Calculate relative probability of model 1 (=Akaike Weight)
Collapse range abbreviations to strings
Get colors for a certain number of single areas
Make a relative probability matrix for a single speciation (bifurcation) event
Parse the output file from python LAGRANGE
get_leftright_nodes_matrix_from_results
Make a table of the Right and Left nodes descending from each node
make_relprob_txtmatrix_sp1
Convert a observed-speciation transition matrix to an unobserved-speciation transition matrix (text version)
Convert a list of ranges text (KOM, MH, KOMIH, etc.)
eval()
function for use in sapply
Get everything BEFORE the last suffix (.nex or whatever)
Print tree in table format
Get the node sister to two nodes
Calculate AICs to make a column in a table
Make a color table for each area and their combinations
Utility function to conditionally print intermediate results
Read a file with detection counts per area
Make a relative dispersal probability matrix (in text form)
Calculate probability of ordered discrete states using a maxent distribution (equations 6.3-6.4 of Harte 2011)
Return TRUE for list1 items when they occur in list2
Convert ranges in the form of letters (A, AB, BFG, etc.) to binary state number codes
params_into_BioGeoBEARS_model_object
Feed modified parameters back into a BioGeoBEARS model object
map_LG_MLsplits_to_tree_corners
Map splits to the corners on a phylogeny
tipranges_to_area_strings
Convert tipranges binary coding to range strings
Calculate the relative likelihoods of the models, from the deltaAIC
Get the simulated model parameters from the row of a table
Merge lists of words and nonwords (numbers) that may be of different length
symbolic_cell_to_relprob_cell
Convert symbolic cell (a text equation) to relprob matrix (a numeric value).
make_relprob_nummatrix_sp1
Convert a observed-speciation transition matrix to an unobserved-speciation transition matrix (numeric version)
relative_probabilities_of_subsets
Calculate probability of different descendant rangesizes, for the smaller descendant, in subset speciation
Get ML states from a BioGeoBEARS model results list
Unlist the columns in a data.frame, with more checks and adf
Load the simulation information from an underscore delimited text string.
save_tipranges_to_LagrangePHYLIP
Save a tipranges object to a LAGRANGE PHYLIP-style file containing binary-encoded geographic ranges
Remove double slash (slash a slash)
Calculate deltaAIC
remove_null_rowcols_from_mat
Remove rows or columns representing a null geographic range from a matrix
Calculate Akaike Weight
label_nodes_postorder_phylo3
Add postorder node number labels to a phylo3 tree object.
Calculate log-likelihood with a transition matrix and speciation events -- byte-compiled
Get the maximum age of all the nodes (above the root)
read_dispersal_multipliers_fn
Read in the hard-coded dispersal multipliers from file
map_LGpy_MLsplits_to_tree
Take the table of ML splits and node number and map on tree (Python version)
Read in the stratification time breakpoints
Mix colors logically to produce colors for multi-area ranges
Read in the area areas by time
Calculate Likelihood Ratio Test (LRT)
Take the table of ML splits and node number and map on tree (C++ LAGRANGE version)
symbolic_to_relprob_matrix_sp
Convert symbolic matrix (with text equations) to relprob matrix (numeric values) -- speciation matrix version
Assign node labels in bottom-up, left-first format (as in e.g. r8s)
mapply_calc_post_prob_presence
Mapply version of calc_post_prob_presence()
Get the ages of each tip above the root
Extract the appropriate probability for a vicariant speciation event, given text code for rangesize of smaller descendant, and ancestor
given_a_starting_state_simulate_branch_end
Given the state at the start of a branch, simulate the state at the end of the branch
Print a table to LaTeX format
tipranges_to_tip_condlikes_of_data_on_each_state
Convert a tipranges object to the tip likelihoods
Construct a (text) cell of the cladogenesis/speciation matrix
Calculate posterior probability of each states/geographic ranges, given prior probabilities and data likelihoods
get_all_daughter_tips_of_a_node
Get all the daughter tips of a node
states_list_indexes_to_areastxt
States (ranges) lists to txt string of the areas
Traverse the tree from node up to the tips
make_dispersal_multiplier_matrix
Make a default matrix of relative dispersal probabilities between areas
print to screen the header of a file
mapply_likelihoods_prebyte
Use mapply on matrix exponentiations -- pre-byte-compiling
Extract the appropriate probability for a sympatric/range-copying speciation event, given text code for rangesize of smaller descendant, and ancestor
Use mapply on matrix exponentiations -- post-byte-compiling
Get the text that comes before the last slash
Convert a list of items to a string
Get the maximum rangesize for a given ancestral rangesize
order_tipranges_by_tree_tips
Reorder the rows in a tipranges
object, to correspond to tree tips
letter_strings_to_tipranges_df
Convert ranges in the form of letters (A, AB, BFG, etc.) to a tipranges
object
simulated_indexes_to_tipranges_object
Convert simulated Qmat 0-based indexes to a tipranges object
Extract optim
results to a row
Remove NAs from a vector/list
String splitting shortcut
Cut down the states list according to areas_allowed_mat
get_infprobs_of_simstates
Get the probabilities of the true (simulated) states
Read a file with the total number of detections in a taphonomic control
Unlist the columns in a data.frame
symbolic_cell_to_relprob_cell_sp
Convert symbolic cell (a text equation) to relprob cell (a numeric value) -- speciation matrix version
simulated_indexes_to_tipranges_file
Convert simulated Qmat 0-based indexes to a tipranges file
parse_lagrange_python_output_old
Parse the output file from python LAGRANGE
-- old version
Extract the appropriate probability for a subset speciation event, given text code for rangesize of smaller descendant, and ancestor
Simulate a biogeographical history, given a transition matrix and cladogenesis model
Convert symbolic matrix to relprob matrix
Unlist the columns in a data.frame, with more checks
Get the per-event probabilities at cladogenesis
A byte-compiled version of expokit_dgpadm_Qmat2_prebyte
relative_probabilities_of_vicariants
Calculate probability of different descendant rangesizes, for the smaller descendant, in vicariant speciation
The tipranges class
get_nodenum_structural_root
Gets the root node
plot_cladogenesis_size_probabilities
Graphical display of P(daughter rangesize) for your input or inferred speciation model
Utility functions to help deal with matrices
Normalize a transition matrix
Convert symbolic matrix to an instantaneous rate matrix (Q matrix)
Print a table to LaTeX format
Calculate the dimensions of the cladogenesis/speciation matrix
Graphical display of your anagenetic and cladogenetic biogeography models
Print an entire table to screen
Section a tree for stratified analysis
Split strings on whitespace
Read in the area areas by time
parse_lagrange_python_output
Parse the output file from python LAGRANGE
bears_5param_standard_fast
5-parameter model, adding j (founder-event speciation), v (vicariance proportion), and maxent_constraint_01 (weighting for size of smaller-ranged descendant lineage)
readfiles_BioGeoBEARS_run
Read in the extra input files, if any
Calculate Likelihood Ratio Test (LRT) results, and add to table
Concatenate cells in each row of a text-based transition matrix, excluding zeros
get_relative_prob_model2old
Calculate relative probability of model 1 (Akaike Weight)
Get internal node numbers in pruningwise order
postorder_nodes_phylo4_return_table
Get a table of node numbers, including DIVA node numbers
bears_2param_standard_slowQ_slowSP
2-parameter model, fixed cladogenesis model -- slow version
Calculate posterior probability of each states/geographic ranges, given prior probabilities and data likelihoods
prune_specimens_to_species
Take a tree and species names/geography table and produce a pruned tree and tipranges object
Read in the distances by time
rel_likes_from_deltaAICs_pairwise
Calculate the relative likelihoods of the models, from the deltaAICs, pairwise
AkaikeWeights_on_summary_table
Calculate Akaike Weights, and add to table
Add a slash to a directory name if needed
Calculate probability of detection data given a true geographic range and a detection probability
2-parameter model, fixed cladogenesis model (as in LAGRANGE)
Check the inputs for various problems
bears_2param_standard_fast_symOnly
2-parameter model, no cladogenesis model (as in BayArea or other purely continuous-time model)
A faster version of expand.grid
Define a maximum likelihood search, perhaps stratified
extend_tips_to_ultrametricize
Take a tree, extend all tips (including fossils) up to 0.0 my before present
Calculate AIC
get_deltaAIC_pairwise_w_ref_model
Calculate deltaAIC
get_infparams_optimx_nosim
Get the inferred parameters from an ML optimization (different filenames)
given_a_starting_state_simulate_split
Given the state just below a node, simulate the states after speciation
Map states to the nodes on a phylogeny
Plot the results of a BioGeoBEARS run
symbolic_to_Q_matrix_exper
Experimental version of symbolic_to_Q_matrix_exper
, including base frequencies
Source all .R files in a directory, except "compile" and "package" files
Read a PHYLIP-format file
Unlist the columns in a data.frame, with more checks, adf, and dfnums_to_numeric
Unlist the columns in a data.frame
Calculate probability of detection data for each OTU at each range in a list of states/geographic ranges