Giter Site home page Giter Site logo

joseph-watts / bayestraits-discrete-nodes-plots Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 1.0 1.4 MB

Creating Consensus Tree Figures with Ancestral State Estimations in BayesTraits

Batchfile 0.96% R 99.04%
bayestraits phylogenetics phylogeny evolutionary-computation comparative-analysis

bayestraits-discrete-nodes-plots's Introduction

Creating Consensus Tree Figures with Ancestral State Estimations in BayesTraits

These R scripts are used to generate figures of consensus trees with nodes that represent the ancestral state estimations and phylogenetic uncertainty. See Primates_Trait_A.pdf and Primates_Trait_B.pdf for examples of figures generated.

This is not a fully automated process, and there are two main steps involved, each with a separate R script. The first step is to generate the commands that you need to enter into BayesTraits before running analyses. This step requires a consensus tree with nodes ordered as you want them in your final images (see BEAST’s TreeAnnotator for how to generate a consensus tree). An efficient way of entering commands into BayesTraits is to use a command file, rather than having to enter all commands line by line. For more information on using command files, check out the “Running BayesTraits with a command file” section the BayesTraits manual. One point of caution here though is that this can hide any warnings, so make sure you are happy with how it is running first.

The second step involves reading in the output from BayesTraits in R, then using this output and the same consensus tree that you used in step one to create two pdf images representing the ancestral state estimation for each trait. These figures will not necessarily be publication quality, and may require further editing, depending on your requirements. I recommend saving the figures in pdf format or some other vector based format to preserve image quality when rescaling and editing.

Example files

The example used in this script is based on the “Primates” dataset from BayesTraits and uses the same settings as the example used in the BayesTraits manual (these settings can be seen in the Primates_AddNodes_Dep_Commands.txt file). The tree files supplied here have been modified slightly to work with the scripts provided (modifications noted in the tree files). When using the fields supplied in this repository, the figures created should look like Primates_Trait_A.pdf and Primates_Trait_B.pdf.

Notes:

  • This script only works for the Discrete Dependent analyses in v3 of BayesTraits. The node orders and commands are different in earlier versions of BayesTraits. It shouldn’t be too hard for others to modify it to work with older version of BayesTraits or for use in the Discrete Independent or Multistate analyses.
  • This is designed to be run with a sample of trees in BayesTraits, not a single tree. The only time a single tree is used here is for the purposes of the consensus tree figure in R.
  • By “phylogenetic uncertainty” I mean the proportion of trees in the tree sample (typically from the posterior distribution) that have a node with the same descendants in the consensus tree.
  • If you use this code, please cite the authors of R, BayesTraits, and ape.
  • I am not a programmer and I know that my code is not elegant or efficient (e.g. I use too many for loops!). I appreciate suggested improvements, though it may take some time for me to work through them. If you spot any mistakes please log them as issues on the issues page so that others are aware of them too.

Examples of some papers with figures based on this code:

Other GitHub pages worth taking a looking at for BayesTraits and R users:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.