Lab 12: Lab Analyses/Statistics

German Diagama

Physiological Ecology 2019 | Prof. Mark Baker

In this lab, we’ll use R instead of Excel, as it makes a few things more straight forward.

First install the xlsx package by running install.packages(xlsx).

We have some winter data that we’ll first read in from excel. First use getwd() to figure out what workspace you’re in. Then set the working directory using setwd() to set your working directory to the one where the winter data is. You have to put your directory in quotes, for instance setwd("/Users/Helen/Documents").

We’ll make a data frame called “class temps” with the first spreadsheet:

class_temps <- read.xlsx("Winter_Data_2019.xlsx", 
                sheetIndex = "Color and Cooling") 
head(class_temps)
##   Color  Size Time Temp                    Who NA.
## 1 white Large    1 48.7 Ben, Armando, Yanathan  NA
## 2 white Large    2 48.4 Ben, Armando, Yanathan  NA
## 3 white Large    3 48.9 Ben, Armando, Yanathan  NA
## 4 white Large    4 48.9 Ben, Armando, Yanathan  NA
## 5 white Large    5 48.3 Ben, Armando, Yanathan  NA
## 6 white Large    6 47.7 Ben, Armando, Yanathan  NA
class_temps<-class_temps[c(1:256),]

Now let’s look at the cooling of the large black container versus the cooling of the small black container.

large_black_data<-data.frame(time=class_temps$Time[class_temps$Size=="Large" & class_temps$Color=="Black"], temp=class_temps$Temp[class_temps$Size=="Large" & class_temps$Color=="Black"])

small_black_data<-data.frame(time=class_temps$Time[class_temps$Size=="Small" & class_temps$Color=="Black"], temp=class_temps$Temp[class_temps$Size=="Small" & class_temps$Color=="Black"])

data<-data.frame(time=small_black_data$time, large_temp=large_black_data$temp[1:24], small_temp=small_black_data$temp)

ylabel <- list(
  title = "Temperature in C"
)

xlabel<-list(
  title="Time"
)

p <- plot_ly(data, x = ~time, y = ~large_temp, name = 'Large Temperature', type = 'scatter', mode = 'lines') %>%
  add_trace(y = ~small_temp, name = 'Small Temperature', mode = 'lines+markers')%>%
  add_trace(x = ~time, y = fitted(lm(large_temp ~ time, data)), mode = "lines", name="Large Temp Trend") %>%
 add_trace(x = ~time, y = fitted(lm(small_temp ~ time, data)), mode = "lines", name="Small Temp Trend") %>%
  layout(xaxis=xlabel,yaxis=ylabel)
p

Let’s now look at black walnut growth. First we’ll read in the tree ring data:

tree_data <- read.xlsx("Winter_Data_2019.xlsx", 
                sheetIndex = "Tree rings") 
kable(head(tree_data))
Year Red.Oak Black.Walnut Hemlock11a Hemlock11b NA.
1911 4 NA NA NA NA
1912 3 NA NA NA NA
1913 4 NA NA NA NA
1914 5 NA NA NA NA
1915 3 NA NA NA NA
1916 4 NA NA NA NA

Now let’s create a data frame with just black walnut data:

walnut_data<-data.frame(year=tree_data$Year[c(48:108)],growth=tree_data$Black.Walnut[c(48:108)])
kable(head(walnut_data))
year growth
1958 1.532
1959 2.908
1960 2.286
1961 5.426
1962 3.978
1963 3.404

We’ll multiply by ten to make the scale more pronounced:

walnut_data$growth <-walnut_data$growth * 10
kable(head(walnut_data))
year growth
1958 15.32
1959 29.08
1960 22.86
1961 54.26
1962 39.78
1963 34.04

Now we plot:

ylabel <- list(
  title = "Tree Ring Growth in mm"
)

xlabel<-list(
  title="Year"
)

