Community ecology with R

From BioDivBorneo2010

Jump to: navigation, search
  • Ecology: "The study of the distribution and abundance of organisms"
  • Community ecology: "The study of variation in composition of multi-species communities"
  • All natural communities have a few common species and many rare species:
    abundance

       |*
       | *
       |  *
       |   *
   50% +....*
       |   . **
       |   .    *****
       |   .         ****************    
       +---+-------------------------
       1   10%                      N
                   rank
  • Composition: position of a sample in multi-dimensional space

Pitfall trap data

Data:

sample|light|site|collem|diplura|blat|is|embi|dermo|hemi|thysan|psoc|neur|dipt|cole|wasp|ant|arach|chil|isopod|protur|orthopt
CG|G|C|20||1|||1|||1||1|3|1|31|2||||3
CF|F|C|31|2|1|2|||3|3|||38|17|11|15|7||5|1|1
DG|G|D|8||2|8|||4||1||32|3|4|13|5||1||
DF|F|D|23|||1|||||||38|11|1|43|6||1||3
RG|G|D|12|1||2|1||2||1|1|42|8|3|41|5|2|4||14
RF|F|D|13|1|2|1|||1||||76|32|10|44|6|2|4||6
insect <- read.table("insect.csv", header=T, sep="|")
rownames(insect) <- insect$sample
insectenv <- data.frame(insect$light,insect$site)
insectenv
colnames(insectenv) <- c("light","site")
rownames(insectenv) <- insect$sample
insect <- insect[,c(-1,-2)]
save(insect,insectenv, file="insect.RData")

load("insect.RData")
insect
insect[is.na(insect)] <- 0
fix(insect)
rowSums(insect)
insectabund <- rowSums(insect)
t.test(insectabund ~ insectenv$light)

summary(lm(insectabund ~ insectenv$light + insectenv$site))

library(vegan)
vegdist(insect)
plot(hclust(vegdist(insect)))
plot(hclust(vegdist(insect,method="bray")))

insecthi <- insect[,c(-2,-3,-5,-6,-8,-9,-10,-16,-18)]
plot(hclust(vegdist(insecthi,method="bray")))
?anosim
anosim(insect, insectenv$light)
insect.anosim <- anosim(insecthi, insectenv$light)
plot(insect.anosim)