MigConnectivity

Brett Hartlaub

What is MigConnectivity

MigConnectivity enables conservation scientists to analyze the migratory behavior of animal species in a given region and annual cycle.

  • The package contains several functions that can calculate transition probabilities, strength of migratory connectivity, etc.

Important Functions

estTransition()

This is the core function for estimating transition probabilities of a species, or the probability that an individual from a specific breeding origin will migrate to a specific non-breeding site.

# Estimating transition probabilities using 
# distances and relative abundance
assignment_results <- estTransition(
  originDist = originDist,      # Distance matrix for breeding
  targetDist = targetDist,      # Distance matrix for non-breeding
  originRelAbund = relAbund,    # Relative abundance of populations
  psi = initial_psi,            # Prior or starting transition matrix
  method = "MCMC",              # Estimation method
  nSamples = 1000               # Number of iterations
)
print(assignment_results$psi$mean)

estStrength()

This function calculates the migratory connectivity metric. it is a value, usually 0 or 1, that quantifies how much a population stays together during migration.

# Calculating MC strength from the transition estimates
mc_strength <- estStrength(
  originDist = originDist,
  targetDist = targetDist,
  originRelAbund = relAbund,
  psi = assignment_results$psi$sample 
)

# A value near 1 indicates very strong, "locked" connectivity
print(mc_strength$MC$mean)

estMantel()

This function does the same as the previous, however it provides the value using a more standardized formula to provide the Mantel Correlation metric. This metric compares the distance between individuals at their origin vs. their destination.

# Mantel correlation for connectivity
mantel_res <- estMantel(
  targetDist = targetDist,
  originDist = originDist,
  targetPoints = targetPoints,
  originPoints = originPoints,
  nSamples = 1000
)
print(mantel_res$rM$mean)

Example visualizations

A large reason for why this package is so useful is the ability for scientists to use visualizations (especially maps) to represent their data and calculations within the package. Here is an example of two maps that define breeding and non-breeding regions for the yellow warbler.

Breeding Regions

Code

library(sf)
library(MigConnectivity)

# 
rawURL <- "[https://raw.githubusercontent.com/SMBC-NZP/MigConnectivity/devpsi2/data-raw/YEWA/](https://raw.githubusercontent.com/SMBC-NZP/MigConnectivity/devpsi2/data-raw/YEWA/)"
target_file <- "YEWA_target_sites.rds"
newDir <- tempdir()

utils::download.file(
  url = paste0(rawURL, target_file), 
  destfile = file.path(newDir, target_file), 
  mode = "wb"
)

YEWA_target_sites <- readRDS(file.path(newDir, target_file))

# 3. Filter for specific columns
YEWA_target_sites <- YEWA_target_sites[,c("Region", "targetSite", "geometry")]

# 4. Define target names for the model
targetNames <- c("Pacific and Central Mexico", 
                 "Atlantic Lowland Mexico", 
                 "Central America", 
                 "South America")

# plot
plot(st_geometry(YEWA_origin_sites), col = "#F5F5DC", border = "white")
plot(st_geometry(YEWA_target_sites), 
     col = c("#EBD17D", "#79B4D1", "#0E648B", "#D1997D"), 
     add = TRUE)

Resources

Data: https://github.com/SMBC-NZP/MigConnectivity/tree/devpsi2/data-raw/YEWA Hostetler et al. 2025

MigConnectivity: https://smbc-nzp.github.io/MigConnectivity/WorkedExample.html

[1] 2