DOI: 10.5061/dryad.msbcc2gbg
title: Density-dependence and territorial competitors can modulate parrotfish social foraging and herbivory on coral reefs

description: Social context can modify the behaviour of animals, influencing how they
 interact with their environment – potentially cascading to effects on
 ecosystem functions. However, typical proxies for functions, such as
 biomass or densities, may not completely capture this behavioural
 variation. We examined how grouping behaviour of an abundant parrotfish
 species, Chlorurus sordidus, influences the critical function of herbivory
 on coral reefs in the Lakshadweep Archipelago and evaluated the role of
 density-dependence and territorial aggression from competitors in driving
 group formation in the entire herbivorous fish assemblage. Bite rates
 increased with increasing group sizes and decreased with aggressive
 encounters, with parrotfish in larger groups consuming about 80% more
 algae per capita than solitary individuals.  Group foragers also
 benefitted marginally from reduced territorial aggression from competing
 herbivores. The propensities of herbivores to form groups, and their group
 sizes were positively density dependent, and, to a lesser extent, were
 driven by access to resources defended by territorial competitors. Our
 study highlights the importance of incorporating behavioural variation in
 assessments and predictive frameworks of ecosystem functioning. As our
 results indicate, for social animals, key ecosystem functions are
 particularly sensitive to animal densities and interspecific interactions,
 especially when individual function varies with social context.
