Roopnarine’s Food Weblog

My science of networks, food webs and extinction

Interaction (edge) strength and compensation

Posted by proopnarine on June 23, 2009

There continues to be a lack of clarity of the role of interaction strengths in stabilizing ecological communities. Most of the empirical and theoretical work done suggests a predominance of weak links. Strongly coupled species tend to have oscillatory or pseudo-oscillatory interactions, but weak links to stable species may tend to dampen, or reduce the amplitude, of the oscillations. The extent to which this is true, given a large and complex network of a species-rich system, remains unknown. Perhaps one way to explore this is to examine network robustness, CEG-style, while manipulating interaction strengths in the following way:

  1. Topological extinction with no link strengths, i.e. all links are of equal and static strength.
  2. Current CEG-style link strengths, where in-link strengths for a species are all equal. Strengths would be static.
  3. Same as above, but strengths are now dynamic, reflecting compensation for lost links.
  4. Same as previous two options, but now repeat with \beta-distributed link strengths, both static and dynamic.

Posted in CEG theory | Tagged: , , , , | Leave a Comment »

Corals, algae and space

Posted by proopnarine on April 28, 2009

roopnarine_fig7.jpg

A new project involves working with the CEG model and coral reef communities. The main goal is an interactive and instructive module for education, but there’s no reason why the data could not be used for some research also. The exercises are to model the impacts of coral bleaching, and reduction/removal of higher trophic-level fish from the system. Now CEG specifically models potential secondary extinction of species, but it occurs to me that one of the major impacts that we observe on reefs is the decline of corals as dominant or co-dominant benthic cover. This is usually accompanied by an expansion of macroalgae with which the corals compete for space. So the model is being modified to examine the impact of the manipulation of trophic networks (food webs) on the spatial state of the reef (along with secondary extinctions, of course). You can read a bit more about this here.

Assume that the community begins in equlibrium (with regard to spatial competition) at time 0 (t=0). If the relative population size of species i is N_{i}, then equlibrium is expressed as
K_{i}N_{i}(0) - \sum_{j=1}^{n}N_{j}(0) = 0
where K_{i} is a competition coefficient (not a constant), and there are n competing species. Therefore,
K_{i}(0) = \frac{\sum_{j=1}^{n}N_{j}(0)}{N_{i}(0)}
Because population sizes are changing in response to non-competitive factors (trophic), we expect changes to relative population sizes, and hence the coefficient is dynamic. Hence the difference equation governing relative population size during a CEG cascade becomes
N_{i}(t) = \frac{ K_{i}(0) \left [ I_{i}(t) - O_{i}(t) \right ]} {K_{i}(t)}
where
\frac{K_{i}(0)}{K_{i}(t)} = \frac{\sum_{j=1}^{n}N_{j}(0)}{N_{i}(0)} \frac{N_{i}(t)}{\sum_{j=1}^{n}N_{j}(t)}
\sum_{j=1}^{n}N_{j}(t) is the same for all competitors, and need be computed only once per cascade step.

Posted in CEG theory | Tagged: , , , , | Leave a Comment »

C++ strcpy, etc.

Posted by proopnarine on April 28, 2009

In making some minor modifications to the main simulation program, CEG-1.4.8, I encountered a compile error using gcc 4.3.2-7. The system is 64-bit AMD based, running Fedora 10. gcc was installed from the rpm package gcc-4.3.2-7.x86_64. The simple compile command g++ -o CEG-1.4.8-SMP CEG-1.4.8-SMP.cpp yielded the following output:
CEG-1.4.8-SMP.cpp: In function ‘int main(int, char**)’:
CEG-1.4.8-SMP.cpp:75: error: ‘strcpy’ was not declared in this scope
CEG-1.4.8-SMP.cpp:114: error: ‘strcpy’ was not declared in this scope
CEG-1.4.8-SMP.cpp:281: error: ‘strcpy’ was not declared in this scope

