Set up

##  [1] "Row.Labels"    "d15N"          "d13C"          "Station"      
##  [5] "Length"        "spc"           "Avg.Length"    "Avg.d15N"     
##  [9] "Avg.d13C"      "Lat"           "Long"          "d15N.stdev"   
## [13] "d13C.stdev"    "Length.stdev"  "Avg.d15N.res"  "Station.Depth"
## [17] "Zoop.d15N"     "Zoop.d13C"

Graphing d15N vc d13C

d %>% filter(spc == 1) %>%
  ggplot()+ 
  geom_point(aes(d13C, d15N, color = Station, size = Length)) + 
  #ggtitle("Fig 1: Cod d15N vs d13C") + 
  labs(x="d13C", y="d15N") +
  theme_bw()

Graphing d15N vs length of fish

# Fig 1
d %>% filter(spc == 1) %>%
  ggplot()+ 
  geom_point(aes(Length, d15N, color = Station, size = Length)) +
  #ggtitle("Fig 2: Cod d15N vs length") + 
  labs(x="Length (cm)", y="d15N (‰ vs air)") +
  theme_bw()

Average d15N per station vs Average length per station

# Fig 2
d %>% filter(spc == 1) %>%
  ggplot()+ 
  geom_point(aes(Avg.Length, Avg.d15N, color = Station), size=5) + 
  geom_errorbar(aes(x=Avg.Length, ymax=Avg.d15N+d15N.stdev, ymin=Avg.d15N-d15N.stdev, width=0.2)) +
  geom_errorbarh(aes(x=Avg.Length, y=Avg.d15N, xmax=Avg.Length+Length.stdev, xmin=Avg.Length-Length.stdev, height=.07)) +
  #ggtitle("Fig 3: Average d15N vs average length per station") + 
  labs(x="Station Average Length (cm)", y="Station Avg d15N (‰ vs air)") +
  theme_bw()

Location of stations

# Fig 3
d %>% filter(spc == 1) %>%
  ggplot()+ 
  geom_point(aes(Long/-100, Lat/100, color = Station), size=5) + 
  #ggtitle("3A") + 
  labs(x="longitude", y="latitude") +
  theme_bw()

#xlim=c(36.644226,45.109741), ylim=c(-78.514394,-64.061092)
#36.644226, -78.514394
#45.109741, -64.061092
cod <- d %>% filter(spc == 1) 
map <- ggmap(get_map(location="Gulf of Maine", zoom=7, maptype="hybrid"))
## Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=Gulf+of+Maine&zoom=7&size=640x640&scale=2&maptype=hybrid&language=en-EN&sensor=false
## Information from URL : http://maps.googleapis.com/maps/api/geocode/json?address=Gulf%20of%20Maine&sensor=false
datamap <- map +
  geom_point(data = cod, aes(Long/-100, Lat/100, color = Avg.d15N, size = Avg.Length), alpha=.7) +
  scale_color_gradient(low = "green", high = "red") +
  #ggtitle("3B") +
  labs(x="longitude", y="latitude")

datamap

cod <- d %>% filter(spc == 1 | spc==3)
map <- ggmap(get_map(location="Gulf of Maine", zoom=7, maptype="hybrid"))
## Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=Gulf+of+Maine&zoom=7&size=640x640&scale=2&maptype=hybrid&language=en-EN&sensor=false
## Information from URL : http://maps.googleapis.com/maps/api/geocode/json?address=Gulf%20of%20Maine&sensor=false
datamap <- map +
  geom_point(data = cod, aes(Long/-100, Lat/100, color = Avg.d15N, size = Avg.Length), alpha=.7) +
  scale_color_gradient(low = "green", high = "red") +
  #ggtitle("3C") +
  labs(x="longitude", y="latitude")

datamap

Detrending for length

# Fig 4
cod <- d %>% filter(spc==1)
fit <- lm(d15N~Length, data = cod)
coef(fit)
## (Intercept)      Length 
##   6.1866122   0.1296773
d15N.predicted <- predict(fit)
d15N.res <- resid(fit)
summary(fit)
## 
## Call:
## lm(formula = d15N ~ Length, data = cod)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1.4683 -0.6118  0.1042  0.5462  1.2679 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)  
## (Intercept)  6.18661    2.30835   2.680   0.0158 *
## Length       0.12968    0.04562   2.843   0.0112 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.7907 on 17 degrees of freedom
## Multiple R-squared:  0.3222, Adjusted R-squared:  0.2823 
## F-statistic: 8.082 on 1 and 17 DF,  p-value: 0.01124
ggplot(cod, aes(x=Length, y=d15N)) +
  geom_point() +
  geom_point(aes(y=d15N.predicted), shape = 1) +
  #ggtitle("4A") +
  theme_bw()

