10 15 2014 Number of Brooders vs Number of Size Class Code

sizeclassvbrood.R code{white-space: pre;} pre:not([class]) { background-color: white; } if (window.hljs && document.readyState && document.readyState === “complete”) { window.setTimeout(function() { hljs.initHighlighting(); }, 0); } .main-container { max-width: 940px; margin-left: auto; margin-right: auto; }

require(TeachingDemos)
## Loading required package: TeachingDemos
require(ggplot2)
## Loading required package: ggplot2
require(scales)
## Loading required package: scales
require(plyr)
## Loading required package: plyr
BRvP<-read.csv('BRvP.csv')
View(BRvP)
numbrood<-BRvP[,c("SizeClass","Pop","NoBrood")]

ggplot()+
geom_bar(data=BRvP, aes(x=SizeClass, y=NoIndSize, group=Pop,colour=Pop,fill=Pop),
binwidth=10, stat="identity",position=position_dodge(),alpha=0.3)+
geom_bar(data=numbrood, aes(x=SizeClass, y=NoBrood, group=Pop,fill=Pop),
binwidth=10, stat="identity",position=position_dodge())+
scale_colour_manual(values=c("blue","purple","orange"))+
scale_fill_manual(values=c("blue","purple","orange"))

// add bootstrap table styles to pandoc tables $(document).ready(function () { $(‘tr.header’).parent(‘thead’).parent(‘table’).addClass(‘table table-condensed’); }); (function () { var script = document.createElement(“script”); script.type = “text/javascript”; script.src = “https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML&#8221;; document.getElementsByTagName(“head”)[0].appendChild(script); })();

10 15 2014 Size Class Code

sizeclassdata.R code{white-space: pre;} pre:not([class]) { background-color: white; } if (window.hljs && document.readyState && document.readyState === “complete”) { window.setTimeout(function() { hljs.initHighlighting(); }, 0); } .main-container { max-width: 940px; margin-left: auto; margin-right: auto; }