p <- plot_ly(walnut_data, x = ~year, y = ~growth, name = 'Tree Ring Width', type = 'scatter', mode = 'lines+markers') %>%
 add_trace(x = ~year, y = fitted(lm(growth ~ year, walnut_data)), mode = "line", name="Growth Trend") %>%
  layout(xaxis=xlabel,yaxis=ylabel)
p

Our regression line has the following summary data, and R-squared:

summary(lm(growth~year,walnut_data))
## 
## Call:
## lm(formula = growth ~ year, data = walnut_data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -76.060 -28.586  -8.657  24.111 199.478 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)   
## (Intercept) -2050.6071   724.0294  -2.832  0.00631 **
## year            1.0689     0.3642   2.935  0.00475 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 50.08 on 59 degrees of freedom
## Multiple R-squared:  0.1274, Adjusted R-squared:  0.1126 
## F-statistic: 8.614 on 1 and 59 DF,  p-value: 0.004746

We can compare this to hemlock growth. Looking at hemlock 11a:

hemlock_data <-data.frame(year=tree_data$Year[c(20:92)],growth=tree_data$Hemlock11a[c(20:92)])
kable(head(hemlock_data))
year growth
1930 0.50
1931 0.60
1932 0.50
1933 0.35
1934 0.20
1935 0.30
Scaling by 10 again:
hemlock_data$growth <-hemlock_data$growth * 10
kable(head(hemlock_data))
year growth
1930 5.0
1931 6.0
1932 5.0
1933 3.5
1934 2.0
1935 3.0
We can plot:
ylabel <- list(
  title = "Tree Ring Growth in mm"
)

xlabel<-list(
  title="Year"
)

p <- plot_ly(hemlock_data, x = ~year, y = ~growth, name = 'Tree Ring Width', type = 'scatter', mode = 'lines+markers') %>%
 add_trace(x = ~year, y = fitted(lm(growth ~ year, hemlock_data)), mode = "line", name="Growth Trend") %>%
  layout(xaxis=xlabel,yaxis=ylabel)
p

Questions

Question 1. Make a plot in excel of of temperature vs. time for the one container. Does the function of temperature vs time look like it is best fit using a line or a curve? Why should that be the case? How does the formula for heat loss by conduction (page 92 in the 4th edition) lead you to expect a linear or curved relationship?

Temperature versus time for each container looks to be best fit with a curve. This makes sense in light of the equation for conduction, which relates the inverse of time \(1/t\), graded by various other parameters, to temperature change. The multiplicative inverse of time when graphed looks much like the curve.

Question 2. Do the medium or small containers lose heat more rapidly? Do black or white containers decline in temperature more quickly? Estimate a rate of heat loss for the opposite color of the container you first plotted, and then for one two sizes larger or smaller. Remember, to measure heat loss you need to start from the same temperature (40 C, 35 C, or 30 C).

We measured rates of heat loss for the large and the small container. We obtained lines of best fit for these, which can be use to approximate the rate of heat loss (as the rate of change of temperature with respect to time, which is proportional to \(Q/t\)).

The statistics for the regression of large black container temperature on time are:

lm(data$large_temp ~ data$time)
## 
## Call:
## lm(formula = data$large_temp ~ data$time)
## 
## Coefficients:
## (Intercept)    data$time  
##     47.9457      -0.9134

The slope is therefore -0.9134 degrees C per minute. For the small black container:

lm(data$small_temp ~ data$time)
## 
## Call:
## lm(formula = data$small_temp ~ data$time)
## 
## Coefficients:
## (Intercept)    data$time  
##     27.0500      -0.4391

The slope is therefore -0.4391 degrees C per minute, almost half the negative rate of the large black container. This at first seems to imply that the small container is losing less heat, and that is certainly correct given its volume. Its thermal capacitance is 540.2 Calories per degree celcius, so it loses 237.2 Calories per minute. The large container’s thermal capacitance is 962 Calories per degree celcius, and so it loses 879.16 Calories per minute, about four times as much.

