Created
January 20, 2014 16:43
-
-
Save skembel/8523702 to your computer and use it in GitHub Desktop.
R code to generate traits with high phylogenetic signal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
###### | |
## 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