require(TeachingDemos)
## Loading required package: TeachingDemos
require(ggplot2)
## Loading required package: ggplot2
require(scales)
## Loading required package: scales
require(plyr)
## Loading required package: plyr
nsize10<-sum(endfid$Tray_1=="2N"&10 %<=% endfid$Length.mm %<% 15)
nsize15<-sum(endfid$Tray_1=="2N"&15 %<=% endfid$Length.mm %<% 20)
nsize20<-sum(endfid$Tray_1=="2N"&20 %<=% endfid$Length.mm %<% 25)
nsize25<-sum(endfid$Tray_1=="2N"&25 %<=% endfid$Length.mm %<% 30)
nsize30<-sum(endfid$Tray_1=="2N"&30 %<=% endfid$Length.mm %<% 35)
nsize35<-sum(endfid$Tray_1=="2N"&35 %<=% endfid$Length.mm %<% 40)
nsize40<-sum(endfid$Tray_1=="2N"&40 %<=% endfid$Length.mm %<% 45)
nsize45<-sum(endfid$Tray_1=="2N"&45 %<=% endfid$Length.mm %<% 50)
nsize50<-sum(endfid$Tray_1=="2N"&50 %<=% endfid$Length.mm %<% 55)
nsize55<-sum(endfid$Tray_1=="2N"&55 %<=% endfid$Length.mm %<% 60)
sizeclassfidn<-matrix(c(nsize10,nsize15,nsize20,nsize25,nsize30,nsize35,nsize40,nsize45,nsize50,nsize55),ncol=10,byrow=F)
colnames(sizeclassfidn)<-c("S10-15","S15-20","S20-25","S25-30","S30-35","S35-40","S40-45","S45-50","S50-55","S55-60")
head(sizeclassfidn)
##      S10-15 S15-20 S20-25 S25-30 S30-35 S35-40 S40-45 S45-50 S50-55 S55-60
## [1,] 8 34 102 129 83 22 1 0 0 0
hsize10<-sum(endfid$Tray_1=="2H"&10 %<=% endfid$Length.mm %<% 15)
hsize15<-sum(endfid$Tray_1=="2H"&15 %<=% endfid$Length.mm %<% 20)
hsize20<-sum(endfid$Tray_1=="2H"&20 %<=% endfid$Length.mm %<% 25)
hsize25<-sum(endfid$Tray_1=="2H"&25 %<=% endfid$Length.mm %<% 30)
hsize30<-sum(endfid$Tray_1=="2H"&30 %<=% endfid$Length.mm %<% 35)
hsize35<-sum(endfid$Tray_1=="2H"&35 %<=% endfid$Length.mm %<% 40)
hsize40<-sum(endfid$Tray_1=="2H"&40 %<=% endfid$Length.mm %<% 45)
hsize45<-sum(endfid$Tray_1=="2H"&45 %<=% endfid$Length.mm %<% 50)
hsize50<-sum(endfid$Tray_1=="2H"&50 %<=% endfid$Length.mm %<% 55)
hsize55<-sum(endfid$Tray_1=="2H"&55 %<=% endfid$Length.mm %<% 60)
sizeclassfidh<-matrix(c(hsize10,hsize15,hsize20,hsize25,hsize30,hsize35,hsize40,hsize45,hsize50,hsize55),ncol=10,byrow=F)
colnames(sizeclassfidh)<-c("S10-15","S15-20","S20-25","S25-30","S30-35","S35-40","S40-45","S45-50","S50-55","S55-60")
head(sizeclassfidh)
##      S10-15 S15-20 S20-25 S25-30 S30-35 S35-40 S40-45 S45-50 S50-55 S55-60
## [1,] 6 68 117 97 20 6 0 0 0 0
ssize10<-sum(endfid$Tray_1=="2S"&10 %<=% endfid$Length.mm %<% 15)
ssize15<-sum(endfid$Tray_1=="2S"&15 %<=% endfid$Length.mm %<% 20)
ssize20<-sum(endfid$Tray_1=="2S"&20 %<=% endfid$Length.mm %<% 25)
ssize25<-sum(endfid$Tray_1=="2S"&25 %<=% endfid$Length.mm %<% 30)
ssize30<-sum(endfid$Tray_1=="2S"&30 %<=% endfid$Length.mm %<% 35)
ssize35<-sum(endfid$Tray_1=="2S"&35 %<=% endfid$Length.mm %<% 40)
ssize40<-sum(endfid$Tray_1=="2S"&40 %<=% endfid$Length.mm %<% 45)
ssize45<-sum(endfid$Tray_1=="2S"&45 %<=% endfid$Length.mm %<% 50)
ssize50<-sum(endfid$Tray_1=="2S"&50 %<=% endfid$Length.mm %<% 55)
ssize55<-sum(endfid$Tray_1=="2S"&55 %<=% endfid$Length.mm %<% 60)
sizeclassfids<-matrix(c(ssize10,ssize15,ssize20,ssize25,ssize30,ssize35,ssize40,ssize45,ssize50,ssize55),ncol=10,byrow=F)
colnames(sizeclassfids)<-c("S10-15","S15-20","S20-25","S25-30","S30-35","S35-40","S40-45","S45-50","S50-55","S55-60")
head(sizeclassfids)
##      S10-15 S15-20 S20-25 S25-30 S30-35 S35-40 S40-45 S45-50 S50-55 S55-60
## [1,] 1 14 88 144 98 20 3 0 0 0
sizeclassfid<-rbind(sizeclassfidn,sizeclassfidh,sizeclassfids)
rownames(sizeclassfid)<-c("Fidalgo","Dabob","OysterBay")
broodersizes<-read.csv('Broodersizes.csv')
broodersizes$Date<-as.Date(broodersizes$Date,"%m/%d/%Y")
bnsize10<-sum(broodersizes$Site=="Fidalgo"&broodersizes$Population=="N"&10 %<=% broodersizes$Size %<% 15)
bnsize15<-sum(broodersizes$Site=="Fidalgo"&broodersizes$Population=="N"&15 %<=% broodersizes$Size %<% 20)
bnsize20<-sum(broodersizes$Site=="Fidalgo"&broodersizes$Population=="N"&20 %<=% broodersizes$Size %<% 25)
bnsize25<-sum(broodersizes$Site=="Fidalgo"&broodersizes$Population=="N"&25 %<=% broodersizes$Size %<% 30)
bnsize30<-sum(broodersizes$Site=="Fidalgo"&broodersizes$Population=="N"&30 %<=% broodersizes$Size %<% 35)
bnsize35<-sum(broodersizes$Site=="Fidalgo"&broodersizes$Population=="N"&35 %<=% broodersizes$Size %<% 40)
bnsize40<-sum(broodersizes$Site=="Fidalgo"&broodersizes$Population=="N"&40 %<=% broodersizes$Size %<% 45)
bnsize45<-sum(broodersizes$Site=="Fidalgo"&broodersizes$Population=="N"&45 %<=% broodersizes$Size %<% 50)
bnsize50<-sum(broodersizes$Site=="Fidalgo"&broodersizes$Population=="N"&50 %<=% broodersizes$Size %<% 55)
bnsize55<-sum(broodersizes$Site=="Fidalgo"&broodersizes$Population=="N"&55 %<=% broodersizes$Size %<% 60)
sizeclassbrfidn<-matrix(c(bnsize10,bnsize15,bnsize20,bnsize25,bnsize30,bnsize35,bnsize40,bnsize45,bnsize50,bnsize55),ncol=10,byrow=F)
colnames(sizeclassbrfidn)<-c("S10-15","S15-20","S20-25","S25-30","S30-35","S35-40","S40-45","S45-50","S50-55","S55-60")
head(sizeclassbrfidn)
##      S10-15 S15-20 S20-25 S25-30 S30-35 S35-40 S40-45 S45-50 S50-55 S55-60
## [1,] 0 1 0 2 4 1 0 0 0 0
bhsize10<-sum(broodersizes$Site=="Fidalgo"&broodersizes$Population=="H"&10 %<=% broodersizes$Size %<% 15)
bhsize15<-sum(broodersizes$Site=="Fidalgo"&broodersizes$Population=="H"&15 %<=% broodersizes$Size %<% 20)
bhsize20<-sum(broodersizes$Site=="Fidalgo"&broodersizes$Population=="H"&20 %<=% broodersizes$Size %<% 25)
bhsize25<-sum(broodersizes$Site=="Fidalgo"&broodersizes$Population=="H"&25 %<=% broodersizes$Size %<% 30)
bhsize30<-sum(broodersizes$Site=="Fidalgo"&broodersizes$Population=="H"&30 %<=% broodersizes$Size %<% 35)
bhsize35<-sum(broodersizes$Site=="Fidalgo"&broodersizes$Population=="H"&35 %<=% broodersizes$Size %<% 40)
bhsize40<-sum(broodersizes$Site=="Fidalgo"&broodersizes$Population=="H"&40 %<=% broodersizes$Size %<% 45)
bhsize45<-sum(broodersizes$Site=="Fidalgo"&broodersizes$Population=="H"&45 %<=% broodersizes$Size %<% 50)
bhsize50<-sum(broodersizes$Site=="Fidalgo"&broodersizes$Population=="H"&50 %<=% broodersizes$Size %<% 55)
bhsize55<-sum(broodersizes$Site=="Fidalgo"&broodersizes$Population=="H"&55 %<=% broodersizes$Size %<% 60)
sizeclassbrfidh<-matrix(c(bhsize10,bhsize15,bhsize20,bhsize25,bhsize30,bhsize35,bhsize40,bhsize45,bhsize50,bhsize55),ncol=10,byrow=F)
colnames(sizeclassbrfidh)<-c("S10-15","S15-20","S20-25","S25-30","S30-35","S35-40","S40-45","S45-50","S50-55","S55-60")
head(sizeclassbrfidh)
##      S10-15 S15-20 S20-25 S25-30 S30-35 S35-40 S40-45 S45-50 S50-55 S55-60
## [1,] 0 1 5 1 1 0 0 0 0 0
bssize10<-sum(broodersizes$Site=="Fidalgo"&broodersizes$Population=="S"&10 %<=% broodersizes$Size %<% 15)
bssize15<-sum(broodersizes$Site=="Fidalgo"&broodersizes$Population=="S"&15 %<=% broodersizes$Size %<% 20)
bssize20<-sum(broodersizes$Site=="Fidalgo"&broodersizes$Population=="S"&20 %<=% broodersizes$Size %<% 25)
bssize25<-sum(broodersizes$Site=="Fidalgo"&broodersizes$Population=="S"&25 %<=% broodersizes$Size %<% 30)
bssize30<-sum(broodersizes$Site=="Fidalgo"&broodersizes$Population=="S"&30 %<=% broodersizes$Size %<% 35)
bssize35<-sum(broodersizes$Site=="Fidalgo"&broodersizes$Population=="S"&35 %<=% broodersizes$Size %<% 40)
bssize40<-sum(broodersizes$Site=="Fidalgo"&broodersizes$Population=="S"&40 %<=% broodersizes$Size %<% 45)
bssize45<-sum(broodersizes$Site=="Fidalgo"&broodersizes$Population=="S"&45 %<=% broodersizes$Size %<% 50)
bssize50<-sum(broodersizes$Site=="Fidalgo"&broodersizes$Population=="S"&50 %<=% broodersizes$Size %<% 55)
bssize55<-sum(broodersizes$Site=="Fidalgo"&broodersizes$Population=="S"&55 %<=% broodersizes$Size %<% 60)
sizeclassbrfids<-matrix(c(bssize10,bssize15,bssize20,bssize25,bssize30,bssize35,bssize40,bssize45,bssize50,bssize55),ncol=10,byrow=F)
colnames(sizeclassbrfids)<-c("S10-15","S15-20","S20-25","S25-30","S30-35","S35-40","S40-45","S45-50","S50-55","S55-60")
head(sizeclassbrfids)
##      S10-15 S15-20 S20-25 S25-30 S30-35 S35-40 S40-45 S45-50 S50-55 S55-60
## [1,] 0 0 1 18 18 1 1 0 0 0
sizeclassbrfid<-rbind(sizeclassbrfidn,sizeclassbrfidh,sizeclassbrfids)
rownames(sizeclassbrfid)<-c("BrooderFidalgo","BrooderDabob","BrooderOysterBay")
head(sizeclassbrfid)
##                  S10-15 S15-20 S20-25 S25-30 S30-35 S35-40 S40-45 S45-50
## BrooderFidalgo 0 1 0 2 4 1 0 0
## BrooderDabob 0 1 5 1 1 0 0 0
## BrooderOysterBay 0 0 1 18 18 1 1 0
## S50-55 S55-60
## BrooderFidalgo 0 0
## BrooderDabob 0 0
## BrooderOysterBay 0 0
brvpopsize<-t(rbind(sizeclassfid,sizeclassbrfid))
brvpopsizedf<-as.data.frame(brvpopsize)
brvpopsizedf$PercBroodFid<-(brvpopsizedf$BrooderFidalgo/brvpopsizedf$Fidalgo)
brvpopsizedf$PercBroodDab<-(brvpopsizedf$BrooderDabob/brvpopsizedf$Dabob)
brvpopsizedf$PercBroodOys<-(brvpopsizedf$BrooderOysterBay/brvpopsizedf$OysterBay)
brvpszfx<-rapply(brvpopsizedf, f=function(x)ifelse(is.nan(x),0,x),how="replace")
brvp<-data.frame(brvpszfx)

