### ENP ACOUSTIC SURVEY METHODS DATA ### #This script analyzes data collected from Everglades National Park 2015 #Uses Compiled CSV file created in script "FileCompile.R" that merged all site-specific CSVs together. #If any changes are made to original CSV files, must first rerun "FileCompile.R" #CSV to be imported: "ENP_SurveyMethods_AcousticID.csv", which has been filtered of non-bat files (noise) and manually vetted for species ID #FUNCTIONS AND LIBRARIES SE <- function(x) sqrt(var(x)/length(x)) library(StreamMetabolism) #for calculating sunrise/set times library(lme4) #for mixed models library(chron) #time library(vegan) #load package with diversity indices library(AICcmodavg) #AICc library(car) #Glossary of Terms #Survey Methods: #Permanent = Single Strategic Stationary Surveys #Temporary = Spatially Replicated Stationary Surveys #Transect = Mobile Transect Surveys #Bat Species: #CORA = Corynorhinus rafinesquii #EUFL = Eumops floridanus #EPFU = Eptesicus fuscus #LAIN = Lasiurus borealis #LABO_LASE = Lasiurus borealis or Lasiurus seminolus #MOMO = Molossus molossus #MYAU = Myotis austroriparius #NYHU = Nycticeius humeralis #PESU = Perimyotis subflavus #TABR = Tadarida brasiliensis #Seasons #Wet = June-July #Dry = Feb-March #Acoustic detections (response variables) #FILES = any file containing >= 2 bat calls of any species #Strict.Files = Files having passed our STRICT/Conservative PROTOCOL to receive species ID: Must have >=0.75 % matching and >= 5 pulses, and be manually vetted if < 10 files in any site #StrictTransectDate = Strict files that were recorded on nights that transects were conducted #StrictTransectDateTime = Strict files that were recorded on nights AND times that transects were conducted #*************************** ### Import DATAFRAME ### #*************************** #SET WORKING DIRECTORY setwd("~/Desktop/RESEARCH/UF/RESEARCH/ENP project/STATISTICS/Manuscripts/Methods/wd") #IMPORT DATA ID<-read.csv("ENP_SurveyMethods_AcousticID.csv",na.strings="",strip.white=T) ID<-within(ID, DATE.12<-as.Date(DATE.12)) #Number of files SummaryFiles<-aggregate(cbind(FILES,Strict.Files)~METHOD,data=ID,sum) #*************************************** ### SUMMARIES of SPECIES DETECTED ### #************************************** # Across entire study (Strict.files), only nights of transect (StrictTransectDate), and only nights/times of transect (StrictTransectDateTime) #For Figure 1 and Table 1 #detection of each species at each site Detections.site<-aggregate(cbind(Strict.Files,StrictTransectDate,StrictTransectDateTime)~ConsensusID+SITE+METHOD+HABITAT,data=ID,max) #Figure 1 - look only at three rare species at each site (not detected with transects) RareDetections.site<-aggregate(cbind(Strict.Files,StrictTransectDate,StrictTransectDateTime)~ConsensusID+SITE+METHOD+HABITAT,subset=ConsensusID=="EUFL"| ConsensusID=="CORA"|ConsensusID=="MOMO",data=ID,max) #By site and method and Habitat (TABLE 1) Detections.method<-aggregate(cbind(Strict.Files,StrictTransectDate,StrictTransectDateTime)~ConsensusID+METHOD,data=ID,max) Detection.season.method<-aggregate(cbind(Strict.Files,StrictTransectDate,StrictTransectDateTime)~ConsensusID+SEASON+METHOD,subset=METHOD!="Temporary",data=ID,max) Detection.hab.method<-aggregate(cbind(Strict.Files,StrictTransectDate,StrictTransectDateTime)~ConsensusID+HABITAT+METHOD,subset=METHOD!="Temporary",data=ID,max) #********************************************************* #### SPECIES RICHNESS #### #********************************************************* #Consolidate to species detections per night SummaryID.night<-aggregate(cbind(Strict.Files,StrictTransectDate,StrictTransectDateTime)~ConsensusID+SITE+DATE.12+HABITAT+METHOD+SEASON,data=ID,sum) #Add species presence per night and on nights of transect SummaryID.night<-within(SummaryID.night,Presence<-ifelse(Strict.Files>0,1,0)) SummaryID.night<-within(SummaryID.night,PresenceTransectDate<-ifelse(StrictTransectDate>0,1,0)) #Calculate species richness per night (number of species detected each survey night) SpeciesRichness.night<-aggregate(cbind(Presence,PresenceTransectDate)~SITE+DATE.12+HABITAT+METHOD+SEASON,data=SummaryID.night,sum) #Calculate Overall Means & SE #Single Strategic vs. Transects - only on nights of transects aggregate(Presence~METHOD,data=SpeciesRichness.night,subset=METHOD!="Temporary"&PresenceTransectDate>0,mean) aggregate(Presence~METHOD,data=SpeciesRichness.night,subset=METHOD!="Temporary"&PresenceTransectDate>0,SE) #SE calculated with nights as replicates #Single Strategic vs. Spatially Replicated - on all nights #across all habitats aggregate(Presence~METHOD,data=SpeciesRichness.night,subset=METHOD!="Transect",mean) aggregate(Presence~METHOD,data=SpeciesRichness.night,subset=METHOD!="Transect",SE) #SE calculated with nights as replicates #split by habitats aggregate(Presence~METHOD+HABITAT,data=SpeciesRichness.night,subset=METHOD!="Transect",mean) aggregate(Presence~METHOD+HABITAT,data=SpeciesRichness.night,subset=METHOD!="Transect",SE) #SE calculated with nights as replicates *************************** ## STATISTICS ## *************************** ## GENERALIZED LINEAR MIXED EFFECTS MODELS #Load Libraries library(lme4) #for mixed models library(blmeco) #for test of overdispersion #************* ### Comparisons between Single Strategic Stationary vs. Mobile Transects #Test Nightly Species Richness detected with each Survey Method, regardless of Habitat and Season (modeled as RANDOM Effects) #Poisson distribution #Presence = Count of # of species detected on each night at each site #Only on nights when transects were conducted #Null model Rich.mmNull<-glmer(Presence~+(1|HABITAT)+(1|SEASON), data=SpeciesRichness.night,family=poisson,subset=METHOD!="Temporary"&PresenceTransectDate>0) summary(Rich.mmNull) qqnorm(resid(Rich.mmNull)) hist(resid(Rich.mmNull)) plot(resid(Rich.mmNull),fitted(Rich.mmNull)) dispersion_glmer(Rich.mmNull) #0.78 - no overdispersion #Alternate model Rich.mmF<-glmer(Presence~METHOD+(1|HABITAT)+(1|SEASON), data=SpeciesRichness.night,family=poisson,subset=METHOD!="Temporary"&PresenceTransectDate>0) qqnorm(resid(Rich.mmF)) hist(resid(Rich.mmF)) plot(resid(Rich.mmF),fitted(Rich.mmF)) dispersion_glmer(Rich.mmF) #0.62 - no overdispersion # likelihood ratio test between alternate and null models anova(Rich.mmF,Rich.mmNull) #effect of survey method significant summary(Rich.mmF) #**************** ### Comparisons between Single Strategic and Spatially Replicated Stationary Surveys #Habitat (veg community) and Season as FIXED effects because interested in how structurally different vegetation communities affect need for spatial sampling #Poisson distribution #Null Model Rich.mmNull<-glmer(Presence~HABITAT+(1|SEASON)+(1|SITE), data=SpeciesRichness.night,family=poisson,subset=METHOD!="Transect"&HABITAT!="Mangrove") qqnorm(resid(Rich.mmNull)) hist(resid(Rich.mmNull)) #Alternate Model Rich.mmF<-glmer(Presence~METHOD+HABITAT+(1|SEASON)+(1|SITE), data=SpeciesRichness.night,family=poisson,subset=METHOD!="Transect"&HABITAT!="Mangrove") qqnorm(resid(Rich.mmF)) plot(resid(Rich.mmF),fitted(Rich.mmF)) # likelihood ratio test between alternate and null models anova(Rich.mmF,Rich.mmNull) #effect of survey method significant summary(Rich.mmF) #Temporary detectors lower species richness per night qqnorm(resid(Rich.mmF)) hist(resid(Rich.mmF)) #Within each Habitat (season as random effect) #Prairie Rich.mmPrairie<-glmer(Presence~METHOD+(1|SEASON)+(1|SITE), data=SpeciesRichness.night,family=poisson,subset=METHOD!="Transect"&HABITAT=="Prairie") Rich.mmPrairieNull<-glmer(Presence~(1|SEASON)+(1|SITE), data=SpeciesRichness.night,family=poisson,subset=METHOD!="Transect"&HABITAT=="Prairie") anova(Rich.mmPrairie,Rich.mmPrairieNull) #no effect of survey method #Pine Rich.mmPine<-glmer(Presence~METHOD+(1|SEASON)+(1|SITE), data=SpeciesRichness.night,family=poisson,subset=METHOD!="Transect"&HABITAT=="Pine") Rich.mmPineNull<-glmer(Presence~(1|SEASON)+(1|SITE), data=SpeciesRichness.night,family=poisson,subset=METHOD!="Transect"&HABITAT=="Pine") anova(Rich.mmPine,Rich.mmPineNull) #significant effect of survey method #********************************************** ####### SPECIES ACCUMULATION CURVES ######## #********************************************** library(vegan) #load package with diversity indices # Function to make lty work in plots plot.specaccum <- function (x, add = FALSE, ci = 1, ci.type = c("bar", "line", "polygon"), col = par("fg"), lty=par("lty"), # that's a new argument... ci.col = col, ci.lty = 1, xlab, ylab = x$method, ylim, xvar = c("sites", "individuals"), ...) { xvar <- match.arg(xvar) xaxvar <- x[[xvar]] if (missing(xlab)) xlab <- paste(toupper(substring(xvar, 1, 1)), substring(xvar, 2), sep = "") ci.type <- match.arg(ci.type) if (!add) { if (missing(ylim)) ylim <- c(1, max(x$richness, x$richness + ci * x$sd)) plot(xaxvar, x$richness, xlab = xlab, ylab = ylab, ylim = ylim, type = "n", ...) } if (!is.null(x$sd) && ci) switch(ci.type, bar = segments(xaxvar, x$richness - ci * x$sd, xaxvar, x$richness + ci * x$sd, col = ci.col, lty = ci.lty, ...), line = matlines(xaxvar, x$richness + t(rbind(-ci, ci) %*% x$sd), col = ci.col, lty = ci.lty, ...), polygon = polygon(c(xaxvar, rev(xaxvar)), c(x$richness - ci * x$sd, rev(x$richness + ci * x$sd)), col = ci.col, lty = ci.lty, ...)) lines(xaxvar, x$richness, col = col, lty = lty, # that's the other new part. Finished. ...) invisible() } ### SURVEY METHODS OVERALL ### Single Stationary (permanent) versus and Mobile transects ### # pdf("sp accum_methods.pdf",width=11,height=8) pdf("sp accum_methods_gray_transectNights.pdf",width=8,height=4) par(mfrow=c(1,2), tck=0.025, lwd=1, oma=c(1.25,0.5,0.5,0.5), mar=c(4,4,3,2)) ##DRY SEASON #Permanent Dry #break data into dataframes for each method and season (ignore habitat) and reshape SpAccum.PermDry<-subset(SummaryID.night,METHOD=="Permanent"&SEASON=="Dry",select=c("ConsensusID","DATE.12","Strict.Files")) #condense by date SpAccum.PermDry<-aggregate(Strict.Files~DATE.12+ConsensusID, data=SpAccum.PermDry,sum) #reshape to have species across the top SpAccum.PermDry<-reshape(SpAccum.PermDry,direction="wide",timevar="ConsensusID",idvar="DATE.12") #remove date SpAccum.PermDry<-SpAccum.PermDry[,-1] SpAccum.PermDry<-as.matrix(SpAccum.PermDry) SpAccum.PermDry[is.na(SpAccum.PermDry)]<-0 #change NAs to zero #take random subsample of 9 nights with no replacement to have equal sample effort with transects SpAccum.PermDry <- SpAccum.PermDry[sample(1:nrow(SpAccum.PermDry),9,replace=FALSE),] #Transect transect<-subset(SummaryID.night,METHOD=="Transect") SpAccum.TransDry<-subset(SummaryID.night,METHOD=="Transect"&SEASON=="Dry",select=c("ConsensusID","DATE.12","Strict.Files")) #condense by date SpAccum.TransDry<-aggregate(Strict.Files~DATE.12+ConsensusID, data=SpAccum.TransDry,sum) #reshape to have species across the top SpAccum.TransDry<-reshape(SpAccum.TransDry,direction="wide",timevar="ConsensusID",idvar="DATE.12") #remove date SpAccum.TransDry<-SpAccum.TransDry[,-1] SpAccum.TransDry<-as.matrix(SpAccum.TransDry) SpAccum.TransDry[is.na(SpAccum.TransDry)]<-0 #change NAs to zero # PLOT - sp. accum curves between methods in dry season xc<-specaccum(SpAccum.PermDry,conditioned=F) zc<-specaccum(SpAccum.TransDry,conditioned=F) plot.specaccum(xc, ci=1,lty=1,ci.type="polygon", ci.lty=0, ci.col=rgb(0,0,0,0.1), lwd=1,xlim=c(0,10),ylim=c(0,10), xlab="No. of Survey Nights",ylab="No. of Species", main="Dry Season",font.main=1,cex.main=1.2,cex.lab=1.2) plot.specaccum(zc, ci=1,lty=6,ci.type="polygon", ci.lty=0, ci.col=rgb(0,0,0,0.1), lwd=1 ,add=T) text(0.5,9.75,labels="[A]") legend('bottomleft', c('Single Strategic','Mobile Transect'), col="black", lty=c(1,2,6), bty='n', inset=0.025) ##WET SEASON #Permanent Wet #break data into dataframes for each method and season (ignore habitat) and reshape SpAccum.PermWet<-subset(SummaryID.night,METHOD=="Permanent"&SEASON=="Wet",select=c("ConsensusID","DATE.12","Strict.Files")) #condense by date SpAccum.PermWet<-aggregate(Strict.Files~DATE.12+ConsensusID, data=SpAccum.PermWet,sum) #reshape to have species across the top SpAccum.PermWet<-reshape(SpAccum.PermWet,direction="wide",timevar="ConsensusID",idvar="DATE.12") #remove date SpAccum.PermWet<-SpAccum.PermWet[,-1] SpAccum.PermWet<-as.matrix(SpAccum.PermWet) SpAccum.PermWet[is.na(SpAccum.PermWet)]<-0 #change NAs to zero #take random subsample of 10 nights SpAccum.PermWet <- SpAccum.PermWet[sample(1:nrow(SpAccum.PermWet),10,replace=FALSE),] ##Transect SpAccum.TransWet<-subset(SummaryID.night,METHOD=="Transect"&SEASON=="Wet",select=c("ConsensusID","DATE.12","Strict.Files")) #condense by date SpAccum.TransWet<-aggregate(Strict.Files~DATE.12+ConsensusID, data=SpAccum.TransWet,sum) #reshape to have species across the top SpAccum.TransWet<-reshape(SpAccum.TransWet,direction="wide",timevar="ConsensusID",idvar="DATE.12") #remove date SpAccum.TransWet<-SpAccum.TransWet[,-1] SpAccum.TransWet<-as.matrix(SpAccum.TransWet) SpAccum.TransWet[is.na(SpAccum.TransWet)]<-0 #change NAs to zero #sp. accum curves between methods in wet season xc<-specaccum(SpAccum.PermWet,conditioned=F) zc<-specaccum(SpAccum.TransWet,conditioned=F) plot.specaccum(xc, ci=1,lty=1,ci.type="polygon", ci.lty=0, ci.col=rgb(0,0,0,0.1), lwd=1,xlim=c(0,10),ylim=c(0,10), xlab="No. of Survey Nights",ylab="No. of Species", main="Wet Season",font.main=1,cex.main=1.2,cex.lab=1.2) plot.specaccum(zc, ci=1, lty=6,ci.type="polygon", ci.lty=0, ci.col=rgb(0,0,0,0.1), lwd=1 ,add=T) text(0.5,9.75,labels="[B]") dev.off() ### Overall SACs between Single stationary and Spatially replicated detectors ### pdf("sp accum_methods_gray_stationary.pdf",width=8,height=12) par(mfrow=c(3,2), tck=-0.025, lwd=1, oma=c(1.25,0.5,0.5,0.5), mar=c(4,4,3,2)) ##DRY SEASON #Permanent Dry #break data into dataframes for each method and season (ignore habitat) and reshape SpAccum.PermDry<-subset(SummaryID.night,METHOD=="Permanent"&SEASON=="Dry"&HABITAT!="Mangrove",select=c("ConsensusID","DATE.12","Strict.Files")) #condense by date SpAccum.PermDry<-aggregate(Strict.Files~DATE.12+ConsensusID, data=SpAccum.PermDry,sum) #reshape to have species across the top SpAccum.PermDry<-reshape(SpAccum.PermDry,direction="wide",timevar="ConsensusID",idvar="DATE.12") #remove date SpAccum.PermDry<-SpAccum.PermDry[,-1] SpAccum.PermDry<-as.matrix(SpAccum.PermDry) SpAccum.PermDry[is.na(SpAccum.PermDry)]<-0 #change NAs to zero #take random subsample of 9 nights with no replacement to have equal sample effort with transects #SpAccum.PermDry <- SpAccum.PermDry[sample(1:nrow(SpAccum.PermDry),9,replace=FALSE),] #Temporary Dry (removed from new figures because reviewer thought misleading due to dif number of detectors) #break data into dataframes for each method and season (ignore habitat) and reshape SpAccum.TempDry<-subset(SummaryID.night,METHOD=="Temporary"&SEASON=="Dry",select=c("ConsensusID","DATE.12","Strict.Files")) #condense by date SpAccum.TempDry<-aggregate(Strict.Files~DATE.12+ConsensusID, data=SpAccum.TempDry,sum) #reshape to have species across the top SpAccum.TempDry<-reshape(SpAccum.TempDry,direction="wide",timevar="ConsensusID",idvar="DATE.12") #remove date SpAccum.TempDry<-SpAccum.TempDry[,-1] SpAccum.TempDry<-as.matrix(SpAccum.TempDry) SpAccum.TempDry[is.na(SpAccum.TempDry)]<-0 #change NAs to zero # PLOT - sp. accum curves between methods in dry season xc<-specaccum(SpAccum.PermDry,conditioned=T) yc<-specaccum(SpAccum.TempDry,conditioned=F) plot.specaccum(xc, ci=1,lty=1,ci.type="polygon", ci.lty=0, ci.col=rgb(0,0,0,0.1), lwd=1,ylim=c(0,10), xlab="No. of Survey Nights",ylab="No. of Species", main="Dry Season",font.main=1,cex.main=1.2,cex.lab=1.2) plot.specaccum(yc, ci=1,lty=2,ci.type="polygon", ci.lty=0, ci.col=rgb(0,0,0,0.1), lwd=1,ylim=c(0,10), add=T) abline(h=c(7,7),lty=c(1,2),col="dark grey");abline(v=c(28,29),lty=c(1,2),col="dark grey") text(1.5,10,labels="[ A ]",font=1,adj=.1) legend('bottomleft', c('Single Strategic','Spatially Replicated'), col="black", lty=c(1,2,6), bty='n', inset=0.025) ##WET SEASON #Permanent Wet #break data into dataframes for each method and season (ignore habitat) and reshape SpAccum.PermWet<-subset(SummaryID.night,METHOD=="Permanent"&SEASON=="Wet"&HABITAT!="Mangrove",select=c("ConsensusID","DATE.12","Strict.Files")) #condense by date SpAccum.PermWet<-aggregate(Strict.Files~DATE.12+ConsensusID, data=SpAccum.PermWet,sum) #reshape to have species across the top SpAccum.PermWet<-reshape(SpAccum.PermWet,direction="wide",timevar="ConsensusID",idvar="DATE.12") #remove date SpAccum.PermWet<-SpAccum.PermWet[,-1] SpAccum.PermWet<-as.matrix(SpAccum.PermWet) SpAccum.PermWet[is.na(SpAccum.PermWet)]<-0 #change NAs to zero #take random subsample of 10 nights #SpAccum.PermWet <- SpAccum.PermWet[sample(1:nrow(SpAccum.PermWet),10,replace=FALSE),] #Temporary Wet (removed from new figures) #break data into dataframes for each method and season (ignore habitat) and reshape SpAccum.TempWet<-subset(SummaryID.night,METHOD=="Temporary"&SEASON=="Wet",select=c("ConsensusID","DATE.12","Strict.Files")) #condense by date SpAccum.TempWet<-aggregate(Strict.Files~DATE.12+ConsensusID, data=SpAccum.TempWet,sum) #reshape to have species across the top SpAccum.TempWet<-reshape(SpAccum.TempWet,direction="wide",timevar="ConsensusID",idvar="DATE.12") #remove date SpAccum.TempWet<-SpAccum.TempWet[,-1] SpAccum.TempWet<-as.matrix(SpAccum.TempWet) SpAccum.TempWet[is.na(SpAccum.TempWet)]<-0 #change NAs to zero #sp. accum curves between methods in wet season xc<-specaccum(SpAccum.PermWet,conditioned=F) yc<-specaccum(SpAccum.TempWet,conditioned=F) plot.specaccum(xc, ci=1,lty=1,ci.type="polygon", ci.lty=0, ci.col=rgb(0,0,0,0.1), lwd=1,ylim=c(0,10), xlab="No. of Survey Nights",ylab="No. of Species", main="Wet Season",font.main=1,cex.main=1.2,cex.lab=1.2) plot.specaccum(yc, ci=1,lty=2,ci.type="polygon", ci.lty=0, ci.col=rgb(0,0,0,0.1), lwd=1,ylim=c(0,10), add=T) abline(h=c(9,9),lty=c(1,2),col="dark grey");abline(v=c(38,38),lty=c(1,2),col="dark grey") text(1.5,10,labels="[ B ]",font=1,adj=.1) #dev.off() # number of nights to reach expected species richness (n=9) xc ##### BY HABITAT #### #pdf("sp accum_Habitats_gray.pdf",width=8,height=8) #par(mfrow=c(2,2), tck=0.025, lwd=1, oma=c(1.25,0.5,0.5,0.5), mar=c(4,4,3,2)) ## PINELANDS ## #DRY #PINE DRY - PERMANENT #break data into dataframes for each method and season (include habitat) and reshape SpAccum.PermDry<-subset(SummaryID.night,METHOD=="Permanent"&SEASON=="Dry"&HABITAT=="Pine",select=c("ConsensusID","DATE.12","Strict.Files")) #condense by date SpAccum.PermDry<-aggregate(Strict.Files~DATE.12+ConsensusID, data=SpAccum.PermDry,sum) #reshape to have species across the top SpAccum.PermDry<-reshape(SpAccum.PermDry,direction="wide",timevar="ConsensusID",idvar="DATE.12") #remove date SpAccum.PermDry<-SpAccum.PermDry[,-1] SpAccum.PermDry<-as.matrix(SpAccum.PermDry) SpAccum.PermDry[is.na(SpAccum.PermDry)]<-0 #change NAs to zero #PINE DRY - TEMPORARY #break data into dataframes for each method and season (include habitat) and reshape SpAccum.TempDry<-subset(SummaryID.night,METHOD=="Temporary"&SEASON=="Dry"&HABITAT=="Pine",select=c("ConsensusID","DATE.12","Strict.Files")) #condense by date SpAccum.TempDry<-aggregate(Strict.Files~DATE.12+ConsensusID, data=SpAccum.TempDry,sum) #reshape to have species across the top SpAccum.TempDry<-reshape(SpAccum.TempDry,direction="wide",timevar="ConsensusID",idvar="DATE.12") #remove date SpAccum.TempDry<-SpAccum.TempDry[,-1] SpAccum.TempDry<-as.matrix(SpAccum.TempDry) SpAccum.TempDry[is.na(SpAccum.TempDry)]<-0 #change NAs to zero #sp. accum curves between methods in PINE in Dry season xc<-specaccum(SpAccum.PermDry,conditioned=T) yc<-specaccum(SpAccum.TempDry,conditioned=F) plot.specaccum(xc,ci=1, lty=1,ci.type="polygon", ci.lty=0, ci.col=rgb(0,0,0,0.1), lwd=1,ylim=c(0,10), xlab="No. of Survey Nights",ylab="No. of Species", cex.main=1.2,cex.lab=1.2) plot.specaccum(yc,ci=1, lty=2,ci.type="polygon", ci.lty=0, ci.col=rgb(0,0,0,0.1), lwd=1,ylim=c(0,10), add=T) abline(h=c(7,7),lty=c(1,7),col="dark grey");abline(v=c(30,31),lty=c(1,2),col="dark grey") text(1.5,10,labels="[ C ]",font=1, adj=.1) # WET SEASON #PINE WET - PERMANENT #break data into dataframes for each method and season (include habitat) and reshape SpAccum.PermWet<-subset(SummaryID.night,METHOD=="Permanent"&SEASON=="Wet"&HABITAT=="Pine",select=c("ConsensusID","DATE.12","Strict.Files")) #condense by date SpAccum.PermWet<-aggregate(Strict.Files~DATE.12+ConsensusID, data=SpAccum.PermWet,sum) #reshape to have species across the top SpAccum.PermWet<-reshape(SpAccum.PermWet,direction="wide",timevar="ConsensusID",idvar="DATE.12") #remove date SpAccum.PermWet<-SpAccum.PermWet[,-1] SpAccum.PermWet<-as.matrix(SpAccum.PermWet) SpAccum.PermWet[is.na(SpAccum.PermWet)]<-0 #change NAs to zero #PINE Wet - TEMPORARY #break data into dataframes for each method and season (include habitat) and reshape SpAccum.TempWet<-subset(SummaryID.night,METHOD=="Temporary"&SEASON=="Wet"&HABITAT=="Pine",select=c("ConsensusID","DATE.12","Strict.Files")) #condense by date SpAccum.TempWet<-aggregate(Strict.Files~DATE.12+ConsensusID, data=SpAccum.TempWet,sum) #reshape to have species across the top SpAccum.TempWet<-reshape(SpAccum.TempWet,direction="wide",timevar="ConsensusID",idvar="DATE.12") #remove date SpAccum.TempWet<-SpAccum.TempWet[,-1] SpAccum.TempWet<-as.matrix(SpAccum.TempWet) SpAccum.TempWet[is.na(SpAccum.TempWet)]<-0 #change NAs to zero #sp. accum curves between methods in PINE in Wet season xc<-specaccum(SpAccum.PermWet,conditioned=F) yc<-specaccum(SpAccum.TempWet,conditioned=F) plot.specaccum(xc,ci=1, lty=1,ci.type="polygon", ci.lty=0, ci.col=rgb(0,0,0,0.1), lwd=1,ylim=c(0,10), xlab="No. of Survey Nights",ylab="No. of Species",font.main=1,cex.main=1.2,cex.lab=1.2) plot.specaccum(yc,ci=1, lty=2,ci.type="polygon", ci.lty=0, ci.col=rgb(0,0,0,0.1), lwd=1,ylim=c(0,10), add=T) abline(h=c(8,8),lty=c(1,2),col="dark grey");abline(v=c(32,39),lty=c(1,2),col="dark grey") text(1.5,10,labels="[ D ]",font=1, adj=.1) #PRAIRIE #PRAIRIE DRY - PERMANENT #break data into dataframes for each method and season (include habitat) and reshape SpAccum.PermDry<-subset(SummaryID.night,METHOD=="Permanent"&SEASON=="Dry"&HABITAT=="Prairie",select=c("ConsensusID","DATE.12","Strict.Files")) #condense by date SpAccum.PermDry<-aggregate(Strict.Files~DATE.12+ConsensusID, data=SpAccum.PermDry,sum) #reshape to have species across the top SpAccum.PermDry<-reshape(SpAccum.PermDry,direction="wide",timevar="ConsensusID",idvar="DATE.12") #remove date SpAccum.PermDry<-SpAccum.PermDry[,-1] SpAccum.PermDry<-as.matrix(SpAccum.PermDry) SpAccum.PermDry[is.na(SpAccum.PermDry)]<-0 #change NAs to zero #PRAIRE DY - TEMPORARY #break data into dataframes for each method and season (include habitat) and reshape SpAccum.TempDry<-subset(SummaryID.night,METHOD=="Temporary"&SEASON=="Dry"&HABITAT=="Prairie",select=c("ConsensusID","DATE.12","Strict.Files")) #condense by date SpAccum.TempDry<-aggregate(Strict.Files~DATE.12+ConsensusID, data=SpAccum.TempDry,sum) #reshape to have species across the top SpAccum.TempDry<-reshape(SpAccum.TempDry,direction="wide",timevar="ConsensusID",idvar="DATE.12") #remove date SpAccum.TempDry<-SpAccum.TempDry[,-1] SpAccum.TempDry<-as.matrix(SpAccum.TempDry) SpAccum.TempDry[is.na(SpAccum.TempDry)]<-0 #change NAs to zero #sp. accum curves between methods in PRAIRIE in DRY season xc<-specaccum(SpAccum.PermDry,conditioned=F) yc<-specaccum(SpAccum.TempDry,conditioned=F) plot.specaccum(yc,ci=1, lty=2,ci.type="polygon", ci.lty=0, ci.col=rgb(0,0,0,0.1), lwd=1,ylim=c(0,10),xlim=c(0,40), xlab="No. of Survey Nights",ylab="No. of Species",cex.main=1.2,cex.lab=1.2) plot.specaccum(xc,ci=1,lty=1,ci.type="polygon", ci.lty=0, ci.col=rgb(0,0,0,0.1), lwd=1,ylim=c(0,10), add=T) abline(h=c(4,6),lty=c(1,2),col="dark grey");abline(v=c(28,35),lty=c(1,2),col="dark grey") text(1.5,10,labels="[ E ]",font=1, adj=.3) #legend('bottomright', c('Single Stationary','Replicated Stationary'), col="black", lty=c(1,2), bty='n', inset=0.025) #PRAIRIE #PRAIRIE WET - PERMANENT #break data into dataframes for each method and season (include habitat) and reshape SpAccum.PermWet<-subset(SummaryID.night,METHOD=="Permanent"&SEASON=="Wet"&HABITAT=="Prairie",select=c("ConsensusID","DATE.12","Strict.Files")) #condense by date SpAccum.PermWet<-aggregate(Strict.Files~DATE.12+ConsensusID, data=SpAccum.PermWet,sum) #reshape to have species across the top SpAccum.PermWet<-reshape(SpAccum.PermWet,direction="wide",timevar="ConsensusID",idvar="DATE.12") #remove date SpAccum.PermWet<-SpAccum.PermWet[,-1] SpAccum.PermWet<-as.matrix(SpAccum.PermWet) SpAccum.PermWet[is.na(SpAccum.PermWet)]<-0 #change NAs to zero #PRAIRE WET - TEMPORARY #break data into dataframes for each method and season (include habitat) and reshape SpAccum.TempWet<-subset(SummaryID.night,METHOD=="Temporary"&SEASON=="Wet"&HABITAT=="Prairie",select=c("ConsensusID","DATE.12","Strict.Files")) #condense by date SpAccum.TempWet<-aggregate(Strict.Files~DATE.12+ConsensusID, data=SpAccum.TempWet,sum) #reshape to have species across the top SpAccum.TempWet<-reshape(SpAccum.TempWet,direction="wide",timevar="ConsensusID",idvar="DATE.12") #remove date SpAccum.TempWet<-SpAccum.TempWet[,-1] SpAccum.TempWet<-as.matrix(SpAccum.TempWet) SpAccum.TempWet[is.na(SpAccum.TempWet)]<-0 #change NAs to zero #sp. accum curves between methods in PRAIRIE in Wet season xc<-specaccum(SpAccum.PermWet,conditioned=F) yc<-specaccum(SpAccum.TempWet,conditioned=F) plot.specaccum(yc,ci=1, lty=2,ci.type="polygon", ci.lty=0, ci.col=rgb(0,0,0,0.1), lwd=1,ylim=c(0,10), xlab="No. of Survey Nights",ylab="No. of Species",cex.main=1.2,cex.lab=1.2) plot.specaccum(xc,ci=1, lty=1,ci.type="polygon", ci.lty=0, ci.col=rgb(0,0,0,0.1), lwd=1,ylim=c(0,10), add=T) abline(h=c(8),lty=c(1),col="dark grey");abline(v=c(28),lty=c(1),col="dark grey") text(1.5,10,labels="[ F ]",font=1, adj=.1) dev.off() ##### BY SITE #### pdf("sp accum_sites_gray.pdf",width=8,height=4) par(mfrow=c(1,2), tck=-0.025, lwd=1, oma=c(1.25,0.5,0.5,0.5), mar=c(4,4,2,2),mgp=c(2.5,1,0)) #PINE DRY - TEMPORARY #break data into dataframes for each method and season (include habitat) and reshape SpAccum.Temp<-subset(SummaryID.night,METHOD=="Temporary"&SEASON=="Dry"&HABITAT=="Pine",select=c("ConsensusID","SITE","Strict.Files")) #condense by date SpAccum.Temp<-aggregate(Strict.Files~SITE+ConsensusID, data=SpAccum.Temp,sum) #reshape to have species across the top SpAccum.Temp<-reshape(SpAccum.Temp,direction="wide",timevar="ConsensusID",idvar="SITE") #remove date SpAccum.Temp<-SpAccum.Temp[,-1] SpAccum.Temp<-as.matrix(SpAccum.Temp) SpAccum.Temp[is.na(SpAccum.Temp)]<-0 #change NAs to zero #Prairie SpAccum.TempPr<-subset(SummaryID.night,METHOD=="Temporary"&SEASON=="Dry"&HABITAT=="Prairie",select=c("ConsensusID","SITE","Strict.Files")) #condense by date SpAccum.TempPr<-aggregate(Strict.Files~SITE+ConsensusID, data=SpAccum.TempPr,sum) #reshape to have species across the top SpAccum.TempPr<-reshape(SpAccum.TempPr,direction="wide",timevar="ConsensusID",idvar="SITE") #remove date SpAccum.TempPr<-SpAccum.TempPr[,-1] SpAccum.TempPr<-as.matrix(SpAccum.TempPr) SpAccum.TempPr[is.na(SpAccum.TempPr)]<-0 #change NAs to zero xc<-specaccum(SpAccum.Temp,conditioned=F) yc<-specaccum(SpAccum.TempPr,conditioned=F) plot.specaccum(xc, ci=1, lty=1,ci.type="polygon", ci.lty=0, ci.col=rgb(0,0,0,0.1), lwd=1,ylim=c(0,10), xlab="No. of Sites",ylab="No. of Species", main="Dry Season",cex.main=.8,cex.lab=.8,cex.axis=.8) plot(yc, ci=1, lty=6, ci.type="polygon", ci.lty=0, ci.col=rgb(0,0,0,0.1), lwd=1 ,add=T) abline(h=c(7),lty=c(1),col="dark grey");abline(v=c(4),lty=c(1),col="dark grey") text(1.2,9.75,labels="[ A ]", font = 2,cex=0.7) legend('bottomleft', c('Pinelands','Prairies'), col="black", lty=c(1,6), bty='n', inset=0.025, cex=.6) #number of sites to reach expected species richness xc yc #PINE WET - TEMPORARY #break data into dataframes for each method and season (include habitat) and reshape SpAccum.Temp<-subset(SummaryID.night,METHOD=="Temporary"&SEASON=="Wet"&HABITAT=="Pine",select=c("ConsensusID","SITE","Strict.Files")) #condense by date SpAccum.Temp<-aggregate(Strict.Files~SITE+ConsensusID, data=SpAccum.Temp,sum) #reshape to have species across the top SpAccum.Temp<-reshape(SpAccum.Temp,direction="wide",timevar="ConsensusID",idvar="SITE") #remove date SpAccum.Temp<-SpAccum.Temp[,-1] SpAccum.Temp<-as.matrix(SpAccum.Temp) SpAccum.Temp[is.na(SpAccum.Temp)]<-0 #change NAs to zero #Prairie SpAccum.TempPr<-subset(SummaryID.night,METHOD=="Temporary"&SEASON=="Wet"&HABITAT=="Prairie",select=c("ConsensusID","SITE","Strict.Files")) #condense by date SpAccum.TempPr<-aggregate(Strict.Files~SITE+ConsensusID, data=SpAccum.TempPr,sum) #reshape to have species across the top SpAccum.TempPr<-reshape(SpAccum.TempPr,direction="wide",timevar="ConsensusID",idvar="SITE") #remove date SpAccum.TempPr<-SpAccum.TempPr[,-1] SpAccum.TempPr<-as.matrix(SpAccum.TempPr) SpAccum.TempPr[is.na(SpAccum.TempPr)]<-0 #change NAs to zero xc<-specaccum(SpAccum.Temp,conditioned=F) yc<-specaccum(SpAccum.TempPr,conditioned=F) plot.specaccum(xc,ci=1,lty=1,ci.type="polygon", ci.lty=0, ci.col=rgb(0,0,0,0.1), lwd=1,ylim=c(0,10), xlab="No. of Sites",ylab="No. of Species", main="Wet Season",cex.main=.8,cex.lab=.8,cex.axis=.8) plot(yc,ci=1, lty=6, ci.type="polygon", ci.lty=0, ci.col=rgb(0,0,0,0.1), lwd=1 ,add=T) abline(h=c(8),lty=c(1),col="dark grey");abline(v=c(4),lty=c(1),col="dark grey") text(1.2,9.75,labels="[ B ]", font = 2,cex=.7) #legend('bottomright', c('Pine','Prairie'), col="black", lty=c(1,6), bty='n', inset=0.025) #number of sites to reach expected species richness xc yc dev.off()