Estimate transition probabilities with the ‘MigConnectivity’ package

Jeffrey A. Hostetler, Michael T. Hallworth

2024-01-12

The estTransition estimates migratory connectivity pattern (ψ, transition probabilities) from seasonal movement data.

The estStrength function estimates the strength of migratory connectivity from transition probabilities (MC). See the estStrength vignette for more details.

estTransition - Estimate transition probabilities while incorporating location and other sampling uncertainty

Example 1: Combining two types of tracking technologies (light-level geolocator & GPS)

To estimate transition probabilities (psi(ψ)) and include location uncertainty the following data are needed:

  1. A logical vector indicating whether each individual’s location estimate was derived from a light-level geolocator (isGL = TRUE) or another data source (isGL = FALSE)
  2. A logical vector indicating whether the device for each animals is a telemetry type device with high precision or not (isTelemetry = TRUE/FALSE)
  3. Location bias - a vector that has error estimates for both longitude and latitude
  4. Location error - a variance, covariance matrix of longitude and latitude
  5. A spatial layer of both breeding and non-breeding regions
  6. The deployment locations and the ‘unknown’ locations derived from the tracking devices

We estimate transition probabilities using bootstrapped data of birds tracked from breeding to non-breeding regions using light-level and GPS geolocation when: 1) GPS location uncertainty was applied to all individuals, 2) GPS and light-level location uncertainty were applied to individuals with those devices and 3) light-level location uncertainty was applied to all individuals (Cohen et al. 2018).

Load location data that accompanies the MigConnectivity package. The location data are data from breeding Ovenbirds that were fit with Light-level geolocators or PinPoint-10 GPS tags.

# Ovenbird data included with the package
data(OVENdata, package = "MigConnectivity") 

names(OVENdata)
##  [1] "geo.bias"       "geo.vcov"       "isGL"           "targetPoints"   "originPoints"  
##  [6] "targetSites"    "originSites"    "originRelAbund" "originDist"     "targetDist"    
## [11] "originNames"    "targetNames"

The figure below shows the two breeding regions (squares), and the three non-breeding regions (gray scale) used in Cohen et al. (2018) to estimate MC for Ovenbirds tracked with light-level geolocators and PinPoint-10 GPS tags.

# Load packages used below
library(sf)
library(terra)
library(maps)

# Set the crs to WGS84
originSitesWGS84 <- st_transform(OVENdata$originSites, 4326)
targetSitesWGS84 <- st_transform(OVENdata$targetSites, 4326)
# Create a simple plot of the origin and and target sites 
op <- graphics::par(no.readonly = TRUE)
on.exit(graphics::par(op))
par(mar=c(0,0,0,0))
plot(originSitesWGS84,
     xlim=c(terra::ext(targetSitesWGS84)[1],
            terra::ext(targetSitesWGS84)[2]),

     ylim=c(terra::ext(targetSitesWGS84)[3],
            terra::ext(originSitesWGS84)[4]))

plot(targetSitesWGS84,
     add = TRUE,
     col=c("gray70","gray35","gray10"))

map("world", add=TRUE)
Figure 1. Origin and Target sites used to estimate Ovenbird migratory connectivity using light-level geolocator and GPS tags deployed in the eastern portion of their distribution
Figure 1. Origin and Target sites used to estimate Ovenbird migratory connectivity using light-level geolocator and GPS tags deployed in the eastern portion of their distribution

The following code demonstrates how to estimate transition probabilities using location data from light-level geolocators and PinPoint-10 GPS tags. Note: When using a combination of light-level geolocators and other more precise tracking technology such as GPS tags, be sure to include both isGL and isTelemetry vectors. Below, we create the isTelemetry vector as the inverse of the isGL vector.

(OVENpsi <- estTransition(isGL=OVENdata$isGL, # Logical vector: light-level geolocator(T)/GPS(F)
                    isTelemetry = !OVENdata$isGL, # Location vector: light-level geolocator(F)/GPS(T)
                 geoBias = OVENdata$geo.bias, # Light-level geolocator location bias
                 geoVCov = OVENdata$geo.vcov, #Light-level geolocator covariance matrix
                 targetSites = OVENdata$targetSites, # Non-breeding / target sites
                 originSites = OVENdata$originSites, # Breeding / origin sites 
                 targetNames = OVENdata$targetNames, # Names of nonbreeding/target sites
                 originNames = OVENdata$originNames, # Names of breeding/origin sites
                 originPoints = OVENdata$originPoints, # Capture locations 
                 targetPoints = OVENdata$targetPoints, # Target locations from devices
                 resampleProjection = sf::st_crs(OVENdata$targetPoints), 
                 maxTries = 300,
                 verbose = 0,   # output options - see help(estTransition)
                 nSamples = 10)) # This is set low for example 