brvp$SizeClass=c("10-15mm","15-20mm","20-25mm","25-30mm","30-35mm","35-40mm","40-45mm","45-50mm","50-55mm","55-60mm")

ggplot()+geom_bar(data=brvp, aes(x=SizeClass,y=PercBroodFid),color="purple", fill="purple",stat="identity")+geom_bar(data=brvp,aes(x=SizeClass, y=PercBroodDab),color="blue",fill="blue",stat="identity")+geom_bar(data=brvp, aes(x=SizeClass,y=PercBroodOys),color="orange",fill="orange",stat="identity")

brvp$PercSizeFidalgo<-(brvp$Fidalgo/(sum(brvp$Fidalgo)))
brvp$PercSizeOysBay<-(brvp$OysterBay/(sum(brvp$OysterBay)))
brvp$PercSizeDabob<-(brvp$Dabob/(sum(brvp$Dabob)))
brvp$BrSzPercFidalgo<-(brvp$PercBroodFid*brvp$PercSizeFidalgo)
brvp$BrSzPercDabob<-(brvp$PercBroodDab*brvp$PercSizeDabob)
brvp$BrSzPercOysBay<-(brvp$PercBroodOys*brvp$PercSizeOysBay)

BRvP<-read.csv('BRvP.csv')
View(BRvP)
ggplot(BRvP, aes(x=SizeClass, y=BrSzPercPop, group=Pop, color=Pop, fill=Pop))+geom_bar(binwidth=10, stat="identity", position=position_dodge())+scale_colour_manual(values=c("blue","purple","orange"))+scale_fill_manual(values=c("blue","purple","orange"))+labs(x="Size Class", y="Percent of Pop. Brooding at Size Class")

