Example 1

Quick Summary of Data

This data is from a validation study I implemented to determine if fecal corticosterone metabolites (FCM) - poop - could be used to non-invasively examine wild Northern Bobwhite stress levels. This method could be used as an additional tool to evaluate the health of a population to help aid in conservation and management efforts.


Packages and Code

# Load necessary packages and data, ensure working directory is set #

library(ggplot2)

vs_plot <- read.csv("ValidationStudy_Analyses_Spreadsheet_11_18_2018.csv")
  
# Subsetting out specific data I want to plot from dataframe #

# Specific pen a bird was help in

pen <- vs_plot$Pen  

# C_CollectionPoint stats for continuous collection point

collection <- vs_plot$C_CollectionPoint 

# FCM level at each given point

cort <- vs_plot$CORT_amount_pg_mg 

# Create new dataframe with selected data #
  
newdf <- data.frame(pen, collection, cort)

# Reorder new dataframe so that is has collection period in chronological order
  
newdf <- newdf[order(newdf$collection),]
  
# Remove any collection points that did not have a fecal sample at that point

newdf <- subset(newdf,cort != "NA")
  
# Change pen to be considered a factor and not a numerical value

newdf$pen <- as.factor(newdf$pen)
  
# Get into plotting FCM levels of all individuals over the study.

# Note: Plot created quickly for use in thesis, not the "neatest" way to create this code, but realistic as our code isn't always as "pretty" as we would like because life gets in the way.

All_Indivs <- ggplot(newdf, aes(x=collection, y=cort, colour=pen, na.rm=FALSE))+
   
    theme_bw()+ # Set the theme as black and white - what most jounrals will want
    theme(legend.position = "none")+ # remove legend
    theme(
      panel.grid.major=element_blank(), # removes major grids
      panel.grid.minor=element_blank(), # removes minor grids
      text=element_text(family = "Times New Roman", colour="black", size=12), # select font style, color, and size
      axis.line=element_line("black"), # color for axis line
      axis.ticks=element_line("black"), # color for axis ticks
      axis.text.x = element_text(colour="black", size=12), # x axis text color and size
      axis.title.y=element_text(colour="black", size=12), # y axis title text color and size
      axis.title.x=element_text(colour="black", size=12), # x axis title text color and size
      axis.text.y = element_text(colour="black", size=12))+ # y axis text color and size
      
      
      geom_line(size=0.70)+ # how this the plotted line will be of FCM levels. 
  
  # creating the rectangles on figure for different treatments, alpha determines b/w shade level.
      annotate("rect", xmin = 0, xmax=48, ymin=0, ymax=350, alpha=0.05)+ 
      annotate("rect", xmin = 48, xmax=96, ymin=0, ymax=350, alpha=.3)+
      annotate("rect", xmin = 96, xmax=144, ymin=0, ymax=350, alpha=.2)+
  
  # Putting the text of each treatment within each rectangle annotation.
      annotate("text", x = 20, y = 270, label=c("Base"), fontface="bold", size=4.5, family="Times New Roman")+
      annotate("text", x = 72, y = 270, label=c("ACTH"), fontface="bold", size=4.5, family="Times New Roman")+
      annotate("text", x = 120, y = 270, label=c("Biological"), fontface="bold", size=4.5,family="Times New Roman")+
    
  # Creating and placing the arrows to denote where specific events occurred in treatments
      geom_segment(aes(x = 0, y = 100, xend = 0, yend = 50),
                   arrow = arrow(length = unit(.3, "cm"), ends = "last", type="closed"),size=.7)+ 
      geom_segment(aes(x = 48, y = 230, xend = 48, yend = 180),
                   arrow = arrow(length = unit(.3, "cm"),ends = "last", type="closed"),size=.7)+ 
      geom_segment(aes(x = 96, y = 100, xend = 96, yend = 50),
                   arrow = arrow(length = unit(.3, "cm"),ends = "last", type="closed"),size=.7)+  
  
  # Creating labels for the arrows indicating the specific event for each treatment.
      annotate("text", x = 0, y = 108, label=c("Initiation"),size=4.0, fontface="bold", family="Times New Roman")+
      annotate("text", x = 48, y = 238, label=c("Injection"),size=4.0, fontface="bold", family="Times New Roman")+
      annotate("text", x = 96, y = 108, label=c("Introduction"), size=4.0, fontface="bold", family="Times New Roman")+
      
  # Had an error making each line black, had to override error by doing it the long hand "messy" way.       
      scale_color_manual(values = c("black","black","black","black","black","black","black",
                                    "black","black","black","black","black","black","black",
                                    "black","black","black","black","black","black","black","black","black"))+
  
  # Name your x and y axis and determine scales.  
    ylab("FCM (Stress) Levels") + scale_y_continuous(breaks=seq(0, 320, 50))+ 
    coord_cartesian(ylim = c(0, 320))+
    xlab("Time (in hours) since study began") + scale_x_continuous(breaks=seq(0, 140, 10))


The Visualization

Figure 1. Observed FCM (stress) levels of all bobwhite individuals throughout the duration of the study. Samples were collected every 4 hours

Figure 1. Observed FCM (stress) levels of all bobwhite individuals throughout the duration of the study. Samples were collected every 4 hours


Want to Learn More About This Study?

Jessica L Mohlman, Kristen J Navara, Michael J Sheriff, Theron M Terhune, II, James A Martin, Validation of a noninvasive technique to quantify stress in northern bobwhite (Colinus virginianus), Conservation Physiology, Volume 8, Issue 1, 2020, coaa026, https://doi.org/10.1093/conphys/coaa026



Example 2

Quick Summary of Data

