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

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

Average d15N per station vs Average length per station

d %>% filter(spc == 1 | spc == 3) %>%
  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", y="Station Avg d15N") +
  theme_bw()

Location of stations

d %>% filter(spc == 1) %>%
  ggplot()+ 
  geom_point(aes(Long/-100, Lat/100, color = Station), size=5) + 
  ggtitle("Fig 4: Station vs GPS coords") + 
  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("Fig 5: Station vs GPS coords, w/d15N and length avgs") +
  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("Fig 5.1 *w/WWJ: Station vs GPS coords, w/d15N and length avgs") +
  labs(x="longitude", y="latitude")

datamap

Detrending for length

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)

ggplot(cod, aes(x=Length, y=d15N)) +
  geom_point() +
  geom_point(aes(y=d15N.predicted), shape = 1) +
  ggtitle("Figure 6: Length trend") +
  theme_bw()

ggplot(cod, aes(x=Length, y=d15N.res)) +
  geom_point() +
  geom_hline(yintercept=0) +
  ggtitle("Figure 7: Detrended") +
  theme_bw()

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") +
  theme_bw()

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("Figure 9: Detrended d15N average per station, mapped") +
  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("Figure 9.1: Same as Fig 9 but with WWJ data added") +
  labs(x="longitude", y="latitude")

datamap

Graphing with plankton data

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 = 4, alpha = 0.7) +
  #scale_fill_gradient(low = "white", high = "red") +
  geom_point(data = cod.WWJ, aes(Long/-100, Lat/100, fill = d15N),
             shape = 22, stroke = 1, size = 3, alpha=.7) +
  #scale_fill_gradient(low = "white", high = "red") +
  ggtitle("Figure 10: Cod d15N overlayed with plankton d15N") +
  labs(x="longitude", y="latitude")

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

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,yjust=0, size = 3) +
  geom_errorbar(aes(x=Avg.d13C, ymax=Avg.d15N+d15N.stdev, ymin=Avg.d15N-d15N.stdev, width=0.2)) +
  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", y="Station Avg d15N") +
  theme_bw()
## Warning: Ignoring unknown parameters: yjust

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,yjust=0, size = 3) +
  ggtitle("Fig 12: Average d15N per station vs depth") +
  labs(x="Depth (m)", y="Station Avg d15N") +
  theme_bw()
## Warning: Ignoring unknown parameters: yjust

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,yjust=0, size = 3) +
  ggtitle("Fig 13: Average d13C per station vs depth") +
  labs(x="Depth (m)", y="Station Avg d13C") +
  theme_bw()
## Warning: Ignoring unknown parameters: yjust

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

ggplot(d %>% filter(spc == 1), aes(Zoop.d15N, Avg.d15N, color=Station, label=Station))+
  geom_point() +
  geom_text(aes(label=Station),hjust=-.25) +
  ggtitle("Fig 14: Average d15N plankton vs cod") +
  labs(x="Zoop d15N", y="Cod d15N") +
  theme_bw()

ggplot(d %>% filter(spc == 1), aes(Zoop.d13C, Avg.d13C, color=Station, label=Station))+
  geom_point() +
  geom_text(aes(label=Station),hjust=-.25) +
  ggtitle("Fig 14: Average d13C plankton vs cod") +
  labs(x="Zoop d13C", y="Cod d13C") +
  theme_bw()

(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