Given that these lines refer to fairly old parts of the code, and that compilation has been successful for years, I suspected that either there is a bug in this version of gcc, this latest RH update to its gcc package, or that my code is no longer legal. It seems to be the latter, and using strcpy is not really a good idea anyway. Here’s an example of the offending code (all uses referred to file reads from command line arguments or opening files for output):
//open existing matrix file specified by user
do
{
strcpy(matrix_name,argv[2]);
std::cout << "\nName of network matrix file: " << matrix_name;
matrix_file.open(matrix_name);
}

Note the use of strcpy in the fourth line. Simply replacing the routine worked. Here’s a correction:
//open existing matrix file specified by user
do
{
const char *matrix_name = argv[2];
std::cout << "\nName of network matrix file: " << matrix_name;
matrix_file.open(matrix_name);
}

Posted in Code | Tagged: , , | 2 Comments »

Generating beta variates

Posted by proopnarine on March 19, 2009

100 Beta variates from example in text.

100 Beta variates from example in text.

Our problems are to (1) draw random variates from various beta distributions, (2) embed the code in the “parallel” SMP version of CEG, and (3) pass the beta variates to CEG simulations. After exploring a number of different ways to generate the variates in C++, notably using the GNU Scientific Library, I’ve decided to simply use an Octave script. The syntax is very easy, and because the C++ simulations are embedded in a Bash script, it’s really easy to simply generate the variates and have C++ load the output files. Here’s the basic Octave script:

#! /bin/octave -qf
#Generate beta variates;
arg_list = argv ();
a = str2double(arg_list{1});
b = str2double(arg_list{2});
c = str2double(arg_list{3});
x = betarnd(a,b,c,1);
disp (x)

This script is run by the following Bash script:
#! /bin/bash
beta_file1=$4
echo $beta_file1
octave -q $1 $2 $3 >$beta_file1

The Bash script is called with command line parameters, namely the parameters for Octave’s betarnd function (a, b, and number of variates; the last parameter is 1, since output is a vector). A call would therefore look like this:
./beta.sh 2 5 100 beta_output1.dat
where beta.sh is the Bash script, the distribution being called is \beta(2,5), and 100 random variates will be generated. The output is re-directed to output file beta_output1.dat. Don’t forget to make your script executable with chmod +x beta.sh

Posted in Code | Tagged: , | Leave a Comment »

Network equivalence

Posted by proopnarine on February 26, 2009

The objective here is to establish the degree of similarity between successive communities, in spite of changing taxonomic compositions and diversities, and ecological/guild diversity.

equiv_slns

Let \mathcal{U} represent an ecosystem over time (e.g. the Karoo series) comprising a series of chronologically successive communities, \mathcal{U}=\{ U_{a},U_{b},\ldots ,U_{n}\}. The metanetwork representation of \mathcal{U} is identical for all U if guild diversities are omitted. That is, the unparameterized metanetworks are automorphisms \forall U. Species-level networks (slns) are generated from the parameterized metanetworks, a finite set for each one. The question being addressed here is, how many of those slns are isomorphic between metanetworks? In other words, how many of a community’s networks are identical to networks in the preceding and succeeding communities? This is a very important question from the perspective of CEG dynamics, because in the model equivalence of ecological dynamics can transcend taxonomic composition and identity. Consider the two slns in the first figure. Specifically they are different, but dynamically they will respond identically to perturbation. This isomorphism extends to the guild level also. Imagine for a moment that the species in the figure are actually different guilds, and that guilds 2 and 3 are very different organisms. IF guild diversities permit the generation of slns with the same numbers of links, then isomorphic slns will be generated. Furthermore, we can remove any guild and species identity completely from the networks and maintain an equivalence of CEG dynamics under the following condition: If the perturbed species/nodes are part of a connected subgraph, and the connected graph is isomorphic with another subgraph, then CEG dynamics of the two networks will be identical! A minimum measure, therefore, of the continuity of ecosystem dynamics between successive communities, is the number of slns that are isomorphic between the sln sets.

