Drift Manipulation Study

Keane Flynn
11/24/2018

Skills used in this project

  1. Use of at least 5 dplyr verbs / functions
  2. Use of regular expressions
  3. Preparing processed data for archiving / publication

Drift Manipulation Study: Summer 2018 Angelo Coast Reserve

In this study, our lab cohort utilized modern three-dimensional videogrammetry technology known as VidSync (Neuswanger 2014) to better quantify a previous study carried out by Kurt Fausch, Shigeru Nakano, and Satoshi Kitano in the late 1990s. This study was carried out on Elder Creek on the UC Ecological Reserve in Branscomb, CA known as the Angelo Coast Reserve. While this experiment was carried out on multiple pools for the sake of reproducibility, the data observed and analyzed in this project will solely look at one pool nicknamed "Monolith Pool".

Utilization of the software VidSync to gather three-dimensional spatial data over time of the observed video sample

This study looked at the effects of available macroinvertebrates as a food supply to foraging Salmonidae species and how their presence/absence affects foraging behavior. In recreating this experiment, we found that methods used in this previous study might have altered in-stream hydraulics which might serve as a causal agent for altering fish behavior rather than the presence/absence of macroinvertebrate drift. In our experiment, we used a similar method to remove macroinvertebrate drift, however we ensured that the hydrology of the stream was not altered from its natural state. This module will recreate this former experiment with modern tools to see whether or not hydrology or biotic forces are the driver of behavioral change in foraging Salmonidae species.

Drift Foraging Steelhead Trout (Oncorhynchus mykiss) from Oregon State University

The data gathered broke down fish foraging behavior into a few main categories: drift foraging, search foraging, and benthic foraging. Drift foraging is defined as “ambushing drifting invertebrates from relatively fixed foraging positions”. Benthos foraging is defined as “actively searching for benthic prey over large areas” (Nakano et al. 1999). Search foraging is defined as “active searching over the streambed, water column, or surface for food” (Harvey & Railsback 2013). These behaviors have been observed to be correlated with distance travelled over time. Generally, fish displaying a drift foraging behavior tend to move less far during an observed behavioral subsample than those displaying search foraging and benthic foraging behaviors which are considered more opportunistic than drift foraging. In the scenario where we remove the drifting insects from the studied stream, we expect to see a shift in foraging behavior from drift foraging where they retain positive rheotaxis and wait for the food to come to them, to more opportunistic foraging behavior like search foraging and benthic foraging.

We will ensure that we properly ceased the flow of macroinvertebrates in the stream by adding a drift sock in the main thalweg (deepest portion of the river with the highest stream velocity) to collect drifting insects in the control and manipulated study. To sufficiently claim that we have "blocked" macroinvertebrate drift, we will aim for reducing the BMI (Body Mass Index) of insects by 90%.

Implementation of drift socks to capture macroinvertebrate drift (Neuswanger 2015)

Loading Necessary Packages

library(tidyverse)
library(dplyr)
library(ggplot2)
library(tidyr)
library(readr)

Import Control Dataset

monolith_control <-
  readr::read_csv("Elder_Monolith_21June2018_Part2.csv",
                  skip = 1,
                  col_names = c("objects", "experiment", "events", "timecode", "time_sec", "X", "Y", "Z", "PLD_error", "re_projection_error", "nearest_camera_distance"),
                  col_types = "ccccddddddd")
## Warning in rbind(names(probs), probs_f): number of columns of result is not
## a multiple of vector length (arg 1)

## Warning: 164 parsing failures.
## row # A tibble: 5 x 5 col     row col   expected   actual     file                                  expected   <int> <chr> <chr>      <chr>      <chr>                                 actual 1     1 <NA>  11 columns 12 columns 'Elder_Monolith_21June2018_Part2.csv' file 2     2 <NA>  11 columns 12 columns 'Elder_Monolith_21June2018_Part2.csv' row 3     3 <NA>  11 columns 12 columns 'Elder_Monolith_21June2018_Part2.csv' col 4     4 <NA>  11 columns 12 columns 'Elder_Monolith_21June2018_Part2.csv' expected 5     5 <NA>  11 columns 12 columns 'Elder_Monolith_21June2018_Part2.csv'
## ... ................. ... ......................................................................... ........ ......................................................................... ...... ......................................................................... .... ......................................................................... ... ......................................................................... ... ......................................................................... ........ .........................................................................
## See problems(...) for more details.
monolith_control
## # A tibble: 164 x 11
##    objects experiment events timecode time_sec      X      Y      Z
##    <chr>   <chr>      <chr>  <chr>       <dbl>  <dbl>  <dbl>  <dbl>
##  1 Subsam… Control    Lengt… 0:00:06…     419.  -4.32 -17.2   3.34 
##  2 Subsam… Control    Searc… 0:00:06…     419.  -4.31 -17.2   3.28 
##  3 Subsam… Control    Drift… 0:00:07…     431.  19.8   57.3   4.11 
##  4 Subsam… Control    Searc… 0:00:07…     425.  -5.21   7.56  8.69 
##  5 Subsam… Control    Lengt… 0:00:06…     419.   4.50 -12.9  -0.258
##  6 Subsam… Control    Searc… 0:00:07…     428.   8.21  50.3   1.03 
##  7 Subsam… Control    Searc… 0:00:07…     440.  -4.10  10.1   2.61 
##  8 Subsam… Control    Searc… 0:00:07…     434.   9.40   8.19 -7.13 
##  9 Subsam… Control    Searc… 0:00:07…     437.  13.3   -2.91 -5.55 
## 10 Subsam… Control    Searc… 0:00:07…     447.  -7.18  -3.07  4.50 
## # ... with 154 more rows, and 3 more variables: PLD_error <dbl>,
## #   re_projection_error <dbl>, nearest_camera_distance <dbl>

