Getting started with network analysis of animal movements in R

Josh Nightingale
4 min readDec 11, 2020

What is it and what’s the point?

Network analysis is the study of relationships. A bunch of things, at least some of which are connected, makes a graph; when the connections vary in strength, you have a network.

In ecology there are two main uses of networks: studying spatial relationships, or social ones. This is a very brief run-through of how I got started looking at spatial networks of bird movements in R.

(If you’re more interested in social networks, check out this paper from Ferreira et al. on getting started, and this one by Silk et al. for the CMRnet R package to implement it)

What can you do with network analysis? You can ask questions about

  • entire networks: Is it densely or sparsely interconnected? Centralised or diffuse?
  • individual sites: How many other sites is it connected to? How many pathways go through it? What happens to the network if that site is taken out?
  • individual relationships: Strong or weak? Directional? Redundant or irreplaceable?

This post/brain-dump goes through the following steps:

Step 1: Background reading

Step 2: Data

Step 3: Analyse

Step 4: Visualise

Background reading

There are quite a few papers using networks in ecology. Here are some reviews I found helpful when planning my own analyses.

Jacoby and Freeman (2016): Emerging Network-Based Tools in Movement Ecology. TREE (journal | pdf)

If you only read one paper before getting started, this is a good choice. It’s pretty comprehensive, gives a useful amount of theory, as well as practical considerations given different data types.

Rayfield et al. (2011): Connectivity for conservation: a framework to classify network measures. Ecology (journal | pdf)

There are a huge array of metrics you can get from standard network analysis packages. This paper goes through a lot of them, applying the underlying theory to habitat connectivity issues.

Silk et al. (2020): CMRnet: An r package to derive networks of social interactions and movement from mark–recapture data. MEE (journal | pdf)

This paper actually came out after I started the project, but I wish I’d had it earlier. It goes through a lot of the key steps in turning capture-recapture data into movement or social networks.

There’s also the book A User’s Guide to Network Analysis in R by Douglas Luke, which is very helpful for the nitty-gritty.

EDIT (12/Apr/23) — I’ve now published the work that inspired this post, explaining how network analysis of animal movements can help improve accuracy of environmental impact assessments and the functioning of protected areas. Nightingale et al. (2023) Conservation beyond Boundaries: using animal movement networks in Protected Area assessment. Animal Conservation (open access link).

Data

Network analysis is flexible enough that it can be applied to all sorts of data types, which all have their own unique problems. So I won’t dwell on this too much.

You will need two things:

1) Sites. You have to divide continuous space into distinct chunks. You may work in a system where habitat patches have distinct boundaries: e.g. mudflats, in my case, or ponds in this seminal paper (pdf). Alternatively, you might have distinct recording areas, or a fixed array of traps, in which case your ‘sites’ may or may not map directly onto something with ecological meaning. Give it some thought.

2) Things that move. There’s all sorts of options here. Commonly, people use a time-series of observations of identifiable individuals. At a previous project, however, we used a large team of volunteers to record movements of waterbird flocks directly, ascertaining both the start and end locations, which did a decent job with high-tide movements. Newfangled tagging data doubtless provides all sorts of exciting opportunities, but I’ve yet to work with it.

Ultimately you need to figure out a way to turn your data into a list of connections. My code needs a bit of tidying before sharing, but my steps were:

  • For each individual within each time-window, find all sites where it was recorded
  • Find all unique combinations of those sites (in an undirected network, A→B is the same as B→A)
  • Tabulate the results, so that each pair of sites has a weight equivalent to the total number of times that combination was recorded.

The CMRnet package mentioned above will do a lot of that for you, if you’re using mark-recapture data.

Analyse

I used the excellent igraph package for everything. It’s available for R, Python, Mathematica and C/C++ — choose your weapon.

There are already plenty of tutorials for igraph available, including its own manual. Here’s another good one, and another if you like the tidyverse approach. The book A User’s Guide to Network Analysis in R also uses igraph extensively, along with a few other packages.

A newer alternative, for those working with mark-recapture data, is CMRnet, which looks promising but I haven’t had a chance to take it for a spin yet.

Visualise

igraph’s analytical functions are excellent, but its plotting leaves a little to be denied. There are — inevitably — various other options, including some that interface with ggplot giving greater flexibility (e.g. plotting my network over a map). I’ve used ggnetwork and there is also ggraph. There are also other network analysis packages, like sna for social networks or bipartite for bipartite networks, with other plotting options. You can convert graph objects between packages using intergraph.

Good luck!

There’s a fair amount of general introductory material on the internet — I’ve covered a tiny amount of what I’ve found useful here.

I’m @Luscinia_joshua on Twitter if you think I can help with something!

P.S.: A note on plotting networks on maps

I think it’s very effective to be able to show your network on top of a map, like this:

A (fake) network of movements in the Tagus estuary, Portugal.

which is doable entirely with R. Here’s a quick run-through of the steps I used, published as a github gist:

--

--

Josh Nightingale

PhD student studying shorebird migration (juvenile settlement and its population consequences) at Universities of Aveiro and East Anglia.