Unfortunately, determining whether two graphs or networks are isomorphic is an NP-complete problem, and slns are very complex graphs. Given the size of the sln sets for each community, it would be impossible to determine the power of their intersection. Given that CEG dynamics are drawn however from the likeliest region of the sln space, that is, stochastic draws are made from defined trophic link distributions, we are really interested in establishing isomorphism of those subsets, not the entire sln space. So, one procedure would be to generate a set of high probability slns from each community, and then test those for isomorphism. The test would have to be one of elimination, i.e. whittling down the number that could be isomorphic, without ever actually arriving at the number that are isomorphic. But that would give us an upper limit of the number that could be isomorphic, and an upper limit on the measure of similarity between the two communities. In the next post I will outline an MCMC approach to generate sets of slns with high likelihood.

It is entirely possible that the result will be that no networks are isomorphic between communities. In that case, it would be obvious that, given similarity of CEG dynamics, the networks are “close enough”. We would then be faced with the even more difficult task of measuring minimum distances between networks, but this is not at all an impossible task. We’d just need some reasonably powerful computers, and acknowledge the fact that our carbon footprints would far outweigh any benefits to be gained from our work.

Posted in CEG theory, NSF proposal | 3 Comments »

Trophic network probability

Posted by proopnarine on February 7, 2009

Given any species level topology (E,V)\text{,} where E represents edges or links, and V represents vertices or species, the probability of that specific topology is the probability of the set of interspecific links specified or composing the topology. Therefore, the probability of the network, given metanetwork U\text{,} is

p(E,V) = \prod_{x=1}^{\sum \vert G_{u}\vert} \prod _{u=1}^{\vert U \vert}p(r_{x}^{u} \mid r_{x})
where the right product is the probability of any species x having a particular pattern or topology of links to other species, and the left product is the product of those probabilities for all species in the community. We can see immediately how the probability of any particular species-level food web is built from the probabilities of individual species networks.

The number of species-level networks that can be derived from a metanetwork depends upon permutations of all possible combinations of link topologies of species in the community, and is generally an astronomical number for even a modest number of species and guilds. The network with the greatest probability, or maximum likelihood of occurrence, is one where the probabilities in the formula above are maximized. This can be approximated if one considers that the probability of x_{i} being linked to any x_{j} is equal, regardless of the in-degree of x_{j}\text{.} One can therefore consider the probability of linking to any x_{j} to simply be the proportion of the predator’s set of prey species that is represented by \vert G_{j}\vert\text{.} These are simply maximum likelihood estimates of the metanetwork link probabilities.

The in-links of each species are assigned randomly to species in other guilds for which a metanetwork in-link exists, i.e. those other guilds comprise potential prey of the species, and a_{iu}=1\text{,} where the species belongs to guild i. The resulting network may be represented as a N\times N adjacency matrix, A_{N}\text{,} where N is the total number of species in the community. Binary entries n_{xy} indicate whether species y is prey to species x\text{.} Furthermore, row sums, \sum n_{xy} equal the in-degree of species x.

