This project analyzed the relation between social connectedness and hierarchically embedded scales of movement using both real and simulated data of the common vampire bat. Included are the raw empirical data, simulated data, NetLogo models, and R code used to analyze the data and create graphs.
This is a repository of all data files and scripts used to study how movement at multiple, hierarchically embedded scales of movement affects the centrality of vampire bats. For a full description, please see the associated paper.
All necessary R packages and NetLogo extensions are listed at the top of each R and NetLogo file, respectively. Filepaths will need to be edited to properly run code.
The file "roosting_information.csv" contains observations of roost-level associations of wild common vampire bats recorded in a previous study (see Reciprocal Food Sharing in the Vampire Bat" and "The Social Organization of the Common Vampire Bat: I. Pattern and Cause of Association," both by Gerald S. Wilkinson), noting the time, place, and identity of bats in particular tree roosts on each observation. The file "roost_switching.R" modifies the original dataset to check whether a change in roost occurred on each observation while monitoring the time since last roost switch for each bat. This is outputted as the "roost_switching.csv" file.
The file "clustering_information.Rdata" (or csv) shows the positions of captive common vampire bats in different corners of a flight cage in a captive, recorded at regular intervals (see "Non-Kin Adoption in the Common Vampire Bat," by Imran Razik, Bridget K. G. Brown, Rachel A. Page, and Gerald G. Carter). The "cluster_switching.R" code modifies the original dataset to denote the position of each bat at each recording period, marking whether a cluster switch occurred and the time since last switch for each bat. This is outputted as "cluster_switching.csv."
Finally, the "events.Rdata" file shows a log of the grooming events for captive vampire bats (recorded for "Non-Kin Adoption in the Common Vampire Bat," by Imran Razik, Bridget K. G. Brown, Rachel A. Page, and Gerald G. Carter). The "partner_switching.R" code can then be run marks whether a bat switched partners on each grooming event, and measures time since last partner switch for each bat. This data is outputted as "partner_switching.csv."
The "roost_switching.csv," "cluster_switching.csv," and "partner_switching.csv" files are required to run the "get_switch_prob-03.R," which creates three datasets that show the probability of switching at a particular scale based on time since last switch at that scale. In these datasets, rows represent different individual vampire bats from empirical data sets, and each column represents a different time since last switch (days for roost switching, hour for cluster switching, minute for partner switching). These files are outputted as "roost_switching_probs.csv," "cluster_switching_probs.csv," and "partner_switching_probs.csv."
The data from "roost_switching_probs.csv," "cluster_switching_probs.csv," and "partner_switching_probs.csv" have all been manually inputted into the relevant NetLogo models that require them as an input. The models, "roost-correlated.nlogo" and "roost-uncorrelated.nlogo," run an agent-based model where individual vampire bats move at empirically-derived roost-switching, cluster-switching, and partner-switching rates, while the number of switches at each scale and the number of grooming partners is monitored by bat. These models differ only in that switching rates are correlated is "roost-correlateed.nlogo," and not correlated in "roost-uncorrelated.nlogo" (see Supplement of research paper for details). The number of bats (100 or 200) needs to be manually manipulated by entering the code and changing the value of "Bats." Additionally, whether switching probabilities are variable by bat can be edited in the "roost-uncorrelated.R" code by commenting out "set roost-switch-vector matrix:get-row roost-switch-matrix b" and leaving in "set roost-switch-vector matrix:get-row rs-mean-matrix 0" (or cluster, partner) in the setup section to make that switching type non-variable (or vice versa, to make that switcing probability variable). This code generates association data, showing where vampire bats reside each minute, and interaction data, showing a list of all grooming interactions each bat had during the course of the simulation.
1,000 association and interaction files have been uploaded "associations.zip," and "interactions.zip." Interaction and association files labeled 0 - 99 are from simulations with uncorrelated movement rates, 200 bats, and inidividually variable movement rates at all scales. Interaction and association files labeled 100 - 199 are from simulations with uncorrelated movement rates, 200 bats, and inidividually variable roost-switching rates. Interaction and association files labeled 200 - 299 are from simulations with uncorrelated movement rates, 200 bats, and inidividually variable cluster-switching rates. Interaction and association files labeled 300 - 399 are from simulations with uncorrelated movement rates, 200 bats, and inidividually variable partner-switching rates. Interaction and association files labeled 400 - 499 are from simulations with correlated movement rates, 200 bats, and inidividually variable roost-switching rates. Interaction and association files labeled 500 - 599 are from simulations with uncorrelated movement rates, 100 bats, and inidividually variable movement rates at all scales. Interaction and association files labeled 600 - 699 are from simulations with uncorrelated movement rates, 100 bats, and inidividually variable roost-switching rates. Interaction and association files labeled 700 - 799 are from simulations with uncorrelated movement rates, 100 bats, and inidividually variable cluster-switching rates. Interaction and association files labeled 800 - 899 are from simulations with uncorrelated movement rates, 100 bats, and inidividually variable partner-switching rates. Interaction and association files labeled 900 - 999 are from simulations with correlated movement rates, 100 bats, and inidividually variable roost-switching rates
The model "roost-no-scales.nlogo" removes scales of movement,puts all bats in the same cluster, only allowing partner switching. The model "roost-nothing.nlogo" additionally gets rid of partner switching propensities, allowing bats to groom without byproduct partner fidelity. The former was used to generate "interactions2400.csv" and "interactions2401.csv." The latter was used to generate "interactions2402.csv" and "interactions2403.csv."
Two more NetLogo models were made, "roost-uncorrelated2.nlogo" and "roost-uncorrelated3.nlogo," which output a file showing the cluster and hour of each interaction or the roost and day of each interaction, respectively. The latter was used to generate "interactions2600.csv."
The file, "social_diff.R," uses both the empirical datasets mentioned aboved and the simulated interaction files to produce estimates of observed and expected social differentiation. Specifically, this file tests whether their is significant social differentiation in the empirical data, tests 50 random simulated datasets to test for significant social differentation, and also measures observed and expected differentations for "interactions548.csv" (a normal, randomly selected simulation), "interactions2400.csv" (no movement outside partner switching), "interactions2401.csv" (no variation in partner switching propensity), "interactions2402.csv" (no byproduct partner fidelity), and "interactions2403.csv" (simultaneous grooming). The observed social differentiations of these five latter simulations is outputted as "obs.csv," and the expected values as "exp548.csv," "exp2400.csv," "exp2401.csv," "exp2402.csv," and "exp2403.csv." A histogram of social differentiation in these five simulations is made in "FIGURE_S6.R," using the observed and expected social differentiations as an input. Further, "social_diff.R" also measures the observed ("obs2600.csv") and expected permutations of "interactions2600.csv," with unconstrained permutations ("exp2600a.csv"), permutations constrained within day and roost ("exp2600b.csv"), and permutations constrained within cluster and hour ("exp2600c.csv"). These files are used to create histograms of social differentiations via "FIGURE_S7.R."
Interactions files 0 - 999 are analyzed in via "scales_of_movement02.R," which analyzes a subsection of the interaction data files, and outputs the effects of switching rate (standardized coefficients of switching rate) on degree and pagerank. To use this code, the name of the output file and input files must be specified. We used the convention of analyzing by groups of 100 (see above). The file, "degree_est0.csv" was the output of analyzing "interactions0.csv" through "interactions99.csv," and "degree_est1.csv" was the output of analyzing "interaction100.csv" through "interactions199.csv" and so on. The files "degree_est0.csv" through "degree_est9.csv" are summarized by violin-box-and-whisker plots, visualizing the effect of movement rates on degree using "FIGURES_4_5_S2_S3." Similarly, "pagerank_est0.csv" through "pagerank_est9.csv" are visualized via violin-box-and-whisker plots via "FIGURES_S4_S5."
The file "consecutive.R" takes the original empirical datasets and finds the mean switching rate for every bat (outputted as "roost_sw.csv," "cluster_sw.csv," "partner_sw.csv," and "partners_sw2.csv," which is within-cluster partner switching). "FIGURE_2.R" plots this data as a histogram.
Then, "centrality.R" uses the datafiles generated by "consecutive.R," as well as "partner_switching.csv" and "transcribe.csv" ("Social grooming in the common vampire bat, Desmodus rotundus" by Gerald S. Wilkinson), to output data files ("gd.csv" for cluster and partner switching, "centrality.csv" for roost switching), which contain the outdegree centrality and switching rate for all bats we have data on both. "FIGURE_3.R" creates three linear model plots showing the relationship between degree centrality and movement rate at each scale.
"FIGURE_S1.R" requires "gd.csv" to create a linear model plot showing the relationship between within-cluster partner switching and cluster switching.