Ecology Lab Wilkes University 2014 1 Lab 1: Kirby Park Tree Diversity Background Ecological edges are formed then two contrasting habitats are adjacent. Forest-field edges are excellent study locations to study edge effects – changes in ecological conditions that occur at the edge. Lab Objectives: Familiarize students with data collection methods Familiarize students with data analysis including o Species accumulation curves o T-test and Mann-Whitney U tests o Graphical presentation of medians and quantiles o Graphical presentation of species accumulation curves Lab Length: 2 weeks Equipment: Field notebook, dbh tape, min 10 m measuring tape Week 1 At arbitrary starting point count trees within an 8 m radius circle. All trees are identified to species and dbh measured. One track of plots are located along the forest edge and another parallel track is located just to the interior but not overlapping with the edge track. Six plot of edge and interior are sampled. Week 2 Students develop a hypotheses and predictions related to the data collected. These hypotheses should account for edge and interior environments and H1: Tree density H2: Tree sizes H3: Species richness 2 H1: Prediction 1: Graph: Analysis: H2: Prediction 2: Graph: Analysis: H3: Prediction 3: Graph: 3 Analysis: Caveats was sampling adequate for species richness assessment? o Species Accumulation curves What is the distribution of the data? o Histograms Statistical Inference Reporting: Inference: Lab Report Write up a lab report, in first person with Short abstract Introduction that explains your hypotheses and predictions Methods that explain how do did it o include tools and accuracy of measurements o how sample sites were determined (systematic, random, arbitrary) Results that simply give the outcomes o Start generally (sample sizes, distributions) o Refer to figures o Give results of statistics Discussion that ties it all together o discusses the problems and solution o maybe more interesting questions that came up o Alternative hypothesis should also be stated 4 Literature Cited 5 Lab 2: Phylogenetic analysis of ecological traits Background: Phylogenetics is the recovery of evolutionary history by reconstructing the relative topology branching points as well as providing the number of changes that have occurred between groups. These data are required to determine if traits are a homoplasy, synapomorphy, or symplesiomorphy. Lab Objectives: Familiarize students phylogenetic methods Familiarize students with character maps Familiarize students with phylogenetic-friendly data sets The data Use GenBank http://www.ncbi.nlm.nih.gov/genbank/ The analysis Please use http://www.phylogeny.fr/ The critters Assigned in class 6 Lab 3: Human Demography: Cemetery Data 7 Lab 4: Population Growth Part 1 Deterministic models: exponential growth # intrinsic reproductive rate r <- 0.1 # let's simulate 80 years t <- 1:80 # 50 years #start with 1 female n_01 <- 1 # set the equation n_t <- n_01*exp(r*t) # see the numbers n_t #let's plot plot(t, n_t, type="o", ylim=c(0,1000)) #increase the starting pop to 10 n_010 <- 10 n_t2 <- n_010*exp(r*t) #add these data to the plot lines(t, n_t2, type="o", col="red", pch=17 ) #increase the starting pop to 100 n_0100 <- 100 n_t3 <- n_0100*exp(r*t) #add these data to the plot lines(t, n_t3, type="o", col="blue", pch=16) Export this graph to Word 1. Write a short statement on what you did 2. What a short statement on the effect of changing the starting population on population dynamics Since many journals do not print color graphs, consider using different line types (e.g., solid, dash, dot) by using lty=X and X is 1,2,3, etc. 8 Part 1.2 The effect of changing r, the intrinsic population growth rate # run simulation for 80 generations t <- 1:80 #start population with 10 n_0 <- 10 # start with r = -0.1 r <- -0.01 #run "simulation" n_t1 <- n_0*exp(r*t) #plot plot(t, n_t1, type="o", ylim=c(0,100)) #let's change r to 0 r2 <- 0 #run simulation n_t2 <- n_0*exp(r2*t) #add to plot lines(t, n_t2, type="o", col="green", pch=17) #lets change r to 0.01 r3 <- 0.01 #run simulation n_t3 <- n_0*exp(r3*t) #add line to plot lines(t, n_t3, type="o", col="blue", pch=17) #lets change r to 0.025 r4 <- 0.025 #run simulation n_t4 <- n_0*exp(r4*t) #add line to plot lines(t, n_t4, type="o", col="red", pch=17) #lets change r to 0.05 r5 <- 0.05 #run simulation 9 n_t5 <- n_0*exp(r5*t) #add line to plot lines(t, n_t5, type="o", col="orange", pch=17) #lets change r to 0.06 r6 <- 0.06 #run simulation n_t6 <- n_0*exp(r6*t) #add line to plot lines(t, n_t6, type="o", col="purple", pch=17) Export this graph to Word 1. Write a short statement on what you did 2. What a short statement on the effect of changing r on population dynamics Part 2. Deterministic models: Logistic Growth Part 2.1 Altering carrying capacity # run simulations for 100 generations t <- 1:100 #let's keep r fixed r <- 0.1 #let's keep the initial populations fixed at 10 n_0 <- 10 # let's be nice and have a large carrying capacity k <- 10000 #do the calculation #be careful with the parentheses!!!! n_t <- k/(1+((k-n_0)/n_0)*exp(-r*t)) #plot the result plot(t, n_t, type="o", ylim=c(0,11000)) # add a horizontal line to show carrying capacity abline(h=10000) #let's be less nice and reduce the carrying capacity to 4000 10 k2 <- 4000 #rerun n_t2 <- k2/(1+((k2-n_0)/n_0)*exp(-r*t)) lines(t, n_t2, type="o", col="orange") abline(h=4000, col="orange") #let's put the squeeze on and reduce carrying capacity to 2000 k3 <- 2000 n_t3 <- k3/(1+((k3-n_0)/n_0)*exp(-r*t)) lines(t, n_t3, type="o", col="blue") abline(h=2000, col="blue") #let's put the squeeze on and reduce carrying capacity to 1000 k4 <- 1000 n_t4 <- k4/(1+((k4-n_0)/n_0)*exp(-r*t)) lines(t, n_t4, type="o", col="red") abline(h=1000, col="red") Export this graph to Word 1. Write a short statement on what you did 2. What a short statement on the effect of changing K on population dynamics Part 2.2 The effect of changing r in a logistic model # run simulations for 100 generations t <- 1:200 #let's keep the initial populations fixed at 10 n_0 <- 10 #let's keep the carrying capacity fixed at 4000 k <- 4000 #lower r r1 <- 0.05 n_t1 <- k/(1+((k-n_0)/n_0)*exp(-r1*t)) plot(t, n_t1, type="o") abline(h=4000) #increase r r2 <- 0.075 n_t2 <- k/(1+((k-n_0)/n_0)*exp(-r2*t)) lines(t, n_t2, type="o", col="purple") #increase r again r3 <- 0.1 n_t3 <- k/(1+((k-n_0)/n_0)*exp(-r3*t)) lines(t, n_t3, type="o", col="red") 11 Export this graph to Word 1. Write a short statement on what you did 2. What a short statement on the effect of changing r on population dynamic Part 2.3 Growth rates in a logistic model k <- 1000 n <- 1:1000 r <- 0.1 growth.rate <- n*r*((k-n)/(k)) plot(n,growth.rate) abline(v=k/2) Export this graph to Word 1. Write a short statement on what you did 2. Interpret the graph 3. What does the vertical line Part 3 Population Lags 1. Go to http://www.cbs.umn.edu/populus/installer and download Populus 2. Click on Model -> Single species dynamics -> Density-dependent growth 3. You can do everything we just did in R in this Window (you probably want to kill me now) 4. Under model click Lagged Logistic 5. Make the lag (tao) = 1, increase r from 0.1 to 1 (note the line relative to K) 6. With r=0.3, increase tao from 0 to 5 Export this graph to Word 1. Write a short statement on what you did 2. Interpret the modifications you made. A paragraph for steps 5 and 6 Part 4: Stochastic Models ###################### # # thanks to Peter Houk (peterhouk@gmail.com) # ######################### t<-100; alpha<-0.01; F<-0.6; N0<-80; r0 <- 1 r<-c(r0, numeric(t)) for (i in 1:t) 12 r[i+1]<- { runif(1,0.2,1.8) } N<-c(N0, numeric(t)) for (i in 1:t) { N[i+1]<(N[i]+r[i]*N[i]*(1-(N[i]*alpha))-F*N[i]) } plot(0:t, N, type="l", xlab="time", ylab="fish population") # Now repeat 100 times and some CI bands t<-100 bevholt<-function(alpha=0.01, r0=1.2, F=0.6, N0=80, t=100) { r<-c(r0, numeric(t)) for (i in 1:t) r[i+1]<- { runif(1,0.4,1.4) } N<-c(N0, numeric(t)) for (i in 1:t) N[i+1]<- { (N[i]+r[i]*N[i]*(1-(N[i]*alpha))-F*N[i]) } return(N) } pop.sim<-bevholt() plot(0:t, pop.sim, type="l", xlab="time", ylab="fish population") sims<-replicate(10, { output<-matrix(bevholt(), nrow=101) }, simplify=TRUE) matplot(0:t, sims, type="l") mean_sim<-apply(sims, 1, mean) plot(0:t, mean_sim, type="l", ylim=c(15,80)) lower_ci<-mean_sim-apply(sims, 1, sd) upper_ci<-mean_sim+apply(sims, 1, sd) lines(lower_ci, lty='dashed') lines(upper_ci, lty='dashed') ################################# # Peter Solymos solymos@ualberta.ca ################################# K <- 10000 # carrying capacity r <- 0.3 # reproductive potential sigma <- 0.2 # error T <- 50 # generations N0 <- 10 # starting pop 13 N <- numeric(T) # make sure N is a number N[1] <- N0 # set the starting pop to N0 for(i in 2:T) { N[i] <- exp(r * (1 - N[i - 1]/K) + log(N[i - 1]) + rnorm(1, 0, sigma)) } plot(N, type="b") # Wrapped in a function, you get: Ricker <- function(r, K, sigma, T, N0) { N <- numeric(T) N[1] <- N0 for(i in 2:T) { N[i] <- exp(r * (1 - N[i - 1]/K) + log(N[i - 1]) + rnorm(1, 0, sigma)) } N } set.seed(1234) NN <- replicate(10, Ricker(r=0.3, K=10^4, sigma=0.2, T=50, N0=10)) matplot(NN, type="l", col=1, lty=1) lines(rowMeans(NN), col=2, lwd=2) abline(h=K, col=4, lty=2) 14 Lab 5: Age/Stage Structured Population Models Background The previous exercise counts the individuals in the population and treats all equally but we know Part 1: Matrices and Matrix operations A matrix is an array of numbers arranged into rows and columns. The dimensions of a matrix are usually expressed as row by column, such as 5 x 6 for a matrix with 5 rows and 6 columns. Typically, matrices are indicated by uppercase letters, early in the alphabet. Elements make up the matrix and have a particular row and column location A vector is a column of elements or you can think of it as a matrix with one column and several vectors. A vector has a particular length, which is the number of elements. A vector can be thought of as a M x 1 matrix. A scalar is a matrix composed of a single element. Exercise In R, create a 3 x 4 matrix. How many elements? ## generate data a <- c(1:12) a A <- matrix(a, nrow=3, ncol=4) A # write the matrix in the space below # but what happens if you say? B <- matrix(a, nrow=3, ncol=4) ## indexing 15 B[2,2] # returns what? A[2,2] # returns what? A[,1] #returns what? A[3,] #returns what? A[,] #Returns what? ###Multiplying a matrix times a scalar A * 5 #returns what? 5 * A #returns what? #### multiplying a matrix times a vector # make a vector B <- c(10,20,30) A * B #returns what? B * A #returns what? ### matrix multiplication b <- c(1:12) B <- matrix(b, nrow=4, ncol=3) B A %*% B #Returns what? B %*% A #returns what? Part 2: Exploring populations with Matrices X <- c(0.5, 0.5, 0, 0, 2.4, 0, 0.8, 0, 1, 0, 0, 0.5, 0, 0, 0, 0) dim(X) <- c(4, 4) 16 X p <- c(20, 10, 40, 30) p X %*% p P <- numeric(40) P dim(P) <- c(4, 10) P[, 1] <- p for (i in 1:9) { P[, i + 1] <- X %*% P[, i]} matplot(1:10, t(P), type = "b", main = "Population projection", xlab = "Year", ylab = "Individuals") ########################################################################### # # # Marc Taylor <marchtaylor@gmail.com> # ##################################################################### # you will need the library popbio for this exercise # go to Packages -> Install and you will be asked to select a mirror; select PA1 #now activate popbio by typing library(popbio) # you only need to install once but you need to activate popbio everytime ################################################################### # # SMALL MAMMAL # ################################################################## # data for the Leslie matrix mydata <- c(0.5, 0.6666, 0, 1.0, 0, 0.3333, 0.75, 0, 0) # create the matrix L=matrix(mydata, nrow=3, ncol=3) #view it L # this is different from the last exam because these data were produced "by column" 17 # where our first example produced the matrix "by row" # run for 10 generations time=10 #starting population structure No=c(2,0,0) POP=c(No) Nt=No # here we loop (repeat the command) for 10 generations for (i in 1:time){ Nt = drop(L %*% Nt) POP=rbind(POP,Nt) } # now plot the data (which we also need to loop plot(0:time,POP[,1], type="l", ylim=range(POP), ylab="numbers", xlab="time") for (i in 2:length(POP[1,])){ lines(0:time,POP[,i],col=i) } #add a legend to the plot legend(0.5*time,max(POP), c(paste("class",(1:length(No)))), lwd=1, col=c(1:length(No))) ###Eigenvalues (info on pop trajectory and distribution) sum(POP[(time),])/sum(POP[(time-1),]) # the rate of population change between the last two iterations x=eigen(L) x #dominant eigen value abs(x$values) #The stable population distribution is specified by the 1st vector. The proportion of each element of the vector sum equals the corresponding class proportions. abs(x$vectors[,1]/sum(x$vectors[,1])) sensitivity(L, zero=F) elasticity(L) lambda(L) 18