large_white_data<-data.frame(time=class_temps$Time[class_temps$Size=="Large" & class_temps$Color=="white"], temp=class_temps$Temp[class_temps$Size=="Large" & class_temps$Color=="white"])

small_white_data<-data.frame(time=class_temps$Time[class_temps$Size=="small" & class_temps$Color=="white"], temp=class_temps$Temp[class_temps$Size=="small" & class_temps$Color=="white"])

data<-data.frame(time=small_white_data$time, large_temp=large_white_data$temp, small_temp=small_white_data$temp)

ylabel <- list(
  title = "Temperature in C"
)

xlabel<-list(
  title="Time"
)

p <- plot_ly(data, x = ~time, y = ~large_temp, name = 'Large Temperature', type = 'scatter', mode = 'lines') %>%
  add_trace(y = ~small_temp, name = 'Small Temperature', mode = 'lines+markers')%>%
  add_trace(x = ~time, y = fitted(lm(large_temp ~ time, data)), mode = "lines", name="Large Temp Trend") %>%
 add_trace(x = ~time, y = fitted(lm(small_temp ~ time, data)), mode = "lines", name="Small Temp Trend") %>%
  layout(xaxis=xlabel,yaxis=ylabel)
p

Interestingly the decrease in temperature of the small container is almost linear. For the regressions:

lm(data$large_temp ~ data$time)
## 
## Call:
## lm(formula = data$large_temp ~ data$time)
## 
## Coefficients:
## (Intercept)    data$time  
##     51.1258      -0.4241

We have a slope of -.4221 degrees C per minute. This corresponds to a heat loss of 228 calories per minute For the small container:

lm(data$small_temp ~ data$time)
## 
## Call:
## lm(formula = data$small_temp ~ data$time)
## 
## Coefficients:
## (Intercept)    data$time  
##     51.0969      -0.8303

We have a slope of -.8303 degrees C per minute. This corresponds to a heat loss 799.16 Calories per minute. More than double the rate of heat loss. This directly contradicts our earlier observations. There may have been in error in labeling, or one container might have been exposed to more convection. In any case, for both large and small whiter containers, the rate of heat loss is slower than their black counterparts, suggesting that white bodies retain heat worse than their black counterparts (this seems to be corroborated by studies of heat absorption).

  1. How does the cost of maintaining body temperature compare between the medium and small containers (how many calories would it cost to make up the heat lost in 10 minutes for a large vs. an extra-small container)? How does this argue for or against Bergmann’s rule?

For the large black container, the rate of change of temperature with respect to time was -.9134 degrees C. For the extra small container:

xsmall_black_data<-data.frame(time=class_temps$Time[class_temps$Size=="X-Small" & class_temps$Color=="Black"], temp=class_temps$Temp[class_temps$Size=="X-Small" & class_temps$Color=="Black"])
lm(xsmall_black_data$temp ~ xsmall_black_data$time)
## 
## Call:
## lm(formula = xsmall_black_data$temp ~ xsmall_black_data$time)
## 
## Coefficients:
##            (Intercept)  xsmall_black_data$time  
##                 41.150                  -0.972

The slope is -.972 degrees C per minute, suggesting a very similar rate of heat loss. The volume of the extra small container was 196.88 mL (196.9 grams worth of water), and the specific heat of water is 1 Calorie per gram celcius. The thermal capacity of the container is thus 196.9 Calories per degree celcius change. Each minute, the container therefore loses 191.39 Calories of heat.

For the large container, its volume is 962.5 mL, or 962.5 grams worth of water. The thermal capacity of the container is thus 962.5 Calories per degree celcius. Each minute, the container therefore loses 879.16 Calories of heat, about four times as much heat as the extra small container.