Creating Control Movement/Behavior Data

final_data_monolith_control <- monolith_control %>%
  arrange(objects, time_sec) %>%
  filter(!grepl("^Length.*", events)) %>% 
  mutate(distance_travelled_X_cm = X - lag(X, default = first(X))) %>%
  mutate(distance_travelled_Y_cm = Y - lag(Y, default = first(Y))) %>%
  mutate(distance_travelled_Z_cm = Z - lag(Z, default = first(Z))) %>%
  mutate(fish_distance_travelled_cm = sqrt((distance_travelled_X_cm)^2
                                        + (distance_travelled_Y_cm)^2
                                        + (distance_travelled_Z_cm)^2)) %>%
  group_by(objects) %>%
  mutate(distance_cm_per_sec = fish_distance_travelled_cm /(time_sec - lag(time_sec, default = first(time_sec)))) %>%
  filter(!distance_cm_per_sec == Inf) %>%
  dplyr::select(objects, experiment, events, time_sec, X, Y, Z, distance_travelled_X_cm, distance_travelled_Y_cm, distance_travelled_Z_cm, distance_cm_per_sec)
final_data_monolith_control
## # A tibble: 112 x 11
## # Groups:   objects [16]
##    objects experiment events time_sec      X      Y      Z distance_travel…
##    <chr>   <chr>      <chr>     <dbl>  <dbl>  <dbl>  <dbl>            <dbl>
##  1 Subsam… Control    Searc…     425.  -5.21   7.56  8.69            -0.893
##  2 Subsam… Control    Searc…     428.   8.21  50.3   1.03            13.4  
##  3 Subsam… Control    Drift…     431.  19.8   57.3   4.11            11.6  
##  4 Subsam… Control    Searc…     434.   9.40   8.19 -7.13           -10.4  
##  5 Subsam… Control    Searc…     437.  13.3   -2.91 -5.55             3.91 
##  6 Subsam… Control    Searc…     440.  -4.10  10.1   2.61           -17.4  
##  7 Subsam… Control    Searc…     447.  -7.18  -3.07  4.50            -3.08 
##  8 Subsam… Control    Searc…     450.  20.6   11.9   7.21            27.8  
##  9 Subsam… Control    Drift…     425.  87.2   47.1   0.416            3.53 
## 10 Subsam… Control    Drift…     431.  73.3   36.9  -0.564          -13.9  
## # ... with 102 more rows, and 3 more variables:
## #   distance_travelled_Y_cm <dbl>, distance_travelled_Z_cm <dbl>,
## #   distance_cm_per_sec <dbl>

Importing Manipulated Dataset

monolith_manipulated <-
  readr::read_csv("Elder_Monolith_22June2018_Part2.csv",
                  skip = 1,
                  col_names = c("objects", "experiment", "events", "timecode", "time_sec", "X", "Y", "Z", "PLD_error", "re_projection_error", "nearest_camera_distance"),
                  col_types = "ccccddddddd")
## Warning in rbind(names(probs), probs_f): number of columns of result is not
## a multiple of vector length (arg 1)

