Supplement 2. The R scripts used in guild proportionality analysis. Guild.Proportionality <- function (x,fnames) { # first, make a list of species classified into guilds using the row number of species in the observed data set. As a example, the numbers in the Guild.list below belongs to data frame with 69 species (rows). Guild.list <- list( Guild1 = c(5,57,65,66), Guild2 = c(6:8,10,11,22,42,43,69), Guild3 = c(4,59), Guild4 = c(58,60:64), Guild5 = c(1,2,9,44,56), Guild6 = c(3,14:16,25:27,36:41), Guild7 = c(23,24,28:35), Guild8 = c(45:55,67,68), Guild9 = c(17:21)) # second, the observed variance in guild proportions is calculated; # data = a data frame with species (rows) by plots (columns) with presence or absence of species on each plot. df <- data.matrix(df[,-1]) RVgp_obs <- sapply(Guild.list, function(idx) var(colSums(df[idx,]) / colSums(df))) # thirdy, calculate the expected variance in guild proportions. The null model was created by randomizing the observed data set while holding both plot richness and species abundances constant. The EcoSim software was used by generate 1,000 null communities. n.Cols= ncol(df) fnames<- list.files(patt="txt\$") dados <- lapply(fnames, read.table, header=T, colClasses=c("NULL",rep("numeric",n.Cols))) Guild.Propor <- lapply(dados, function(x)sapply(Guild.list, function(idx) var(colSums(x[idx,])/colSums(x)) )) RVgp_null<- apply(do.call('rbind', Guild.Propor), 2, mean) RVgp_exp <- data.frame(do.call('rbind', Guild.Propor)) # here we calculate the observed Variance Relative Index (Watkins and Wilson 2003). This index has a range of +1 to -1. Assumes values equal to 0 when the observed variance in guild proportion is equal to that expected under the null model, and a value smaller than 0 when there is guild proportionality (Alpha guilds). A value > 0 indicates disproportionality (Beta guilds structuring). Var_Rel<- round((2*(RVgp_obs/(RVgp_obs+RVgp_null))-1), digits=4) # here we calculate the P values under the null model to Alpha-guilds structuring (negative Var_Rel values) or Beta-guilds structuring (positive Var_Rel values). beta.guild<- ncol(RVgp_exp) for (i in 1:9) beta.guild[i] <- sum(RVgp_exp[i]>= RVgp_obs[i])/1000 # Beta-guilds test res.beta<- as.data.frame(beta.guild, row.names=colnames(RVgp_obs)) alpha.guild<- ncol(RVgp_exp) for (i in 1:9) alpha.guild[i] <- sum(RVgp_exp[i]<= RVgp_obs[i])/1000 # Alpha-guilds test res.alpha<- data.frame(alpha.guild, row.names=names(RVgp_obs)) res<- cbind(Var_Rel,res.alpha,res.beta,row.names=names(RVgp_exp)) return(res) }