Recently in Computation Category

Crash course in ABC

| No Comments
On July 3rd and 4th, the Australian Statistical Conference put on a free satellite workshop at the University of New South Wales, which introduced Approximate Bayesian Computation (ABC) to anyone interested. Having some familiarity with Bayesian statistics and a strong curiosity for ABC, I decided it was worth my 4th of July to attend. 

The first day of the workshop provided a crash course in ABC methods, while the second day consisted of lectures on ABC applications to research. It turns out that approximate Bayesian analysis is useful when the likelihood function is computationally intractable and when likelihood-based inference models are unavailable. ABC is a non-parametric Bayesian method where pseudo data is generated by a candidate \theta parameter. The summary statistics from the two data sets are compared and if they are similar, then \theta is acceptable for the real data. We use this procedure to estimate the posterior distribution of the parameters of a model. This gets more complicated with dimensionality, but I'll leave that to the Bayesian experts for now. Wikipedia has a decent explanation on this for those who are interested. 

ABC is a fairly new statistical frontier that dates back to only the 1980s. It started as a niche idea in population genetics and is now gaining momentum in mainstream statistics. Although ABC still feels a bit weird and awkward to me, my gut intuition is that these methods will become useful when modeling other natural systems too. 

A dynamical systems link between traits and ecosystems

| No Comments
Over the past few decades, ocean ecosystem modelers like myself have gone from a Nutrient-Phytoplankton-Zooplankton picture of the ocean that looks like this:
NPZ.jpg


...to one that looks more like this:

NNPPZZ.jpg

The motivation, I would say, has been that the simple paradigm misses important processes, like species life history, or important properties, like diversity and its consequences. (Not to mention the myriad of Z that do not consume P.) The more complex picture, although impressive looking, comes with baggage. Among others, there is also the problem of parameterizing these models. Lots of boxes and arrows means lots of rates and properties to be measured--increasing roughly with the square of the number of species (or state variables).

One approach to simplifying this mess is to organize the ocean according to certain traits. Trait-based perspectives are not new, and I think they might be able to clean up the NNNNPPPPPZZZZZZZZZZ spider web we're tinkering around with these days. For example, we can approximate the distribution of a trait across species with a curve. With some analysis, we can then look at the effect of the shape of this curve on the structure of the community. In the example below, a Gaussian distribution of growth rates (gamma) produces realistic rank-abundance curves in a zooplankton population. Different curves produce different community-level patterns.

Traits.jpg

This is an idealized analytical model. The real world is messier. Still, as long as we are modeling species by using collections of ecologically important traits, we can use the distributions of those traits to inform the model. 

As a messier example, I'll draw from a more complex copepod model. We included a number of traits, such as activation energies, development times, and diapause strategies (many copepods go into dormancy during certain stages). These traits have been painstakingly tabulated across many species by people who I assume have lots of coffee and live in cold, cloudy places. By drawing from these distributions in a sort of stochastic way, and plugging the model into different parts of the ocean, we get very different communities emerging at different places.

TraitModel.jpg


The next image shows preliminary output from a North Atlantic model. These are the results for the diapause trait. Basically, in northern latitudes, species that diapause make up the majority of the population. Closer to the equator, they don't fare well. On the right you can see an image of what the population looks like in terms of the size of the animals, and a distribution of the diapause trait as a function of life stage. In the north, there are large diapausing species with long development times. In the south, the opposite.

DiapauseMap.jpg

If you know the North Atlantic well, you'll recognize that this map is not perfect, and we are still a ways from describing the whole ecosystem this way. Still, by shifting the perspective away from the individual species, and towards properties of the community, we are able to make some more sense out of the NNNNNNPPPPPPPZZZZZZZZZZZZ spider web.

Nick Record, signing off


Hubbell SP (2001) The unified neutral theory of biodiversity and biogeography (MPB-32) (Vol. 32). Princeton University Press.

Record NR, Pershing AJ, Maps F (2013) Emergent copepod communities in an adaptive trait-structured model. Ecol Model