## Warning: 252 parsing failures.
## row # A tibble: 5 x 5 col     row col   expected   actual     file                                  expected   <int> <chr> <chr>      <chr>      <chr>                                 actual 1     1 <NA>  11 columns 12 columns 'Elder_Monolith_22June2018_Part2.csv' file 2     2 <NA>  11 columns 12 columns 'Elder_Monolith_22June2018_Part2.csv' row 3     3 <NA>  11 columns 12 columns 'Elder_Monolith_22June2018_Part2.csv' col 4     4 <NA>  11 columns 12 columns 'Elder_Monolith_22June2018_Part2.csv' expected 5     5 <NA>  11 columns 12 columns 'Elder_Monolith_22June2018_Part2.csv'
## ... ................. ... ......................................................................... ........ ......................................................................... ...... ......................................................................... .... ......................................................................... ... ......................................................................... ... ......................................................................... ........ .........................................................................
## See problems(...) for more details.
monolith_manipulated 
## # A tibble: 252 x 11
##    objects experiment events timecode time_sec      X     Y     Z PLD_error
##    <chr>   <chr>      <chr>  <chr>       <dbl>  <dbl> <dbl> <dbl>     <dbl>
##  1 Subsam… Manipulat… Lengt… 0:00:07…     453.  73.5   59.8  9.11    0.128 
##  2 Subsam… Manipulat… Drift… 0:00:07…     450.  74.5   55.1  1.29    0.248 
##  3 Subsam… Manipulat… Lengt… 0:00:07…     453.  87.0   54.5 14.5     0.0442
##  4 Subsam… Manipulat… Drift… 0:00:07…     453.  87.3   54.8 14.6     0.0445
##  5 Subsam… Manipulat… Searc… 0:00:07…     462.   1.13  99.7  7.16    0.433 
##  6 Subsam… Manipulat… Lengt… 0:00:07…     470.  44.1   81.0  1.08    0.391 
##  7 Subsam… Manipulat… Lengt… 0:00:07…     465.  23.7  106.  10.4     0.485 
##  8 Subsam… Manipulat… Drift… 0:00:07…     471.  -5.37  56.9 15.7     0.207 
##  9 Subsam… Manipulat… Drift… 0:00:07…     471.  73.5   36.6  3.89    0.119 
## 10 Subsam… Manipulat… Lengt… 0:00:07…     471.  -5.40  56.8 15.7     0.206 
## # ... with 242 more rows, and 2 more variables: re_projection_error <dbl>,
## #   nearest_camera_distance <dbl>

Creating Manipulated Movement/Behavior Data

final_data_monolith_manipulated <- monolith_manipulated %>%
  arrange(objects, time_sec) %>%
  filter(!grepl("^Length.*", events)) %>% #In this experiment, length was not considered a relevant data point
  mutate(distance_travelled_X_cm = X - lag(X, default = first(X))) %>%
  mutate(distance_travelled_Y_cm = Y - lag(Y, default = first(Y))) %>%
  mutate(distance_travelled_Z_cm = Z - lag(Z, default = first(Z))) %>%
  mutate(fish_distance_travelled_cm = sqrt((distance_travelled_X_cm)^2
                                        + (distance_travelled_Y_cm)^2
                                        + (distance_travelled_Z_cm)^2)) %>%
  group_by(objects) %>%
  mutate(distance_cm_per_sec = fish_distance_travelled_cm /(time_sec - lag(time_sec, default = first(time_sec)))) %>%
  filter(!distance_cm_per_sec == Inf) %>%
  dplyr::select(objects, experiment, events, time_sec, X, Y, Z, distance_cm_per_sec)
final_data_monolith_manipulated
## # A tibble: 164 x 8
## # Groups:   objects [20]
##    objects   experiment events time_sec     X     Y     Z distance_cm_per…
##    <chr>     <chr>      <chr>     <dbl> <dbl> <dbl> <dbl>            <dbl>
##  1 Subsampl… Manipulat… Drift…     453.  87.3  54.8 14.6             6.15 
##  2 Subsampl… Manipulat… Drift…     456.  83.4  54.2  6.55            2.98 
##  3 Subsampl… Manipulat… Drift…     459.  81.8  53.2  8.30            0.857
##  4 Subsampl… Manipulat… Drift…     462.  79.8  52.5 11.4             1.27 
##  5 Subsampl… Manipulat… Drift…     465.  78.1  51.0  8.30            1.28 
##  6 Subsampl… Manipulat… Drift…     468.  67.1  37.6  3.45            5.99 
##  7 Subsampl… Manipulat… Drift…     471.  73.5  36.6  3.89            2.18 
##  8 Subsampl… Manipulat… Drift…     474.  94.1  39.6 11.0             7.33 
##  9 Subsampl… Manipulat… Drift…     477.  87.8  54.6  7.15            5.58 
## 10 Subsampl… Manipulat… Drift…     480. 101.   64.1  5.90            5.39 
## # ... with 154 more rows

Data Visualization

Here we can make sense of the movement data collected and look at how the manipulated study differs from the control data that is collected.

Plotting Control Data

