Skip to content

Instantly share code, notes, and snippets.

@darmitage darmitage/phylosim
Created Dec 12, 2011

What would you like to do?
histograms of phylogenetic similarity
#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)
#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]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.