This code uses two different datasets to examine jellyfish depth distribution inside of the aggregations. The first dataset is from closing nets that collected jellyfish in the top and bottom halves of the water column. The second dataset is from go-pro footage that captured images at every meter, in which jellyfish were counted.

Markdown file is here: https://rpubs.com/HailaSchultz/field_depth-distribution

load packages

library(ggplot2)
library(dplyr)

Net Tows

Set up data

Read data into R

Depth_Stratified_Tows <- read.csv("/Users/hailaschultz/Dropbox/Other studies/Aurelia project/Data Analysis/data/current_data/Depth_Stratified_Tows.csv")

Calculate percentage of water column towed

Depth_Stratified_Tows$Depth_proportion<-Depth_Stratified_Tows$Meters_towed/Depth_Stratified_Tows$Wire_Out

Calculate water volume

Depth_Stratified_Tows$Water_volume<-Depth_Stratified_Tows$Depth_proportion*Depth_Stratified_Tows$Water_volume_full

Calculate biomass per volume

Depth_Stratified_Tows$Jelly_Biomass<-Depth_Stratified_Tows$Jelly_Mass/Depth_Stratified_Tows$Water_volume

test for differences

check for normality

hist(Depth_Stratified_Tows$Jelly_Biomass)

Since the data is non-normally distributed and zero-inflated, there is not a good test, but I can report that most of the jellyfish were distributed in the the top half of the water column

It looks like of the 14 paired tows, only 3 of the bottom tows had jellies whereas all of the surface tows had jellies. The bottom tows with jellies occurred during ebb tide (2) and low tide (1).

GoPro Data

Read gopro data into R

gopro_data <- read.csv("/Users/hailaschultz/Dropbox/Other studies/Aurelia project/Data Analysis/data/current_data/GOPRO_DATA.csv")

subset to remove miscellaneous stations

gopro_data<-subset(gopro_data,Station!="SC13a")
gopro_data<-subset(gopro_data,Station!="SC15A")

add tide phase

stat.labs <- c("Ebb Tide", "Low Tide","Flood Tide","High Tide")
names(stat.labs) <- c("SC10","SC11","SC14","SC16")

plots

non-normalized

Individual profiles

profile<-ggplot(data = gopro_data, aes(number.of.jellies.visible.at.stop, Stop.Depth..m.)) +
  geom_point()+
  geom_path()+
  facet_wrap(~ Station)+
  scale_y_reverse()+
  theme_classic()+
  xlab("Number of Aurelia Visible") + ylab("Depth (m)")
profile

combine profiles by tidal phase

Tidal.Dis<-ggplot(data = gopro_data, aes(number.of.jellies.visible.at.stop, Stop.Depth..m.,color=Station)) +
  geom_path()+
  facet_wrap(~ Location,ncol=4, labeller = labeller(Location = stat.labs))+
  scale_y_reverse()+
  theme_classic()+
  xlab("Number of Aurelia Visible") + ylab("Depth (m)")

Tidal.Dis

get averages at each meter

gopro_data$Stop.Depth<-as.factor(gopro_data$Stop.Depth..m.)
Depth.Sum<- gopro_data %>%
  group_by(Location,Stop.Depth..m.) %>%
  summarise(
    Mean = mean(number.of.jellies.visible.at.stop),
    Min = min(number.of.jellies.visible.at.stop),
    Max = max(number.of.jellies.visible.at.stop),
    Stdev = sd(number.of.jellies.visible.at.stop),
    Count = n(),
    Sterr = Stdev / sqrt(Count)
  )

stat.labs <- c("Ebb Tide", "Low Tide","Flood Tide","High Tide")
names(stat.labs) <- c("SC10","SC11","SC14","SC16")
depth.average<-ggplot(data = Depth.Sum, aes(Mean, Stop.Depth..m.,color=Location)) +
  geom_path()+
  facet_wrap(~ Location,ncol=4, labeller = labeller(Location = stat.labs))+
  scale_y_reverse()+
  theme_classic()+
  xlab("Number of Aurelia Visible") + ylab("Depth (m)")