ggplot(final_data_monolith_control, aes(time_sec, distance_cm_per_sec, group = events, color = objects)) + geom_point() + facet_wrap(~ objects) + ggtitle("Individual Fish Movement During Different Subsamples: Control Data") + xlab("Time in Seconds") + ylab("Distance Travelled (cm/sec)")

Plotting Manipulated Data

This will give us a rough estimation of the movement for each fish in each subsample

  ggplot(final_data_monolith_manipulated, aes(time_sec, distance_cm_per_sec, group = events, color = objects)) + geom_point() + facet_wrap(~ objects) + ggtitle("Individual Fish Movement During Different Subsamples: Manipulated Data") + xlab("Time in Seconds") + ylab("Distance Travelled (cm/sec)")

Plotting Boxplot Control Data

ggplot(final_data_monolith_control, aes(time_sec, distance_cm_per_sec)) + geom_boxplot(aes(time_sec, color = objects)) + 
labs(x = "Time in Video (sec)", y = "Distance Travelled per Unit Time (cm/sec)") +
ggtitle("Control: Distance Travelled per Time (cm/sec) Boxplot")

Plotting Boxplot Manipulated Data

ggplot(final_data_monolith_manipulated, aes(time_sec, distance_cm_per_sec)) +        geom_boxplot(aes(time_sec, color = objects)) + 
labs(x = "Time in Video (sec)", y = "Distance Travelled per Unit Time (cm/sec)") +  ggtitle("Manipulated: Distance Travelled per Time (cm/sec) Boxplot")

Creating Summarized Movement Data & Statistical Analysis

This dataset will provide a summary of the movement of the observed juvenile steelhead trout (Oncorhynchus mykiss) from each study. This data is relevant to determining fish behavior since there is a higher correlation between higher fish movement and increase opportunistic foraging events rather than drift foraging events which occur at times of

Summary of Control Movement Data

monolith_control_summary <- final_data_monolith_control %>%
  group_by(objects) %>%
  summarize(control_mean_fish_distance_travelled_cm_per_sec = mean(distance_cm_per_sec), control_median_fish_distance_travelled_cm_per_sec = median(distance_cm_per_sec)) 
monolith_control_summary
## # A tibble: 16 x 3
##    objects        control_mean_fish_distance… control_median_fish_distanc…
##    <chr>                                <dbl>                        <dbl>
##  1 Subsample_1 1…                        8.41                         6.19
##  2 Subsample_1 2…                        2.25                         1.85
##  3 Subsample_1 3…                        5.10                         3.65
##  4 Subsample_1 4…                       12.4                          9.45
##  5 Subsample_2 5…                        8.54                         5.80
##  6 Subsample_2 6…                       14.3                         13.3 
##  7 Subsample_2 7…                       11.2                         10.5 
##  8 Subsample_2 8…                        2.83                         1.85
##  9 Subsample_3 1…                       18.8                          6.05
## 10 Subsample_3 9…                       10.5                         10.1 
## 11 Subsample_4 1…                        3.97                         4.75
## 12 Subsample_4 1…                        9.11                         7.46
## 13 Subsample_5 1…                        3.45                         3.25
## 14 Subsample_5 1…                        8.67                         7.13
## 15 Subsample_6 1…                        6.86                         6.25
## 16 Subsample_6 1…                        8.61                         7.66

Summary of Manipulated Movement Data

monolith_manipulated_summary <- final_data_monolith_manipulated %>%
  group_by(objects) %>%
  summarize(manipulated_mean_fish_distance_travelled_cm_per_sec = mean(distance_cm_per_sec), manipulated_median_fish_distance_travelled_cm_per_sec = median(distance_cm_per_sec))
monolith_manipulated_summary
## # A tibble: 20 x 3
##    objects       manipulated_mean_fish_dista… manipulated_median_fish_dis…
##    <chr>                                <dbl>                        <dbl>
##  1 Subsample_1 …                         3.90                        4.19 
##  2 Subsample_1 …                         5.68                        4.09 
##  3 Subsample_1 …                        10.1                         9.22 
##  4 Subsample_1 …                         5.50                        5.50 
##  5 Subsample_2 …                         6.71                        6.24 
##  6 Subsample_2 …                         3.40                        2.55 
##  7 Subsample_2 …                        16.0                        16.2  
##  8 Subsample_3 …                        12.3                         4.54 
##  9 Subsample_3 …                         3.85                        2.93 
## 10 Subsample_4 …                         5.50                        3.23 
## 11 Subsample_4 …                         5.01                        4.70 
## 12 Subsample_4 …                         7.34                        6.72 
## 13 Subsample_5 …                         3.10                        3.00 
## 14 Subsample_5 …                         3.55                        1.81 
## 15 Subsample_5 …                         7.02                        6.21 
## 16 Subsample_5 …                         5.30                        0.955
## 17 Subsample_6 …                         9.46                        7.29 
## 18 Subsample_6 …                         6.02                        5.29 
## 19 Subsample_6 …                         7.53                        8.20 
## 20 Subsample_6 …                         4.28                        1.62

Statistical Summary: Control Data

Total Average Movement in Control Dataset (cm/sec)

mean(monolith_control_summary$control_mean_fish_distance_travelled_cm_per_sec)
## [1] 8.439308

Median Distance Travelled in Control Dataset (cm/sec)

mean(monolith_control_summary$control_median_fish_distance_travelled_cm_per_sec)
## [1] 6.579131

Standard Deviation from Mean: Control Data

sd(monolith_control_summary$control_mean_fish_distance_travelled_cm_per_sec)
## [1] 4.454632

Summary of Manipulated Movement Data

Total Average Movement in Manipulated Dataset (cm/sec)

mean(monolith_manipulated_summary$manipulated_mean_fish_distance_travelled_cm_per_sec)
## [1] 6.581297

Median Distance Travelled in Manipulated Dataset (cm/sec)

mean(monolith_manipulated_summary$manipulated_median_fish_distance_travelled_cm_per_sec)
## [1] 5.22252

Standard Deviation from Mean: Manipulated Data

sd(monolith_manipulated_summary$manipulated_mean_fish_distance_travelled_cm_per_sec)
## [1] 3.272845

Interpretation of Results

These results proved interesting in regard to what has been reported in previous studies. It had been previously thought that an increase in distance travelled per time (cm/sec) was associated with more opportunistic foraging events such as search foraging and benthic foraging. In each statistically relevant category, it was seen that foraging O. mykiss had a higher rate of movement in the control data rather than the manipulated data. One interesting point that could be viewed as a statistically relevant piece of data would be the higher standard deviation in movement in the control dataset compared to the manipulated data. This would tell us that there is a higher instance of opportunistic foraging in the control sampling event. This negates our original hypothesis, and that of previous studies, that removing drifting insects will lead to more opportunistic foraging events in Salmonidae fish species.

Breakdown of Observed Foraging types

Along with the analyzed movement data, each data point in each recorded subsample was labeled with a foraging type: drift foraging, search foraging, benthic foraging, or other (which was composed of acts of aggression, surface strikes, etc.). These behaviors will be summed and placed into a pie chart to compare the relative proportion of forage event types between the control and monipulated sampling events.

Pie Chart: Proportion of O. Mykiss Foraging Behavior Types

Tallying Foraging Types Dataset: Contol

control_behavior_tally <- final_data_monolith_control %>%
  dplyr::select(events) %>%
  ungroup() %>%
  mutate(benthic_forage = grepl("^Benthic_Forage.*", events)) %>%
  mutate(drift_forage = grepl("^Drift_Forage.*", events)) %>%
  mutate(search_forage = grepl("Search_Forage.*", events)) %>%
  mutate(benthic_forage_int = if_else(benthic_forage == TRUE, 1, 0)) %>%
  mutate(drift_forage_int = if_else(drift_forage == TRUE, 1, 0)) %>%
  mutate(search_forage_int = if_else(search_forage == TRUE, 1, 0))
## Adding missing grouping variables: `objects`
control_behavior_tally
## # A tibble: 112 x 8
##    objects events benthic_forage drift_forage search_forage
##    <chr>   <chr>  <lgl>          <lgl>        <lgl>        
##  1 Subsam… Searc… FALSE          FALSE        TRUE         
##  2 Subsam… Searc… FALSE          FALSE        TRUE         
##  3 Subsam… Drift… FALSE          TRUE         FALSE        
##  4 Subsam… Searc… FALSE          FALSE        TRUE         
##  5 Subsam… Searc… FALSE          FALSE        TRUE         
##  6 Subsam… Searc… FALSE          FALSE        TRUE         
##  7 Subsam… Searc… FALSE          FALSE        TRUE         
##  8 Subsam… Searc… FALSE          FALSE        TRUE         
##  9 Subsam… Drift… FALSE          TRUE         FALSE        
## 10 Subsam… Drift… FALSE          TRUE         FALSE        
## # ... with 102 more rows, and 3 more variables: benthic_forage_int <dbl>,
## #   drift_forage_int <dbl>, search_forage_int <dbl>

Fraction of Foraging Events: Control

ttoc <- control_behavior_tally %>% #Total number of events types (112)
  count(objects) %>%
  tally(n) %>%
  as.numeric()
  
tbfc <- control_behavior_tally %>% #Total number of benthic forage events
  tally(benthic_forage_int) %>%
  as.numeric()

tdfc <- control_behavior_tally %>% #Total number of drift forage events
  tally(drift_forage_int) %>%
  as.numeric()

