To test whether the modelling results were sensitive to the photoreceptor ratios used, we repeated these analyses using published ratios that represent the known variation in insects. Specifically, we compared the changes in contrast when shifting the LWS peak from 580 nm to 660 nm between tetrachomat visual systems with different photoreceptor ratios.
We applied the same modelling method described in the Main models but using ratios of different insects, including the jewel beetle, Agrilus planipennis (same as the ratio used in the main text; 1.14: 1: 1.26: 1.38; UVS: SWS: MWS: LWS), and two butterflies, Papilio Xuthus (1: 1: 4.08: 2.92) and Heliconius sp. type III (1.00: 1.44: 2.22: 11.11).
The model parameters and the statistical methods remain the same as described in main text of the paper.
library(pavo)
library(dplyr)
library(stringr)
library(tidyr) #for gather() function
library(ggplot2)
library(lme4)
library(car)
library(multcomp)
library(boot) #for mean() function
library(pander) #for creating tidy tables
library(ggpubr) #for ggarrange() function
<- specsensbuprest.model2[,1]
wl <- gather(specsensbuprest.model2[,2:9], peak, value) %>%
peaks cbind(wl)
#order the peaks in the legend
<- c("UVS.355.A1.", "SWS.445.A1.", "MWS.530.A1.", "LWS.570.A1..filter580.", "LWS.570.A1..filter600.", "LWS.570.A1..filter620.", "LWS.570.A1..filter640.", "LWS.570.A1..filter660.")
peak.order
ggplot(peaks,
aes(x = wl,
y = value,
col = peak))+
geom_line()+
guides(color = guide_legend(title = "peak sensitivity"))+
scale_color_manual(
values = c("darkorchid4", "dodgerblue3", "olivedrab4", "orange1", "orange3","darkorange3", "orangered1", "red2"),
labels = c("355 nm", "445 nm","530 nm", "580 nm", "600 nm", "620 nm", "640 nm", "660 nm" ),
breaks = peak.order)+
xlab("Wavelength (nm)")+
ylab("Relative spectral sensitivity")+
theme_classic()
We used the same spectral data and daylight illumination described in the Main models section.
We created 3 different visual systems using different receptor ratios from 3 insect species (UVS, SWS, MWS, LWS):
Agrilus planipennis: 1.14, 1, 1.26, 1.38
Papilio xuthus: 1, 1, 4.08, 2.92
Heliconius sp. type III : 1, 1.44, 2.22, 11.11
We ran the visual models with the same parameter settings and steps as in the Main models.
We first calculated the quantum catches, then calculated the contrasts.
<- function(i){
get.d65.vismodel
<- vismodel(dataset[1:501,],
vs.i visual = i, #this need to change according to the visual system
bkg = aveleaf$aveleaf,
illum = irradiance.d65[1:501,2],
qcatch = 'fi',
relative = FALSE,
vonkries = TRUE)
return(vs.i)
}
#shared between 3 species
<- list(VS580 <- specsensbuprest.model2[, 1:5],
sens.list <- specsensbuprest.model2[, c(1,2,3,4,6)],
VS600 <- specsensbuprest.model2[, c(1,2,3,4,7)],
VS620 <- specsensbuprest.model2[, c(1,2,3,4,8)],
VS640 <- specsensbuprest.model2[, c(1,2,3,4,9)])
VS660 <- list(VS580 = NA, VS600 = NA, VS620 = NA, VS640 = NA, VS660 = NA)
d65.vismodel.output
# Set a loop for calculating quantum catch for each visual system
for (i in 1:length(sens.list)){
<- get.d65.vismodel(sens.list[[i]]) # for D65
vs.result.d65 <- vs.result.d65
d65.vismodel.output[[i]]
}
<- d65.vismodel.output$VS580
buprest580 <- d65.vismodel.output$VS600
buprest600 <- d65.vismodel.output$VS620
buprest620 <- d65.vismodel.output$VS640
buprest640 <- d65.vismodel.output$VS660 buprest660
<- list(Agrilus <- c(1.14, 1, 1.26, 1.38),
recep.density.list <- c(1, 1, 4.08, 2.92),
Papilio <- c(1, 1.44, 2.22, 11.11))
Heliconius
<- function(i, sp){
get.sens.coldist
<- coldist(modeldata = i, # put output of vismodel()
con noise = "neural",
achro = FALSE,
n = recep.density.list[[sp]],
weber = 0.12,
weber.ref = 4)
return(con)
}
<- list(buprest580,
vismodel.list
buprest600,
buprest620,
buprest640,
buprest660)#for Agrilus planipennis
<- list(VS580 = NA, VS600 = NA, VS620 = NA, VS640 = NA, VS660 = NA)
Agrilus.contrast.output
for (i in 1:length(vismodel.list)) {
<- get.sens.coldist(vismodel.list[[i]], 1)
contrast.result.i <- contrast.result.i
Agrilus.contrast.output[[i]]
}
<- Agrilus.contrast.output$VS580
Cbuprest580 <- Agrilus.contrast.output$VS600
Cbuprest600 <- Agrilus.contrast.output$VS620
Cbuprest620 <- Agrilus.contrast.output$VS640
Cbuprest640 <- Agrilus.contrast.output$VS660
Cbuprest660
#for Papilio xuthus
<- list(VS580 = NA, VS600 = NA, VS620 = NA, VS640 = NA, VS660 = NA)
Papilio.contrast.output
for (i in 1:length(vismodel.list)) {
<- get.sens.coldist(vismodel.list[[i]], 2)
contrast.result.i <- contrast.result.i
Papilio.contrast.output[[i]]
}
<- Papilio.contrast.output$VS580
Cpapilio580 <- Papilio.contrast.output$VS600
Cpapilio600 <- Papilio.contrast.output$VS620
Cpapilio620 <- Papilio.contrast.output$VS640
Cpapilio640 <- Papilio.contrast.output$VS660
Cpapilio660
#for Heliconius sp
<- list(VS580 = NA, VS600 = NA, VS620 = NA, VS640 = NA, VS660 = NA)
Heliconius.contrast.output
for (i in 1:length(vismodel.list)) {
<- get.sens.coldist(vismodel.list[[i]], 3)
contrast.result.i <- contrast.result.i
Heliconius.contrast.output[[i]]
}
<- Heliconius.contrast.output$VS580
Cheliconius580 <- Heliconius.contrast.output$VS600
Cheliconius600 <- Heliconius.contrast.output$VS620
Cheliconius620 <- Heliconius.contrast.output$VS640
Cheliconius640 <- Heliconius.contrast.output$VS660 Cheliconius660
#Organize data before GLMM
<- list("VS580.fl", "VS600.fl", "VS620.fl", "VS640.fl", "VS660.fl")
fl.vissys <- list("VS580.bl", "VS600.bl", "VS620.bl", "VS640.bl", "VS660.bl")
bl.vissys <- list("VS580.bf", "VS600.bf", "VS620.bf", "VS640.bf", "VS660.bf")
bf.vissys
# for Agrilus planipennis
<- list(Cbuprest580,
Agrilus.vissys
Cbuprest600,
Cbuprest620,
Cbuprest640,
Cbuprest660)##flower vs leaf
<- data_frame()
allvis.fl.Agrilus for (i in 1:length(Agrilus.vissys)) {
<- Agrilus.vissys[[i]] %>%
temp.i filter(str_detect(patch1,"flower")) %>%
filter(str_detect(patch2,"leaves")) %>%
::select(1:3)
dplyr
$vissys <- strrep(fl.vissys[[i]],1)
temp.i
<- temp.i %>% rbind(allvis.fl.Agrilus)
allvis.fl.Agrilus
}
### beetle vs leaf
<- data_frame()
allvis.bl.Agrilus for (i in 1:length(Agrilus.vissys)) {
<- Agrilus.vissys[[i]] %>%
temp.i filter(str_detect(patch1,"leaves")) %>%
filter(str_detect(patch2,"beetle")) %>%
::select(1:3)
dplyr
$vissys <- strrep(bl.vissys[[i]],1)
temp.i
<- temp.i %>% rbind(allvis.bl.Agrilus)
allvis.bl.Agrilus
}
##beetle vs flower
<- data_frame()
allvis.bf.Agrilus for (i in 1:length(Agrilus.vissys)) {
<- Agrilus.vissys[[i]] %>%
temp.i filter(str_detect(patch1,"flower")) %>%
filter(str_detect(patch2,"beetle")) %>%
::select(1:3)
dplyr
$vissys <- strrep(bf.vissys[[i]],1)
temp.i
<- temp.i %>% rbind(allvis.bf.Agrilus)
allvis.bf.Agrilus
}
#for Papilio xuthus
<- list(Cpapilio580,
Papilio.vissys
Cpapilio600,
Cpapilio620,
Cpapilio640,
Cpapilio660)##flower vs leaf
<- data_frame()
allvis.fl.Papilio for (i in 1:length(Papilio.vissys)) {
<- Papilio.vissys[[i]] %>%
temp.i filter(str_detect(patch1,"flower")) %>%
filter(str_detect(patch2,"leaves")) %>%
::select(1:3)
dplyr
$vissys <- strrep(fl.vissys[[i]],1)
temp.i
<- temp.i %>% rbind(allvis.fl.Papilio)
allvis.fl.Papilio
}
##beetle vs leaf
<- data_frame()
allvis.bl.Papilio for (i in 1:length(Papilio.vissys)) {
<- Papilio.vissys[[i]] %>%
temp.i filter(str_detect(patch1,"leaves")) %>%
filter(str_detect(patch2,"beetle")) %>%
::select(1:3)
dplyr
$vissys <- strrep(bl.vissys[[i]],1)
temp.i
<- temp.i %>% rbind(allvis.bl.Papilio)
allvis.bl.Papilio
}
##beetle vs flower
<- data_frame()
allvis.bf.Papilio for (i in 1:length(Papilio.vissys)) {
<- Papilio.vissys[[i]] %>%
temp.i filter(str_detect(patch1,"flower")) %>%
filter(str_detect(patch2,"beetle")) %>%
::select(1:3)
dplyr
$vissys <- strrep(bf.vissys[[i]],1)
temp.i
<- temp.i %>% rbind(allvis.bf.Papilio)
allvis.bf.Papilio
}
#for Heliconius sp
<- list(Cheliconius580,
Heliconius.vissys
Cheliconius600,
Cheliconius620,
Cheliconius640,
Cheliconius660)##flower vs leaf
<- data_frame()
allvis.fl.Heliconius for (i in 1:length(Heliconius.vissys)) {
<- Heliconius.vissys[[i]] %>%
temp.i filter(str_detect(patch1,"flower")) %>%
filter(str_detect(patch2,"leaves")) %>%
::select(1:3)
dplyr
$vissys <- strrep(fl.vissys[[i]],1)
temp.i
<- temp.i %>% rbind(allvis.fl.Heliconius)
allvis.fl.Heliconius
}
##beetle vs leaf
<- data_frame()
allvis.bl.Heliconius for (i in 1:length(Heliconius.vissys)) {
<- Heliconius.vissys[[i]] %>%
temp.i filter(str_detect(patch1,"leaves")) %>%
filter(str_detect(patch2,"beetle")) %>%
::select(1:3)
dplyr
$vissys <- strrep(bl.vissys[[i]],1)
temp.i
<- temp.i %>% rbind(allvis.bl.Heliconius)
allvis.bl.Heliconius
}
##beetle vs flower
<- data_frame()
allvis.bf.Heliconius for (i in 1:length(Heliconius.vissys)) {
<- Heliconius.vissys[[i]] %>%
temp.i filter(str_detect(patch1,"flower")) %>%
filter(str_detect(patch2,"beetle")) %>%
::select(1:3)
dplyr
$vissys <- strrep(bf.vissys[[i]],1)
temp.i
<- temp.i %>% rbind(allvis.bf.Heliconius)
allvis.bf.Heliconius }
Click the tabs to see the results for each comparison group ( Flower vs. Leaf / Beetle vs. Leaf / Beetle vs. Flower) in 3 different speceis (Agrilus planipennis / Papilio xuthus / Heliconius sp).
<- function(inputdat){
get.lmer.sens
lmer(dS ~ vissys + (1|patch2) + (1|patch1),
data = inputdat, REML = F)
#REML=F, in order to fit the model using the likelihood ratio test. Otherwise, the lmer default will fit the model using the REML (REstricted Maximum Likelihood) criterion.
}
<- function(modelx){
get.posthocsum
summary(glht(modelx,
linfct = mcp(vissys = "Tukey")),
test = adjusted("bonferroni"))
}
# for Agrilus planipennis
## Flower vs Leaf
<- get.lmer.sens(allvis.fl.Agrilus)
m.flower.vs.leaf.bup <- get.posthocsum(m.flower.vs.leaf.bup)
sum.flower.vs.leaf.bup
##Beetle vs Leaf
<- get.lmer.sens(allvis.bl.Agrilus)
m.beetle.vs.leaf.bup <- get.posthocsum(m.beetle.vs.leaf.bup)
sum.beetle.vs.leaf.bup
##Beetle vs Flower
<- get.lmer.sens(allvis.bf.Agrilus)
m.beetle.vs.flower.bup <- get.posthocsum(m.beetle.vs.flower.bup)
sum.beetle.vs.flower.bup
#for Papilio xuthus
##Flower vs Leaf
<- get.lmer.sens(allvis.fl.Papilio)
m.flower.vs.leaf.pap <- get.posthocsum(m.flower.vs.leaf.pap)
sum.flower.vs.leaf.pap
##Beetle vs Leaf
<- get.lmer.sens(allvis.bl.Papilio)
m.beetle.vs.leaf.pap <- get.posthocsum(m.beetle.vs.leaf.pap)
sum.beetle.vs.leaf.pap
##Beetle vs Flower
<- get.lmer.sens(allvis.bf.Papilio)
m.beetle.vs.flower.pap <- get.posthocsum(m.beetle.vs.flower.pap)
sum.beetle.vs.flower.pap
#for Heliconius sp
##Flower vs Leaf
<- get.lmer.sens(allvis.fl.Heliconius)
m.flower.vs.leaf.heli <- get.posthocsum(m.flower.vs.leaf.heli)
sum.flower.vs.leaf.heli
##Beetle vs Leaf
<- get.lmer.sens(allvis.bl.Heliconius)
m.beetle.vs.leaf.heli <- get.posthocsum(m.beetle.vs.leaf.heli)
sum.beetle.vs.leaf.heli
##Beetle vs Flower
<- get.lmer.sens(allvis.bf.Heliconius)
m.beetle.vs.flower.heli <- get.posthocsum(m.beetle.vs.flower.heli) sum.beetle.vs.flower.heli
<- list(
vislist.heatmap c("VS 600", "VS 620","VS 640","VS 660","VS 620","VS 640","VS 660","VS 640","VS 660","VS 660"),
c("VS 580","VS 580","VS 580","VS 580","VS 600","VS 600","VS 600","VS 620","VS 620","VS 640"))
# Set up the function
<- function(i,z){
get.heatmap.datframe
<- data.frame(as.numeric(str_extract(i[[1]],"([0-9]+).*$"))) %>%
heatmapdat.i cbind(as.numeric(str_extract(i[[2]],"([0-9]+).*$"))) %>%
cbind(as.numeric(str_extract(i[[3]],"([0-9]+).*$"))) %>%
::rename(flower.vs.leaf = 1, beetle.vs.leaf = 2, beetle.vs.flower = 3) %>%
dplyrcbind(z[[1]]) %>%
cbind(z[[2]])
colnames(heatmapdat.i)[4:5] <- c("VislistA", "VislistB")
return(heatmapdat.i)
}
# Create pvalue dataset
## for Agrilus planipennis
<- list(sum.flower.vs.leaf.bup[["test"]][["pvalues"]],
pdata.Agrilus "test"]][["pvalues"]],
sum.beetle.vs.leaf.bup[["test"]][["pvalues"]])
sum.beetle.vs.flower.bup[[
<- get.heatmap.datframe(pdata.Agrilus, vislist.heatmap)
heat.Agrilus
## for Papilio xuthus
<- list(sum.flower.vs.leaf.pap[["test"]][["pvalues"]],
pdata.Papilio "test"]][["pvalues"]],
sum.beetle.vs.leaf.pap[["test"]][["pvalues"]])
sum.beetle.vs.flower.pap[[
<- get.heatmap.datframe(pdata.Papilio, vislist.heatmap)
heat.Papilio
## for Heliconius sp
<- list(sum.flower.vs.leaf.heli[["test"]][["pvalues"]],
pdata.Heliconius "test"]][["pvalues"]],
sum.beetle.vs.leaf.heli[["test"]][["pvalues"]])
sum.beetle.vs.flower.heli[[
<- get.heatmap.datframe(pdata.Heliconius, vislist.heatmap)
heat.Heliconius
# Assign asterisk signs
<- list(heat.Agrilus, heat.Papilio, heat.Heliconius)
pdatalist
for (i in 1:length(pdatalist)) {
$sig.flower.vs.leaf[pdatalist[[i]]$flower.vs.leaf > 0.05] <- ""
pdatalist[[i]]$sig.flower.vs.leaf[pdatalist[[i]]$flower.vs.leaf < 0.05] <- "*"
pdatalist[[i]]$sig.flower.vs.leaf[pdatalist[[i]]$flower.vs.leaf < 0.01] <- "**"
pdatalist[[i]]$sig.flower.vs.leaf[pdatalist[[i]]$flower.vs.leaf < 0.0001] <- "***"
pdatalist[[i]]$sig.beetle.vs.leaf[pdatalist[[i]]$beetle.vs.leaf > 0.05] <- ""
pdatalist[[i]]$sig.beetle.vs.leaf[pdatalist[[i]]$beetle.vs.leaf < 0.05] <- "*"
pdatalist[[i]]$sig.beetle.vs.leaf[pdatalist[[i]]$beetle.vs.leaf < 0.01] <- "**"
pdatalist[[i]]$sig.beetle.vs.leaf[pdatalist[[i]]$beetle.vs.leaf < 0.0001] <- "***"
pdatalist[[i]]$sig.beetle.vs.flower[pdatalist[[i]]$beetle.vs.flower > 0.05] <- ""
pdatalist[[i]]$sig.beetle.vs.flower[pdatalist[[i]]$beetle.vs.flower < 0.05] <- "*"
pdatalist[[i]]$sig.beetle.vs.flower[pdatalist[[i]]$beetle.vs.flower < 0.01] <- "**"
pdatalist[[i]]$sig.beetle.vs.flower[pdatalist[[i]]$beetle.vs.flower < 0.0001] <- "***"
pdatalist[[i]]
}
# Because we did the assignment on a data list, now we need to link the loop output back to the data respectively
<- pdatalist[[1]]
heat.Agrilus <- pdatalist[[2]]
heat.Papilio <- pdatalist[[3]] heat.Heliconius
# a = data
# b = 1/2/3; 1 for flower.vs.leaf, 2 for beetle.vs.leaf, 3 for beetle.vs.flower
<- function(a, b){ggplot(data = a,
get.pheatmap aes(x = VislistA,
y = VislistB,
fill = a[,b])) +
geom_tile(colour = "white", size = 4)+
geom_text(aes(VislistA,
VislistB, label = paste(format(round(a[,b], 2), nsmall = 2),
+5])))+
a[, bscale_fill_continuous(high = "#132B43", low = "#56B1F7", limit = c(0,1))+ #delete if want to reverse the colour
theme_bw()+
theme(axis.title.x = element_blank(),
axis.title.y = element_blank(),
panel.grid = element_blank(),
panel.border = element_blank(),
axis.ticks = element_blank() )+
labs(fill = "p vaalue")
}
Anova(m.flower.vs.leaf.bup) %>% pander()
Chisq | Df | Pr(>Chisq) | |
---|---|---|---|
vissys | 2268 | 4 | 0 |
Click the tabs to see the p-value summary plot or the original model output
get.pheatmap(heat.Agrilus, 1)
sum.flower.vs.leaf.bup
##
## Simultaneous Tests for General Linear Hypotheses
##
## Multiple Comparisons of Means: Tukey Contrasts
##
##
## Fit: lmer(formula = dS ~ vissys + (1 | patch2) + (1 | patch1), data = inputdat,
## REML = F)
##
## Linear Hypotheses:
## Estimate Std. Error z value Pr(>|z|)
## VS600.fl - VS580.fl == 0 0.42097 0.04777 8.812 <2e-16 ***
## VS620.fl - VS580.fl == 0 1.17568 0.04777 24.609 <2e-16 ***
## VS640.fl - VS580.fl == 0 1.80399 0.04777 37.760 <2e-16 ***
## VS660.fl - VS580.fl == 0 1.76193 0.04777 36.880 <2e-16 ***
## VS620.fl - VS600.fl == 0 0.75471 0.04777 15.797 <2e-16 ***
## VS640.fl - VS600.fl == 0 1.38301 0.04777 28.949 <2e-16 ***
## VS660.fl - VS600.fl == 0 1.34096 0.04777 28.068 <2e-16 ***
## VS640.fl - VS620.fl == 0 0.62831 0.04777 13.151 <2e-16 ***
## VS660.fl - VS620.fl == 0 0.58625 0.04777 12.271 <2e-16 ***
## VS660.fl - VS640.fl == 0 -0.04206 0.04777 -0.880 1
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## (Adjusted p values reported -- bonferroni method)
Anova(m.flower.vs.leaf.pap) %>% pander()
Chisq | Df | Pr(>Chisq) | |
---|---|---|---|
vissys | 5425 | 4 | 0 |
Click the tabs to see the p-value summary plot or the original model output
get.pheatmap(heat.Papilio, 1)
sum.flower.vs.leaf.pap
##
## Simultaneous Tests for General Linear Hypotheses
##
## Multiple Comparisons of Means: Tukey Contrasts
##
##
## Fit: lmer(formula = dS ~ vissys + (1 | patch2) + (1 | patch1), data = inputdat,
## REML = F)
##
## Linear Hypotheses:
## Estimate Std. Error z value Pr(>|z|)
## VS600.fl - VS580.fl == 0 0.57457 0.03751 15.319 <2e-16 ***
## VS620.fl - VS580.fl == 0 1.47910 0.03751 39.435 <2e-16 ***
## VS640.fl - VS580.fl == 0 2.19498 0.03751 58.521 <2e-16 ***
## VS660.fl - VS580.fl == 0 2.17608 0.03751 58.017 <2e-16 ***
## VS620.fl - VS600.fl == 0 0.90454 0.03751 24.116 <2e-16 ***
## VS640.fl - VS600.fl == 0 1.62041 0.03751 43.202 <2e-16 ***
## VS660.fl - VS600.fl == 0 1.60151 0.03751 42.698 <2e-16 ***
## VS640.fl - VS620.fl == 0 0.71587 0.03751 19.086 <2e-16 ***
## VS660.fl - VS620.fl == 0 0.69697 0.03751 18.582 <2e-16 ***
## VS660.fl - VS640.fl == 0 -0.01890 0.03751 -0.504 1
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## (Adjusted p values reported -- bonferroni method)
Anova(m.flower.vs.leaf.heli) %>% pander()
Chisq | Df | Pr(>Chisq) | |
---|---|---|---|
vissys | 6518 | 4 | 0 |
Click the tabs to see the p-value summary plot or the original model output
get.pheatmap(heat.Heliconius, 1)
sum.flower.vs.leaf.heli
##
## Simultaneous Tests for General Linear Hypotheses
##
## Multiple Comparisons of Means: Tukey Contrasts
##
##
## Fit: lmer(formula = dS ~ vissys + (1 | patch2) + (1 | patch1), data = inputdat,
## REML = F)
##
## Linear Hypotheses:
## Estimate Std. Error z value Pr(>|z|)
## VS600.fl - VS580.fl == 0 0.35075 0.02222 15.782 <2e-16 ***
## VS620.fl - VS580.fl == 0 0.94433 0.02222 42.491 <2e-16 ***
## VS640.fl - VS580.fl == 0 1.42640 0.02222 64.183 <2e-16 ***
## VS660.fl - VS580.fl == 0 1.39784 0.02222 62.898 <2e-16 ***
## VS620.fl - VS600.fl == 0 0.59358 0.02222 26.709 <2e-16 ***
## VS640.fl - VS600.fl == 0 1.07566 0.02222 48.400 <2e-16 ***
## VS660.fl - VS600.fl == 0 1.04710 0.02222 47.115 <2e-16 ***
## VS640.fl - VS620.fl == 0 0.48207 0.02222 21.691 <2e-16 ***
## VS660.fl - VS620.fl == 0 0.45351 0.02222 20.406 <2e-16 ***
## VS660.fl - VS640.fl == 0 -0.02856 0.02222 -1.285 1
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## (Adjusted p values reported -- bonferroni method)
Anova(m.beetle.vs.leaf.bup) %>% pander()
Chisq | Df | Pr(>Chisq) | |
---|---|---|---|
vissys | 2119 | 4 | 0 |
Click the tabs to see the p-value summary plot or the original model output
get.pheatmap(heat.Agrilus, 2)
sum.beetle.vs.leaf.bup
##
## Simultaneous Tests for General Linear Hypotheses
##
## Multiple Comparisons of Means: Tukey Contrasts
##
##
## Fit: lmer(formula = dS ~ vissys + (1 | patch2) + (1 | patch1), data = inputdat,
## REML = F)
##
## Linear Hypotheses:
## Estimate Std. Error z value Pr(>|z|)
## VS600.bl - VS580.bl == 0 0.57356 0.04944 11.602 < 2e-16 ***
## VS620.bl - VS580.bl == 0 1.22449 0.04944 24.770 < 2e-16 ***
## VS640.bl - VS580.bl == 0 1.72490 0.04944 34.892 < 2e-16 ***
## VS660.bl - VS580.bl == 0 1.93477 0.04944 39.137 < 2e-16 ***
## VS620.bl - VS600.bl == 0 0.65093 0.04944 13.167 < 2e-16 ***
## VS640.bl - VS600.bl == 0 1.15135 0.04944 23.290 < 2e-16 ***
## VS660.bl - VS600.bl == 0 1.36121 0.04944 27.535 < 2e-16 ***
## VS640.bl - VS620.bl == 0 0.50041 0.04944 10.123 < 2e-16 ***
## VS660.bl - VS620.bl == 0 0.71028 0.04944 14.368 < 2e-16 ***
## VS660.bl - VS640.bl == 0 0.20986 0.04944 4.245 0.000218 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## (Adjusted p values reported -- bonferroni method)
Anova(m.beetle.vs.leaf.pap) %>% pander()
Chisq | Df | Pr(>Chisq) | |
---|---|---|---|
vissys | 4046 | 4 | 0 |
Click the tabs to see the p-value summary plot or the original model output
get.pheatmap(heat.Papilio, 2)
sum.beetle.vs.leaf.pap
##
## Simultaneous Tests for General Linear Hypotheses
##
## Multiple Comparisons of Means: Tukey Contrasts
##
##
## Fit: lmer(formula = dS ~ vissys + (1 | patch2) + (1 | patch1), data = inputdat,
## REML = F)
##
## Linear Hypotheses:
## Estimate Std. Error z value Pr(>|z|)
## VS600.bl - VS580.bl == 0 0.71260 0.04192 16.998 < 2e-16 ***
## VS620.bl - VS580.bl == 0 1.47367 0.04192 35.152 < 2e-16 ***
## VS640.bl - VS580.bl == 0 2.03704 0.04192 48.590 < 2e-16 ***
## VS660.bl - VS580.bl == 0 2.27321 0.04192 54.224 < 2e-16 ***
## VS620.bl - VS600.bl == 0 0.76107 0.04192 18.154 < 2e-16 ***
## VS640.bl - VS600.bl == 0 1.32444 0.04192 31.592 < 2e-16 ***
## VS660.bl - VS600.bl == 0 1.56060 0.04192 37.226 < 2e-16 ***
## VS640.bl - VS620.bl == 0 0.56337 0.04192 13.438 < 2e-16 ***
## VS660.bl - VS620.bl == 0 0.79954 0.04192 19.072 < 2e-16 ***
## VS660.bl - VS640.bl == 0 0.23617 0.04192 5.633 1.77e-07 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## (Adjusted p values reported -- bonferroni method)
Anova(m.beetle.vs.leaf.heli) %>% pander()
Chisq | Df | Pr(>Chisq) | |
---|---|---|---|
vissys | 3617 | 4 | 0 |
Click the tabs to see the p-value summary plot or the original model output
get.pheatmap(heat.Heliconius, 2)
sum.beetle.vs.leaf.heli
##
## Simultaneous Tests for General Linear Hypotheses
##
## Multiple Comparisons of Means: Tukey Contrasts
##
##
## Fit: lmer(formula = dS ~ vissys + (1 | patch2) + (1 | patch1), data = inputdat,
## REML = F)
##
## Linear Hypotheses:
## Estimate Std. Error z value Pr(>|z|)
## VS600.bl - VS580.bl == 0 0.46256 0.02883 16.042 < 2e-16 ***
## VS620.bl - VS580.bl == 0 0.95329 0.02883 33.062 < 2e-16 ***
## VS640.bl - VS580.bl == 0 1.32086 0.02883 45.809 < 2e-16 ***
## VS660.bl - VS580.bl == 0 1.48159 0.02883 51.384 < 2e-16 ***
## VS620.bl - VS600.bl == 0 0.49073 0.02883 17.019 < 2e-16 ***
## VS640.bl - VS600.bl == 0 0.85829 0.02883 29.767 < 2e-16 ***
## VS660.bl - VS600.bl == 0 1.01903 0.02883 35.342 < 2e-16 ***
## VS640.bl - VS620.bl == 0 0.36756 0.02883 12.748 < 2e-16 ***
## VS660.bl - VS620.bl == 0 0.52830 0.02883 18.322 < 2e-16 ***
## VS660.bl - VS640.bl == 0 0.16074 0.02883 5.575 2.48e-07 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## (Adjusted p values reported -- bonferroni method)
Anova(m.beetle.vs.flower.bup) %>% pander()
Chisq | Df | Pr(>Chisq) | |
---|---|---|---|
vissys | 607.9 | 4 | 3.052e-130 |
Click the tabs to see the p-value summary plot or the original model output
get.pheatmap(heat.Agrilus, 3)
sum.beetle.vs.flower.bup
##
## Simultaneous Tests for General Linear Hypotheses
##
## Multiple Comparisons of Means: Tukey Contrasts
##
##
## Fit: lmer(formula = dS ~ vissys + (1 | patch2) + (1 | patch1), data = inputdat,
## REML = F)
##
## Linear Hypotheses:
## Estimate Std. Error z value Pr(>|z|)
## VS600.bf - VS580.bf == 0 0.37988 0.07044 5.393 6.93e-07 ***
## VS620.bf - VS580.bf == 0 0.84419 0.07044 11.985 < 2e-16 ***
## VS640.bf - VS580.bf == 0 1.22628 0.07044 17.409 < 2e-16 ***
## VS660.bf - VS580.bf == 0 1.51287 0.07044 21.477 < 2e-16 ***
## VS620.bf - VS600.bf == 0 0.46431 0.07044 6.592 4.35e-10 ***
## VS640.bf - VS600.bf == 0 0.84640 0.07044 12.016 < 2e-16 ***
## VS660.bf - VS600.bf == 0 1.13299 0.07044 16.084 < 2e-16 ***
## VS640.bf - VS620.bf == 0 0.38209 0.07044 5.424 5.82e-07 ***
## VS660.bf - VS620.bf == 0 0.66868 0.07044 9.493 < 2e-16 ***
## VS660.bf - VS640.bf == 0 0.28659 0.07044 4.069 0.000473 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## (Adjusted p values reported -- bonferroni method)
Anova(m.beetle.vs.flower.pap) %>% pander()
Chisq | Df | Pr(>Chisq) | |
---|---|---|---|
vissys | 1264 | 4 | 2.33e-272 |
Click the tabs to see the p-value summary plot or the original model output
get.pheatmap(heat.Papilio, 3)
sum.beetle.vs.flower.pap
##
## Simultaneous Tests for General Linear Hypotheses
##
## Multiple Comparisons of Means: Tukey Contrasts
##
##
## Fit: lmer(formula = dS ~ vissys + (1 | patch2) + (1 | patch1), data = inputdat,
## REML = F)
##
## Linear Hypotheses:
## Estimate Std. Error z value Pr(>|z|)
## VS600.bf - VS580.bf == 0 0.55397 0.06493 8.531 < 2e-16 ***
## VS620.bf - VS580.bf == 0 1.17015 0.06493 18.021 < 2e-16 ***
## VS640.bf - VS580.bf == 0 1.65504 0.06493 25.488 < 2e-16 ***
## VS660.bf - VS580.bf == 0 2.01940 0.06493 31.099 < 2e-16 ***
## VS620.bf - VS600.bf == 0 0.61618 0.06493 9.489 < 2e-16 ***
## VS640.bf - VS600.bf == 0 1.10107 0.06493 16.957 < 2e-16 ***
## VS660.bf - VS600.bf == 0 1.46543 0.06493 22.568 < 2e-16 ***
## VS640.bf - VS620.bf == 0 0.48489 0.06493 7.467 8.17e-13 ***
## VS660.bf - VS620.bf == 0 0.84925 0.06493 13.079 < 2e-16 ***
## VS660.bf - VS640.bf == 0 0.36436 0.06493 5.611 2.01e-07 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## (Adjusted p values reported -- bonferroni method)
Anova(m.beetle.vs.flower.heli) %>% pander()
Chisq | Df | Pr(>Chisq) | |
---|---|---|---|
vissys | 1218 | 4 | 1.996e-262 |
Click the tabs to see the p-value summary plot or the original model output
get.pheatmap(heat.Heliconius, 3)
sum.beetle.vs.flower.heli
##
## Simultaneous Tests for General Linear Hypotheses
##
## Multiple Comparisons of Means: Tukey Contrasts
##
##
## Fit: lmer(formula = dS ~ vissys + (1 | patch2) + (1 | patch1), data = inputdat,
## REML = F)
##
## Linear Hypotheses:
## Estimate Std. Error z value Pr(>|z|)
## VS600.bf - VS580.bf == 0 0.3330 0.0405 8.221 2.22e-15 ***
## VS620.bf - VS580.bf == 0 0.7093 0.0405 17.514 < 2e-16 ***
## VS640.bf - VS580.bf == 0 1.0101 0.0405 24.940 < 2e-16 ***
## VS660.bf - VS580.bf == 0 1.2356 0.0405 30.510 < 2e-16 ***
## VS620.bf - VS600.bf == 0 0.3764 0.0405 9.293 < 2e-16 ***
## VS640.bf - VS600.bf == 0 0.6771 0.0405 16.719 < 2e-16 ***
## VS660.bf - VS600.bf == 0 0.9027 0.0405 22.289 < 2e-16 ***
## VS640.bf - VS620.bf == 0 0.3008 0.0405 7.426 1.12e-12 ***
## VS660.bf - VS620.bf == 0 0.5263 0.0405 12.996 < 2e-16 ***
## VS660.bf - VS640.bf == 0 0.2256 0.0405 5.570 2.55e-07 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## (Adjusted p values reported -- bonferroni method)
#import the sample color code
<- read.csv("../data/color code list.csv", header=TRUE)
color.code
# Set up a function to calculate means for the plot
<- function(a, b, c){
get.plotmeans if (a == "aim1"){
if(b == "bl"){
<- c %>%
plotmean.i group_by(patch2, vissys) %>%
summarize(mean.dS.sub = mean(dS)) %>%
ungroup() %>%
rename(beetleID = patch2) %>%
merge(beetle.colour.aim1[,c("species", "colour")], by.x = c("beetleID"), by.y = c("species")) %>%
distinct()
return(plotmean.i)
else {
} <- c %>%
plotmean.i group_by(patch1, vissys) %>%
summarize(mean.dS.sub = mean(dS)) %>%
ungroup() %>%
rename(flowerID = patch1) %>%
merge(flower.colour.aim1[,c("species", "colour")], by.x = c("flowerID"), by.y = c("species")) %>%
distinct()
return(plotmean.i)
}else if (a == "aim2"){
} if (b == "bl"){
<- c %>%
plotmean.i group_by(patch2, vissys) %>%
summarize(mean.dS.sub = mean(dS)) %>%
ungroup() %>%
rename(beetleID = patch2) %>%
merge(beetle.colour.aim2[,c("species", "colour")], by.x = c("beetleID"), by.y = c("species")) %>%
distinct()
return(plotmean.i)
else {
} <- c %>%
plotmean.i group_by(patch1, vissys) %>%
summarize(mean.dS.sub = mean(dS)) %>%
ungroup() %>%
rename(flowerID = patch1) %>%
merge(flower.colour.aim2[,c("species", "colour")], by.x = c("flowerID"), by.y = c("species")) %>%
distinct()
return(plotmean.i)
}
}
}
# What should be put in the function get.plotmeans()
# a = "aim1" or "aim2"
# b = comparison type: "fl", "bl", "bf"
# c = input data, e.g. allvis.fl_d65.aim1
#create a list of species name used in the spec data in oder to merge() with mean data set later
<- gather(dataset[,2:131],
dataset.transpose key = "species",
value = "reflectance",
na.rm = FALSE,
convert = FALSE, factor_key = FALSE)
<- unique(dataset.transpose$species) %>%
name.list sort() %>% #order it alphabetically
data.frame() %>%
::rename(species = ".") #make it a data frame and name the column "species"
dplyr
# create flower and beetle name list
<- c( "flower", "beetle")
colourgrouplist <- vector("list", 4)
tempcolordat
## for Aim 2
for(i in seq_along(colourgrouplist)){
<- name.list %>%
ouput.i filter(str_detect(species, colourgrouplist[i])) %>%
cbind(color.code %>%
filter(str_detect(type, colourgrouplist[i])) %>%
arrange(name)) %>%
::select(-type) %>%
dplyrmutate(count = 5) %>%
uncount(count)
+2]] <- ouput.i # here same in i+2 because 1-2 is for aim1
tempcolordat[[i
}<- tempcolordat[[3]]
flower.colour.aim2 <- tempcolordat[[4]] beetle.colour.aim2
<- list(allvis.fl.Agrilus, allvis.bl.Agrilus, allvis.bf.Agrilus,
allvis.list
allvis.fl.Papilio, allvis.bl.Papilio, allvis.bf.Papilio,
allvis.fl.Heliconius, allvis.bl.Heliconius, allvis.bf.Heliconius)
<- vector("list", length(allvis.list))
tempcolordat
for(i in seq_along(allvis.list)){
<- allvis.list[[i]] %>%
temp.meandS.i group_by(vissys) %>%
summarize(mean.dS = mean(dS))
<- temp.meandS.i
tempcolordat[[i]]
}
<- list("Flower vs. Leaf", "Beetle vs. Leaf", "Beetle vs. Flower")
title.list
<- list(fl <- c("VS580.fl", "VS600.fl", "VS620.fl", "VS640.fl", "VS660.fl"),
vis.comp.list <- c("VS580.bl", "VS600.bl", "VS620.bl", "VS640.bl", "VS660.bl"),
bl <- c("VS580.bf", "VS600.bf", "VS620.bf", "VS640.bf", "VS660.bf"))
bf <- list(fl.Agrilus <- c("a","b","c","d","d"),
stats.list <- c("a","b","c","d","e"),
bl.Agrilus <- c("a","b","c","d","e"),
bf.Agrilus <- c("a","b","c","d","d"),
fl.Papilio <- c("a","b","c","d","e"),
bl.Papilio <- c("a","b","c","d","e"),
bf.Papilio <- c("a","b","c","d","d"),
fl.Heliconius <- c("a","b","c","d","e"),
bl.Heliconius <- c("a","b","c","d","e"))
bf.Heliconius <- c("grey80", NA) # choose NA for beetle.vs.leaf
backgorund.list
<- function(dat, title, visomplist, compgroupnstats, background){
get.contrastplot.sens ggplot(dat, aes(x = vissys,
y = mean.dS.sub,
group = factor(dat[,1])))+
geom_point(col = dat$colour,
size = 1, alpha = 0.7) +
geom_line(col = dat$colour,
size = 0.5, alpha = 0.7)+
xlab("Visual system") +
ylab("Chromatic contrast (JND)") +
ylim(0, 21)+
theme(panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.background = element_rect(fill = backgorund.list[background], size = NA),
axis.title.x = element_text(size = 12),
axis.text.x = element_text(size = 8, colour = "black", angle = 90),
axis.title.y = element_text(size = 12, vjust = 1),
axis.text.y = element_text(size = 8, colour = "black"),
axis.line.x = element_line(colour = 'black', size = 0.5, linetype = 'solid'),
axis.line.y = element_line(colour = 'black', size = 0.5, linetype = 'solid'),
legend.justification = c(1,0),
legend.position = c(1,0.45),
legend.key = element_blank(),
legend.title = element_text(size = 10),
legend.text = element_text(size = 9))+
scale_x_discrete(limits = vis.comp.list[[visomplist]],
labels = c("VS 580", "VS 600","VS 620","VS 640","VS 660"))+
geom_point(data = dat,
aes(x = vis.comp.list[[visomplist]][1],
y = tempcolordat[[compgroupnstats]]$mean.dS[1]),
col = "black", size = 3)+
geom_point(data = dat,
aes(x = vis.comp.list[[visomplist]][2],
y = tempcolordat[[compgroupnstats]]$mean.dS[2]),
col = "black", size = 3)+
geom_point(data = dat,
aes(x = vis.comp.list[[visomplist]][3],
y = tempcolordat[[compgroupnstats]]$mean.dS[3]),
col = "black", size = 3)+
geom_point(data = dat,
aes(x = vis.comp.list[[visomplist]][4],
y = tempcolordat[[compgroupnstats]]$mean.dS[4]),
col = "black", size = 3)+
geom_point(data = dat,
aes(x = vis.comp.list[[visomplist]][5],
y = tempcolordat[[compgroupnstats]]$mean.dS[5]),
col = "black", size = 3)+
ggtitle(title.list[[title]])+
annotate("text", x = vis.comp.list[[visomplist]], y = 21,
label = stats.list[[compgroupnstats]])
}
# create a data set for means
<- get.plotmeans("aim2", "fl", allvis.fl.Agrilus)
mean.fl.Agrilus <- get.plotmeans("aim2", "bl", allvis.bl.Agrilus)
mean.bl.Agrilus <- get.plotmeans("aim2", "bf", allvis.bf.Agrilus)
mean.bf.Agrilus
# plot individual panel
<- get.contrastplot.sens(mean.fl.Agrilus, 1, 1, 1, 1)
fl.Agrilus <- get.contrastplot.sens(mean.bl.Agrilus, 2, 2, 2, 2)
bl.Agrilus <- get.contrastplot.sens(mean.bf.Agrilus, 3, 3, 3, 1)
bf.Agrilus
# bind the 3 panels
<- ggarrange(fl.Agrilus,
figure.bup
bl.Agrilus,
bf.Agrilus, ncol = 3, nrow = 1)
figure.bup
# create a data set for means
<- get.plotmeans("aim2", "fl", allvis.fl.Papilio)
mean.fl.Papilio <- get.plotmeans("aim2", "bl", allvis.bl.Papilio)
mean.bl.Papilio <- get.plotmeans("aim2", "bf", allvis.bf.Papilio)
mean.bf.Papilio
# plot individual panel
<- get.contrastplot.sens(mean.fl.Papilio, 1, 1, 4, 1)
fl.Papilio <- get.contrastplot.sens(mean.bl.Papilio, 2, 2, 5, 2)
bl.Papilio <- get.contrastplot.sens(mean.bf.Papilio, 3, 3, 6, 1)
bf.Papilio
# bind the 3 panels
<- ggarrange(fl.Papilio,
figure.pap
bl.Papilio,
bf.Papilio, ncol = 3, nrow = 1)
figure.pap
# create a data set for means
<- get.plotmeans("aim2", "fl", allvis.fl.Heliconius)
mean.fl.Heliconius <- get.plotmeans("aim2", "bl", allvis.bl.Heliconius)
mean.bl.Heliconius <- get.plotmeans("aim2", "bf", allvis.bf.Heliconius)
mean.bf.Heliconius
# plot individual panel
<- get.contrastplot.sens(mean.fl.Heliconius, 1, 1, 7, 1)
fl.Heliconius <- get.contrastplot.sens(mean.bl.Heliconius, 2, 2, 8, 2)
bl.Heliconius <- get.contrastplot.sens(mean.bf.Heliconius, 3, 3, 9, 1)
bf.Heliconius
# bind the 3 panels
<- ggarrange(fl.Heliconius,
figure.heli
bl.Heliconius,
bf.Heliconius, ncol = 3, nrow = 1)
figure.heli
The results were qualitatively the same for different photoreceptor ratios among three comparison groups – contrast increased for LWS photoreceptors with peak sensitivity from 580 to at least 640 nm. This indicates that our results were not biased by photoreceptor ratios in our hypothetical visual systems.