Learn R Programming

PhylogeneticEM (version 1.8.0)

Automatic Shift Detection using a Phylogenetic EM

Description

Implementation of the automatic shift detection method for Brownian Motion (BM) or Ornstein–Uhlenbeck (OU) models of trait evolution on phylogenies. Some tools to handle equivalent shifts configurations are also available. See Bastide et al. (2017) and Bastide et al. (2018) .

Copy Link

Version

Install

install.packages('PhylogeneticEM')

Monthly Downloads

271

Version

1.8.0

License

GPL (>= 2) | file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Paul Bastide

Last Published

February 14th, 2025

Functions in PhylogeneticEM (1.8.0)

compute_dist_phy

Phylogenetic Distances
compute_expectations.BM

Compute the expected states of a BM
compute_fixed_moments

Compute fixed moments for E step.
compute_actualization_matrix_ultrametric

Compute Matrix W of actualization (Ultrametric case)
compute_expectations.scOU

Compute the expected states of a scOU
compute_E.simple

E step
compute_times_ca

Common Ancestors Times
compute_log_likelihood.simple

Log Likelihood
compute_sum_var_diff

Compute weighted sum of var_diff
compute_gauss_lasso

Do a lm on top of a lasso regression.
compute_tree_correlations_matrix.BM

Matrix of tree-induced correlations for the BM
compute_shifts_from_betas

Computation of shifts from the vector of optimal values
compute_tree_correlations_matrix.scOU

Matrix of tree-induced correlations for the scOU
compute_residuals.simple

Residuals
compute_stationary_variance

Compute the stationary variance matrix
compute_var_M.BM

Computation of the variance.
compute_var_diff.BM

Compute variances of differences between nodes and parents.
compute_state_filter

List of potential daughter states when parent is in state k.
clusters_from_shifts

Clustering associated to a shift allocation, assuming no homoplasy.
correspondenceEdges

Correspondence between edges numbers
enlight

Make the result lighter
compute_mean_variance.simple

Compute moments of params_old
compute_diff_exp.BM

Compute differences of expectations between node and parent.
compute_variance_covariance.OU

Complete variance covariance matrix for OU
equivalent_shifts_edges

Find all the equivalent shift edges allocations.
compute_variance_covariance.BM

Complete variance covariance matrix for BM
compute_variance_block_diagonal.BM

Tips Variances for the BM
check_range_alpha

Check range of alpha
compute_variance_block_diagonal.OU

Tips Variances for the OU
equivalent_shifts

Find all equivalent shifts allocations and values.
compute_betas_from_shifts

Computation of the optimal values at nodes and tips.
extract.parsimonyCost

Extraction of the actual number of solutions.
extract.parsimonyNumber

Extraction of the actual number of solutions.
find_rotation

Test for rotation invariant datasets
estimateEM

Perform One EM
compute_variance_covariance.OU.nonsym

Complete variance covariance matrix for OU
compute_mahalanobis_distance.simple

Squared Mahalanobis Distance
find_independent_regression_vectors.glmnet_multivariate

Given a regularization path, find K selected independent variables.
incidence.matrix

Incidence matrix of a tree.
incidence.matrix.full

Incidence matrix of a tree.
init.incidence.matrix

Initialization for incidence matrix
compute_variance_covariance.scOU

Complete variance covariance matrix for scOU
equivalent_shifts_values

Find values given edges. OU stationary case. Ultrametric tree.
find_grid_alpha

Find a reasonable grid for alpha
extract_variance_covariance

Extract sub-matrices of variance.
extract.equivalent_shifts

Extract the shifts values for one trait.
extract.enumerate_parsimony

Extract the result of enumerate_parsimony at a node.
enumerate_parsimony

Enumerate all the possible regime allocations, given a clustering of the tips.
enumerate_tips_under_edges

Tips descendants of nodes.
init.simulate.BM

Initialize BM
extract

Extraction function
imputed_traits

Ancestral State Reconstruction
extract.partitionsNumber

Extract from object partitionsNumber
extract.simul_process

Extraction of simulated traits
estimate.alpha

Function to estimate alpha
go_back_to_original_process

Scale the parameters back to the original process
find_shift_values

Find values given edges. OU stationary case. Ultrametric tree.
init.simulate.OU

Initialize state and expectation matrices
init.incidence.matrix.full

Initialization for incidence matrix (full tree)
init.parsimonyCost

Initialization for parsimonyCost.
init.parsimonyNumber

Initialization for parsimonyNumber.
is.in.ranges

Check whether parameters are in ranges.
init.simulate.StateAndExp

Initialize state and expectation matrices
params_process.PhyloEM

Parameter estimates
format_output

Run the EM for several values of K
get_criterion