The probability of a species a\text{'s} link topology, p(a_{i})\text{,} or the binary pattern of the row A_{a}\text{,} is the product of the probabilities of each link. This can be calculated efficiently as the multinomial probability of a pattern of links spread among the guilds. Say that the probability of a link between a and a species in guild G_{j} is equal to the fraction of the diversity of a\text{'s} prey that is represented by the species richness of G_{j}\text{,} then the probability of a is
p(a_{i}) = \frac{r_{a}!}{r_{a}^{1}!r_{a}^{2}!,\ldots,r_{a}^{n}!} \prod_{x=1}^{n}\left( \frac{\vert G_{x}\vert}{\vert R_{i}\vert}\right) ^{r_{a}^{x}} \Rightarrow  \frac{r_{a}!}{r_{a}^{1}!r_{a}^{2}!,\ldots,r_{a}^{n}!}  \left( \frac{1}{\vert R_{i}\vert}\right)^{r_{a}}  \prod_{x=1}^{n}\left( \vert G_{x}\vert\right) ^{r_{a}^{x}}
where r_{a}^{x} is the number of a\text{'s} links to species in guild G_{x}\text{,} \vert G_{x}\vert is the species richness of G_{x}\text{,} and \vert R_{i}\vert is the total number of prey potentially available to a according to metanetwork U, where a\in G_{i}\text. It is important to note that each term in the formula exists iff a_{ix}=1\text{,} i.e. a metanetwork link exists G_{i}\leftarrow G_{x}. This prevents the inclusion of zero probabilities. Finally, the overall probability of the network is calculated as p(E,V)=\prod_{a=1}^{a=N}p(a)\text{,} the product of all species probabilities, which in turn are the products of all link probabilities.

Posted in CEG theory | Tagged: , , , | Leave a Comment »

Another view

Posted by proopnarine on February 5, 2009

sf_bay_metanetwork

This is another rendering of the San Francisco Bay food web (see below) using a different drawing algorithm. This view arranges guilds hierarchically instead of in a circular fashion. It is very interesting to note that “layers” roughly equivalent to trophic levels emerge naturally from the data. Primary producer guilds are at the bottom, and top predators at the top!

This figure was rendered by Rachel using AT&T’s Graphviz dot algorithm.

Posted in Visualization | Tagged: , , , | Leave a Comment »

San Francisco Bay community food web

Posted by proopnarine on February 4, 2009

SFBay_Metanetwork_circo_green

Now that’s complex! This is a rendering of the metanetwork for the San Francisco Bay food web. The network consists of 163 nodes, each node being a guild. In total, they represent ~1,600 species of invertebrates and fish, as well as four nodes representing various types of autotrophic producers. There are 5,024 links or trophic interactions between the guilds. The dataset currently excludes birds and marine mammals. Those data are being incorporated even as I type! So, when faced with this level of complexity, how does one determine if the system is resilient, or vulnerable to the removal or addition of specific types of species, or can withstand the effects of climate change?

The figure was produced by one of my graduate students, Rachel Hertog, who has done a tremendous amount of work on this project, as well as the Dominican Republican paleocommunities. The data come almost entirely from the collections of the California Academy of Sciences, notably the Dept. of Invertebrate Zoology & Geology, and the Dept. of Ichthyology.

Posted in Visualization | Tagged: , , | 1 Comment »

the written word

Posted by proopnarine on February 1, 2009

wordle1

Check out Wordle. It’s fun.

Posted in Uncategorized | Leave a Comment »

And the answer is…

Posted by proopnarine on January 28, 2009

The number of species-level food webs, or variations of the community (such as the web shown in the previous post) that can be derived for the Miocene marine community, comprising 130 heterotrophic species grouped into 25 guilds (plus for autotrophic guilds) is:
1.354169406609263 \text{x}10^{1213}

That’s much larger than the paltry 10^{72} or 10^{87} particles estimated to make up the known Universe! I can feel the weight of my Hindu ancestry here. A very nice discussion of large numbers can be found in The Biggest Numbers in the Universe. Therein is listed an old favourite of mine from The Hitchhiker’s Guide to the Galaxy: “Space is big. Really big. You just won’t believe how vastly hugely mind-bogglingly big it is. I mean, you may think it’s a long way down the road to the chemist, but that’s just peanuts to space.”

So just how meaningful is all the possible community network variation? One caveat to the answer is that primary productivity is specified in the network as units of productivity, and not actual species. So there are actually a total of 1320 nodes representing primary production in the network, and those certainly contribute significantly to the huge number. But let’s say we reduce those nodes to simply one for each producer guild, resulting in substantially smaller species-level networks. The number of possible networks is now
1.07583\text{x}10^{237}
That’s still pretty big!

Posted in CEG theory | Tagged: , , | Leave a Comment »