depth.average

normalized plots

get the max depth at each station

Depth_max<-gopro_data %>%
  group_by(Station) %>%
  summarise(
    max.depth = max(Stop.Depth..m.))

add max depth to dataframe and standardize by it

gopro_data$max.depth<- Depth_max$max.depth[match(gopro_data$Station, Depth_max$Station)]
gopro_data$Depth.proportional<-gopro_data$Stop.Depth..m./gopro_data$max.depth

standardize by number of jellies in entire water column

Jelly_sum<-gopro_data %>%
  group_by(Station) %>%
  summarise(
    sum.jellies = sum(number.of.jellies.visible.at.stop))
gopro_data$sum.jellies<- Jelly_sum$sum.jellies[match(gopro_data$Station, Jelly_sum$Station)]
gopro_data$jellies.proportional<-gopro_data$number.of.jellies.visible.at.stop/gopro_data$sum.jellies

plot normalized profiles

Tidal.Dis.normalized<-ggplot(data = gopro_data, aes(jellies.proportional, Depth.proportional,color=Station)) +
  geom_path()+
  facet_wrap(~ Location,ncol=4, labeller = labeller(Location = stat.labs))+
  scale_y_reverse()+
  theme_classic()+
  ylab("Proportional Depth of Water Column") + 
  xlab("Mean Proportion of Aurelia Observed")
Tidal.Dis.normalized

plot normalized profiles as boxplot

#round to 0.1
gopro_data$Depth.prop.round<-round(gopro_data$Depth.proportional/.1)*.1
gopro_data$Depth.prop<-as.factor(gopro_data$Depth.prop.round)
normalized_boxplot <- ggplot(gopro_data, aes(Depth.prop,jellies.proportional, color=Location))+
  geom_boxplot()+
  facet_wrap(~ Location,ncol=4, labeller = labeller(Location = stat.labs))+
  theme_classic()+coord_flip()+scale_x_discrete(limits = rev(levels(gopro_data$Depth.prop)))
normalized_boxplot

final plot with standard error bars

Depth.Sum.Prop<- gopro_data %>%
  group_by(Location,Depth.prop.round) %>%
  summarise(
    Mean = mean(jellies.proportional),
    Min = min(jellies.proportional),
    Max = max(jellies.proportional),
    Stdev = sd(jellies.proportional),
    Count = n(),
    Sterr = Stdev / sqrt(Count)
  )

depth.distribution<-ggplot(Depth.Sum.Prop, aes(Depth.prop.round,Mean, color=Location)) +
  geom_line(aes(group = 1)) +
  geom_errorbar( aes(ymin = Mean-Sterr, ymax = Mean+Sterr),width = 0.02) +
  geom_point(size = 2)+
  facet_wrap(~ Location,ncol=4, labeller = labeller(Location = stat.labs))+
  theme_classic()+
  theme(strip.text.x = element_text(size = 10))+
  xlab("Normalized Depth") + 
  ylab("Mean Proportion of Jellyfish Observed")+theme(axis.text=element_text(size=10),       axis.title=element_text(size=15))+theme(legend.position = "none")+
  scale_x_reverse(breaks = seq(0.1, 1, 0.1), limits = c(1,0.1))  + 
  scale_y_continuous(breaks=seq(0,0.3,0.1),limits = c(0, 0.3))+coord_flip()+
  theme(panel.spacing = unit(1, "cm", data = NULL))
depth.distribution

save figure

setwd("/Users/hailaschultz/Dropbox/Other studies/Aurelia project/Data Analysis/figures/Final_Figures")
ggsave(filename = "SuppFig1.png", plot = depth.distribution, width = 164, height = 100, units="mm", device='png', dpi=600)
ggsave(filename = "SuppFig1.tif", plot = depth.distribution, width = 164, height = 100, units="mm", device='tiff', dpi=600)