if (FALSE) {
if(require(ade4)){
data(macroloire, package="ade4")
# Analysis of the feeding habits of macroinvertebrates in the Loire river, France
# The matrix named feed below contains feeding attributes as rows,
# species as columns, and affinities (proportions) as entries.
feed <- macroloire$traits[, -(1:4)]
# Feeding habits comprise seven categories: engulfers, shredders, scrapers,
# deposit-feeders, active filter-feeders, passive filter-feeders and piercers, in this order.
# Functional similarities among species are computed as indicated in Pavoine and Ricotta (2014)
s_species_ochiai_feed <- dsimFun(feed, vartype = "P", method=4)
# To check that this matrix of trait-based similarities
# among species is positive semidefinite (p.s.d.)
# we have to verify that its eigenvalues are all nonnegative:
all(eigen(s_species_ochiai_feed)$val>-(1e-8))
dspca_feed <- dspca(t(macroloire$fau), s_species_ochiai_feed)
# eigenvalue distribution:
barplot(dspca_feed$eig)
# The eigenvalues show strong similarities in the composition of the sites
# regarding the feeding habits of the macroinvertebrates.
# In this data set, communities (sites) are named from S1 to S38 from upstream to downstream
rownames(t(macroloire$fau))
# species are coded from E1 to E40
colnames(t(macroloire$fau))
plot(dspca_feed, autolab=TRUE,
colors= list(ifelse(feed[,6]>0.5,"red","black"),
hcl.colors(38, "cyan")))
# The graphical display shows that most sites are characterized by the dominance of a few species
# (which are mostly passive filter-feeders, in red).
# In a few sites mostly upstream (in blue), the diversity in feeding habits is higher.
}
}
Run the code above in your browser using DataLab