ggplot(BRvP, aes(x=SizeClass, y=NoBrood, group=Pop, color=Pop, fill=Pop))+geom_bar(binwidth=10, stat="identity", position=position_dodge())+scale_colour_manual(values=c("blue","purple","orange"))+scale_fill_manual(values=c("blue","purple","orange"))+labs(x="Size Class", y="Number of Pop. Brooding at Size Class")

// add bootstrap table styles to pandoc tables $(document).ready(function () { $(‘tr.header’).parent(‘thead’).parent(‘table’).addClass(‘table table-condensed’); }); (function () { var script = document.createElement(“script”); script.type = “text/javascript”; script.src = “https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML&#8221;; document.getElementsByTagName(“head”)[0].appendChild(script); })();

10 3 2014 How to Convert and Plot HoboLogger Temp Data

TempDataConcatScript.R code{white-space: pre;} pre:not([class]) { background-color: white; } if (window.hljs && document.readyState && document.readyState === “complete”) { window.setTimeout(function() { hljs.initHighlighting(); }, 0); } .main-container { max-width: 940px; margin-left: auto; margin-right: auto; }

#Temp concat
library(plyr)
library(ggplot2)
library(scales)
oysaugfeb<-read.table('OysAugtoFeb.csv', row.names=1)
#read in data, first change column names and remove data name in excel to make it work
head(oysaugfeb)
##          V2    V3    V4
## 1 8/17/2013 12:42 23.77
## 2 8/17/2013 12:57 23.20
## 3 8/17/2013 13:12 23.20
## 4 8/17/2013 13:27 23.39
## 5 8/17/2013 13:42 23.58
## 6 8/17/2013 13:57 23.77
oysaugfeb<-rename(oysaugfeb, c("V2"="Date",'V3'='Time','V4'='Temp'))
#rename columns
oysaugfeb$Date<-as.Date(oysaugfeb$Date, "%m/%d/%Y")
#tell R that these are dates
tmptst<-ddply(oysaugfeb,.(Date),summarise, mean_temp=mean(Temp,na.rm=T))
#creates mean temperature per date using summary statistics and ddply
plot(mean_temp~Date,data=tmptst)

