Ecological networks from abundance distributions

Scott Chamberlain




Another grad student and I tried recently to make a contribution to our understanding of the relationship between ecological network structure (e.g., nestedness) and community structure (e.g., evenness)...

...Alas, I had no luck making new insights. However, I am providing the code used for this failed attempt in hopes that someone may find it useful. This is very basic code. It was roughly based off of the paper by Bluthgen et al. 2008 Ecology (here). In my code the number of interactions is set to 600, and there are 30 plant species, and 10 animal species. This assumes they share the same abundance distributions and sigma values.

UPDATE: I changed the below code a bit to just output the metrics links per species, interaction evenness and H2.

#######################################################
library(bipartite)
 
# Set of mean and sd combinations of log-normal distribution
# In my case, these values were those empirically estimated
# from many bipartite networks from the Interaction Web Database
mu <- c(0.5,2.9,5.3)
sig <- c(0.75,1.6,2.45)
 
# Function to make a set of matrices based on some combination of mu and sigma values
make.matrices <- function(a,b,nmats){
plants <- round(rlnorm(n=30, meanlog=mu[a], sdlog=sig[b]))
animals <- round(rlnorm(n=10, meanlog=mu[a], sdlog=sig[b]))
plants <- plants(600/sum(plants))
animals <- animals
(600/sum(animals))
r2dtable(nmats,animals,plants)
}
 
# Output matrices
matrices11 <- make.matrices(1,1,100)
 
# Etc. for the remaining combinations of mu and sigma
#matrices12 <- make.matrices(1,2,100)
#matrices13 <- make.matrices(1,3,100)
#matrices21 <- make.matrices(2,1,100)
# etc.....
 
# Calculate some network metrics-e.g., for one combination of mu and sigma
linkspersp11 <- numeric(100)
inteven11 <- numeric(100)
h211 <- numeric(100)
 
for(i in 1:length(matrices11)){
m <- matrix(unlist(matrices11[i]),ncol=30,byrow=F)
metrics <- t(networklevel(m,index=c("links per species","H2","interaction evenness")))
linkspersp11[i] <- metrics[1]
inteven11[i] <- metrics[2]
h211[i] <- metrics[3]
}
 
linkspersp11
h211
inteven11
Created by Pretty R at inside-R.org

Posted in  Ecology Networks R


blog comments powered by Disqus
Fork me on GitHub