Category Archives: Code


Here come old flat top
He come groovin’ up slowly
He got joo joo eyeball
Come together
Lennon  & Mccartney

We have been working on the applications of random matrix theory to ecology for four years. By now, it is quite clear that the most important challenge ahead is to extend the theory to the case of structured networks (as described here). A new study we just published is a first step in this direction:

 Stefano Allesina, Jacopo Grilli, György Barabás, Si Tang, Johnatan Aljadeff & Amos Maritan
Predicting the stability of large structured food webs
Nature Communications, 2015

In this work, we studied community matrices produced according to the cascade model, in which “big fish eat little fish”. These matrices look like this:

eyeballmatwhere the red squares represent negative coefficients (effects of predators on prey), and the blue ones positive coefficients (effects of prey on predators). These matrices produce a peculiar spectrum, suggestive of an “eyeball”:


In the paper, we derive simple, analytical results that allow us to approximate the spectrum (and hence the stability) of the eyeball.

 I wrote an R package that performs the analysis described in the paper, and published it on github.

PS: Despite the quote from the Beatles above, all I could listen to while writing the paper was Pink Floyd. Maybe because I remember another eyeball I saw a long time ago


I always joke in the lab that anybody who wants to propose a new measure in ecology (or index, etc.) should pay $1,000, $2,000 if the new measure has an acronym. These funds could pay for graduate students to go to some conference.

The only exception to the rule is for studies showing that two seemingly different measures are in fact the same thing. This is the case of our recent study on nestedness, published today in Nature Communications:

The ghost of nestedness in ecological networks
Phillip P. A. Staniczenko, Jason C. Kopp & Stefano Allesina
Ecologists are fascinated by the prevalence of nestedness in biogeographic and community data, where it is thought to promote biodiversity in mutualistic systems. Traditionally, nestedness has been treated in a binary sense: species and their interactions are either present or absent, neglecting information on abundances and interaction frequencies. Extending nestedness to quantitative data facilitates the study of species preferences, and we propose a new detection method that follows from a basic property of bipartite networks: large dominant eigenvalues are associated with highly nested configurations. We show that complex ecological networks are binary nested, but quantitative preferences are non-nested, indicating limited consumer overlap of favoured resources. The spectral graph approach provides a formal link to local dynamical stability analysis, where we demonstrate that nested mutualistic structures are minimally stable. We conclude that, within the binary constraint of interaction plausibility, species preferences are partitioned to avoid competition, thereby benefiting system-wide resource allocation.

We uploaded the code needed for the analysis here.