#plot using native plotting function to view temp graph, fix later with ggplot2 graph
oysfebmay<-read.table('Oyster_BayFebtoMay2014.csv', row.names=1)
oysmayjun<-read.table('OysterBayMaytoJune14.csv', row.names=1)
oysjun<-read.table('OysterBayJune14.csv',row.names=1)
oysjunjul<-read.table('Oyster_BayJuntoJul14.csv',row.names=1)
oysjunsep<-read.table('OysterBayJuntoSept.csv',row.names=1)
oysjulaug<-read.table('Oyster_BayJultoAug.csv',row.names=1)
oysaugsep<-read.table('Oyster_BayAug14toSep.csv',row.names=1)
#reads in as tables the other 4 temp data sets
oysfebmay<-rename(oysfebmay, c("V2"="Date",'V3'='Time','V4'='Temp'))
oysmayjun<-rename(oysmayjun, c("V2"="Date",'V3'='Time','V4'='Temp'))
oysjun<-rename(oysjun, c("V2"="Date",'V3'='Time','V4'='Temp'))
oysjunjul<-rename(oysjunjul, c("V2"="Date",'V3'='Time','V4'='Temp'))
oysjunsep<-rename(oysjunsep, c("V2"="Date",'V3'='Time','V4'='Temp'))
oysjulaug<-rename(oysjulaug, c("V2"="Date",'V3'='Time','V4'='Temp'))
oysaugsep<-rename(oysaugsep, c("V2"="Date",'V3'='Time','V4'='Temp'))
#renames the columns of the other 4 data sets
oysfebmay$Date<-as.Date(oysfebmay$Date, "%m/%d/%Y")
oysmayjun$Date<-as.Date(oysmayjun$Date, "%m/%d/%Y")
oysjun$Date<-as.Date(oysjun$Date, "%m/%d/%Y")
oysjunjul$Date<-as.Date(oysjunjul$Date, "%m/%d/%Y")
oysjunsep$Date<-as.Date(oysjunsep$Date, "%m/%d/%Y")
oysjulaug$Date<-as.Date(oysjulaug$Date, "%m/%d/%Y")
oysaugsep$Date<-as.Date(oysaugsep$Date, "%m/%d/%Y")
#tells R that all the date columns are dates
oysaugmay<-merge(oysaugfeb,oysfebmay,by = c("Date","Time","Temp"),all=T)
#merges oysaugfeb to oysfebmay into one continuous data file
oysy1<-rbind(oysaugfeb,oysfebmay,oysmayjun,oysjun,oysjunjul,oysjunsep,oysjulaug,oysaugsep)
#merges all temp files into a single table
oysmeantemp<-ddply(oysy1,.(Date),summarise,mean_temp=mean(Temp,na.rm=T))
#creates mean temp file
oysmintemp<-ddply(oysy1,.(Date),summarise,min_temp=min(Temp,na.rm=T))
#creates min temp file
oysmaxtemp<-ddply(oysy1,.(Date),summarise,max_temp=max(Temp,na.rm=T))
#creates max temp file
oysmedtemp<-ddply(oysy1,.(Date),summarise,med_temp=median(Temp,na.rm=T))
#creates median temp file
ggplot(data=oysmedtemp, aes(Date, med_temp, group=1))+geom_line(color="orange",size=1.5)+geom_abline(intercept=12.5, slope=0,color="red", size=2)+scale_x_date(breaks="1 month", minor_breaks="1 week",labels=date_format("%B %Y"))+theme(axis.text.x=element_text(angle=45, size=10, vjust=0.5))

#generates plot of median temps
ggplot(data=oysmeantemp, aes(Date, mean_temp, group=1))+geom_line(color="orange",size=1.5)+geom_abline(intercept=12.5, slope=0,color="red", size=2)+scale_x_date(breaks="1 month", minor_breaks="1 week",labels=date_format("%B %Y"))+theme(axis.text.x=element_text(angle=45, size=10, vjust=0.5))

#creates plot of mean temp data with 12.5 C line
ggplot(data=oysmintemp, aes(Date, min_temp, group=1))+geom_line(color="orange",size=1.5)+geom_abline(intercept=12.5, slope=0,color="red", size=2)+scale_x_date(breaks="1 month", minor_breaks="1 week",labels=date_format("%B %Y"))+theme(axis.text.x=element_text(angle=45, size=10, vjust=0.5))

#creates plot of min temp data with 12.5 C line
ggplot(data=oysmaxtemp, aes(Date, max_temp, group=1))+geom_line(color="orange",size=1.5)+geom_abline(intercept=12.5, slope=0,color="red", size=2)+scale_x_date(breaks="1 month", minor_breaks="1 week",labels=date_format("%B %Y"))+theme(axis.text.x=element_text(angle=45, size=10, vjust=0.5))

#creates plot of max temps with 12.5 C line
ggplot()+geom_line(data=oysmeantemp, aes(Date,mean_temp, group=1), color="orange",size=1)+geom_line(data=oysmintemp, aes(Date,min_temp,group=1),color="blue",size=1)+geom_line(data=oysmaxtemp,aes(Date,max_temp,group=1),color="red",size=1)+geom_abline(intercept=12.5, slope=0,color="red", size=0.5)+labs(x="Date",y="Min|Max|Mean Temperatures(C)")+scale_x_date(breaks="1 month", minor_breaks="1 week",labels=date_format("%B %Y"))+theme(axis.text.x=element_text(angle=45, size=10, vjust=0.5))

#generates plot containing min,max, and mean temp color coordinated as well as 12.5 C line. 
meanmax<-merge(oysmeantemp,oysmaxtemp,by="Date",all=T)
#merges mean and max frames
medmin<-merge(oysmedtemp,oysmintemp,by="Date",all=T)
#merges median and min frames
oystmpstat<-merge(meanmax,medmin,by="Date",all=T)
#merges meanmax and medmin frames together
oysy1stat<-merge(oysy1,oystmpstat,by="Date",all=T)
#merges year 1 temp info with stats for each date
write.csv(oysy1stat, file="oysY1stats.csv",row.names=F)
#creates CSV file with all temp and stat info

