Data and code from: Simple a posteriori insertion of fossil tips in molecular phylogenies can improve inferences of continuous trait evolution
Data files
Sep 22, 2026 version files 1.05 GB
-
R_Data_and_Files_for_Empirical_Case_Study.zip
205.64 MB
-
R_Data_and_Files_for_the_Simulations.zip
22.97 MB
-
R_Files_and_Data_for_Empirical_EB_Check.zip
819.43 MB
-
README.md
13.37 KB
Abstract
Integrating neontological and paleontological information improves inferences about the tempo and mode of phenotypic evolution over long timescales. Such investigations require a total-evidence phylogeny and a matching phenotypic dataset for both extant and extinct species. However, outside a few exemplar clades, morphological matrices establishing formal phylogenetic placements of fossils within molecular phylogenies are often lacking, limiting the inclusion of fossil data in macroevolutionary inferences. Informal fossil placements are commonly inferred through morphological assessment (e.g., as is often the case for node-age calibrations), but determining branch length durations is less straightforward. Using simulations, we compared four methods of a posteriori fossil insertion on models of continuous trait evolution. We find that arbitrarily assigning branch lengths to fossil taxa or analytically estimating them using continuous trait data had minor impacts on phenotypic inferences relative to true branch lengths. However, use of minimum fossil branch lengths biased model selection toward an Ornstein-Uhlenbeck process and inflated rate estimates. Applying these methods to a comparative dataset of carangarian fishes revealed an early burst pattern of trait evolution that goes undetected in extant-only analyses. We demonstrate that a posteriori insertion of fossils, even with designated rather than inferred branch lengths, shifts inferences about the tempo and mode of phenotypic evolution relative to those based only on extant taxa.
This README file is associated with the article
DeHaan et al. 2026. Simple a posteriori insertion of fossil tips in molecular phylogenies can improves inferences of continous trait evolution. Evolution.
Authors:
Lindsey M DeHaan, Graham J Slater, and Matt Friedman
For questions, comments, or concerns regarding the following script, please contact:
Lindsey DeHaan
lmdehaan@umich.edu or linzdehaan@gmail.com.
Description and setup README file
This README File is set up as a series of 3 sections with detailed descriptions of all the data and R scripts needed to replicate the analyses. The first section includes all the R scripts and R data files needed to run the a posteriori fossil placement simulations. These R data files and R scripts are located in the zip file called "R_Data_and_Files_for_the_Simulations.zip". The second section includes all the data files and R scripts to run the empirical case study analyses using Carangarian fishes. These R data files and R scripts are located in the zip file called "R_Data_and_Files_for_Empirical_Case_Study.zip" The last section includes all the R scripts and R data that were needed to check whether the early burst pattern detected in the empirical analyses was due to the impact of adding 11 fossil taxa or the addition of 11 terminal tips in the phylogeny in general. These R data files and R scripts are located in the zip file called "R_Files_and_Data_for_Empirical_EB_Check.zip"
Section 1. R Scripts and Data for A Posteriori Fossil Grafting Methods Simulations
Section 1 includes 9 R scripts and 3 Rdata files. A detailed description of the workflow and R scripts for each section can each can be found below.
R Scripts:
(1) No_Fossil_Outgroup_function.R
(2) No_Fossils_Sister_to_Extant_Clade_function.R
(3) No_Sister_Fossils_function.R
(4) Fossil_Extreme_V3.R
(5) Locate_Fossil_Loop_V3.R
(6) Fossil_Data_Info_Function.R
(7) VCV_Generator.R
(8) Script_To_Make_Figures_From_Cluster_Data.R
(9) 100_fitContinuous_Univariate_Simulations_Simple_Models.R
Rdata Files:
(1) Simulated_Tree.Rdata
(2) fossil_tip_vectors.Rdata
(3) Cluster_1000_Simulaations_wo_seed.Rdata
Simulating the phylogeny and implementing the four fossil grafting methods were all carried out in the main R script - "100_fitContinuous_Univariate_Simulations_Simple_Models.R". The beginning of this script includes the code that was used to simulated the phylogeny and perform the fossil pruning procedure described in the "Simulating a Phylogenetic Tree" section of the Methods and Materials. The pruning procedure required three functions listed below. A more detailed explanation of these functions can be found inside each script.
(1) No_Fossil_Outgroup_function.R
This custom function requires a phylogenetic tree as input (class phylo in R). This function removes the earliest diverging lineage from a phylogenetic tree if the earliest diverging lineage is a fossil taxon. The output of this function is a phylogenetic tree of class phylo.
(2) No_Fossils_Sister_to_Extant_Clade_function.R
This custom function requires a phylogenetic tree as input (class phylo in R). This function will prune fossil taxa out of a phylogenetic tree until one fossil taxon is sister to each extant clade. This function is necessary as an assumption of the fossil grafting methods implemented is that only one fossil can be placed on a stem lineage. The output of this function will be a phylogenetic tree of class phylo.
(3) No_Sister_Fossils_function.R
This custom function requires a phylogenetic tree as input (class phylo in R). This custom function prunes fossil taxa out of the phylogenetic tree until each fossil lineage is monotypic. The output of this function will be a phylogenetic tree of class phylo.
After scripts (1), (2), and (3) were applied to the simulated phylogeny, the resulting phylogeny had 51 fossil and 100 extant taxa in it, and it was saved as Simulated_Tree.Rdata. Because we only used one tree in our simulations, the code to make this tree again was commented out in the main script, and the resulting simulated phylogeny was just read into the main script.
Next, we pruned out sets of fossil taxa so that we can investigate the impacts of the number of fossil taxa on our fossil grafting methods. In order to make sure that the same fossil taxa were being pruned out for each iteration, we made vectors of fossil tips names that were dropped for each round. The vectors of differing numbers of fossil taxa to be dropped out of the tree were stored as fossil_tip_vectors.Rdata.
Next it was time to implement the simulations. The four fossil grafting methods were implemented on the simulated tree and repeated for each set number of fossil taxa to be included. The following four custom functions had to be loaded in for the simulations to run
(4) Fossil_Extreme_V3.R
This script implemented the maximum rule, halfway rule, and minimum rule fossil grafting methods and required the use of the simulated phylogeny (Simulated_Tree.Rdata). Specific details on how to use these functions can be found in the Fossil_Extreme_V3.R script.
(5) Locate_Fossil_Loop_V3.R
This function was used to implement the locate.fossil grafing method that was first generated by Revell et al 2015 Evolution. This script here is just a wrapper around that function located in the R package phytools. This function requires the use of the simulated phylogeny (Simulated_Tree.Rdata).
(6) Fossil_Data_Info_Function.R
This custom function set up a dataframe that was to be read by "Locate_Fossil_Loop_V3.R" so that locate.fossil knew where to place the fossil and the age of the fossil. The input of this function is the simulated phylogeny (Simulated_Tree.Rdata).
(7) VCV_Generator.R
This custom function generated a variance-covariance matrix that is required to simulate multivariate datasets under BM, OU, and EB.
The main R script - 100_fitContinuous_Univariate_Simulations_Simple_Models.R - was ran 1000 times on a high-performance computing cluster as an array. The output of the simulations were then saved into the following R data object: "Cluster_1000_Simulaations_wo_seed.Rdata"
All figures and reported results associated with the simulations were analyzed in the following R script
(8) Script_To_Make_Figures_From_Cluster_Data.R
Section 2. R Scripts and Data for Empirical Case Study of Carangarian Fishes
Section 2 includes 5 R scripts and 6 Rdata files. These scripts and Rdata files were used to implement the four fossil grafting methods to the Carangarian phylogenetic tree for the empirical case study.
R Scripts:
(1) Fix_Ultrametric_Tree_Code.R
(2) Fossil_Data_Info_Function.R
(3) Fossil_Extreme_V3.R
(4) Locate_Fossil_Loop_V3.R
(5) Empirical_Case_Study_Script.R
Rdata Files:
(1) Carangaria-MCC.tre
(2) Carangaria-procb-posterior.trees
(3) Carangiform_Extant_Trait_Data_v2.csv
(4) Carangiform_Fossil_Info_and_Data_v2.csv
(5) Randomly_Sampled_200_Phylogeneies.Rdata
(6) Empirical_Pos_Dis_Results_200_phy.Rdata
The main R script of this section is the "Empirical_Case_Study_Script.R" script. All analyses and iterations were run in this single script. The 4 other custom R scripts and all the data files are read into this script
Description of the data files loaded in:
(1) Carangaria-MCC.tre
Maximum clade credibility tree from Ribeiro et al. 2018.
(2) Carangaria-procb-posterior.trees
Posterior distribution of trees from Ribeiro et al. 2018.
(3) Carangiform_Extant_Trait_Data_v2.csv
Linear data for carangarians extracted from FishShapes v1 (Price et al. 2022). This dataset has 8 columns.
column (1) - Tip_Labels: Taxon names that match the tip labels in the phylogenetic tree
column (2) - Family: Taxonomic family of each taxon
column (3) - Order: Taxonomic order of each taxon
column (4) - Standard_length: Standard length measured in millimeters (mm)
column (5) - Max_body_depth: Maximum body depth measured in mm
column (6) - Head_depth: Head depth mearued in mm
column (7) - Lower_jaw_length: Lower jaw length measured in mm
column (8) - Min_caudalpeduncle_depth: Minimum caudal peduncle depth measured in mm
(4) Carangiform_Fossil_Info_and_Data_v2.csv
Linear data and specified phylogenetic placement and tip age for 11 fossils included in this study. This dataset has 11 columns.
column (1) - Fossil_Taxa: Fossil taxon name
column (2) - Taxonomnic_Position: Either "Sister_Clade" or "Sister_Species". This taxonomic labeling is read by the fossil grafting method scripts to infer the taxonomic placement in the tree.
column (3) - Age_of_Fossil: Tip age of fossil in units of "millions of years ago". Fossil ages were taken from the fossil descriptions.
column (4) - Extant_sister_Taxa: An extant taxon tip label. If the taxonomic position (column 2) reads "Sister_Species," then the fossil will be placed sister to the taxon label in this column.
column (5) - Sister_to_x: An extant taxon tip label. See note below
column (6) - Sister_to_y: An extant taxon tip label. See note below
column (7) - Standard_length: Standard length of the fossil taxon measured in mm
column (8) - Max_body_depth: Maximum body depth of the fossil taxon measured in mm
column (9) - Head_depth: Head depth of the fossil taxon measured in mm
column (10) - Lower_jaw_length: Lower jaw length of the fossil taxon measured in mm
column (11) - Min_caudalpeduncle_depth: Minimum caudal peduncle depth of the fossil taxon measured in mm
** Note: For columns 5 and 6, if the taxonomic position (column 2) reads "Sister_Clade" then the taxonomic position of the Fossil_Taxa in this row will be placed on the stem branch subtending the most recent common ancestor denoted by the extant tip labels in columns 5 and 6.
(5) Randomly_Sampled_200_Phylogeneies.Rdata
200 phylogenetic trees sampled from the posterior distribution that were used in the empirical case study
(6) Empirical_Pos_Dis_Results_200_phy.Rdata
Empirical model fitting data that was recovered by applying the 4 fossil grafting methods to the MCC and 200 randomly sampled trees from the posterior distribution.
Description of the R scripts loaded in:
(1) Fix_Ultrametric_Tree_Code.R
The MCC tree was not reading in as "ultrametric" for some reason. We used this code to force the tree to be read as ultrametric.
(2) Fossil_Data_Info_Function.R
Same function as described in section 1. This custom function set up a dataframe that was to be read by "Locate_Fossil_Loop_V3.R" so that locate.fossil knew where to place the fossil and the age of the fossil.
(3) Fossil_Extreme_V3.R
Same function described in section 1. This script implemented the maximum rule, halfway rule, and minimum rule fossil grafting methods
(4) Locate_Fossil_Loop_V3.R
Same function described in section 1. This was used to implement the locate.fossil grafting method that was first generated by Revell et al 2015 Evolution. This script here is just a wrapper around that function located in the R package phytools
Section 3. R Scripts and Data for Checking the Validity of the Early Burst Pattern Detected in Carangarian Fishes
Section 3 includes 1 R script and 4 R data files.
R Scripts:
(1) Deciphering_EB_Results_Full_Loop.R
Rdata Files:
(1) Deciphering_EB_Full_Results_v2.Rdata
(2) Empirical_Pos_Dis_Results_200_phy.Rdata
(3) Fineness_Ratio_Trait_Vector.Rdata
(4) fitContinous_Empirical_MCC_Results.Rdata
After applying the four fossil grafting methods to the MCC and 200 randomly sampled trees from the posterior distribution of Carangaria, we found that the addition of fossil taxa recovers an early burst model as the best fit, whereas the extant-only analyses recovered a Brownian motion model as the best fit. The extant-only dataset included 84 taxa, and the extant and fossil dataset included 95 taxa. The change in the favored mode of evolution could have been due to the addition of 11 terminal tips generally or the addition of fossil information. To test this, we repeated our empirical case study analyses above but randomly dropped 11 extant tips. We repeated this 100 times. The R scripts and R data files needed for this are explained below.
(1) Deciphering_EB_Results_Full_Loop.R
This script was used to perform the analysis described on line 177. This script requires all four Rdata files listed above. An explanation of each Rdata file is below.
(1) Empirical_Pos_Dis_Results_200_phy.Rdata
Empirical modeling fitting results recovered from Section 2. These results are loaded into this section because this object contains all the trees made using the fossil grafting methods in Section 2.
(2) fitContinous_Empirical_MCC_Results.Rdata
Empirical modeling fitting results for the MCC tree from section 2. These results are loaded into this section because this object contains all the trees made using the fossil grafting methods in section 2.
(3) Fineness_Ratio_Trait_Vector.Rdata
A vector of fineness ratio trait data.
(4) Deciphering_EB_Full_Results_v2.Rdata
The output of data recovered from the main script in this section.
Code/Software
R is required to run all the analyses listed in this script. Further detail regarding each R script can be found within the R script documents itself.