tsfc <- control_behavior_tally %>% #Total number of search forage events
  tally(search_forage_int) %>%
  as.numeric()

totc <- (ttoc - tbfc - tdfc - tsfc) %>% #Total number of "other" events
  as.numeric()

benthic_fraction_control <- (tbfc/ttoc)*100
drift_fraction_control <- (tdfc/ttoc)*100
search_fraction_control <- (tsfc/ttoc)*100
other_fraction_control <- (totc/ttoc)*100

Control Sampling Event

slices_control <- c(tbfc, tdfc, tsfc, totc)
slices_names <- c("Benthic Forage (3%)", "Drift Forage (65%)", "Search Forage (29%)", "Other (3%)")
pie(slices_control, labels = slices_names, col = rainbow(length(slices_names))) + title("Proportion of Fish Foraging Behaviors: Control")

## integer(0)

Tallying Foraging Types Dataset: Manipulated

manipulated_behavior_tally <- final_data_monolith_manipulated %>%
  dplyr::select(events) %>%
  ungroup() %>%
  mutate(benthic_forage = grepl("^Benthic_Forage.*", events)) %>%
  mutate(drift_forage = grepl("^Drift_Forage.*", events)) %>%
  mutate(search_forage = grepl("Search_Forage.*", events)) %>%
  mutate(benthic_forage_int = if_else(benthic_forage == TRUE, 1, 0)) %>%
  mutate(drift_forage_int = if_else(drift_forage == TRUE, 1, 0)) %>%
  mutate(search_forage_int = if_else(search_forage == TRUE, 1, 0)) 
## Adding missing grouping variables: `objects`
manipulated_behavior_tally 
## # A tibble: 164 x 8
##    objects events benthic_forage drift_forage search_forage
##    <chr>   <chr>  <lgl>          <lgl>        <lgl>        
##  1 Subsam… Drift… FALSE          TRUE         FALSE        
##  2 Subsam… Drift… FALSE          TRUE         FALSE        
##  3 Subsam… Drift… FALSE          TRUE         FALSE        
##  4 Subsam… Drift… FALSE          TRUE         FALSE        
##  5 Subsam… Drift… FALSE          TRUE         FALSE        
##  6 Subsam… Drift… FALSE          TRUE         FALSE        
##  7 Subsam… Drift… FALSE          TRUE         FALSE        
##  8 Subsam… Drift… FALSE          TRUE         FALSE        
##  9 Subsam… Drift… FALSE          TRUE         FALSE        
## 10 Subsam… Drift… FALSE          TRUE         FALSE        
## # ... with 154 more rows, and 3 more variables: benthic_forage_int <dbl>,
## #   drift_forage_int <dbl>, search_forage_int <dbl>

Fraction of Foraging Events: Manipulated

ttom <- manipulated_behavior_tally %>% #Total number of events types (164)
  count(objects) %>%
  tally(n) %>%
  as.numeric()

tbfm <- manipulated_behavior_tally %>% #Total number of benthic forage events
  tally(benthic_forage_int) %>%
  as.numeric()

tdfm <- manipulated_behavior_tally %>% #Total number of drift forage events
  tally(drift_forage_int) %>%
  as.numeric()

tsfm <- manipulated_behavior_tally %>% #Total number of search forage events
  tally(search_forage_int) %>%
  as.numeric()

totm <- (ttom - tbfm - tdfm - tsfm) %>% #Total number of "other" events
  as.numeric()

benthic_fraction_manipulated <- (tbfm/ttom)*100
drift_fraction_manipulated <- (tdfm/ttom)*100
search_fraction_manipulated <- (tsfm/ttom)*100
other_fraction_manipulated <- (totm/ttom)*100

Manipulated Sampling Event

slices_manipulated <- c(tbfm, tdfm, tsfm, totm)
slices_names <- c("Benthic Forage (5%)", "Drift Forage (70%)", "Search Forage (22%)", "Other (3%)")
pie(slices_manipulated, labels = slices_names, col = rainbow(length(slices_names))) + title("Proportion of Fish Foraging Behaviors: Manipulated")

## integer(0)

Interpretation of Pie Chart Results

These results were rather odd in that they demonstrated little change in foraging behavior, but the change that was displayed was opposite of what would have been expected. There was a slight increase in drift foraging in the manipulated sampling event in which the insect drift was removed from the river, so that is confusing. This data does corroborate with the movement data showing that there was more movement in the control sampling event than the manipulated sampling event

Change in Spatial Distribution of the Fish in the River

I will be looking at the nearest neighbor distance (NND) to look at how the presence/absence of macroinvertebrate drift affects fish spatial distribution.