ggplot(cod, aes(x=Length, y=d15N.res)) +
  geom_point() +
  geom_hline(yintercept=0) +
  #ggtitle("4B") +
  theme_bw()

# Fig 5
cod.WWJ <- d %>% filter(spc==3)

ggplot(cod, aes(x=Station, y=d15N.res)) +
  stat_summary(fun.y="mean", geom="point") +
  geom_point(data=cod.WWJ, aes(x=Station,y=Avg.d15N.res)) +
  #stat_summary(fun.y="mean", geom="text", aes(label=sprintf("%1.9f", ..y..))) +
  #ggtitle("Figure 8: Detrended average per station, with wWJ cod added") +
  theme_bw()

# Fig 6
map <- ggmap(get_map(location="Gulf of Maine", zoom=7, maptype="hybrid"))
## Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=Gulf+of+Maine&zoom=7&size=640x640&scale=2&maptype=hybrid&language=en-EN&sensor=false
## Information from URL : http://maps.googleapis.com/maps/api/geocode/json?address=Gulf%20of%20Maine&sensor=false
datamap <- map +
  geom_point(data = cod, aes(Long/-100, Lat/100, color = Avg.d15N.res), alpha=.7, size = 3) +
  #ggtitle("6A") +
  labs(x="longitude", y="latitude")

datamap

cod.WWJ <- d %>% filter(spc==3)

map <- ggmap(get_map(location="Gulf of Maine", zoom=7, maptype="hybrid"))
## Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=Gulf+of+Maine&zoom=7&size=640x640&scale=2&maptype=hybrid&language=en-EN&sensor=false
## Information from URL : http://maps.googleapis.com/maps/api/geocode/json?address=Gulf%20of%20Maine&sensor=false
datamap <- map +
  geom_point(data = cod, aes(Long/-100, Lat/100, color = Avg.d15N.res), alpha=.7, size = 3) +
  geom_point(data = cod.WWJ, aes(Long/-100, Lat/100, color = Avg.d15N.res), alpha=.7, size = 3) +
  #ggtitle("6B") +
  labs(x="longitude", y="latitude")

datamap

Graphing with plankton data

# Fig 7
map <- ggmap(get_map(location="Gulf of Maine", zoom=7, maptype="hybrid"))
## Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=Gulf+of+Maine&zoom=7&size=640x640&scale=2&maptype=hybrid&language=en-EN&sensor=false
## Information from URL : http://maps.googleapis.com/maps/api/geocode/json?address=Gulf%20of%20Maine&sensor=false
datamap <- map +
  geom_point(data = cod, aes(Long/-100, Lat/100, fill = Avg.d15N.res),
             shape = 24, stroke = 1, size = 3, alpha = 0.7) +
  geom_point(data = cod.WWJ, aes(Long/-100, Lat/100, fill = d15N),
             shape = 22, stroke = 1, size = 3, alpha=.7) +
  scale_fill_gradientn(colors = terrain.colors(4)) +
  #ggtitle("Figure 10: Cod d15N overlayed with 250um Zoop d15N") +
  labs(x="longitude", y="latitude")

datamap +
  geom_point(data = z250_2015, aes(long, lat, color = d15N), alpha =.7, size =3)
## Warning: Removed 3 rows containing missing values (geom_point).

# Fig 8
ggplot(d %>% filter(spc != 2), aes(Avg.d13C, Avg.d15N, color=Station, label=Station)) +
  geom_point() +
  geom_text_repel(aes(label=ifelse(Avg.d15N<=10,Station,'')), size = 3) +
  geom_text(aes(label=ifelse(Avg.Length>20,Station,'')),hjust=-.25, size = 3) +
  geom_errorbar(aes(x=Avg.d13C, ymax=Avg.d15N+d15N.stdev, ymin=Avg.d15N-d15N.stdev, width=0.1)) +
  geom_errorbarh(aes(x=Avg.d13C, y=Avg.d15N, xmax=Avg.d13C+d13C.stdev, xmin=Avg.d13C-d13C.stdev, height=.2)) +
  #ggtitle("Fig 11: Average d15N vs average d13C per station, w/250um zoop") +
  labs(x="Station Average d13C (‰ vs air)", y="Station Avg d15N (‰ vs air)") +
  theme_bw()

Cod d15N and d13C by depth

ggplot(d %>% filter(spc != 2), aes(Station.Depth, Avg.d15N, color=Station, label=Station))+
  geom_point() +
  geom_text_repel(aes(label=ifelse(Avg.d15N<=10,Station,'')), size = 3) +
  geom_text(aes(label=ifelse(Avg.Length>20,Station,'')),hjust=-.25, size = 3) +
  #ggtitle("Fig 12: Average d15N per station vs depth") +
  labs(x="Depth (m)", y="Station Avg d15N") +
  theme_bw()