Thus the large container loses 8791.6 Calories in 10 minutes versus 1913.39 Calories for the extra small. For large organisms, that makes it essential to store heat well. The cost of maintaining body temperature between medium and small containers is similarly significantly larger for the medium container.

This doesn’t necessarily fly in the face of Bergmann’s rule, which suggests that larger organisms are better adapted to the cold. If the increased loss of calories is made up for by not growing as fast as the body volume, then the increased loss may be worth it. The large container is 4.89 times the volume of the extra small container, but it only loses heat at 4.6 times the quantity lost per minute. Perhaps this tradeoff is worth it.

  1. What is our understanding of an exotherm in an insect cooling curve? What was the average supercooling point of the overwintering potato beetles collected during diapause and cooled in class? How do the supercooling points measured compare with this measurement of soil near-surface temperatures (red line) from nearby Canada? What does this say about the risk of freezing in diapausing potato beetles?

An exotherm in an insect cooling curve indicates extracellular freezing, or a failure of the insect to induce vitrification properly. I do not have the data for the supercooling points of insects collected during soil sampling. However, 2-inch soil temperature along canadian border was 0 degrees F is January 2019. The supercooling point of potato beetles at similar latitudes have ranged from -6 to -17 Cin diapause, and so are quite a bit below surface temperature. The risk of freezing is therefore low for the northern potato beetle.

  1. Using the t-testinator on the spreadsheet, compare either the mean supercooling points of summer-generation beetles vs diapausing beetles, or between weevils and all potato beetles. What are the means of each category, and what do you conclude about their supercooling points

Let’s read in the data:

ectotherm_data <- read.xlsx("Ectotherms.xlsx", sheetIndex = 1) 
ectotherm_data<-ectotherm_data[c(1:15),]
kable(head(ectotherm_data))
Date Time Species Exotherm.Temp. Exotherm.endpoint Who NA.
2019-01-15 225 sec Winter potato beetle -7.0 -5.2 Michelle, Lex, Sam, Amanpreet, Momina, Kanishka NA
2019-01-15 210 sec Summer potato beetle -7.0 -0.3 Michelle, Lex, Sam, Amanpreet, Momina, Kanishka NA
2019-01-15 360 sec Weevil -22.8 -15.1 Michelle, Lex, Sam, Amanpreet, Momina, Kanishka NA
2019-01-15 135 sec Japanese beetle -8.8 -7.8 Michelle, Lex, Sam, Amanpreet, Momina, Kanishka NA
2019-01-15 315 sec Winter potato beetle -7.0 -4.9 Shevin, Kevin, Andrew, Jaskaran, Sam, Nadia NA
2019-01-15 315 sec Winter potato beetle 2 -8.4 -7.1 Shevin, Kevin, Andrew, Jaskaran, Sam, Nadia NA

First, we’ll define the supercooling point as the mean of the exotherm start temperature and endpoint.

