Supplement 3. The R code used in morphological null models analysis and guild proportionality analysis. source('MNND_Analysis.R') ## morphological null model analysis: # consider dataset 'x', 'pool', 'prob.vector', where: x <- read.table('x.csv', header=TRUE); pool <- as.data.frame(read.table('y.csv', header=TRUE)) prob.vector <- read.table('z.csv', header=TRUE) # x = is a dataframe for each site, with species names (rows) and morphlogical variables (columns) # pool = is a data frame with the regional species pool, with species names (rows) and morphlogical variables (columns) # prob.vector = is a vector of probability weights for obtaining the elements of the vector being sampled # Here we do morphological analysis resMorphologicalAnalysis <- MNND (x=x, y= pool, z = prob.vector) # components of resMorphologicalAnalysis is a data frame with observed MNND (size and shape) and P values under the morphological null model ## guild proportionality tests: source ('GuildProportionalityTests.R') # consider data set 'df' is a presence/absence matrix with species (rows) and samples (columns), where if: df<- read.table('df.csv',header=TRUE) # df[,1] = is species names # df[,2:ncol(df)] is data set for each site. # also, consider data set 'fnames' is a list of the random matrices of co-occurrences (*.txt files) generated using the software EcoSim (Gotelli and Entsminger 2004). The number of species occurring in each sample, and the overall frequency of each species, were both held as found in the original matrix. fnames<- list.files(patt="txt$") # Here we do guild proportionality tests: # Warning: It is necessary to make a list of species classified into guilds using the row number of species in the observed data set. See the function Guild.list in the source.R file (below) and change it according the data set that will be used in the analysis. GuildProportionality <- Guild.Proportionality (df,fnames) # components of GuildProportionality is a dataframe with the observed variance relative index and P values under the null model to Alpha guilds and Beta guilds.