Record NR, Pershing AJ, Maps F (2013) The paradox of "the paradox of the plankton". ICES J. Mar. Sci. 

  

Coffeemaker from a MacPro

| 1 Comment
Loyal Seascape reader(s) will know that Nick is slowly transitioning out of the lab and will soon be teaching oceanography at Bowdoin College.  In recognition of his contributions, we wanted to get him a gift that would truly represent what he has meant to the lab.  Since he doesn't wear jewelry, we decided to make him something.  My original idea was to take our non-functioning G5 MacPro "Eubalaena" and turn it into a seat for his office.  Eubalaena means "true whale" and is the genus of our beloved right whale.  It is also the computer on which Nick launched his copepod modeling career.   Dom and Sigrid correctly noted that the chair idea was stupid, so we went into a round of strategic planning.  During that process we realized that, while we appreciate Nick's scientific acumen and ability to get our code to run on the Kraken, we really value the way he slowly and carefully pours the water in to our respective coffee filters every morning.  This led to the idea of putting this:
coffee001sm.jpga $10 off-brand coffee maker into this:
coffee002.jpg
a non-functioning computer that cost about $4K back in the day.

In case you have a spare MacPro lying around, here's how we did it.  Note, this project involves electricity, water, and you.  Electricity would love to kill you, and water would be happy to help, so be very careful and don't hold us liable if you or someone you love gets injured.  

1. Open the case.  Apple's great design innovation with the MacPro was the ability to open the side and easily access the hardware.  This gives you the illusion that you might be able to fix or upgrade the thing yourself.  We decided from the beginning to maintain the integrity of the case, so that it would look like a regular computer to the untrained eye.
coffee 003.jpg
2. Remove the guts.  This took us about 6 hours, but to be fair, most of that time was spent trying to find the right tools.  With a good set of computer screwdrivers, this should be much faster.  I found gloves to be essential: circuit boards are sharp!
coffee 004.jpg
3. With a little persistence, and a set of torx screwdrivers, you can also remove the power unit that sits in the bottom.  We cleaned that baby out too.  Man, that is a scary piece of electronics.
4. Give the coffeemaker the same treatment.  Apparently, the guts of coffeemakers are either dangerous or contain national secrets that are not meant to be shared on the internet.  The guts are protected by several "safety screws"--little screws with a bump in the middle so your normal screwdriver can't access them.  Fortunately, the coffee maker is made of soft plastic that is easily cut with a Dremel.  So much for safety.
coffee 005.jpg
5. A coffeemaker is a deceptively simple thing.  It consists of a curved metal pipe attached to a heating element.  Water flows in one side of the pipe, through a simple ball valve, gets heated, and then bubbles out the other side.  Check out this video if you really want to know how one works.
6. Our main innovation was to put the heating unit inside the junction box from the power unit.  We added some tubing to carry water to the heater and another to carry the hot water up the back of the computer.
coffee 006.jpgcoffee 007.jpg
7. We had to wire in a new switch.  This was pretty easy and we were able to connect to the wires coming out of the original Apple plug (maintaining the integrity of the case).  Note: connecting a DC switch to 120V AC power tends to create uncomfortable popping sounds accompanied by smoke.  Make sure you buy components and wires up to the task.
8. We made a holder for the filter basket using parts of the one of the fans, suspended from the built-in shelf using threaded rod.  We also used part of the heat sink as a platform for a mug.
coffee 008.jpg
Believe it or not, the thing actually works.  Here's a short video of the thing in action:

Simpupods

| No Comments
What maintains diversity in ecosystems?  How is diversity structured?  What facilitates coexistence?

Indeed, these are the questions that plague me in the wee hours of night.  I think to myself, "if only I could pare down those ecosystems to their fundamental properties, and tinker with them."  But alas, the biosphere is far too complex.