## Migratory Connectivity Estimates
## 
## Transition probability (psi) estimates (mean):
##        FL   Cuba   Hisp
## NH 0.0000 0.1614 0.8386
## MD 0.3147 0.6853 0.0000
## +/- SE:
##        FL    Cuba    Hisp
## NH 0.0000 0.06656 0.06656
## MD 0.1752 0.17515 0.00000
## 95% confidence interval (simple quantile):
##    FL               Cuba             Hisp            
## NH 0.00000 - 0.0000 0.05179 - 0.2500 0.75000 - 0.9482
## MD 0.04091 - 0.5877 0.41227 - 0.9591 0.00000 - 0.0000
## 
## This is a subset of what's available inside this estMigConnectivity output.
## For more info, try ?estTransition or str(obj_name, max.level = 2).

Take a closer look at what is included in the output

# not run 
str(OVENpsi, max.level = 2)

New plotting functions allow users to quickly plot transition probabilities including confidence intervals. Users can customize plots to suit their needs as additional arguments (...) are supported.

# THE FIGS ARE TOO SMALL IN VINGETTE HTML SO NEED TO ADD ADDITIONAL PARAMETERS TO MAKE IT LOOK HALFWAY DECENT

plot(OVENpsi, legend = "top", cex = 0.5, las = 2)
Figure 2. Transition probablities of Ovenbirds from breeding origin sites to non-breeding target sites
Figure 2. Transition probablities of Ovenbirds from breeding origin sites to non-breeding target sites

Example 2: Combining tracking technology and genoscape assignments

Below we estimate transition probabilities for Yellow Warblers (Setophaga petechia) by integrating several different data sources such as tracking data (light-level geolocators) and genoscape assignments. Furthermore, the data sources were derived from both breeding and non-breeding individuals. The following parameters are needed to estimate transition probabilities with integrating different data types. Below, we provide a streamlined example once the data are formatted for the analysis. See Worked Examples for how to derive and structure the data for analysis.

  1. Four logical vectors indicating the type of information the location/assignment estimates were derived from
    (light-level geolocators, telemetry, isotopes, and/or genoscapes)
  2. Location Bias - a vector that has error estimates for both longitude and latitude
  3. Location error - a variance, covariance matrix of longitude and latitude
  4. Distance matrices between breeding and non-breeding regions
  5. A spatial layer of both breeding and non-breeding regions
  6. Capture locations and the ‘unknown’ locations/assignments derived from the tracking devices or intrinsic markers
  7. The relative (or absolute) abundance within each region where the birds originate from (deployment regions)
# Read in the processed Yellow Warbler data 
# see the Worked Examples Vignette for details on how data structured/created
set.seed(1)
newDir <- tempdir()
baseURL <- 'https://github.com/SMBC-NZP/MigConnectivity/blob/devpsi2/data-raw/YEWA/'
file.name <- "yewa_estTrans_data.rds"
url1 <- paste0(baseURL, file.name, '?raw=true')
temp <- paste(newDir, file.name, sep = '/')
utils::download.file(url1, temp, mode = 'wb')
YEWA_target_sites <- readRDS(temp)
YEWAdata <- readRDS(temp)
unlink(temp)