This data was used in determining if rabbit hunting effected Northern Bobwhite movement behaviors. This specific example looks at the effect of rabbit hunting on Northern Bobwhite step-length (e.g. how far they moved every 30 minutes).

Bayesian Overview

This data was analyzed in a Bayesian framework using a BACI (before‐after‐control‐impact) design to reduce confounding effects of site and annual variation (Figure 2). Using Bayesian allowed us to provide more clear-cut ecologically meaningful results to stakeholders (which we will get into).

Examined difference in between…
  • Reference -> Reduced
  • Reference -> No Rabbit Hunting
  • Reduced -> No Rabbit Hunting
Figure 2. Treatment Design

Figure 2. Treatment Design


Packages and Code

# Loading saved .RData step-length simulations and needed packages

load(file = "BACI_Step_12_4_2018.RData")

library(tidybayes)
library(dplyr)
library(ggplot2)

# Creating a dataframe for Reference-No Rabbit Hunting BACI ratios

sl.nrab <- data.frame(Ratio = ipm$sims.list$BACI_ratio.nrab, Contrast = rep("Reference-No Rabbit Hunting",length(ipm$sims.list$BACI_ratio.nrab)))

# Creating a dataframe for Reference-Reduced BACI ratios

sl.red <- data.frame(Ratio = ipm$sims.list$BACI_ratio.red, Contrast = rep("Reference-Reduced",length(ipm$sims.list$BACI_ratio.red)))

# Creating a dataframe for Reduced-No Rabbit Hunting BACI ratios

sl.redno <- data.frame(Ratio = (1/ipm$sims.list$BACI_ratio.redno), Contrast = rep("Reduced-No Rabbit Hunting",length((ipm$sims.list$BACI_ratio.redno))))

# Combine ratio dataframes

ratios<-rbind(sl.red,sl.redno,sl.nrab)

# Look at how the BACI ratios look (there are over 100,000)

head(ratios)
##      Ratio          Contrast
## 1 1.137397 Reference-Reduced
## 2 1.164484 Reference-Reduced
## 3 1.177250 Reference-Reduced
## 4 1.182602 Reference-Reduced
## 5 1.199438 Reference-Reduced
## 6 1.195321 Reference-Reduced
# Summary of BACI ratios to understand what they look like and how many simulations there are

summary(ratios)
##      Ratio                               Contrast    
##  Min.   :0.7129   Reference-Reduced          :45000  
##  1st Qu.:1.0678   Reduced-No Rabbit Hunting  :45000  
##  Median :1.2439   Reference-No Rabbit Hunting:45000  
##  Mean   :1.2517                                      
##  3rd Qu.:1.4025                                      
##  Max.   :2.7434
# Creating violin plots

sl.violin<-ggplot(ratios,aes(y=Ratio, x= Contrast)) + # bring in new ratio dataframe, Contrast = treatment combo
    geom_violin(color=NA, fill="gray") + # color for violins, journal didn't want color
    stat_pointinterval(.width = c(0.95,0.50))+ # defining credible intervals
    labs(y="BACI Ratio Contrasts for Step-length", x="Treatment") + # titles for x and y axis
  # putting a dashed line at 1 to define positive or negative relationships
    geom_hline(yintercept=1, linetype="dashed", color = "black", size=.5)+ 
   ylim(0,2.5)+
    theme_bw()+ #setting black and white theme
    theme(
      panel.grid.major = element_blank(),# no major grids
      text=element_text(family = "serif", colour="black",size=12), # setting font, color, and size
      panel.grid.minor = element_blank(), # no minor grids
      panel.border = element_blank(), # no figure border
      axis.line=element_line("black"), # black line for axis
      axis.ticks=element_blank(), # no ticks on axis
      axis.text.y = element_text(colour="black",size=12), # y axis text color and size
      axis.text.x = element_text(colour="black",size=12), # x axis text color and size
      axis.title.y=element_text(colour="black",size=12), # y axis title text color and size
      axis.title.x=element_text(colour="black",size=12)) # y axis title text color and size
BACI Ratio
  • (> 1 = positive relationship)
  • (< 1 = negative relationship)
BACI Ratio Percent Change Example
  • (1 - .70) * 100 = -30%
  • (1.30 - 1) * 100 = +30%


The Visualization

Figure 3. BACI contrasts with shaded regions representing the full posterior distribution for bobwhite step-length in relation to rabbit hunting.

Figure 3. BACI contrasts with shaded regions representing the full posterior distribution for bobwhite step-length in relation to rabbit hunting.


Plot Elements

  • Points indicate mean values for step-length, with lines representing the 50% and 95% credible interval.

  • BACI contrasts above 1 indicate an increase in step length while BACI contrasts below 1 indicate a decrease.

  • Reference‐Reduced denotes the effect of reducing rabbit hunting from 5 to 3 days.

  • Reduced‐No Rabbit Hunting denotes the effect of decreasing rabbit hunting from 3 to 0 days.

  • Reference‐No Rabbit Hunting denotes the effect of decreasing rabbit hunting from 5 to 0 days

Plot Interpretation

  • In the absence of rabbit hunting, bobwhite increased their step-length by 38% when compared to the Reference (Bayesian P-value = 0.99 [99% chance of occurring]).

  • Reducing rabbit hunting to zero days from 3 days increased step-length 33% (Bayesian P-value = 0.99 [99% chance of occurring]).

  • Overall increase in movement in the absence of rabbit hunting.

  • Decrease in movement in areas with rabbit hunting—regardless of number of days.


Want to Learn More About This Study?

Mohlman JL, Gardner RR, Parnell IB, Wilhite NG, Martin JA. Nonconsumptive effects of hunting on a nontarget game bird. Ecol Evol. 2019;9:9324–9333. https://doi.org/10.1002/ece3.5479


Contact Information