// add bootstrap table styles to pandoc tables $(document).ready(function () { $(‘tr.header’).parent(‘thead’).parent(‘table’).addClass(‘table table-condensed’); }); (function () { var script = document.createElement(“script”); script.type = “text/javascript”; script.src = “https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML&#8221;; document.getElementsByTagName(“head”)[0].appendChild(script); })();

9 19 2014 oyster bay fall maintenance

Kamilche wa

High 60s low 70s cloudy to mostly sunny

Participants: Sean Bennett,  Jonathan Allen,  and Jake heare.

Took live dead counts for all remaining trays. Then moved remaining oysters from trays to new hexagonal hanging cages. Then tied the cages together and hung them off the same hanging ropes. Very high survival in all trays, less than 2% mortality. Food growth in all trays. Some oysters look market size now. Mussel incursion was much better than expected with very little in most trays. More red rock crabs than I expected but seemed to have little effect on survival. Also lots of oyster spat in all trays. Collected spat for DNA workup if desired.

Numbers as follow

1S9-12
Live.           3
Dead.         3
Sampled     3

1H13-16
Live.           12
Dead.          2
Sample.      12

1N1-4
Live.           72
Dead.         0
Sample.      20

1H5-8
Live.          49
Dead.         7
Sample.      13

1S1-4
Live.          80
Dead.         4
Sample.      24

1S13-16
Live.          71
Dead.          2
Sample.      23

1N5-8
Live.          51
Dead.         0
Sample.      10

1H9-12.     
Live.          80
Dead.         3
Sample.      15

1H1-4
Live.         67
Dead.        3
Sample.     10

1N9-12
Live.          77
Dead.         1
Sample.      20

Pics below. 1S1-4 tray with 3 live on it is actually 1S9-12. 

9 14 2014 Kaplan Meier Graphs Improved

KMgraphsWorking.R code{white-space: pre;} pre:not([class]) { background-color: white; } if (window.hljs && document.readyState && document.readyState === “complete”) { window.setTimeout(function() { hljs.initHighlighting(); }, 0); } .main-container { max-width: 940px; margin-left: auto; margin-right: auto; }

library(survival)
## Loading required package: splines
kmdab=read.csv("KMdataDabob.csv")
names(kmdab)
## [1] "Animal"     "Population" "Death"      "Status"
with(kmdab, tapply(Death[Status==1],Population[Status==1],mean))
##     H     N     S 
## 4.385 4.522 4.715
with(kmdab, tapply(Death[Status==1],Population[Status==1],var))
##      H      N      S 
## 0.4524 0.9786 1.6039
fit1=with(kmdab,survfit(Surv(Death,Status)~Population))
plot(fit1, col=c(1:3), xlab="Survival Time from Outplant in Months", ylab="% Surviving")
legend("bottomleft", title="Population", c("Dabob","Fidalgo","Oyster Bay"), fill=c(1:3))

kmman=read.csv("KMdataMan.csv")
names(kmman)
## [1] "Animal"     "Population" "Death"      "Status"
with(kmman, tapply(Death[Status==1],Population[Status==1],mean))
##      H      N      S 
## 10.540 9.368 9.197
with(kmman, tapply(Death[Status==1],Population[Status==1],var))
##     H     N     S 
## 1.519 6.468 6.321
fit2=with(kmman, survfit(Surv(Death,Status)~Population))
plot(fit2, col=c(1:3), xlab="Survival Time from Outplant in Months", ylab="% Surviving")
legend("bottomleft", title="Population", c("Dabob","Fidalgo","Oyster Bay"), fill=c(1:3))

kmfid=read.csv("KMdataFid.csv")
with(kmfid, tapply(Death[Status==1],Population[Status==1],mean))
##     H     N     S 
## 5.921 5.754 6.897
with(kmfid, tapply(Death[Status==1],Population[Status==1],var))
##     H     N     S 
## 2.554 2.189 3.989
fit3=with(kmfid, survfit(Surv(Death,Status)~Population))
plot(fit3, col=c(1:3), xlab="Survival Time from Outplant in Months", ylab="% Surviving")
legend("bottomleft", title="Population", c("Dabob","Fidalgo","Oyster Bay"), fill=c(1:3))

kmoys=read.csv("KMdataOys.csv")
with(kmoys, tapply(Death[Status==1],Population[Status==1],mean))
##     H     N     S 
## 7.550 8.069 8.396
with(kmoys, tapply(Death[Status==1],Population[Status==1],var))
##     H     N     S 
## 7.774 5.805 5.814
fit4=with(kmoys, survfit(Surv(Death,Status)~Population))
plot(fit4, col=c(1:3), xlab="Survival Time from Outplant in Months", ylab="% Surviving")
legend("bottomleft", title="Population", c("Dabob","Fidalgo","Oyster Bay"), fill=c(1:3))

