Created
December 12, 2011 22:22
-
-
Save darmitage/1469414 to your computer and use it in GitHub Desktop.
histograms of phylogenetic similarity
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
require(picante) | |
#function that maps dissimilarity to similarity & scales between 0 and 1 | |
range01 <- function(x){exp((-1/max(x))*x)} | |
#Calculate branch lengths bewteen taxa | |
dist <- cophenetic(tree) | |
#calculate similarity between taxa from 0 to 1 | |
Z <- range01(dist) | |
hist(Z) | |
#if you have a community matrix and want to do a site-by-site comparison of distances, you need to subset your matrix | |
#X = your site of interest (should be a row or set of rows in a community matrix) | |
site <- subset(names(samp[X,]), samp[X,] > 0) | |
Z <- Z[site,site] | |
upper <- col(Z) <= row(Z) | |
Z <- Z[upper] | |
hist(Z) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment