Summary: There are two python scripts used to execute BayesTraits on the subdirectories in the previous bundle, "BayesTraits_wrapper_ML.py" and "BayesTraits_wrapper_Bayesian.py". Each will automatically generate the independent and dependent model files required to run BayesTraits, and automatically access the tree file and BayesTraits executable in the subdirectory. It will run serial analyses across all the input files in a subdirectory, using the maximum likelihood version or Bayesian version with stepping stone sampling. Instructions and details are annotated at the top of those scripts. The results can be summarized using the relevant python script, bayesian ("Summary_bf_testing.py") or ml ("Summary_lr_testing.py") version. These will open the output files from each of the 500 analyses in a subdirectory and perform either likelihood ratio tests or bayes factors to compare the independent and dependent models for each input file. The output of these scripts for our set of analyses is provided in the directory "4_Results". Running Analyses: Each of the subdirectories ("ecol_ovi", "ecol_water", "ovi_water") will contain the 500 bayestraits binary character input files from the previous step. There will also be the tree file used for the analyses, but you will need to download the BayesTraitsV2 executable (http://www.evolution.rdg.ac.uk/BayesTraits.html) and place this in each subdirectory for the scripts to work. I had some issues with the BayesTraitsV2 binary working on my OSX, but searched around and managed to find a functioning version. To use both the maximum likelihood and bayesian versions of the Bayestraits wrappers, you will need to duplicate each subdirectory (you can't run both scripts on the same directory). Before you get started, please open and read the top of the scripts for instructions on usage. Here are instructions from the bayesian script (BayesTraits_wrapper_Bayesian.py): ''' usage: python BayesTraits_wrapper_Bayesian.py [full path to one of the directories with binary simulation data] The point of this script is to execute BayesTraitsV2 across each file within one of the directories with simulated data, which are converted to binary format. The directories of interest in this example are "ecol_ovi", "ecol_water", and "ovi_water". They already have the tree I used inside ("Big_tree_pruned.tre") as well as a functioning copy of the BayesTraitsV2 executable (works on OSX). This script runs the Bayesian implementation with stepping stone sampling. The necessary input command files are generated automatically for each of the binary simulation files in this directory. Run the "Summary_bf_testing.py" script afterwards on this directory to summarize the results. ''' And here are the instructions from the maximum likelihood script (BayesTraits_wrapper_ML.py): ''' usage: python BayesTraits_wrapper_ML.py [full path to one of the directories with binary simulation data] The point of this script is to execute BayesTraitsV2 across each file within one of the directories with simulated data, which are converted to binary format. The directories of interest in this example are "ecol_ovi", "ecol_water", and "ovi_water". They already have the tree I used inside ("Big_tree_pruned.tre") as well as a functioning copy of the BayesTraitsV2 executable (works on OSX). This script runs the ML implementation. The necessary input command files are generated automatically for each of the binary simulation files in this directory. Run the "Summary_lr_testing.py" script afterwards on this directory to summarize the results. ''' Summarizing Results: After the analyses are complete we need to evaluate if the dependent or independent models were a better fit for each trait comparison. This can be done manually 500 times, or the summary scripts can be run to automatically gather this information for an entire subdirectory. There are two versions of the scripts, one for maximum likelihood and one for bayesian analyses. Note these do very different things, one will perform likelihood ratio tests and the other will compare models using bayes factors, so use the appropriate one based on which analyses you've performed. Here are the instructions for one of the summary scripts: ''' usage: Summary_bf_testing.py [full path to directory with BayesTraits analyses completed] The point of this script is to collect information for each of the independent and dependent analyses of all the simulated data within a particular folder. This script assumes all the BayesTraitsV2 analyses have been run using the script "BayesTraits_wrapper_Bayesian.py". This will perform bayes factor comparisons between the independent and dependent models and write the results to an output file called "BF_Output.txt". It is tab-delimited and will have the following columns: Simulation_Number Dependent_lh Independent_lh Log_BF You can open this in excel and sort by log_BF to find significant results. Hopefully there are not many because these traits were independently simulated. ''' You can run the summary script across all three subdirectories to collect all the model testing results, and combine these to look at the results of 1,500 comparisons. The outputs of both ML and Bayesian analyses are summarize in the directory "4_Results", for each of the character comparison subdirectories. These are what we reported in our paper, and we noticed there was a much higher error rate with Bayesian inference. This may be due to not properly tuning priors for all 1,500 analyses, or maybe stationarity wasn't always reached. The ML analyses seemed more robust in this sense, and gave a much lower number of false positives. The overall workflow for our power analyses should be fully accessible and repeatable using the data and scripts provided here. The scripts are specific to our data set, but could potentially be amended to work with other data sets too. For this, knowledge of the python language will be required. The BayesTraits wrappers will work for your application if the input file naming schemes are similar and the tree file name is changed in the script. Following this, the summary scripts should work the same. Good luck!