# take a quick look at the data # 
str(YEWAdata, 1)
## List of 22
##  $ originSites       :Classes 'sf' and 'data.frame': 5 obs. of  3 variables:
##   ..- attr(*, "sf_column")= chr "geometry"
##   ..- attr(*, "agr")= Factor w/ 3 levels "constant","aggregate",..: NA NA
##   .. ..- attr(*, "names")= chr [1:2] "population" "originSite"
##  $ targetSites       :Classes 'sf' and 'data.frame': 4 obs. of  3 variables:
##   ..- attr(*, "sf_column")= chr "geometry"
##   ..- attr(*, "agr")= Factor w/ 3 levels "constant","aggregate",..: NA NA
##   .. ..- attr(*, "names")= chr [1:2] "Region" "targetSite"
##  $ originPoints      :Classes 'sf' and 'data.frame': 7 obs. of  3 variables:
##   ..- attr(*, "sf_column")= chr "geometry"
##   ..- attr(*, "agr")= Factor w/ 3 levels "constant","aggregate",..: NA NA
##   .. ..- attr(*, "names")= chr [1:2] "bird" "Type"
##  $ targetPoints      :Classes 'sf' and 'data.frame': 210 obs. of  2 variables:
##   ..- attr(*, "sf_column")= chr "geometry"
##   ..- attr(*, "agr")= Factor w/ 3 levels "constant","aggregate",..: NA
##   .. ..- attr(*, "names")= chr "Type"
##  $ originAssignment  : num [1:203, 1:5] 6.16e-03 1.91e-17 1.86e-18 1.38e-20 5.45e-11 ...
##   ..- attr(*, "dimnames")=List of 2
##  $ originNames       : chr [1:5] "Arctic" "Pacific Northwest" "Southwest" "Central" ...
##  $ targetNames       : chr [1:4] "Pacific and Central Mexico" "Atlantic Lowland Mexico" "Central America" "South America"
##  $ nSamples          : num 10
##  $ isGL              : logi [1:210] TRUE TRUE TRUE TRUE TRUE TRUE ...
##  $ isTelemetry       : logi [1:210] FALSE FALSE FALSE FALSE FALSE FALSE ...
##  $ isRaster          : logi [1:210] FALSE FALSE FALSE FALSE FALSE FALSE ...
##  $ isProb            : logi [1:210] FALSE FALSE FALSE FALSE FALSE FALSE ...
##  $ captured          : chr [1:210] "origin" "origin" "origin" "origin" ...
##  $ geoBias           : Named num [1:2] -6513 50965
##   ..- attr(*, "names")= chr [1:2] "difflong" "difflat"
##  $ geoVCov           : num [1:2, 1:2] 2.59e+08 -8.94e+08 -8.94e+08 4.71e+09
##   ..- attr(*, "dimnames")=List of 2
##  $ verbose           : num 2
##  $ maxTries          : num 400
##  $ resampleProjection:List of 2
##   ..- attr(*, "class")= chr "crs"
##  $ nSim              : num 40
##  $ dataOverlapSetting: chr "none"
##  $ targetRelAbund    : Named num [1:4] 0.0881 0.1645 0.4287 0.3187
##   ..- attr(*, "names")= chr [1:4] "Pacific and Central Mexico" "Atlantic Lowland Mexico" "Central America" "South America"
##  $ originRelAbund    : Named num [1:5] 0.169 0.125 0.284 0.247 0.175
##   ..- attr(*, "names")= chr [1:5] "Arctic" "Pacific Northwest" "Southwest" "Central" ...

Below we estimate (psi) or transition probabilities using the estTransition function.

Note - in the Yellow Warbler data there are no overlap of data sources for individuals, i.e., we only had one type of data for each bird - so we set the overlap setting to “none”. However, when there’s only one type of data in the whole dataset, the function runs faster if you leave dataOverlapSetting at “dummy”

## Run analysis for psi
psiYEWA <- estTransition(originSites = YEWAdata$originSites,
                         targetSites = YEWAdata$targetSites,
                         originPoints = YEWAdata$originPoints,
                         targetPoints = YEWAdata$targetPoints,
                         originAssignment = YEWAdata$originAssignment,
                         originNames = YEWAdata$originNames,
                         targetNames = YEWAdata$targetNames,
                         nSamples = 10,
                         isGL = YEWAdata$isGL,
                         isTelemetry = YEWAdata$isTelemetry,
                         isRaster = YEWAdata$isRaster,
                         isProb = YEWAdata$isProb,
                         captured = YEWAdata$captured,
                         geoBias = YEWAdata$geoBias,
                         geoVCov = YEWAdata$geoVCov,
                         originRaster = YEWAdata$originRaster,
                         verbose = 2, 
                         maxTries = 400,
                         resampleProjection = YEWAdata$resampleProjection,
                         nSim = 10,
                         dataOverlapSetting = "none",
                         targetRelAbund = YEWAdata$targetRelAbund,
                         returnAllInput = FALSE)
## Configuring data overlap settings
## Warning in reassignInds(dataOverlapSetting = dataOverlapSetting, originPoints = originPoints, : Not all origin capture locations are within originSites. Assigning to closest site.
## Affects animal: 1
## Warning in reassignInds(dataOverlapSetting = dataOverlapSetting, originPoints = originPoints, : Not all origin capture locations are within originSites. Assigning to closest site.
## Affects animal: 2
## Warning in reassignInds(dataOverlapSetting = dataOverlapSetting, originPoints = originPoints, : Not all origin capture locations are within originSites. Assigning to closest site.
## Affects animal: 3
## Warning in reassignInds(dataOverlapSetting = dataOverlapSetting, originPoints = originPoints, : Not all origin capture locations are within originSites. Assigning to closest site.
## Affects animal: 4
## Creating targetAssignment
## Not all target capture locations are within targetSites. Assigning to closest site
## Warning in estTransitionBoot(isGL = isGL, isTelemetry = isTelemetry, isRaster = isRaster, : Not all target capture locations are within targetSites. Assigning to closest site.
## Affects animals: 133,134,135,136,137,138,139,140,141,142,143,144,145,146,184,189,190,191,192
## Starting bootstrap
## Bootstrap Run 1 of 10 at Fri Jan 12 15:13:56 2024 
## Bootstrap Run 2 of 10 at Fri Jan 12 15:13:56 2024 
## Bootstrap Run 3 of 10 at Fri Jan 12 15:13:56 2024 
## Bootstrap Run 4 of 10 at Fri Jan 12 15:13:56 2024 
## Bootstrap Run 5 of 10 at Fri Jan 12 15:13:57 2024 
## Bootstrap Run 6 of 10 at Fri Jan 12 15:13:57 2024 
## Bootstrap Run 7 of 10 at Fri Jan 12 15:13:57 2024 
## Bootstrap Run 8 of 10 at Fri Jan 12 15:13:57 2024 
## Bootstrap Run 9 of 10 at Fri Jan 12 15:13:58 2024 
## Bootstrap Run 10 of 10 at Fri Jan 12 15:13:58 2024
# Take a look at the results # 
psiYEWA
## Migratory Connectivity Estimates
## 
## Transition probability (psi) estimates (mean):
##                   Pacific and Central Mexico Atlantic Lowland Mexico Central America
## Arctic                               0.00000                 0.74968          0.2503
## Pacific Northwest                    0.03625                 0.24841          0.7153
## Southwest                            0.40188                 0.05573          0.5424
## Central                              0.00000                 0.08382          0.6125
## East                                 0.00000                 0.00000          0.0000
##                   South America
## Arctic                   0.0000
## Pacific Northwest        0.0000
## Southwest                0.0000
## Central                  0.3037
## East                     1.0000
## +/- SE:
##                   Pacific and Central Mexico Atlantic Lowland Mexico Central America
## Arctic                               0.00000                 0.12899         0.12899
## Pacific Northwest                    0.03904                 0.04066         0.05800
## Southwest                            0.06930                 0.03869         0.07157
## Central                              0.00000                 0.02048         0.05509
## East                                 0.00000                 0.00000         0.00000
##                   South America
## Arctic                  0.00000
## Pacific Northwest       0.00000
## Southwest               0.00000
## Central                 0.05385
## East                    0.00000
## 95% confidence interval (simple quantile):
##                   Pacific and Central Mexico Atlantic Lowland Mexico Central America 
## Arctic            0.00000 - 0.0000           0.60667 - 0.9786        0.02143 - 0.3933
## Pacific Northwest 0.00000 - 0.1020           0.19500 - 0.3015        0.61970 - 0.7942
## Southwest         0.28446 - 0.5071           0.00000 - 0.1137        0.44228 - 0.6668
## Central           0.00000 - 0.0000           0.05835 - 0.1209        0.53869 - 0.7024
## East              0.00000 - 0.0000           0.00000 - 0.0000        0.00000 - 0.0000
##                   South America   
## Arctic            0.00000 - 0.0000
## Pacific Northwest 0.00000 - 0.0000
## Southwest         0.00000 - 0.0000
## Central           0.22664 - 0.3799
## East              1.00000 - 1.0000
## 
## This is a subset of what's available inside this estMigConnectivity output.
## For more info, try ?estTransition or str(obj_name, max.level = 2).

Plot the results using the built-in plotting function

par(mar = c(2,3,0,0))
plot(psiYEWA, legend = "top", cex = 0.4)
Estimated transition probabilities of the Yellow Warbler between breeding and nonbreeding periods
Estimated transition probabilities of the Yellow Warbler between breeding and nonbreeding periods

Literature Cited

Cohen, E. B., J. A. Hostetler, M. T. Hallworth, C. S. Rushing, T. S. Sillett, and P. P. Marra. 2018. Quantifying the strength of migratory connectivity. Methods in Ecology and Evolution 9:513–524.