Nearest Neighbor Distance: Unmanipulated

nnd_dataset_control <- final_data_monolith_control %>%
  ungroup() %>%
  dplyr::select(objects, time_sec, X, Y, Z) %>%
  arrange(time_sec) %>%
  group_by(time_sec) %>%
  mutate(distance_travelled_X_cm = X - lag(X, default = first(X))) %>%
  mutate(distance_travelled_Y_cm = Y - lag(Y, default = first(Y))) %>%
  mutate(distance_travelled_Z_cm = Z - lag(Z, default = first(Z))) %>%
  mutate(nnd = sqrt((distance_travelled_X_cm)^2
                                        + (distance_travelled_Y_cm)^2
                                        + (distance_travelled_Z_cm)^2)) %>%
  group_by(time_sec) %>%
  filter(!nnd == 0) %>%
  filter(nnd == min(nnd)) 
nnd_dataset_control
## # A tibble: 31 x 9
## # Groups:   time_sec [31]
##    objects time_sec     X     Y       Z distance_travel… distance_travel…
##    <chr>      <dbl> <dbl> <dbl>   <dbl>            <dbl>            <dbl>
##  1 Subsam…     425.  87.2  47.1   0.416            92.4             39.5 
##  2 Subsam…     428.  14.7  95.1 -10.2               6.46            44.7 
##  3 Subsam…     431.  73.3  36.9  -0.564            53.5            -20.4 
##  4 Subsam…     434.  10.3  37.3  -6.24            -18.2            -57.5 
##  5 Subsam…     437.  42.0  46.2  14.6             -11.4            -53.1 
##  6 Subsam…     440.  80.5  40.2   5.29             84.6             30.1 
##  7 Subsam…     443. -14.6  71.7   2.36            -93.7             31.6 
##  8 Subsam…     447.  80.2  42.1   6.59             87.4             45.2 
##  9 Subsam…     483.  69.4  40.1 -15.7              67.3              5.83
## 10 Subsam…     486.  47.6  71.2  -3.16             13.4             25.4 
## # ... with 21 more rows, and 2 more variables:
## #   distance_travelled_Z_cm <dbl>, nnd <dbl>
mean(nnd_dataset_control$nnd)
## [1] 77.86774

Nearest Neighbor Distance: Manipulated

nnd_dataset_manipulated <- final_data_monolith_manipulated %>%
  ungroup() %>%
  dplyr::select(objects, time_sec, X, Y, Z) %>%
  arrange(time_sec) %>%
  group_by(time_sec) %>%
  mutate(distance_travelled_X_cm = X - lag(X, default = first(X))) %>%
  mutate(distance_travelled_Y_cm = Y - lag(Y, default = first(Y))) %>%
  mutate(distance_travelled_Z_cm = Z - lag(Z, default = first(Z))) %>%
  mutate(nnd = sqrt((distance_travelled_X_cm)^2
                                        + (distance_travelled_Y_cm)^2
                                        + (distance_travelled_Z_cm)^2)) %>%
  group_by(time_sec) %>%
  filter(!nnd == 0) %>%
  filter(nnd == min(nnd)) 
nnd_dataset_manipulated
## # A tibble: 57 x 9
## # Groups:   time_sec [57]
##    objects time_sec       X     Y      Z distance_travel… distance_travel…
##    <chr>      <dbl>   <dbl> <dbl>  <dbl>            <dbl>            <dbl>
##  1 Subsam…     456.  46.4    32.3  -1.69           -37.0            -21.9 
##  2 Subsam…     459.  18.5    50.2   2.39           -63.3             -3.02
##  3 Subsam…     462.   1.13   99.7   7.16            -2.42            42.8 
##  4 Subsam…     465.  34.9   102.   12.8             35.9             43.0 
##  5 Subsam…     468.  20.8    90.8   7.39            19.2             34.2 
##  6 Subsam…     471.  71.7    79.5   2.69            77.1             22.6 
##  7 Subsam…     474.  -5.12   58.1  18.9            -99.2             18.5 
##  8 Subsam…     477.   6.89   58.3  16.3            -80.9              3.67
##  9 Subsam…     480.  23.5    57.9  -2.67           -77.4             -6.25
## 10 Subsam…     543.  -0.842  57.9  17.4            -53.5             44.7 
## # ... with 47 more rows, and 2 more variables:
## #   distance_travelled_Z_cm <dbl>, nnd <dbl>
mean(nnd_dataset_manipulated$nnd)
## [1] 75.62127

Results of NND Data

These two data points show almost no difference, this tells us that the presence/absence of macroinvertebrate drift had little to no effect on intraspecies interactions coming in the form of aggression or habitat usage.

Insect Data Analyzation

