Skip to content

Instantly share code, notes, and snippets.

@scisus
Last active November 23, 2015 23:13
Show Gist options
  • Save scisus/ea71b1ea146416ce440e to your computer and use it in GitHub Desktop.
Save scisus/ea71b1ea146416ce440e to your computer and use it in GitHub Desktop.
# Ordonez supplementary info analysis
#==================================================
#
#This project builds graphs of latitudinal velocities of range edges versus climate velocity using data from Supplementary Information Table 2 in Ordonez, A., & Williams, J. W. (2013). Climatic and biotic velocities for woody taxa distributions over the last 16 000 years in eastern North America. Ecology Letters. doi:10.1111/ele.12110
#More info at http://blogs.ubc.ca/aitkenlab/2015/11/24/runtrees/
library("RColorBrewer")
library(ggplot2)
source('Ordonez_functions.R')
# Read in and Reformat data
supp <-read.csv("Appendix_S2.csv", header=TRUE, skip=4, stringsAsFactors=FALSE)
supp <- supp[,colSums(is.na(supp))==0] #remove empty columns
colnames(supp)[c(1:2)] <- c("Taxa", "Time.Period")
## Separate latitudinal velocity columns into center, low, and high. Using columns with 95% rather than 100% confidence intervals
South <- sep_conf(supp$South.Velocity) #southern range edge biotic velocity
colnames(South) <- colprefix(South, "s")
North <- sep_conf(supp$North.Velocity) #northern range edge biotic velocity
colnames(North) <- colprefix(North, "n")
ClimSouth <- sep_conf(supp$South.Velocity.2) # southern range edge climate velocity
colnames(ClimSouth) <- colprefix(ClimSouth, "cs")
ClimNorth <- sep_conf(supp$North.Velocity.2) #northern range edge climate velocity
colnames(ClimNorth) <- colprefix(ClimNorth, "cn")
runtrees <- data.frame(Taxa = supp$Taxa, Time.Period = supp$Time.Period, South, North, ClimSouth, ClimNorth, stringsAsFactors=FALSE)
## Pull out only pinaceae
runtrees <- subset(runtrees, runtrees$Taxa %in% c("Abies", "Picea", "Pinus.subg.Pinus", "Pinus.subg.Strobus"))
# Graph data
## South
### make errorbars for south edge
limits <- aes(ymax=runtrees$s_high, ymin=runtrees$s_low)
limitsh <- aes(xmax=runtrees$cs_high, xmin=runtrees$cs_low)
ggplot(runtrees, aes(x=cs_avg, y=s_avg, color = Taxa, shape = Time.Period)) +
ggtitle("Southern Range Edge") +
geom_point(size=5) +
geom_errorbar(limits, alpha=.4) +
geom_errorbarh(limitsh, alpha=.4) +
theme_bw(20) +
xlab("Climate velocity (km/decade)") +
ylab("Bioltic velocity (km/decade)") +
geom_abline(intercept = 0, slope = 1, aes(linetype = "dotted")) +
geom_vline(xintercept = 0, linetype = "dotted") +
scale_linetype_manual(values = c("dotted", "solid")) +
scale_color_brewer(palette="Paired")
## North
### make error bars for north edge
nlimits <- aes(ymax=runtrees$n_high, ymin=runtrees$n_low)
nlimitsh <- aes(xmax=runtrees$cn_high, xmin=runtrees$cn_low)
ggplot(runtrees, aes(x=cn_avg, y=n_avg, color = Taxa,shape = Time.Period)) +
ggtitle("Northern Range Edge") +
geom_point(size=5) +
geom_errorbar(nlimits, alpha=.4) +
geom_errorbarh(nlimitsh, alpha=.4) +
theme_bw(20) +
xlab("Climate velocity (km/decade)") +
ylab("Biotic velocity (km/decade)") +
geom_abline(intercept = 0, slope = 1, aes(linetype = "dotted")) +
geom_vline(xintercept = 0, linetype = "dotted") +
scale_linetype_manual(values = c("dotted", "solid")) +
scale_color_brewer(palette = "Paired")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment