# Example of unconstrained ordination analysis using Vltava data # Import of data via clipboard: # vltava.spe <- read.delim (file = "clipboard", row.names = 1) # Import of data from the file in the computer: #vltava.spe <- read.delim (file = "C:\\Users\\Zeleny\\Dropbox\\anavegr\\vltava.spe.txt", row.names = 1) #vltava.env <- read.delim (file = "C:\\Users\\Zeleny\\Dropbox\\anavegr\\vltava.env.txt") # Import of data stored online: vltava.spe <- read.delim ('http://www.davidzeleny.net/anadat-r/data-download/vltava-spe.txt', row.names = 1) vltava.env <- read.delim ('http://www.davidzeleny.net/anadat-r/data-download/vltava-env.txt') vltava.env$GROUP # install.packages ("vegan") library (vegan) # log transform the species composition data: #vltava.spe.log <- log (vltava.spe + 1) vltava.spe.log <- log1p (vltava.spe) # Calculate detrended correspondence analysis: DCA <- decorana (vltava.spe.log) DCA # Calculate correspondence analysis (to know the total inertia): CA <- cca (vltava.spe.log) CA plot (DCA) # this is drawing DCA ordination diagram # plot (CA) # this is drawing CA ordination diag. #plot (DCA, choices = c(2,3), display = 'sites') windows () plot (DCA, display = 'sites', type = 'none') # ordispider (ord = DCA, groups = vltava.env$GROUP, label = T) ordispider (ord = DCA, groups = vltava.env$GROUP, label = T, show.group = 1) ordispider (ord = DCA, groups = vltava.env$GROUP, label = T, show.group = 2, col = 'red') ordispider (ord = DCA, groups = vltava.env$GROUP, label = T, show.group = 3, col = 'green') ordispider (ord = DCA, groups = vltava.env$GROUP, label = T, show.group = 4, col = 'blue') # Project environmental variables as supplementary to ordination diagram: env <- vltava.env[, c("ASPSSW", "pH", "SOILDPT")] ef <- envfit (DCA, env) plot (ef) # project randomly generated environmental variables as supplementary to ordination diagram rand.var <- matrix (rnorm (6*97), ncol = 6, nrow = 97) ef.rand <- envfit (DCA, rand.var) ef.rand plot (ef.rand, col = 'navy')