0

There is a function called LINKTREE in PRIMER where a tree is created based on community dissimilarity, but each breakpoint must correspond to a threshold in one or more environmental (constraining) variables.

Is there an equivalent function in R? hclust creates trees based on dissimilarity matrices, but I haven't figured out a way to "constrain" it using a second data frame.

Data to play with:

library(vegan)
comm <- data.frame(oak = c(4,10,3), birch = c(3,6,1), maple = c(9,6,3), 
                   row.names = c('site 1','site 2','site 3'))
comm.dist <- dist(comm)
env <- data.frame(temp = c(35,39,31), rain = c(103,85,80), 
                  row.names = c('site 1','site 2','site 3'))
tree <- hclust(comm.dist)
plot(tree)
cca <- cca(comm ~ ., data = env)
plot(cca, display = c('sp', 'bp'))

The desired output would be a tree where the first breakpoint would separate site 2 from 1 and 3 because it is most dissimilar, but it would also be labeled 'temp>37', because site 2 is the only site with a temperature above 37. The breakpoint between 1 and 3 would be 'temp>33' and/or 'rain>95'

Jen F.
  • 57
  • 1
  • 8
  • Do you want to have a constrained tree where each branch **must** be based on a break in external variables, or do you want to have labels for breaks in environmental variables in unconstrained tree? The first goal can hardly be achieved with agglomerative methods (`hclust`), but it needs a divisive or a partitioning method. The second is only a problem of re-ordering tree and labelling a tree. – Jari Oksanen Oct 30 '17 at 08:31
  • Hi @JariOksanen! I'm looking for the former option. Do you have any suggestions for a divisive or partitioning method that would produce a tree? – Jen F. Nov 02 '17 at 16:46

0 Answers0