ectotherm_data$SP <- rowMeans(subset(ectotherm_data, select=c(Exotherm.Temp.,Exotherm.endpoint)))
ectotherm_data
##          Date    Time                Species Exotherm.Temp.
## 1  2019-01-15 225 sec   Winter potato beetle           -7.0
## 2  2019-01-15 210 sec   Summer potato beetle           -7.0
## 3  2019-01-15 360 sec                 Weevil          -22.8
## 4  2019-01-15 135 sec        Japanese beetle           -8.8
## 5  2019-01-15 315 sec   Winter potato beetle           -7.0
## 6  2019-01-15 315 sec Winter potato beetle 2           -8.4
## 7  2019-01-15     345        Japanese beetle           -8.6
## 8  2019-01-15     285   Summer potato beetle           -6.3
## 9  2019-01-15    <NA>   Winter Potato Beetle          -16.0
## 10 2019-01-15    <NA>   Winter Potato Beetle           -8.0
## 11 2019-01-15    <NA>                 Weevil          -18.0
## 12 2019-01-15    <NA>   Summer Potato Beetle           -8.0
## 13 2019-01-15    <NA>  Winter potato Beetle            -6.1
## 14 2019-01-16    <NA>  Winter potato Beetle           -11.8
## 15 2019-01-17    <NA>        Japenese Bettle           -8.3
##    Exotherm.endpoint
## 1               -5.2
## 2               -0.3
## 3              -15.1
## 4               -7.8
## 5               -4.9
## 6               -7.1
## 7               -4.1
## 8               -4.8
## 9               -8.0
## 10              -5.0
## 11             -15.0
## 12              -4.9
## 13              -4.0
## 14              -9.2
## 15              -7.0
##                                                                                          Who
## 1                                            Michelle, Lex, Sam, Amanpreet, Momina, Kanishka
## 2                                            Michelle, Lex, Sam, Amanpreet, Momina, Kanishka
## 3                                            Michelle, Lex, Sam, Amanpreet, Momina, Kanishka
## 4                                            Michelle, Lex, Sam, Amanpreet, Momina, Kanishka
## 5                                                Shevin, Kevin, Andrew, Jaskaran, Sam, Nadia
## 6                                                Shevin, Kevin, Andrew, Jaskaran, Sam, Nadia
## 7                                                Shevin, Kevin, Andrew, Jaskaran, Sam, Nadia
## 8                                                Shevin, Kevin, Andrew, Jaskaran, Sam, Nadia
## 9  Abby, Armondo, Benjamin, Irma, Jessica, Jonathan, Kelvin, Marvin, Mary Pat, Nikki, Samira
## 10 Abby, Armondo, Benjamin, Irma, Jessica, Jonathan, Kelvin, Marvin, Mary Pat, Nikki, Samira
## 11 Abby, Armondo, Benjamin, Irma, Jessica, Jonathan, Kelvin, Marvin, Mary Pat, Nikki, Samira
## 12 Abby, Armondo, Benjamin, Irma, Jessica, Jonathan, Kelvin, Marvin, Mary Pat, Nikki, Samira
## 13                                                                      Allyson,Kris, Andrea
## 14                                                                      Allyson,Kris, Andrea
## 15                                                                      Allyson,Kris, Andrea
##     NA.     SP
## 1  <NA>  -6.10
## 2  <NA>  -3.65
## 3  <NA> -18.95
## 4  <NA>  -8.30
## 5  <NA>  -5.95
## 6  <NA>  -7.75
## 7  <NA>  -6.35
## 8  <NA>  -5.55
## 9  arwa -12.00
## 10 arwa  -6.50
## 11 Arwa -16.50
## 12 Arwa  -6.45
## 13 <NA>  -5.05
## 14 <NA> -10.50
## 15 <NA>  -7.65

Now let’s combine the potato beetle data:

beetleSP<-ectotherm_data$SP[ectotherm_data$Species=="Winter potato beetle" | ectotherm_data$Species=="Winter Potato Beetle" | ectotherm_data$Species=="Summer potato beetle" | ectotherm_data$Species == "Summer Potato Beetle" | ectotherm_data$Species == "Winter potato Beetle" | ectotherm_data$Species=="Winter potato beetle 2"]

beetleSP<-append(beetleSP,c(-5.05,-10.50))

And extract the weevil data:

weevilSP <- ectotherm_data$SP[ectotherm_data$Species=="Weevil"]
weevilSP
## [1] -18.95 -16.50

Doing a t-test:

t.test(beetleSP,weevilSP)
## 
##  Welch Two Sample t-test
## 
## data:  beetleSP and weevilSP
## t = 7.3688, df = 1.9903, p-value = 0.01816
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##   4.453987 17.096013
## sample estimates:
## mean of x mean of y 
##    -6.950   -17.725

