Skip to content

Instantly share code, notes, and snippets.

@skembel
Created January 20, 2014 16:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skembel/8523702 to your computer and use it in GitHub Desktop.
Save skembel/8523702 to your computer and use it in GitHub Desktop.
R code to generate traits with high phylogenetic signal
######
## example of generating traits with high phylogenetic signal
require(picante)
require(geiger)
#generate a phylogeny
phy <- rcoal(50)
## if you wanted a balanced tree instead:
#phy <- compute.brlen(stree(32, "balanced"), 1)
#generate a trait using the actual phylogeny
phy.trait <- rTraitCont(phy)
#generate a trait after scaling phylogeny branch lengths with delta model
phy.trait.delta <- rTraitCont(transform(phy, model="delta", 0.01))
#calculate phylogenetic signal
Kcalc(phy.trait, phy)
Kcalc(phy.trait.delta, phy)
#plot traitgrams
par(mfrow=c(1,2))
traitgram(phy.trait, phy)
traitgram(phy.trait.delta, phy)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment