# Sample script # Distance analyses (Methods 1 to 23) ------------------------------------- # This script contains the coding information for performing the analyses of the distances of fledglings to their corresponding mothers (i.e., reference benchmark). This is also applicable to some of the analyses concerning the distance of fledglings to their natal nests. Methods 1 to 23 are related with the distances to nests, so this basic script can be modified to examine any of these methods (e.g., total distances, c.v. of daily distances, thresholds...) # This script has "dummy" GPS information, due to the sensitivity of the location data of both the individuals and nests of an endangered species such as the Chaco eagle (Buteogallus coronatus). Thus, the distances represented here (along with the "example_data.csv"), do not show the actual results of the paper, but are useful for anyone willing to carry out similar analyses. # Data was first downloaded from movebank.org. In each case, we separately downloaded the location data of both mother and its corresponding fledgling, and made them match temporally (i.e., date and hour). Afterwards, we randomly chose one location (for both individuals) per day, from the central hours of the day (i.e., 1000 H – 1400 H), as the daily location to measure the daily distance between the mother and the fledgling. This was done to avoid very early (or late) daily locations when the fledgling (and the adult) would presumably roost near the nest or nearby areas (Tapia & Zuberogoitia, 2018), thus underestimating their distances moved. After, we made a new variable ("days_pfdp"), which counts the days, from the very first flight of the Chaco eagle fledgling from its nest (i.e., days after fledgling). # Tapia, L., & Zuberogoitia, I. (2018). Breeding and nesting biology in raptors. Birds of Prey: Biology and conservation in the XXI century, 63-94. # For measuring the distances of the fledgling to its mother, we followed a similar script to that proposed here: https://stackoverflow.com/questions/22184101/calculate-distance-between-each-pair-of-coordinates-in-wide-dataframe library(geosphere) library(dplyr) library(sp) library(ggplot2) library(gcookbook) library(cowplot) #data, one example eagle1 <- read.csv("C:/Users/usuario/Desktop/example_data.csv", header=TRUE, sep=";", dec=".") # Distance with mother (i.e., reference benchmark) attach(eagle1) str(eagle1) ll <- c("lat_fledgling", "long_fledgling") coords <- eagle1[ll] attach(eagle1) eagle1$dist_mother <- sapply(1:nrow(eagle1),function(i) spDistsN1(as.matrix(eagle1[i,2:3]),as.matrix(eagle1[i,4:5]),longlat=T)) attach(eagle1) # We then visually determined the onset of dispersal by looking at the locations ggplot(eagle1, aes(x=days_pfdp, y=dist_mother)) + geom_point(size=1.5, shape=21, col="black") + xlim(0, max(eagle1$days_pfdp)) + xlab("Days after fledgling") + ylim(0, max(eagle1$dist_mother)) + ylab("Distance (km)") + theme(plot.title=element_text(face="bold", size=14, hjust=0.5)) + theme(axis.title.x=element_text(face="bold", size=12)) + theme(axis.title.y=element_text(face="bold", size=12)) + theme(axis.text.x=element_text(size=11)) + theme(axis.text.y=element_text(size=11)) + theme(axis.line = element_line(colour = "black"), panel.grid.major = element_blank(), panel.grid.minor = element_blank(), panel.border = element_blank(), panel.background = element_blank()) # Ranging areas analyses (Methods 23 to 31)----------------------------------- # Now, this is the base script to run ctmmweb app. This web application, based on the ctmm package, is what we have used for visualizing movement data, excluding outliers and carrying out the analyses on distances traveled, weekly ranging areas, and area overlaps. Methods 24 to 31 are based on the calculations of this program. As in the other script, data was first downloaded from movebank.org. # This script is copied from the course Animove: Statistics for Animal Tracking Data, by the Smithsonian-Mason School of Conservation, and its theoretical background can be found in Calabrese et al. (2021). Since the web app does not include any script, and since the report generated by this program for each eagle includes sensitive information (nest areas, location of fledglings...), we did not include any additional information. Anyway, the underlying codes of the different functions of the ctmmweb shinny app can be found here: https://github.com/ctmm-initiative/ctmmweb , under the folder "R": https://github.com/ctmm-initiative/ctmmweb/tree/master/R #Calabrese, J. M., Fleming, C. H., Noonan, M. J., & Dong, X. (2021). ctmmweb: A graphical user interface for autocorrelation‐informed home range estimation. Wildlife Society Bulletin, 45(1), 162-169. #This script installs the packages required for the ctmm course #First it installs the necessary packages from CRAN #Then it installs ctmm and the web app from github #Get list of installed packages avail <- installed.packages()[, 1] #Make a list of the required packages needed <- c("bit64", "fftw", "sp", "devtools", "move") #Check which ones are missing install <- needed[!needed %in% avail] #And then install them if necessary if (length(install) > 0) { install.packages(install) } #Finally, install the ctmm from github devtools::install_github("ctmm-initiative/ctmm") #And the web app from github devtools::install_github("ctmm-initiative/ctmmweb") library(move) library(ctmm) library(ctmmweb) app() #An example of the weekly home ranges (95% AKDE - Autocorrelated Kernel Density Estimation) is included in the Dryad database, named "example_areas.csv" # Another way to determine these ranging areas is by manually using the code for the calculation of the AKDEs, as is explained below: # "hrs" should be location points of all eagles from our study downloaded directly from movebank as a .csv file. We cannot include this data because this is an endangered species whose location points are sensible (they are near breeding areas) eagle <- read.csv("hrs.csv", sep=",") # We now select only those rows with gps (and not argos doppler) information, because these locations are more accurate eagle <- eagle[which(eagle$sensor.type=="gps"),] # Now we choose the columns of interest (location longitude, latitude, tag.local.identifier, etc.) eagle_sel <- eagle[,c(1,3,4,5,36)] # Create telemetry object BC.CTMM <- as.telemetry(eagle_sel) PROJ <- projection(BC.CTMM) eagle_sel$timestamp <- as.POSIXct(eagle_sel$timestamp,tz="EST") # We now choose one eagle ("dummy"), and a weekly interval ("dummy"), which should be how one can calculate weekly ranging areas manually. This following procedure should then be done with every week, for every individual. M <-subset(eagle_sel,tag.local.identifier==11111) #dummy number# # Subset the data by week. This can also be done with a loop M <- subset(M, timestamp >= as.POSIXct('2012-01-22 09:00:00') & timestamp <= as.POSIXct('2012-01-29 9:00')) # Create telemetry object M.CTMM <- as.telemetry(M, projection = PROJ) plot(M.CTMM) # Look for outliers Mout <- outlie(M.CTMM) plot(Mout) Moutliers <- which(Mout$speed>1) # This number is not real, it should be adjusted to the biology of the species. For instance, would we consider an outlier a speed of 1 km/h in eagles? Probably not. Moutliers1 <- which(Mout$distance>1) # Same idea than above # Once the outliers are identified, they can be removed M.CTMM <-M.CTMM[-Moutliers,] M.CTMM <-M.CTMM[-Moutliers1,] # Variogram creation, and visual inspection. See references vgM <- variogram(M.CTMM) plot(vgM) gM <- variogram.fit(vgM, interactive=FALSE) gM$error <- TRUE plot(vgM,gM) control <- list(method='pNewton') # Fit movement model fM <- ctmm.select(M.CTMM, gM,control=control,trace=TRUE) summary(fM) # Control for residuals rM <- residuals(M.CTMM, fM) plot(rM) # Create AKDE object and examine values. These values are the ones used in the methods proposed (weekly ranging areas). HRM <- akde(M.CTMM,fM) summary(HRM) windows() plot(M.CTMM,UD=HRM) #The overlap should be done with all pairs of telemetry objects and fitted models (of every week). Let's say that M1.CTMM is the telemetry object that corresponds to the following week list_tel <- list(M.CTMM,M1.CTMM) list_fit <- list(fM,fM1) UD_both <- akde(list_tel,list_fit) overlap(UD_both) plot(UD_both) # REFERENCES USED FOR CTMM ANALYSES # Fleming CH, Fagan WF, Mueller T, Olson KA, Leimgruber P, Calabrese JM. Rigorous home range estimation with movement data: a new autocorrelated kernel density estimator. Ecology. 2015;96(5):1182–8. https://doi.org/10.1890/14-2010.1 # Calabrese JM, Fleming CH, Gurarie E. ctmm: an r package for analyzing animal relocation data as a continuous‐time stochastic process. Methods Ecol Evol. 2016;7(9):1124–32. https://doi.org/10.1111/2041-210X.12559 # Calabrese JM, Fleming CH, Noonan MJ, Dong X. ctmmweb: A Graphical User Interface for Autocorrelation‐Informed Home Range Estimation. Wildlife Soc B. 2021;45(1):162–9. https://doi.org/10.1002/wsb.1154 # X. Dong, C.H. Fleming, M.J. Noonan, and J.M. Calabrese. 2018. ctmmweb: A Shiny web app for the ctmm movement analysis package. https://github.com/ctmm-initiative/ctmmweb