The means appear at first glance to be significantly different, and our P-value of .01816 indicates that they are. It makes sense that the weevil’s supercooling point would be significantly lower given its environment.s

  1. How have winter vs annual temperatures changed over time as measured in Central Park, NY? Look at the lines of fit that we generated in class. How do the rates of warming compare between winter (Jan-March) vs annual temperatures? Why might the slopes vary? Why might the variabilities vary?

We can generate a comparison like so:

annual_temps <- read.xlsx("Winter_Data_2019.xlsx", 
                sheetIndex = "Winter temperatures") 

data<-data.frame(year=annual_temps$YEAR, annual=annual_temps$ANNUAL, winter=annual_temps$Winter)

ylabel <- list(
  title = "Temperature in C"
)

xlabel<-list(
  title="Year"
)

p <- plot_ly(data, x = ~year, y = ~annual, name = 'Annual Temperature', type = 'scatter', mode = 'lines') %>%
  add_trace(y = ~winter, name = 'Winter Temperature', mode = 'lines+markers')%>%
  add_trace(x = ~time, y = fitted(lm(annual ~ year, data)), mode = "lines", name="Annual Temp Trend") %>%
 add_trace(x = ~time, y = fitted(lm(winter ~ year, data)), mode = "lines", name="Winter Temp Trend") %>%
  layout(xaxis=xlabel,yaxis=ylabel)
p

You can see that there is a steady upward trend in annual temperatures, and an even more powerful positive increase in winter temperatures. This makes sense because winter is a temperature extreme, and its cooling effects are compounding, whereas the year includes more neutral times like fall which don’t have compounding effects. Variance is also greater in winter temperatures because those are averaged over 3 months rather than 12 months, and according to the central limit theorem, the larger your sample of data points, the less variance there will be.

  1. Describe the growth pattern in the black walnut. How is it different from the hemlock sequences? Why might that be?

We see that hemlocks have gotten steadily narrower in their tree rings while black walnuts have gotten wider. Conditions have thus become more favorable for black walnuts than for hemlocks. One possibility is that we’re measuring different time invervals, so we might see a different trend if we only looked at the same years. Things look more flat for hemlocks in that case. But the increasing annual temperatures may have negatively affected weather patterns in the areas where hemlocks are prominent, or have negatively affected their ability to deal with stress.

  1. Show the calculation for the water quality index from lab, and repeat them on an older dataset, from our class in 2016. How does the water quality appear to compare between winter 2019 and 2016?

The macroinvertebrate biotic index is given by:

\[\sum_{i}^{n} \frac{X_i \times T_i}{N}\]

Where \(n\) is the number of taxa, \(X_i\) is the number of individuals in the \(i\)th taxon, \(T_i\) is the tolerance value for that taxon, and \(N\) is the total number of organisms sampled.

Applying this formula to the 2016 data, we get an MBI of 2.55, which is excellent. The biotic index for both our groups in 2019 was 3.37 (data points lost), which is also excellent, though we seemed to collect far less organisms.

  1. Which location of origin (stream vs hillside for hemlock) and which species is expected the have the highest stomatal density, and which the lowest. Why?

Hemlock by the stream are predicted to have much higher stomatal density due to the fact that it is not costly to lose water by the openings of the stoma, since the stream is nearby. This is in fact what we found.

  1. Calculate (and show your calculations) the total number of stomata, and stomatal densities, of red pine, and hemlock from streamside and hillside. Are the calculated densities consistent with your predictions?

The calculated densities were consistent with our predictions, and were almost double for the hemlock from the stream (90 stomata per square mm versus 40).

  1. What kinds of interactions did you use to calculate a dominance hierarchy for birds at the open feeder? Make a table of the interactions you scored, then a table below to summarize. What is your estimate of a linear hierarchy for the species at the feeder?

The only interaction we were able to use to track dominance was displacement, either direct or indirect. We found that for almost every bird, there was a displacement relation between it and another bird at some point during the feeding.

knitr::include_graphics("https://i.imgur.com/ZJ7Ma2Q.png")