ggplot(d %>% filter(spc != 2), aes(Station.Depth, Avg.d13C, color=Station, label=Station))+
  geom_point() +
  geom_text_repel(aes(label=ifelse(Avg.d15N<=10,Station,'')), size = 3) +
  geom_text(aes(label=ifelse(Avg.Length>20,Station,'')),hjust=-.25, size = 3) +
  #ggtitle("Fig 13: Average d13C per station vs depth") +
  xlim(0,300) +
  labs(x="Depth (m)", y="Station Avg d13C (‰ vs air)") +
  theme_bw()

Cod d15N and d13C vs plankton d15N and d13C of same station

# Fig 9
ggplot(d %>% filter(spc == 1 | spc == 3), aes(Zoop.d15N, Avg.d15N, color=Station, label=Station))+
  geom_point() +
  geom_text(aes(label=Station),hjust=-.25) +
  #ggtitle("9A") +
  xlim(5, 7) +
  labs(x="Zoop d15N (‰ vs air)", y="Cod d15N (‰ vs air)") +
  theme_bw()

ggplot(d %>% filter(spc == 1 | spc == 3), aes(Zoop.d13C, Avg.d13C, color=Station, label=Station))+
  geom_point() +
  geom_text(aes(label=Station),hjust=-.25) +
  #ggtitle("9B") +
  xlim(-22.5, -18) +
  labs(x="Zoop d13C (‰ vs air)", y="Cod d13C (‰ vs air)") +
  theme_bw()
## Warning: Removed 1 rows containing missing values (geom_point).
## Warning: Removed 1 rows containing missing values (geom_text).

Correlation tests

cod.Keo <- d %>% filter(spc == 1)
cor.test(cod.Keo$Length, cod.Keo$d15N)
## 
##  Pearson's product-moment correlation
## 
## data:  cod.Keo$Length and cod.Keo$d15N
## t = 2.8428, df = 17, p-value = 0.01124
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.1528300 0.8123902
## sample estimates:
##       cor 
## 0.5676358
cor.test(cod.Keo$Zoop.d15N, cod.Keo$Avg.d15N)
## 
##  Pearson's product-moment correlation
## 
## data:  cod.Keo$Zoop.d15N and cod.Keo$Avg.d15N
## t = 1.4823, df = 17, p-value = 0.1566
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1369479  0.6869558
## sample estimates:
##      cor 
## 0.338305
cor.test(cod.Keo$Station.Depth, cod.Keo$Avg.d15N)
## 
##  Pearson's product-moment correlation
## 
## data:  cod.Keo$Station.Depth and cod.Keo$Avg.d15N
## t = 2.4841, df = 17, p-value = 0.02371
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.08078024 0.78602284
## sample estimates:
##       cor 
## 0.5160549
###################################################

###################################################

###################################################

cod.All <- d %>% filter(spc == 1 | spc == 3)
cor.test(cod.All$Length, cod.All$d15N)
## 
##  Pearson's product-moment correlation
## 
## data:  cod.All$Length and cod.All$d15N
## t = 0.8713, df = 20, p-value = 0.3939
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.2505794  0.5671167
## sample estimates:
##      cor 
## 0.191232
cor.test(cod.All$Zoop.d15N, cod.All$Avg.d15N)
## 
##  Pearson's product-moment correlation
## 
## data:  cod.All$Zoop.d15N and cod.All$Avg.d15N
## t = 2.7373, df = 20, p-value = 0.0127
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.1287930 0.7734288
## sample estimates:
##       cor 
## 0.5220538
cor.test(cod.All$Station.Depth, cod.All$Avg.d15N)
## 
##  Pearson's product-moment correlation
## 
## data:  cod.All$Station.Depth and cod.All$Avg.d15N
## t = 0.64839, df = 20, p-value = 0.5241
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.2960318  0.5328584
## sample estimates:
##       cor 
## 0.1434849

(Intercept) Length 6.1866122 0.1296773

11.62525 12.08419 10.91293

Phytoplankton 250um WWJ west 400/500 <-> Jordan Basin/Acid 5 GOM WWJ east 600 <-> 45 GOM 1 306/307 <-> 28 GB 2 328 <-> NE Channel 297 <-> 30 GB 1

400 - St George 500 - Damariscotta 600 - Passamaquoddy

CODN15 V SIZE COD & PLANK ON THE MAP PLOT N V DEPTH

TO DO:

Graph data over other maps

Small cod have more trophic variability Plot Willis values from lower sites for compatibility N fixation vs nitrate = oceanic signal

Closest possible zoop station, not exact