Instead, I build simplified ecosystems like the one shown below.  If you have Java 5 or higher enabled in your browser settings, you can play with this system of "simpupods".  These simpupods bounce around randomly within this artificial ecosystem.  Different species are denoted by different colors.  Each species has an assigned egg size, and an adult size.  When two individuals encounter each other, after an implied struggle for survival, the larger one dispassionately consumes the smaller one, and grows accordingly.  Once an individual reaches its adult size, it divides its mass into new individuals.  "Adult size" and "egg size" are traits that are passed on to offspring.

You'll notice from the histograms below that some species (i.e. egg size / adult size combo) go extinct quickly, while others persist.  You can add species by clicking the "add species" button.  You can also adjust the speed of the simulation, making it easier to watch.

Nick Record, signing off.
 


CLICK HERE FOR MODEL

Regional Ocean Modeling System

| 2 Comments
The chilly November winds have arrived.  They fetch across the water each morning and snatch away all my warmth as I ride the boat into work.  

Some hardy marine scientists are still out there sampling, but for this ecosystem modeling lab, the darker months are a time when we turn our efforts toward knitting scarves and coding models.  A few of us even enjoy the view of the ocean from our lab in the winter.

Modeling.jpg

View of the ocean from the Seascape Modeling Lab.

Our library of ecosystem models continues to grow.  One of the capabilities we're adding this winter is integration with the Regional Ocean Modeling System.  To be hip with the jargon, you should call it "ROMS".  The model basically a computation of the equations that govern the motion of the ocean.

I'm just learning this particular model now myself.  Becoming familiar with a new model is often an emotional affair.  Generally, after warming my frigid hands with a cup of coffee in the morning, I spend the subsequent hours alternately tugging my hair out and then crying out in exultation.

Below I've included a link to an animation of the first model computation that most ROMS learners start off with.  There are a few things missing from this animation, so don't worry too much if it's not clear what's happening---I've only just started using this model, after all.  What you should be seeing is a model of wind-driven upwelling.  This is a well-documented process in the ocean.  Wind effectively pushes surface water in one direction, and the deeper waters rise up to replace it.  The color scale shows temperature (C).

Yes, I acknowledge that this is a crude plot, and much is wrong with it.  But it's important through these cold, coding months to celebrate the little things.




Learning to Model

| 2 Comments
Computational modeling requires a diverse set of skills.  While most aspiring modelers are expected to have solid math skills, many advisors assume that other skills, like writing programs or building complex FORTRAN projects, will be learned on the fly.  These skills form what I call "applied scientific computing" and they can be some of the biggest challenges that rookies and even some veterans face.  For example, we're trying to get an implementation of ROMS running on our lab system.  Like many large models, ROMS comes as a series of FORTRAN files.  These files must be compiled and then linked against a series of external libraries (for example, NetCDF).  Magnanimous developers will often provide a "make" file or build script to make the compiling and linking simpler.  However, my experience is it always takes some digging to get this process to work.  Even if you've had a course on FORTRAN programming, you very likely have no idea what it means to link to an external library.  At one point, it was my mission in life (well, not quite) to fight against the "I had to teach myself this stuff, you should too" mentality.  I developed a series of short courses on doing science with Matlab, FORTRAN programming, and even a course on libraries.  I've created a "Scientific Computing" section of seascapemodeling, and put a couple of the courses on there.  I'll try to get the complete set up shortly.  If this is a topic that's interesting to you, please leave a comment or send me an email.

The Art of Modeling

| No Comments
Apparently, the concept made its way into the mainstream scientific journals. The art resides in the numerous educated guesses and assumptions an ecologist faces when building and (as importantly) assessing the validity of his model. From the conceptualization of the scientific question addressed, to the choice of the numerical method(s), the amount and level of precision of the processes to represent, their mathematical formulation, and the determination of the parameters of the equations etc. At each step, some subjectivity, some instinct, some serendipitous success, maybe...

The highest level of certainty an ecological modeler knows is that there are some apparently unavoidable pitfalls. One is mortality (any biological modeler reading this will nod in spite of himself). Sooner or later, in a meeting like the one I am this week, you'll hear something spirited like "...but your mortality function is not based on any mechanism, so what the ... are we (non-modelers) supposed to do with your results..."

