Dear all,

I sampled within 24 sites, by using 2 distinct methods, fish assemblages 
(6 replicates) and macro-invertebrates assemblages (3 replicates).
I want to compute the pairwise distances among sites considering both 
assemblages(using braycurtis dissimilarity), let's say the overall 
distances among sites
I see 2 options:
option 1, averaging at the site scale fishes and macro-invertebrates 
abundances , cbind the two mean abundances matrix and calculating 
bray-curtis
option 2, for each assemblage, computing bray-curtis and distances among 
sites centroids, and then summing up the 2 distance matrix.

Please, could tell me if the option 2 is correct (and more appropriate 
than option 1) and if my code is correct

thank you in advance.

library(plyr)
library(vegan)

#assemblage 1: 15 fish species, 6 replicates per site
a1.env=data.frame(
   Habitat=paste("H",gl(2,12*6),sep=""),
   Site=paste("S",gl(24,6),sep=""),
   Replicate=rep(paste("R",1:6,sep=""),24))
summary(a1.env)

a1.bio=as.data.frame(replicate(15,rpois(144,sample(1:10,1))))
names(a1.bio)=paste("F",1:15,sep="")
a1.bio[1:72,]=2*a1.bio[1:72,]

#assemblage 2: 10 taxa of macro-invertebrates, 3 replicates per site
a2.env=a1.env[a1.env$Replicate%in%c("R1","R2","R3"),]
summary(a2.env)
a2.bio=as.data.frame(replicate(10,rpois(72,sample(10:100,1))))
names(a2.bio)=paste("I",1:10,sep="")
a2.bio[1:36,]=0.5*a2.bio[1:36,]


# "environmental" data at the sit scale
env=unique(a1.env[,c("Habitat","Site")])
env=env[order(env$Site),]

######## OPTION 1, averaging abundances and cbind

a1.bio.mean=ddply(cbind(a1.bio,a1.env),.(Habitat,Site),numcolwise(mean))
a1.bio.mean=a1.bio.mean[order(a1.bio.mean$Site),]

a2.bio.mean=ddply(cbind(a2.bio,a2.env),.(Habitat,Site),numcolwise(mean))
a2.bio.mean=a2.bio.mean[order(a2.bio.mean$Site),]

bio.mean=cbind(a1.bio.mean[,-c(1:2)],a2.bio.mean[,-c(1:2)])

dist.mean=vegdist(sqrt(bio.mean),"bray")


#######OPTION 2, computing for each assemblage distance among centroids 
and summing the 2 distances matrix
a1.dist=vegdist(sqrt(a1.bio),"bray")
a1.coord.centroid=betadisper(a1.dist,a1.env$Site)$centroids
a1.dist.centroid=vegdist(a1.coord.centroid,"eucl")

a2.dist=vegdist(sqrt(a2.bio),"bray")
a2.coord.centroid=betadisper(a2.dist,a2.env$Site)$centroids
a2.dist.centroid=vegdist(a2.coord.centroid,"eucl")

dist.centroid=a1.dist.centroid+a2.dist.centroid
coord.centroid=cmdscale(dist.centroid,k=23) # for further distance-based 
analysis (is it correct ?)


### COMPARING OPTION 1 AND 2
pco.mean=cmdscale(vegdist(sqrt(bio.mean),"bray"))
pco.centroid=cmdscale(dist.centroid)

comparison=procrustes(pco.centroid,pco.mean)
protest(pco.centroid,pco.mean)


-- 
*Pierre THIRIET*

Doctorant en écologie marine - Marine Ecology PhD student
----------------------------------------------------------------------------------------------------------------------------------------
EA 4228 - ECOMERS - /Ecosystèmes Côtiers Marins et Réponses aux Stress/
Université de Nice - Sophia Antipolis, Faculté des Sciences, Parc 
Valrose, 06108 Nice Cedex 2, France
More about my work and my lab. 
<http://www.unice.fr/ecomers/index.php?option=com_comprofiler&task=userProfile&user=101&Itemid=111&lang=fr>
----------------------------------------------------------------------------------------------------------------------------------------
Cell: +336 79 44 91 90
Office: +334 92 07 68 33
Skype: pierre.d.thiriet
Mail: pierre.thiriet@unice.fr
Mail(bis): pierre.d.thiriet@gmail.com

	[[alternative HTML version deleted]]

