## # Endriss & Vahsen et al. density-dependent dispersal analyses ## # FigS3 - Interaction panel plot (dispden:momden) for sd and max. # Extracted lsmeans from supplemental analysis for maximum distance dispersed # and standard deviation of distance dispersed. # Created by MLV 26 August 2018 # Updated by MLV 27 August 2018 # Clear object memory rm(list=ls()) # ------------------------------ # # Note: Need to set directory or # include file path for .csv # ------------------------------ # indata_sd <- read.csv("LMM_DM_SD.csv") indata_max <- read.csv("LMM_DM_Max.csv") # Remove first nuisance column sd <- indata_sd[,colnames(indata_sd) != "X"] max <- indata_max[,colnames(indata_max) != "X"] # We have 1000 interations for each of these mean values. We take # the average values of the means and CIs for plotting. summary_sd <- colMeans(sd) summary_max <- colMeans(max) # Separate data back into manageable form (rr [background] beetles are # specified; if no rr, then assume sf [experimental]) # Standard deviation (first set is sf: experimental) DM_int_means_sd <- summary_sd[5:8] DM_int_lower_sd <- summary_sd[13:16] DM_int_upper_sd <- summary_sd[21:24] DM_int_means_rr_sd <- summary_sd[1:4] DM_int_lower_rr_sd <- summary_sd[9:12] DM_int_upper_rr_sd <- summary_sd[17:20] # Maximum DM_int_means_max <- summary_max[5:8] DM_int_lower_max <- summary_max[13:16] DM_int_upper_max <- summary_max[21:24] DM_int_means_rr_max <- summary_max[1:4] DM_int_lower_rr_max <- summary_max[9:12] DM_int_upper_rr_max <- summary_max[17:20] pdf("FigS3.pdf", height = 7.60, width = 5.15) # First panel = dispersal density by juvenile density SD # Plot experimental beetles first x <- c(1.2,2.2) colors <- c("plum","#e17ca5","#7a7a7a", "#3d3d3d") par(mar = c(0,5,2,2), fig = c(0, 1, 0.527, 1), cex = 1) plot(x, DM_int_means_sd[c(3,1)], ylim = c(0.4,1.3), col = colors[1], pch = 16, xlim = c(0.85, 2.35), xaxt = "n", xlab = "", ylab = "", yaxt = "n", cex = 2) axis(side = 1, at = c(0,1.1,2.1,3), labels = FALSE) axis(side = 2, at = seq(-0.5,3,0.25), labels = TRUE, las = 1, tick = TRUE) # Axis labels mtext("( and standardized individuals)", side=2, padj = -5.5, cex = 0.8) mtext("experimental", side=2, col = colors[2], font = 2, padj = -5.5, at = 0.58, cex = 0.8) mtext("std dev of distance dispersed", side=2, padj = -6, cex=1) # Overlay standardized beetles lines(x-0.15, DM_int_means_rr_sd[c(3,1)], lwd = 1.2, col = colors[3], lty = 2) lines(x-0.2, DM_int_means_rr_sd[c(4,2)], lwd = 1.2, col = colors[4]) points(x-0.15, DM_int_means_rr_sd[c(3,1)], cex = 2, col = colors[3], pch = 16) points(x-0.2, DM_int_means_rr_sd[c(4,2)], cex = 2, col = colors[4], pch = 16) arrows(x-0.15, DM_int_lower_rr_sd[c(3,1)], x-0.15, DM_int_upper_rr_sd[c(3,1)], col = colors[3], code = 3, angle = 90, length = 0.1,lwd = 1.5) arrows(x-0.2, DM_int_lower_rr_sd[c(4,2)], x-0.2, DM_int_upper_rr_sd[c(4,2)], col = colors[4], code = 3, angle = 90, length = 0.1,lwd = 1.5) points(x-0.2, DM_int_means_rr_sd[c(4,2)], col = "white", cex = 1.5, pch = 16) points(x-0.15, DM_int_means_rr_sd[c(3,1)], col = "white", cex = 1.5, pch = 16) # Continue with experimental beetles lines(x, DM_int_means_sd[c(3,1)], lwd = 1.5, col = colors[1], lty = 2) points(x-0.05, DM_int_means_sd[c(4,2)], pch = 16, col = colors[2], cex = 2) lines(x-0.05, DM_int_means_sd[c(4,2)], lwd = 1.5, col = colors[2], lty=1) arrows(x, DM_int_lower_sd[c(3,1)], x, DM_int_upper_sd[c(3,1)], col = colors[1], code = 3, angle = 90, length = 0.1,lwd = 1.5) arrows(x-0.05, DM_int_lower_sd[c(4,2)], x-0.05, DM_int_upper_sd[c(4,2)], col = colors[2], code = 3, angle = 90, length = 0.1,lwd = 1.5) points(x-0.05, DM_int_means_sd[c(4,2)], col = "white", cex = 1.5, pch = 16) points(x, DM_int_means_sd[c(3,1)], col = "white", cex = 1.5, pch = 16) text(1.6, 1.05, "high current density", col = colors[4], srt = 11) text(1.6, 0.62, "low current density", col = colors[3], srt = -3) text(expression('p'['D'%*%'J']== 0.091), x = 1.025, y = 0.4025) text('A', font = 2, x = 0.875, y = 1.27, cex = 1.5) # Second panel: dispersal density by juvenile density interaction MAX par(mar = c(5,5,1,2), fig = c(0, 1, 0, 0.534), cex = 1, new = TRUE) plot(x, DM_int_means_max[c(3,1)], ylim = c(1,4), col = colors[1], pch = 16, xlim = c(0.85, 2.35), xaxt = "n", xlab = "", ylab = "", yaxt = "n", cex = 2) axis(side = 1, at = c(0,1.1,2.1,3), labels = FALSE) axis(side = 2, at = seq(-0.5,4,1), labels = TRUE, las = 1, tick = TRUE) mtext(side = 1, at = c(1.1,2.1), c("low", "high"), padj=1) mtext(side = 1, at = 1.6, "juvenile density", padj = 3, cex=1.25) # Axis labels mtext("( and standardized individuals)", side=2, padj = -5.5, cex = 0.8) mtext("experimental", side=2, col = colors[2], font = 2, padj = -5.5, at = 1.50, cex = 0.8) mtext("max distance dispersed", side=2, padj = -6, cex=1) # Overlay standardized beetles lines(x-0.15, DM_int_means_rr_max[c(3,1)], lwd = 1.2, col = colors[3], lty = 2) lines(x-0.2, DM_int_means_rr_max[c(4,2)], lwd = 1.2, col = colors[4]) points(x-0.15, DM_int_means_rr_max[c(3,1)], cex = 2, col = colors[3], pch = 16) points(x-0.2, DM_int_means_rr_max[c(4,2)], cex = 2, col = colors[4], pch = 16) arrows(x-0.15, DM_int_lower_rr_max[c(3,1)], x-0.15, DM_int_upper_rr_max[c(3,1)], col = colors[3], code = 3, angle = 90, length = 0.1,lwd = 1.5) arrows(x-0.2, DM_int_lower_rr_max[c(4,2)], x-0.2, DM_int_upper_rr_max[c(4,2)], col = colors[4], code = 3, angle = 90, length = 0.1,lwd = 1.5) points(x-0.15, DM_int_means_rr_max[c(3,1)], col = "white", cex = 1.5, pch = 16) points(x-0.2, DM_int_means_rr_max[c(4,2)], col = "white", cex = 1.5, pch = 16) # Back to experimental beetles lines(x, DM_int_means_max[c(3,1)], lwd = 1.2, col = colors[1], lty = 2) points(x-0.05, DM_int_means_max[c(4,2)], pch = 16, col = colors[2], cex = 2) lines(x-0.05, DM_int_means_max[c(4,2)], lwd = 1.2, col = colors[2], lty=1) arrows(x, DM_int_lower_max[c(3,1)], x, DM_int_upper_max[c(3,1)], col = colors[1], code = 3, angle = 90, length = 0.1) arrows(x-0.05, DM_int_lower_max[c(4,2)], x-0.05, DM_int_upper_max[c(4,2)], col = colors[2], code = 3, angle = 90, length = 0.1) points(x-0.05, DM_int_means_max[c(4,2)], col = "white", cex = 1.5, pch = 16) points(x, DM_int_means_max[c(3,1)], col = "white", cex = 1.5, pch = 16) text(1.6, 3.15, "high current density", srt = 9, col = colors[4]) text(1.6, 1.7, "low current density", srt = -3, col = colors[3]) text(expression('p'['D'%*%'J']== 0.047), x = 1.025, y = 1.05) text('B', font = 2, x = 0.875, y = 3.85, cex = 1.5) dev.off()