Mortality rates of the small plankton are notoriously difficult to measure in the field, and thus, this term is one of the most difficult to constrain. Most single species copepod models have developed empirical relationships with temperature and/or food (for seasonality purpose) and many include some form of density dependence (for numerical purpose). Those choices arise from the trade-offs between the availability of data and the necessity to move forward and do actual modeling.

The case of temperature-dependent functions illustrates this situation: the Gulf of Maine time series suggest that herring predation may limit Calanus finmarchicus abundance. Predation by herring is the highest in the summer and the seasonal changes could then be approximated as a function of temperature. If spring conditions were warmer, we might expect that herring would begin feeding earlier, and thus, the temperature dependent mortality would adequately reflect interannual changes in a mechanistic way. However, it seems unlikely that herring predation would respond to a temperature anomaly of a few days, and it is unclear whether a warming throughout the year would correspond to higher mortality.

A novel approach of mortality in copepod models requires a mortality function that reflects some aspects of the dynamical response of predator populations to copepod abundance. This requirement becomes essential to enable realistic projections under climate variability and change. Our knowledge of copepod predators remains limited, and attempting to model the populations of all of the major predators of the life stages of our copepod would just be unfeasible. Following the "middle-out" framework, in future iteration of our models we want to use a compromise mortality function. This new function will make use of several populations of predators, each representing predation by progressively larger animals preying on progressively larger copepods. We will use classical size-dependent feeding behavior for the predators, namely a type II ingestion function (rapid increase at low food concentrations) for small predators and type III function (depressed feeding at low concentrations) for large predators. The result will be that on one hand, the predation rate on smaller copepods (early life stages) will increase largely through changes in the abundance of the predators, while on the other hand predation on larger copepods (later life stages) will respond to changes in their own abundance through the variable ingestion rate of the larger predators. That, is a bold move!

racoon.jpg This picture has nothing to do with what I just talked about... I just feel that the pictures on the blog are discriminatory toward the earthly mammals ! And raccoons are cute (at 3pm, not 3am, though...).

Where's Sheldon? The plankton-or-detritus game.

| No Comments
We live in a digital age.  Grocery stores use automatic scanning to read prices.  Factories use machines to build machines.  Robots can vacuum carpets and land on Mars.  Even our trusted local RoboCop struggles with his dual cyborg identity.

But what does this have to do with plankton?

Digital instruments are changing the way we view the ocean as well.  While nets are still the most common plankton sampling device, other instruments are starting to catch on.  In our lab, we use the laser optical plankton counter, or LOPC, which I've written about before.  Instead of hauling up a net and counting every critter by eye, we lower this instrument into the ocean, it scans the nearby water with a laser, and records what it sees.  Very futuristic.

The advantage to this technology is that we can now collect large amounts of detailed data at a much faster rate, and sometimes in rougher weather conditions.  Also, we don't have to mess with chemicals and look through a microscope for long hours to identify each critter one at a time.

Still, as we march relentlessly toward a dystopian future ruled by hyper-intelligent robots, it's important to bear in mind the value of a human--in this case, a taxonomist human.  To illustrate the point, I've invented a game called "Where's Sheldon?  The plankton-or-detritus game."  When we lower the LOPC into the water, it records every particle that is sees.  Some of those particles are planktonic, and others are not.  It can often be difficult to distinguish the two.

Can you tell the difference?  I did a lab test, and passed these items through the LOPC:
Thumbnail image for LOPC_items02.jpg
As you can see, there is one planktonic organism--Sheldon the copepod--and a collection of detritus.  Each item passed through the LOPC three times.  Here's the output:
LOPC_items02_answer.jpg
Can you identify Sheldon the copepod?  Click on the figure for the answer.

Some of the items are easy to identify, like the coin and the paper clip.  Others are trickier.  Also, these items are roughly 10 times larger (at least) than the plankton that we're interested in.  Now imagine not just trying to pick out the plankton, but trying to identify the species.  That means that the plankton-or-detritus game that we play in the lab is much more difficult than the version that you just played.