Get Model Selection Criterion
incidence_matrix_actualization_factors

Compute the actualization factors to apply to the incidence matrix.
merge_complementary_vectors

Merge several complementary vectors into one.
init.EM.lasso

Initialization of the shifts using Lasso.
merge_params_independent

Merge a list of independent parameters into into one parameter
log_likelihood

Log Likelihood of a fitted object
merge_rotations

Merge fits from independent runs of PhyloEM.
init.alpha.gamma.estimation

Initialization the selection strength alpha using robust estimation
init.allocate_regimes_from_shifts

Initialization for the allocation of shifts.
lasso_regression_K_fixed.glmnet_multivariate

Do a lasso regression with the number of non-zero variables fixed.
matrix_of_possibles

Compute parent matrix from possibles daughter matrices.
qr_solve_exact

exact qr.solve
params_process

Create an object params_process
recursionDown

Generic recursion down the tree.
monkeys

New World Monkeys dataset
params_OU

Create an object params_process for an OU
params_BM

Create an object params_process for a BM
plot.PhyloEM

Plot for class PhyloEM
init.compute_betas_from_shifts

Initialization for the computation of the optimal values
penalty_pBIC

Penalty function type pBIC
init.enumerate_parsimony

Initialization for the enumeration of parsimonious solutions.
penalty_BirgeMassart_shape2

Penalty function type Birgé-Massart 2
get_variance_node

Get variance matrix of a node
model_selection

Model Selection of a fitted object
merge_alpha_grids

Merge PhyloEM fits on various grids of alpha values
params_process.character

Create an object params_process
plot.enumerate_parsimony

Plot all the equivalent solutions.
parsimonyCost

Minimal number of shifts needed to get a clustering.
parsimonyNumber

Number of equivalent parsimonious allocations.
partitionsNumber

Number of different models
penalty_BaraudGiraudHuet_likelihood

Penalty function type Baraud Giraud Huet.
update.enumerate_parsimony

Actualization of the enumeration.
plot.equivalent_shifts

Plot all the equivalent solutions.
update.incidence.matrix

Update function for incidence matrix
residuals.PhyloEM

Residuals of a fitted object
sample_edges_intervals

Sample equally spaced edges.
shifts.vector_to_list

Compute the list of shifts.
shifts_to_simmap

Simmap format mapping from list of edges
shifts.list_to_matrix

Compute the matrix of shifts.
segmentation.OU.specialCase.same_shifts

Segmentation in the OU special case, conserving the same shifts position.
update.incidence.matrix.full

Update function for incidence matrix
sum_partitions.cardFixed

Sum on subsets of a given cardinal.
penalty_BirgeMassart_shape1

Penalty function type Birgé-Massart 1
shifts.matrix_to_list

Compute the list of shifts.
shifts.list_to_vector

Compute the vector of shifts.
sum_simplex

Sum on a simplex
update.allocate_regimes_from_shifts

Update function for regime allocation.
sum_prod.comb

Sum on a simplex
update.compute_betas_from_shifts

Update function for optimal value computation
node_optimal_values

Computation of the optimal values at nodes and tips.
update.parsimonyNumber

Actualization for parsimonyNumber.
update.parsimonyCost

Actualization for parsimonyCost.
simul_process

Simulate a Stochastic Process on a tree
plot.params_process

Plot for class simul_process
segmentation.OU.specialCase.lasso

Segmentation in the OU special case, using lasso regression
segmentation.BM

Segmentation in the BM case
wrapper_E_step

Wrapper for E step in EM
simulate_internal

Simulate a Stochastic Process on a tree
update.partitionsNumber.gen

Update formula in the general case
plot_criterion

Plot Model Selection Criterion
split_params_independent

Split independent parameters into a list of parameters
prod_index

Product of elements of a matrix
sum_partitions

Sum on all subsets.
scale_params

Scale variance and selection strength from a linear transform
sample_shifts_edges

Sample shifts edges in a parsimonious way.
transform_branch_length

Transform branch length for a re-scaled BM
transform_shifts_values

Transform the shift values
test.root.state

Test state of root.
PhyloEM

Model Estimation with Detection of Shifts
check_parsimony

Check Parsimony, assuming no homoplasy
allocate_subset_node.simulate

Iteration allocation
allocate_shifts_from_regimes

Allocation of shifts to edges
allocate_regimes_from_shifts

Allocation of regimes to nodes.
check.selection.strength

Check selection strength
check_parsimony_clusters

Check whether an allocation of the shifts is parsimonious, in the "infinite site model".
check_dimensions

Check dimensions of the parameters
add_complementary

Add several entries, when only one is not NA.
check_data

Test the format of data entry.