Skip to contents

Function to perform ancestral state reconstruction using corHMM. Output is parsed into a dataset with episodes of trait gain, loss, and continuation across the phylogeny

Usage

asr(
  df,
  tr,
  tip_name_variable,
  trait,
  model = "ER",
  node_states = "joint",
  upper_bound = 1e+50,
  lower_bound = 1e-09,
  confidence_threshold = NULL
)

Arguments

df

Dataframe with tip name (e.g., tip_name_variable) and phenotype/trait (e.g., trait) variables

tr

Phylogeny object of class "phylo"

tip_name_variable

Name of variable containing tip names in the dataframe (df). Tip name variable must correspond to tip names in the tree.

trait

Name of phenotype/trait variable in the dataframe (df).

model

Type of rate transition matrix. Options: equal rates model ("ER") or all rates different ("ARD"). The option, "MF", selects the best performing model using sample-size corrected Akaike information criterium (AICc). Default: ER

node_states

Perform "joint" or "marginal" reconstruction. Default: joint

upper_bound

Upper bound for likelihood search. Default: 1e50

lower_bound

Lower bound for likelihood search. Default: 1e-9

confidence_threshold

The confidence threshold to categorize ancestral state inferences from a marginal reconstruction.We suggest using a value of 0.5 (i.e., winner takes all), but permit modification to elevated values. Required when node_states == "marginal".

Value

corHMM_output

corHMM output

corHMM_model_statistics

Dataframe containing the inferred rates, log-likelihood, AIC, and chosen transition model. See documentation of characterize_asr_model for more information.

parent_child_df

Dataframe of parent-child relationships with additional descriptive information

node_states

Characetr string whether "joint" or "marginal" reconstruction was performed