// add bootstrap table styles to pandoc tables $(document).ready(function () { $(‘tr.header’).parent(‘thead’).parent(‘table’).addClass(‘table table-condensed’); }); (function () { var script = document.createElement(“script”); script.type = “text/javascript”; script.src = “https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML&#8221;; document.getElementsByTagName(“head”)[0].appendChild(script); })();

9 12 2014 Brooder Numbers Graphs

Fecundityplots.R code{white-space: pre;} pre:not([class]) { background-color: white; } if (window.hljs && document.readyState && document.readyState === “complete”) { window.setTimeout(function() { hljs.initHighlighting(); }, 0); } .main-container { max-width: 940px; margin-left: auto; margin-right: auto; }

library(ggplot2)
repro2<-read.csv("Repro2.csv")
# reorganized reproduction table to work with subsets
fidalgo<-subset(repro2, Site=="Fidalgo")
# Subset for just Repro Numbers from Fidalgo
ggplot(data=fidalgo, aes(x=Date, y=Brooders, group=Pop, colour=Pop))+geom_line()+geom_point()+ylim(c(0,15))+scale_colour_manual(values=c("#3366CC","#CC66CC","#FF9900"))+theme(axis.text.x=element_text(angle=90, size=10, vjust=0.5))

# Plots Brooders at Fidalgo for all three populations
manch<-subset(repro2, Site == "Manchester")
# Subset for just Manchester
ggplot(data=manch, aes(x=Date, y=Brooders, group=Pop, colour=Pop))+geom_line()+geom_point()+ylim(c(0,15))+scale_colour_manual(values=c("#3366CC","#CC66CC","#FF9900"))+theme(axis.text.x=element_text(angle=90, size=10, vjust=0.5))

# Plots Brooders at Manchester for all pops
oysbay<-subset(repro2, Site=="Oyster Bay")
# Subset for just Oyster Bay data
ggplot(data=oysbay, aes(x=Date, y=Brooders, group=Pop, colour=Pop))+geom_line()+geom_point()+ylim(c(0,15))+scale_colour_manual(values=c("#3366CC","#CC66CC","#FF9900"))+theme(axis.text.x=element_text(angle=90, size=10, vjust=0.5))

# Plots brooders at Oyster Bay for all Pops
ggplot(repro2, aes(x=Date, y=Brooders, group=Pop, colour=Pop))+geom_line()+geom_point()+facet_wrap(~Site, ncol=1)+scale_colour_manual(values=c("#3366CC","#CC66CC","#FF9900"))+theme(axis.text.x=element_text(angle=90, size=10, vjust=0.5))

# Creates a multi-level plot of all Brooders at All Sites
ggplot(repro2, aes(x=Date, y=Brooders, group=Site, colour=Site))+geom_line()+geom_point()+facet_wrap(~Pop, ncol=1)+theme(axis.text.x=element_text(angle=90, size=10, vjust=0.5))

# Creates a multi-level plot of all sites comparing different populations
repro3<-read.csv('reproperc.csv')
# CSV with percent brooders
ggplot(repro3, aes(x=Date, y=Percent, group=Site, colour=Site))+geom_line()+geom_point()+facet_wrap(~Pop, ncol=1)+theme(axis.text.x=element_text(angle=90, size=10, vjust=0.5))

# Plots percent brooders for each pop comparing sites
ggplot(repro3, aes(x=Date, y=Percent, group=Pop, colour=Pop))+geom_line()+geom_point()+facet_wrap(~Site, ncol=1)+theme(axis.text.x=element_text(angle=90, size=10, vjust=0.5))+scale_colour_manual(values=c("#3366CC","#CC66CC","#FF9900"))

# Plots percent brooders for each site comparing pops

// add bootstrap table styles to pandoc tables $(document).ready(function () { $(‘tr.header’).parent(‘thead’).parent(‘table’).addClass(‘table table-condensed’); }); (function () { var script = document.createElement(“script”); script.type = “text/javascript”; script.src = “https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML&#8221;; document.getElementsByTagName(“head”)[0].appendChild(script); })();

9 9 2014 Distribution Overlay Graphs in R for Size Data

DistributionOverlayGraphs.R code{white-space: pre;} pre:not([class]) { background-color: white; } if (window.hljs && document.readyState && document.readyState === “complete”) { window.setTimeout(function() { hljs.initHighlighting(); }, 0); } .main-container { max-width: 940px; margin-left: auto; margin-right: auto; }

library(ggplot2)
#ggplot2 makes the distribution curve graphs
library(car)
#not sure what car does but I think it works with lattices
library(splitstackshape)
## Loading required package: data.table
#splitstackshape is an easy package that can help you split columns that have delimiters,
#Original CSV file column labelled "Tray" had entries that needed to be split
picsize5=read.csv('ImageJsize4.csv')
#creates dataframe and reads in the CSV file for sizes
picsize6<-concat.split.multiple(picsize5, "Tray", " ")
#splits the Tray column into Tray_1 with Site Number and Tray_2 with Tray number
foys<-subset(picsize6, Date=="2/26/2014"& Site=="Oyster Bay")
#creates a subset data frame for just the size data from February 26th at Oyster Bay
ggplot(foys, aes(x=Length.mm))+geom_density(aes(group=Tray_1, colour=Tray_1, fill=Tray_1),alpha=0.3)