To me, this is an important reminder of the value of expert humans.  It's also a reminder of the value of collecting samples of actual animals that can be identified by eye.  Digital technology, so far at least, is at best a good compliment to conventional methods.

On the other hand, in order to get around this problem, scientists are now using machine-learning algorithms.  Essentially, this means that we program computers to be able to think, and they are definitely getting smarter and smarter all the time.  Still, I think it'll be quite some time before we have robot oceanographers.


Defend Hudson Bay !

| No Comments
A fun part of being a grad student, is making bonds beyond the regular "have-to-share-the-same-open-area-office" friendship. The challenges to overcome are so tough, the emotions shared are so strong than you can never break those bonds. So last week was emotional for me, as I assisted to the Ph.D. thesis defence of my last two buddies from my grad school modeling lab.

Both worked on the Hudson Bay system, a very exciting environment to work on. It's the southernmost Arctic sea, a transition zone between the Arctic Ocean and the Atlantic Ocean at the forefront of the impacts of the current global warming.



Pierre St-Laurent defended brilliantly the 17th of May his thesis entitled "Variabilité saisonnière et interannuelle des eaux douces dans les mers Arctiques : Le cas de la baie d'Hudson".


Pierre showed the audience how the fresh-water budget is regulated in the Hudson Bay. He tackled both liquid and solid (seasonal sea-ice) aspects of it. As an example of how great a tool is modeling in a well formed scientific mind, he first studied this issue with a realistic high resolution sea-ice / ocean 3-D circulation model of the Hudson Bay, developed in the numerical modeling lab of ISMER in Rimouski.

summer_tracer_river.pngHe then constructed an idealized system to sort out the relative importance of the various hydrological, atmospheric and oceanic forcing.


conc_mod_stacked.png

This allowed him to demonstrate for the first time the role of changing wind regimes in the periodic retention/expulsion of fresh water from the Hudson Bay towards the North-West Atlantic.


stress_field.png

Pierre will soon lend his brain as a post-doc to the Old Dominion University in Norfolk, VA

(He's too modest to agree for me to tell you that there is a tenure track position attached at the end of his 3 years as post-doc).



Virginie Sibert defended not less brilliantly the 20th of May her thesis entitled "Modélisation de la variabilité saisonnière et de la sensibilité au climat des productions glacielle et pélagique de la baie d'Hudson".


Virginie managed to build a model of primary and secondary production within the sea-ice in Hudson Bay.


1D_IA.png

She coupled this to the ice compartment of the same high-resolution 3-D circulation model than Pierre. After characterizing the spatio-temporal patterns of this system, she coupled it further with an NPZD pelagic production model to have a complete picture of the primary production in the system.

View image


After a rigorous validation process which guaranteed a good confidence in the model results, she finally tested one of the IPCC scenario of climate change (A2) for the Hudson Bay system.


anomaly_IA.png

A nice outcome of her work is that the Hudson Bay system would not, for its most part, pass a tipping point yet. Primary production of both ice algea and phytoplankton would increase, even if their respective blooms would occur sooner in the season.


Virginie has already brought her talent and charm as a post-doc in the IFREMER lab of Brest, France.

Publications

| No Comments
Our lab has had a good month for publications.  Fred's paper on C. finmarchicus diapause, and the role of lipids, finally made it to press.  The paper appears in the Marine Ecology Progress Series, and can be found here.  The paper was submitted for review on the 4th of November, 2008--roughly 17 months ago.

Not all review experiences are as lengthy or arduous.  Our lab had three other papers accepted for publication this month.  Two of them were submitted earlier this year.  We will post an update when they make it to press.  Meanwhile, a list of our publications can be found on our welcome page, here.

Fred.jpg
Sample image from Fred's paper.  MEPS 403: 165-180.

About this Archive

This page is an archive of recent entries in the Computation category.

Climate is the previous category.

Copepod Modeling is the next category.

Find recent content on the main index or look in the archives to find all content.