description: # README file for "Density dependence and territorial competitors can
 modulate parrotfish social foraging and herbivory on coral reefs"
 Access this dataset on Dryad (10.5061/dryad.msbcc2gbg) # General outline
 This file is a guide to the code, data, and metadata for the above
 mentioned paper. It contains instructions to replicate the analysis. The
 data contains **behavioural observations of** ***Chlorurus sordidus***
 **and timed swims for the herbivore assemblage on the coral reefs of the
 Lakshdaweep Archipelago.** * Extract the sub-folders from the file
 "data.zip". * All raw unprocessed data is contained in the
 folder "raw_data". * The cleaned dataset, ready for analysis is
 in the folder "analysis_data". * The folder "scripts"
 (uploaded on Zenodo in the folder code, with also contains the R project)
 contains all the R code used in the analysis. We recommend running it
 through the R project "grouping_herbivory.Rproj". * **Put the R
 project, the folder "scripts", and the two data folders
 "raw_data" and "analysis_data" in the same
 directory/folder**, then proceed with the scripts through the R project.
 To replicate the modelling and results, download the entire folder, then
 open the R project "grouping_herbivory.Rproj". From here,
 sequentially run the scripts "03_.." to "07_.." to
 skip the data cleaning and get straight to the analysis. # Code All code
 accompanying this data is uploaded on Zenodo. **Folder
 "scripts"** contains: *
 "01_data_cleaning_behaviour.Rmd" and
 "02_data_cleaning_grouping.Rmd" which take raw data from the
 folder "raw_data", subset the data used for analysis, calculate
 the metrics required for analysis, and export it to the folder
 "analysis_data". These scripts can be skipped if only the
 modelling is to be replicated. *
 "03_behaviour_sordidus_analysis.Rmd" contains code for the
 individual-level behavioural analysis - including code for running the
 models, and generating the figures. The data used is from the focal
 behavioural observations of *Chlorurus sordidus*. *
 "04_grouping_analysis.Rmd" contains code for the herbivore
 assemblage scale analysis - including code for running the models, and
 generating the figures. The data used is from timed swims. *
 "05_network_plot.Rmd" contains code to make the network plot in
 figure 3 of the main text from the timed swim data. *
 "06_dag_visualisation.Rmd" contains code to plot the directed
 acyclic graphs (DAGs) with some prettier visualisation. *
 "07_sensitivity_analyses.Rmd" contains the code to perform the
 sensitivity analyses presented in the electronic supplementary material. R
 version 4.4.1 was used for all analysis. # Description of data and file
 structure **Folder "analysis_data"** contains the cleaned data.
 Details of specific sheets are below: 1. **fishbase_ab_traits.csv**
 contains fish traits values for fish from FishBase (only FG column used in
 analysis). Refer to FishBase for detailed column descriptions. Columns:\
 Species - species ID\ Observed mean size (cm) - observed mean length in
 centimetres\ a - constant in the formula for biomass, weight = a *
 length^b\ b - constant in the formula for biomass, weight = a * length^b\
 Common_fam - common English name of family\ Family - family name\ FG -
 feeding functional group\ Homerange - homerange size category\ Schooling -
 grouping (schooling tendency) category; SmallG, MedG, and LargeG are
 small, medium, and large groups respectively\ Wcposition - water column
 position 2. **sordidus_context.csv** contains data from focal behavioural
 observations of *Chlorurus sordidus* required for model 1 and model 2 in
 the paper. Each row corresponds to a focal individual. Columns:\ shoal_id
 - identification number for the group the focal individual was part of\
 ind_id - identification number for the focal individual\ date - date in
 mm/dd/yyyy\ site - site name\ island - island name\ species - species of
 focal individual\ sex - f refers to initial phase (IP) individuals; m
 refers to terminal phase (TP) - only IP were used\ body_size - total
 length of individual in cm\ species_richness - number of species in the
 group\ shoal_size - group size\ duration - duration of observation in
 seconds\ total_bites - total bites taken by focal individual during the
 observation period\ mean_bout - mean number of bites in a foraging bout
 (total bites/total number of bouts)\ sd_bites - standard deviation of
 number of bites in a bout\ bite_rate - number of bites per minute (total
 bites/observation duration in minutes)\ prop_s - proportion of individuals
 in the group that were *Chlorurus sordidus\ *shoal_comp - shoal
 composition; "mono" if all were same species and
 "multi" if there was at least one individual other than *C.
 sordidus\ *shoal_comp95 - monospecific or multi-species group at 95%
 threshold; "mono" if more than 95% individuals were *C.
 sordidus\ *shoal_comp80 - monospecific or multi-species group at 80%
 threshold; "mono" if more than 80% individuals were *C.
 sordidus\ *shoal_comp60 - monospecific or multi-species group at 60%
 threshold; "mono" if more than 60% individuals were *C.
 sordidus\ *shoal_comp50 - monospecific or multi-species group at 50%
 threshold; "mono" if more than 50% individuals were *C.
 sordidus\ *algae - average percentage algal cover over point counts\
 structure - average of structural complexity ranked on a scale of 0-5 on
 the point counts\ encounter_rate - number of aggressive encounters
 received by the focal individual per minute\ damselfish - average number
 of territorial damselfish in the point counts\ surgeonfish - average
 number of territorial acanthurids in the point counts\ total_aggressors -
 sum of damselfish and surgeonfish columns\ predators - number of predators
 &gt; 35cm at the site from separate 50 m belt transects\ shoal_size_site -
 mean of shoal_size column for a site\ encounter_rate_site - mean of
 encounter_rate column for a site\ algae_site - mean of algae column for a
 site\ structure_site - mean of structure column for a site 3.
 **timed_swims_shoals.csv** contains data on group composition of herbivore
 groups from the timed swims used in the herbivore assemblage scale
 analysis of group composition presented in figure 3. Columns:\ date - date
 of observation in m/dd/yyyy\ site - name of site of observation\ island -
 island name\ observer - observer name\ transect_no - transect ID at a
 site\ depth_class - depth class for the timed swim; "shallow" is
 6-8 m depth and "deep" is 10-12 m depth\ species - species
 scientific name\ size - estimated total length in cm\ count - number of
 individuals of a species and length\ shoal_no - unique ID given to each
 observed group on a timed swim\ the last unnamed column contains used for
 remarks, not used in analysis 4. **transects.csv** contains data of the
 entire herbivore assemblage observed from the timed swims used in the
 herbivore assemblage scale analysis in model 3 and model 4. Columns:\ site
 - site name\ transect_no - timed swim ID at the site\ total_herbivores -
 total number of herbivores observed on a timed swim\ territorials - total
 number of territorial herbivores on a timed swim\ non_territorials - total
 number of non-territorial herbivores on a timed swim\ damsel_count - sum
 of territorial damselfish counts from three point counts along a transect
 n_predators - number of predators &gt;35 cm on a timed swim\
 total_shoaling - total number of grouping individuals on a timed swim\
 mean_shoal_size - mean group size on a timed swim\ n_shoals - number of
 groups observed on a timed swim\ structure - mean of visually estimated
 structural complexity (ranked on a scale of 0-5) averaged over three point
 counts along a timed swim\ algal cover - mean of visually estimated algal
 cover averaged over 3 point counts on a swim\ algal height - mean algal
 height averaged over 3 point counts ranked from 1-3 (visually estimated);
 not used in analysis\ algae - same as algal_cover column\
 proportion_shoaling - porportion of the herbivore assemblage that was
 forming groups; calculated from data as total_shoaling/total_herbivores;
 referred to as grouping propensity\ total_territorials - total territorial
 individuals on a timed swim (swim + point counts)\ resource_defence -
 calculated as algae/total_territorials; not used in analysis\
 resource_defence_cover - same as resource_defence column; not used in
 analysis\ non_territorials_site - mean of the non_territorial column for a
 site\ total_territorials_site - mean of the total_territorial column for a
 site The folder analysis_data has **sub-folder "dag"** which
 contains .xlsx files having details on nodes and edges of the DAGs for
 visualisation used in the script "06_dag_visualisation.Rmd". 1.
 **dag_behaviour_edges.xlsx** contains edge details for the behaviour DAG.
 Each row represents an arrow in the DAG. Columns:\ from - variable name
 from where arrow in DAG originates\ to - variable name to which the arrow
 is directed\ interest - whether the relationship is of interest for
 analysis or not; y - yes; n - no\ type - type of relationship; a variable
 coded for visualization\ weight - weight of the arrow for visualisation\
 color - colour (hexadecimal code) of the arrow for visualisation 2.
 **dag_behaviour_nodes.xlsx** contains node details for the behaviour DAG.
 Columns:\ id - name of the variable/node used in the code\ variable -
 display name of the variable for visualisation\ type - whether the
 variable was observed or unobserved in the study 3.
 **dag_grouping_edges.xlsx** contains edge details for the herbivore
 grouping DAG. Each row represents an arrow in the DAG. Columns:\ from -
 variable name from where arrow in DAG originates\ to - variable name to
 which the arrow is directed\ interest - whether the relationship is of
 interest for analysis or not; y - yes; n - no\ type - type of
 relationship; a variable coded for visualization\ weight - weight of the
 arrow for visualisation\ color - colour (hexadecimal code) of the arrow
 for visualisation 4. **dag_grouping_nodes.xlsx** contains node details for
 the herbivore grouping DAG. Columns:\ id - name of the variable/node used
 in the code\ variable - display name of the variable for visualisation\
 type - whether the variable was observed or unobserved in the study
 **Folder raw_data** contains all the collected raw data, irrespective of
 whether it was used in analysis or not (scipts 01_.. and 02_.. do the
 filtering and cleaning). Details of specific sheets are below: 1.
 **individuals.csv** contains details of focal individuals from all
 behavioural observations. Columns:\ shoal_id - a unique ID/ number
 assigned to each group\ ind_id - a unique ID/number assigned to each
 individual, no two individuals have the same ind_id\ date - date of
 observation in mm/dd/yyyy\ site - site name\ island - atoll name\ video -
 video file name where available, discarded this method because esimating
 in 2D was very difficult, structure caused problems and hinderance, and it
 was just inefficient; empty cells in this column indicate that videos were
 not recorded for those observations\ duration - duration of observation in
 seconds\ species - focal individual species identity\ sex - phase of
 parrotfish individuals; "f" is intial phase for parrotfish,
 "m" is terminal phase for parrotfish, "0" for
 acanthurids\ body_size - total length estimated in centimetres\
 shoal_mono_multi - whether the group has one or more species;
 "multi" if there were more than one species in the group,
 "mono" if the group had only one species\ species richness -
 number of species in the group\ shoal_size - total number of individuals
 in the group\ use - preliminary decisision of whether to use the
 observation or not, "n" if discarded due to quality issues or if
 measurement error was perceived to be high, "y" if initial
 decision was to use the observation for analysis\ context - whether
 context data was collected using point counts, "y" for yes and
 "n" for no; context data includes algal cover, territorial
 species, structure. Did not collect during initial sampling so those
 observations were not used.\ observer - observer name; not noted for
 initial observations, probably HT, but those observations were not used\
 remarks - remarks written while collecting or entering data\ the last
 three un-named columns were also used for remarks 2. **encounters.csv**
 contains data on aggressive encounters received by the focal individual
 and aggression directed to others by the focal individual during focal
 follows. Columns:\ shoal_id - a unique ID/ number assigned to each group\
 ind_id - a unique ID/number assigned to each individual, no two
 individuals have the same ind_id\ date - date of observation in
 mm/dd/yyyy\ site - site name\ island - atoll name\ focal_species - species
 of focal individual\ other_species - species identity of the other
 individual involved in the aggressive encounter; "0" when the
 focal individual had no aggressive encounters in the observation period\
 focal_aggressor_aggressee - whether the focal individual was the aggressor
 or received aggression; "ee" when the focal individual received
 the aggression; "or" if it was the aggressor; and "0"
 if the observation had no aggressive encounters\ encounters - total number
 aggressive encounters for that observation\ sex_other_species - phase of
 individual if it was parrotfish, "m" is terminal phase and
 "f" is initial phase\ remarks - remarks given while observing or
 entering data 3. **shoal.csv** contains data on group composition of the
 groups that the focal individuals were a part of from focal behavioural
 observations. Each row is an individual in a group. Columns:\ shoal_id - a
 unique ID/ number assigned to each group\ ind_id - a unique ID/number
 assigned to each individual, no two individuals have the same ind_id\ date
 - date of observation in mm/dd/yyyy\ site - site name\ island - atoll
 name\ video - video file name where available, discarded this method
 because esimating in 2D was very difficult, structure caused problems and
 hinderance, and it was just inefficient; empty cells in this column
 indicate that videos were not recorded for those observations\ duration -
 duration of observation in seconds\ species - focal individual species
 identity\ sex - phase of parrotfish individuals; "f" is intial
 phase for parrotfish, "m" is terminal phase for parrotfish,
 "0" for acanthurids\ body_size - total length estimated in
 centimetres\ shoal_mono_multi - whether the group has one or more species;
 "multi" if there were more than one species in the group,
 "mono" if the group had only one species\ bite_obs - whether
 that individual was observed for bite rates - "y" is yes,
 "n" is no\ remarks - remarks given while observing or entering
 data 4. **bouts.csv** has data on each feeding bout of a focal individual
 during focal observations. Each row is a feeding bout.\ shoal_id - a
 unique ID/ number assigned to each group\ ind_id - a unique ID/number
 assigned to each individual, no two individuals have the same ind_id\ date
 - date of observation in mm/dd/yyyy\ site - site name\ island - atoll
 name\ video - video file name where available, discarded this method
 because esimating in 2D was very difficult, structure caused problems and
 hinderance, and it was just inefficient; empty cells in this column
 indicate that videos were not recorded for those observations\ sex - phase
 of parrotfish individuals; "f" is intial phase for parrotfish,
 "m" is terminal phase for parrotfish, "0" for
 acanthurids\ duration - duration of observation in seconds\ species -
 focal individual species identity\ body_size - total length estimated in
 centimetres\ bites - number of bites taken in the feeding bout\ the
 un-named column at the end was used for remarks 5.
 **benthic_point_counts.csv** has data from benthic data collected on the
 point counts conducted during focal observations.\ shoal_id - a unique ID/
 number assigned to each group\ ind_id - a unique ID/number assigned to
 each individual, no two individuals have the same ind_id\ date - date of
 observation in mm/dd/yyyy\ island - atoll name\ site - site name\ observer
 - intials of observer\ point - the number of point count for that group, 1
 is first, 2 is second and so on\ structure - visual estimate of structural
 complexity on a scale of 0 to 5\ algal_cover - visual estimate of
 percentage algal cover\ algal_height - visual estimate of algal height
 ranked on a scale of 1 to 3, not used in analysis\ notes - remarks written
 during observation or while entering data 6. **fish_point_counts.csv** has
 data from point counts of fish during focal behavioural observations.
 Columns:\ shoal_id - a unique ID/ number assigned to each group\ ind_id -
 a unique ID/number assigned to each individual, no two individuals have
 the same ind_id\ date - date of observation in mm/dd/yyyy\ island - atoll
 name\ site - site name\ observer - intials of observer\ point - the number
 of point count for that group, 1 is first, 2 is second and so on\ species
 - species identity\ size - estimated total length in centimetres\ count -
 number of fish of a species and size on a point count 7.
 **fishbase_ab_traits.csv** ontains fish traits values for fish from
 FishBase (only FG column used in analysis). Refer to FishBase for detailed
 column descriptions. Same as in "analysis_data". Columns:\
 Species - species ID\ Observed mean size (cm) - observed mean length in
 centimetres\ a - constant in the formula for biomass, weight = a *
 length^b\ b - constant in the formula for biomass, weight = a * length^b\
 Common_fam - common English name of family\ Family - family name\ FG -
 feeding functional group\ Homerange - homerange size category\ Schooling -
 grouping (schooling tendency) category; SmallG, MedG, and LargeG are
 small, medium, and large groups respectively\ Wcposition - water column
 position 8. **timed_swims_herbivores.csv** contains data describing all
 herbivores observed on the timed swims. Columns:\ date - date of
 observation in mm/dd/yyyy\ site - site name\ island - atoll name\ observer
 - initials of observer collecting data\ transect_no - timed swim ID at the
 site\ depth - depth at which the timed swim was conducted; in metres\
 depth_class - depth class (deep or shallow) assigned to the timed swim\
 species - species identity of fish\ size - estimated total length of fish
 in centimetres\ count - number of fish of a species and size on a timed
 swim\ shoal_sorting - a column created while entering data from paper for
 convenience in noting down group compositions and creating the
 timed_swims_groups.csv datasheet; it was only used for sorting individuals
 into groups and arbitrary character values were assigned to make it clear
 that the consecutive entries belonged to the same group; this column was
 not used in analysis and its contents are irrelevant to the data; this
 column intentionally contains empty cells to indicate that the individuals
 in those rows were not part of any groups; for example - a series of
 consecutive rows with empty columns indicates that those individuals were
 not in groups, this might be followed by two rows with the values
 "s" indicating that those individuals were in the same group, if
 this group was followed by another group right after, it would be entered
 as "s2" to indicate that those individuals were part of a
 different group; if this observation was followed by individuals outside
 groups, it would be indicated by empty columns and the naming (s/s2) would
 reset from the beginning\ comments - remarks given while collecting or
 entering data 9. **timed_swims_groups.csv** contains group composition
 data from the timed swims for the subset of the herbivore assemblage that
 was observed in groups. The columns "site" and
 "transect_no" will correspond to the same columns in all other
 timed swim data and can be together used as unique identifiers for a swim.
 Columns:\ date - date of observation in mm/dd/yyyy\ site - site name\
 island - atoll name\ observer - initials of observer collecting data\
 transect_no - timed swim ID at the site\ depth_class - depth class (deep
 or shallow) assigned to the timed swim\ species - species identity of
 fish\ size - estimated total length of fish in centimetres\ count - number
 of fish of a species and size on a timed swim\ shoal_no - unique number
 assigned to a timed swim within a site\ comments - remarks given while
 collecting or entering data 10. **timed_swims_benthic.csv** contains data
 on benthic composition collected at three point counts along each timed
 swim. Colums:\ date - date of observation in mm/dd/yyyy\ island - atoll
 name\ site - site name\ observer - intials of observer\ depth_class -
 depth class (deep or shallow) assigned to the timed swim\ transect_no -
 timed swim ID at the site\ depth - depth at which the timed swim was
 conducted; in metres\ point_count - the number of point count for that
 timed swim, 1 is the first, 2 is the second and so on\ structure - visual
 estimate of structural complexity on a scale of 0 to 5\ algal_cover -
 visual estimate of percentage algal cover\ algal_height - visual estimate
 of algal height ranked on a scale of 1 to 3, not used in analysis 11.
 **timed_swims_damsel_point_counts.csv** contains data on the damselfish
 counted at point counts along the timed swims.\ date - date of observation
 in mm/dd/yyyy\ island - atoll name\ site - site name\ observer - intials
 of observer\ depth_class - depth class (deep or shallow) assigned to the
 timed swim\ transect_no - timed swim ID at the site\ depth - depth at
 which the timed swim was conducted; in metres\ point_count - the number of
 point count for that timed swim, 1 is the first, 2 is the second and so
 on\ species - species identity of fish\ size - estimated total length of
 fish in centimetres\ count - number of individuals of a species and size
 at a point count 12. **timed_swims_predators.csv** contains data on
 piscivorous and invertivorous fish observed on the timed swims. Columns:\
 date - date of observation in mm/dd/yyyy\ island - atoll name\ site - site
 name\ observer - intials of observer\ habitat - whether the timed swim was
 a the reef slope or shelf; not noted at all sites and not used in
 analysis\ depth_class - depth class (deep or shallow) assigned to the
 timed swim\ transect_no - timed swim ID at the site\ depth - depth at
 which the timed swim was conducted; in metres\ point_count - the number of
 point count for that timed swim, 1 is the first, 2 is the second and so
 on\ species - species identity of fish\ size - estimated total length of
 fish in centimetres\ count - number of individuals of a species and size
 at a point count 13. **fish_transect_final.csv** contains fish community
 data from underwater visual censuses (UVCs) on 50 m belt transects (5 m on
 each side). Columns:\ date - date of observation in mm/dd/yyyy\ island -
 atoll name\ site - site name\ transect_no - belt transect ID at the site;
 values starting with "d" correspond to transects in the deep
 depth class and values starting with "s" correspond to transects
 in the shallow depth class\ size is in cm\ species - species identity of
 fish\ size - estimated total length of fish in centimetres\ count - number
 of individuals of a species and size on a transect\ observer - initials of
 the observer\ area - area covered on the belt transect in square metres\
 aspect - aspect of the atoll at which the site is located; east/west 14.
 **dag_behaviour_edges.xlsx** contains edge details for the behaviour DAG.
 Each row represents an arrow in the DAG. Same as in the sub-folder
 "dag" in "analysis_data". Columns:\ from - variable
 name from where arrow in DAG originates\ to - variable name to which the
 arrow is directed\ interest - whether the relationship is of interest for
 analysis or not; y - yes; n - no\ type - type of relationship; a variable
 coded for visualization\ weight - weight of the arrow for visualisation\
 color - colour (hexadecimal code) of the arrow for visualisation 15.
 **dag_behaviour_nodes.xlsx** contains node details for the behaviour DAG.
 Same as in the sub-folder "dag" in "analysis_data".
 Columns:\ id - name of the variable/node used in the code\ variable -
 display name of the variable for visualisation\ type - whether the
 variable was observed or unobserved in the study 16.
 **dag_grouping_edges.xlsx** contains edge details for the herbivore
 grouping DAG. Each row represents an arrow in the DAG. Same as in the
 sub-folder "dag" in "analysis_data". Columns:\ from -
 variable name from where arrow in DAG originates\ to - variable name to
 which the arrow is directed\ interest - whether the relationship is of
 interest for analysis or not; y - yes; n - no\ type - type of
 relationship; a variable coded for visualization\ weight - weight of the
 arrow for visualisation\ color - colour (hexadecimal code) of the arrow
 for visualisation 17. **dag_grouping_nodes.xlsx** contains node details
 for the herbivore grouping DAG. Same as in the sub-folder "dag"
 in "analysis_data". Columns:\ id - name of the variable/node
 used in the code\ variable - display name of the variable for
 visualisation\ type - whether the variable was observed or unobserved in
 the study