In this section I will examine the insect data and see whether or no we were able to effectively block macropivertebrate drift which will allow us to confidently say that Salmonid behavior was changed/remained constant as a result of the insects in the river.

Importing Monolith Pool Dataset

BMI_data_monolith <- 
  readr::read_csv("Drift Manipulation Macroinvertebrate Sheet - Drift Manipulation.csv",
                  col_names = TRUE,
                  col_types = "cccccccccdddddc") %>%
  select(Stream, Pool, Event, Date, ID, Order, Number, Size_Class, biomass) %>%
  filter(Pool == "Monolith")
## Warning in rbind(names(probs), probs_f): number of columns of result is not
## a multiple of vector length (arg 1)

## Warning: 6 parsing failures.
## row # A tibble: 5 x 5 col     row col     expected actual file                                       expected   <int> <chr>   <chr>    <chr>  <chr>                                      actual 1    64 lna     a double #N/A   'Drift Manipulation Macroinvertebrate She… file 2    64 b       a double #N/A   'Drift Manipulation Macroinvertebrate She… row 3    64 biomass a double #N/A   'Drift Manipulation Macroinvertebrate She… col 4    88 lna     a double #N/A   'Drift Manipulation Macroinvertebrate She… expected 5    88 b       a double #N/A   'Drift Manipulation Macroinvertebrate She…
## ... ................. ... .......................................................................... ........ .......................................................................... ...... .......................................................................... .... .......................................................................... ... .......................................................................... ... .......................................................................... ........ ..........................................................................
## See problems(...) for more details.
BMI_data_monolith
## # A tibble: 36 x 9
##    Stream   Pool    Event  Date  ID      Order   Number Size_Class biomass
##    <chr>    <chr>   <chr>  <chr> <chr>   <chr>    <dbl>      <dbl>   <dbl>
##  1 Elder_C… Monoli… Contr… 6/21… Baetid… Baetid…      1          1  0.0053
##  2 Elder_C… Monoli… Contr… 6/21… Baetid… Baetid…      2          2  0.0778
##  3 Elder_C… Monoli… Contr… 6/21… Baetid… Baetid…      1          3  0.125 
##  4 Elder_C… Monoli… Contr… 6/21… Baetid… Baetid…      1          5  0.542 
##  5 Elder_C… Monoli… Contr… 6/21… Simuli… Simuli…      3          1  0.006 
##  6 Elder_C… Monoli… Contr… 6/21… Simuli… Simuli…     10          2  0.161 
##  7 Elder_C… Monoli… Contr… 6/21… Simuli… Simuli…      1          4  0.130 
##  8 Elder_C… Monoli… Contr… 6/21… Simuli… Simuli…      1          5  0.254 
##  9 Elder_C… Monoli… Contr… 6/21… Chiron… Chiron…      1          1  0.0018
## 10 Elder_C… Monoli… Contr… 6/21… Chiron… Chiron…      4          2  0.0442
## # ... with 26 more rows

Calculating BMI of Drifting Macroinvertebrates Captured

BMI_data_monolith %>%
  group_by(Event) %>%
  summarise(Total_BMI_Captured_mg = sum(biomass, na.rm = TRUE)) 
## # A tibble: 2 x 2
##   Event       Total_BMI_Captured_mg
##   <chr>                       <dbl>
## 1 Control                      8.65
## 2 Manipulated                  1.33

This calculation shows that roughly 85% of the macroivertebrate drift (in mg) was blocked which does not reach our preferred goal in this experiment, however it did effectively block more drift than when this study was carried out previously in which approximately only 70% of insect drift was blocked. This data allows us to comfortably say that insect drift was sufficiently altered to the point where it would alter the normal foraging behavior of present fish species.

Final Interpretation of Results

These results tell us that when macroinvertebrate drift is restricted in a pool-riffle environment bearing Salmonidae fish species, that the result, if any, lead to less opportunistic foraging. These results support the idea of optimal foraging theory where organisms expend less energy when there are fewer opprtunities for caloric consumption. Given in our experiment we were able to leave the in-stream hydraulics unaltered, which in previous studies (Nakano et al. 1999 & Nislow et al. 1999) these considerations were not taken and the hydraulics of the stream were likely altered due to their methods of blocking macroinvertebrate drift. This difference between our study and theirs leads us to believe that the alteration of stream flow was the main driver for the differences in foraging behavior. This would oppose the previous belief that the main driver of alteration is the availability of food. As far as utilizing this information for future management options, this could be used to better manage rivers altered by dams to keep fish foraging at an optimal state: containing high amounts of drift foraging fish. Utilizing three dimensional video analysis is lucrative to better understand the movement of fish on a very precise scale and allow for better vizualization of the behaviors and movement of the present fish species.