#creates distribution graph overlays for all populations in Feb at Oyster Bay. Looks cool.
fman<-subset(picsize6, Date=="2/26/2014"& Site=="Manchester")
ggplot(fman, aes(x=Length.mm))+geom_density(aes(group=Tray_1, colour=Tray_1, fill=Tray_1),alpha=0.3)

ffid<-subset(picsize6, Date=="2/28/2014"&Site=="Fidalgo")
ggplot(ffid, aes(x=Length.mm))+geom_density(aes(group=Tray_1, colour=Tray_1, fill=Tray_1),alpha=0.3)

#ffid and fman are just repeating the same subset dataframe command
#and then creating distribution overlay graphs for each site

// add bootstrap table styles to pandoc tables $(document).ready(function () { $(‘tr.header’).parent(‘thead’).parent(‘table’).addClass(‘table table-condensed’); }); (function () { var script = document.createElement(“script”); script.type = “text/javascript”; script.src = “https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML&#8221;; document.getElementsByTagName(“head”)[0].appendChild(script); })();

9 8 2014 Kaplan Meier Survival Graphs

Seattle, WA

Mid 50s to Low 70s Mostly Cloudy

Worked through the examples in Statistical Computing as well as an R instruction video which uses the same sample problem as Statistical Computing as seen below.

Using my own data from Dabob since the experiment has concluded there, I was able to create a Kaplan Meier graph of survival that compares all three populations at Dabob. This information is censured as there were some animals lost during the experiment. This censorship is marked with a cross at the end as I assumed that when the trays were picked up all animals would be accounted for unless they were definitely missing. The graph is below.

As you can see their seems to be a difference in Survival between the populations. I was not sure if this difference was significant. By modifying the example code from Statistical Computing, I was able to show the mean month of death for each population, the variance for each population, as well as test for significant difference by using survreg. This function helps elucidate any differences between samples that may have extreme variance from one another. In this data set, it showed that there is a significant difference in month of death between all populations. You can see the code for everything and the responses below.

>KMdata3=read.csv(“KMdata3.csv”)
>attach(KMdata3)
>names(KMdata3)
#[1] “Animal”     “Population” “Death”      “Status”  
>tapply(Death[Status==1],Population[Status==1],mean)
#H        N        S 
#6.034682 5.163311 5.744186 
>tapply(Death[Status==1],Population[Status==1],var)
#H        N        S 
#5.471257 3.280445 4.768906 
>model<-survreg(Surv(Death,Status)~Population,dist="exponential")
> summary(model)
#
#Call:
#  survreg(formula = Surv(Death, Status) ~ Population, dist = “exponential”)
#Value Std. Error     z        p
#(Intercept)  2.293     0.0538 42.66 0.00e+00
#PopulationN -0.518     0.0716 -7.24 4.65e-13
#PopulationS -0.361     0.0722 -5.00 5.87e-07
#
#Scale fixed at 1 
#
#Exponential distribution
#Loglik(model)= -3641   Loglik(intercept only)= -3668.9
#Chisq= 55.8 on 2 degrees of freedom, p= 7.6e-13 
#Number of Newton-Raphson Iterations: 3 
#n= 1440 
> plot(fit3, col=c(1:3), xlab=”Survival Time in Months”, ylab=”% Surviving”)
> legend(“bottomleft”, title=”Population”, c(‘Dabob’,’Northern’,’Southern’), fill=c(1:3))

8 19 2014 ImageJ Analysis

FTR 230

Hi 60s to low 70s sunny

Participants: Sam Adams and Jake Heare

Sam showed me how to do the ImageJ measurements on the trays today as well as complete several of the trays. The procedure is quite simple.

  1. Open original image in ImageJ
  2. Select line tool
  3. Using on tray size standard (calipers or tile) draw a line
  4. Click M to save after each measurement
  5. repeat this 5 times on the size standard
  6. On each oyster start at the edge of the umbo and draw a line to the furthest point on the bill. 
  7. Click M to save each measure
  8. Proceed measure all oysters in a logical manner from left to right in each quadrant. 
  9. Once all have been measure click Save As in Results window
  10. Save file with the tray label followed by date followed by the word Raw.
  11. Open file in Excell
  12. To get the size conversion you must average of the first 5 “Area” measurements.
  13. Then divide the known size of the Size standard. (10 mm on calipers, 6 inches for tile) by the average you get from the firt 5 measurements.
  14. Using the conversion ratio you can then multiple each ImageJ “Area” measurement by the conversion ratio. 
  15. On the right side of the spreadsheet dedicate 5 columns to the measurements
  16. Column 1 (C1) = Date, C2 = Tray, C3 = Oyster Number, C4 = Area measure, C5 = converted area measurement
  17. Fill in columns with appropriate info
  18. Save file as Excel workbook in eagle/dermochelys/ImageJake with just the tray label and date info
  19. Copy and paste the 5 right side columns into the google sheets master document on Google docs
  20. Repeat process for each image. This should create two files for each image, a raw data and a converted data file. 

This is a backup for my primary blogger notebook