# This set directory will need to be updated for where you store the files setwd("/Users/mmgdepartment/Dropbox/Avida-ED/Publications in progress/EEO Curriculum manuscript (JS lead)/LB145 F14 Data from Exercises 1-3") # Here we read these data files into R. data.exercise.1.pos <- read.table(file="Ex.1.pos.csv", sep=",", header=T) data.exercise.1.muts <- read.table(file="Ex.1.muts.csv", sep=",", header=T) data.exercise.2 <- read.table(file="Ex.2.32.csv", sep=",", header=T) data.exercise.3 <- read.table(file="Ex.3.csv", sep=",", header=T) data.fig.4 <- read.table(file="Data.Fig.4.csv", sep=",", header=T) data.probit <- read.table(file="Scored.Data.For.Probit.csv", sep=",", header=T) data.affect.fall <- read.table(file="Affect.Fall.csv", sep=",", header=T) data.affect.spring <- read.table(file="Affect.Spring.csv", sep=",", header=T) # Do the number of mutations differ from the expected value of 5? t.test(x=data.exercise.1.muts, mu=5, alternative=c("two.sided")) # No, they don't. # Figure 1A: Histogram of observed mutations graphics.off() pdf(file="Figure.1.A.pdf", width=6.9, height=4.6) par(mfrow=c(1,1), oma=c(3,3, 1.5, 1.5), bty="n", xpd=NA, mar=c(3, 3, 1, 1)) hist(data.exercise.1.muts$Number.of.mutations, breaks=c(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13), xlim=c(0, 13), ylim=c(0,30), axes=F, xlab="", ylab="", main="", col="lightskyblue") axis(2, at=c(0, 30), labels=c("", ""), lwd.ticks=0, pos=0) axis(1, at=c(0, 13), labels=c("", ""), lwd.ticks=0, pos=0) axis(1, at=c(0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5), labels=c("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13"), pos=0.0) axis(2, at=c(0, 5, 10, 15, 20, 25, 30), labels=c("0", "5", "10", "15", "20", "25", "30"), las=2, pos=0) mtext("Number of Mutations", side=1, outer=TRUE, cex=1.2) mtext("Frequency", side=2, outer=TRUE, cex=1.2) dev.off() # Figure 1B: Where are the observed mutations in the genome? graphics.off() pdf(file="Figure.1.B.pdf", width=6.9, height=4.6) par(mfrow=c(1,1), oma=c(3,3, 1.5, 1.5), bty="n", xpd=NA, mar=c(3, 3, 1, 1)) barplot(height=data.exercise.1.pos$Number.of.mutations, xlim=c(1, 50), ylim=c(0, 20), xlab="Position in the Avidian Genome", ylab="Number of mutations", axes=F, width=0.8, space=0.25, col="lightskyblue") axis(2, at=c(0, 20), labels=c("", ""), lwd.ticks=0, pos=0) axis(1, at=c(0, 4.6, 9.6, 14.6, 19.6, 24.6, 29.6, 34.6, 39.6, 44.6, 49.6), labels=c("0", "5", "10", "15", "20", "25", "30", "35", "40", "45", "50"), pos=0.0) axis(2, at=c(0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20), labels=c("0", "2", "4", "6", "8", "10", "12", "14", "16", "18", "20"), las=2, pos=0) mtext("Position in the Avidian Genome", side=1, outer=TRUE, cex=1.2) mtext("Number of Mutations", side=2, outer=TRUE, cex=1.2) dev.off() # Now we graph the proportions of organisms performing the task both when it is and is # not being rewarded. Some of the values are impossible, due to students misreporting the # data; we report what the students told us, and accept that this includes error. student.names <- c("", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "") Proportion.no <- t(data.exercise.2$Proportion.Task.No.Reward) Proportion.yes <-t(data.exercise.2$Proportion.Task.Reward) combined.for.fig.2 <- rbind(Proportion.no, Proportion.yes) rownames(combined.for.fig.2) <- c("No reward", "Reward") colnames(combined.for.fig.2) <- t(data.exercise.2$Student.Number) graphics.off() pdf(file="Figure.2.pdf", width=6.9, height=4.6) par(mfrow=c(1,1), oma=c(3,3, 1.5, 1.5), bty="n", xpd=NA, mar=c(3, 3, 1, 1)) barplot(combined.for.fig.2, beside=T, col=c("lightskyblue", "darkred"), width=0.4, xlim=c(1, 40), ylim=c(0, 1.3), ylab="", xlab="", axes=F, names.arg=student.names, legend.text=T, args.legend=list(x=32.5, y=1.3, bty="y")) axis(2, at=c(0, 1.2), labels=c("", ""), lwd.ticks=0, pos=0) axis(1, at=c(0, 40), labels=c("", ""), lwd.ticks=0, pos=0) axis(1, at=c(2, 4.4, 6.8, 9.2, 11.6, 14, 16.4, 18.8, 21.2, 23.6, 26, 28.4, 31, 33.4, 35.8, 38.2), labels=c("2", "4", "6", "8", "10", "12", "14", "16", "18", "20", "22", "24", "26", "28", "30", "32"), las=2, pos=0) axis(2, at=c(0, 0.2, 0.4, 0.6, 0.8, 1.0, 1.2), labels=c("0.0", "0.2", "0.4", "0.6", "0.8", "1.0", "1.2"), las=2, pos=0) mtext("Student", side=1, outer=TRUE, cex=1.2) mtext("Proportion of population performing task", side=2, outer=TRUE, cex=1.2) dev.off() # Figure 3: Time of task evolution based on whether or not the task is rewarded pair.names<-c("", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "") data.no <- subset(data.exercise.3, Reward=="No") data.yes <- subset(data.exercise.3, Reward=="Yes") Updates.no <- t(data.no[, 2]) Updates.yes <- t(data.yes[, 2]) combined <- rbind(Updates.no, Updates.yes) rownames(combined) <- c("No reward", "Reward") colnames(combined) <- t(data.no[,1]) graphics.off() pdf(file="Figure.3.pdf", width=6.9, height=4.6) par(mfrow=c(1,1), oma=c(3,3, 1.5, 1.5), bty="n", xpd=NA, mar=c(3, 3, 1, 1)) barplot(combined, beside=T, legend.text=T, col=c("lightskyblue", "darkred"), width=0.4, xlim=c(1, 30), ylim=c(0, 1000), ylab="", xlab="", axes=F, names.arg=pair.names, args.legend=list(x=15, y=1000, bty="y")) axis(2, at=c(0, 1000), labels=c("", ""), lwd.ticks=0, pos=0) axis(1, at=c(0, 30), labels=c("", ""), lwd.ticks=0, pos=0) axis(1, at=c(2, 4.4, 6.8, 9.2, 11.6, 14, 16.4, 18.8, 21.2, 23.6, 26, 28.4), labels=c("2", "4", "6", "8", "10", "12", "14", "16", "18", "20", "22", "24"), las=2, pos=0) axis(2, at=c(0, 200, 400, 600, 800, 1000), labels=c("0", "200", "400", "600", "800", "1,000"), las=2, pos=0) mtext("Student", side=1, outer=TRUE, cex=1.2) mtext("Update at which task first appeared", side=2, outer=TRUE, cex=1.2) dev.off() # Does the task appear at different times when rewarded versus not rewarded? reorganized.combined <- t(combined) colnames(reorganized.combined) <- c("No", "Yes") reorganized.combined <- as.data.frame(reorganized.combined) reorganized.combined$Difference <- reorganized.combined$No - reorganized.combined$Yes Rewarded.early <- subset(reorganized.combined, Difference >0) Rewarded.late <- subset(reorganized.combined, Difference <0) Number.early <- length(Rewarded.early$Difference) Number.late <- length(Rewarded.late$Difference) binom.test(x=Number.early, n=Number.early+Number.late, alternative=c("two.sided")) # No, it does not. # Now I'm going to ignore doing this as a probit analysis and see if I can directly replicate # Wendy's stats. DNA.or.gene <- matrix(nrow=length(data.probit$Student), ncol=1) for (i in 1:length(data.probit$Student)) { current.DNA <- data.probit$DNA[i] current.allele <- data.probit$allele[i] if (current.DNA == 1) { output.value <- 1} else if(current.allele == 1) { output.value <- 1} else output.value <-0 DNA.or.gene[i] <- output.value } data.for.fig.4 <- matrix(nrow=length(data.probit$Student), ncol=9) data.for.fig.4[,1] <- as.numeric(as.character(data.probit$Student)) data.for.fig.4[,2] <- as.character(data.probit$Treatment) data.for.fig.4[,3] <- as.numeric(as.character(data.probit$mutation)) data.for.fig.4[,4] <- as.numeric(as.character(data.probit$random)) data.for.fig.4[,5] <- as.numeric(as.character(data.probit$DNA)) data.for.fig.4[,6] <- as.numeric(as.character(data.probit$Reproduction)) data.for.fig.4[,7] <- as.numeric(as.character(data.probit$Pass.on.gene.trait)) data.for.fig.4[,8] <- as.numeric(as.character(data.probit$selection)) data.for.fig.4[,9] <- as.numeric(as.character(data.probit$directed)) data.for.fig.4<-as.data.frame(data.for.fig.4) colnames(data.for.fig.4) <- c("Student", "Treatment", "Mutation", "Random", "DNA", "Reproduction", "Pass.on.gene", "Selection", "Intentionality") for (i in 1:length(data.for.fig.4$Student)) { current.mut <- data.probit$mutation[i] current.random <- data.probit$random[i] current.repro <- data.probit$Reproduction[i] current.pass <- data.probit$Pass.on.gene.trait[i] if (current.repro == 1) { total.repro <- 1} else if(current.pass == 1) { total.repro <- 1} else total.repro <-0 if (current.mut == 1) { total.DNA <- 1} else if(current.random == 1) { total.DNA <- 1} else total.DNA <-0 data.for.fig.4$Mutation[i] <- total.DNA data.for.fig.4$Reproduction[i] <- total.repro } summary(data.for.fig.4) # Figure 4: Comparing responses from students with Avida-ED to those without. fig.4.with<-subset(data.for.fig.4, Treatment=="With") fig.4.without<-subset(data.for.fig.4, Treatment=="Without") fig.4.graphing <- matrix(nrow=2, ncol=7) fig.4.graphing[2,1] <- summary(fig.4.with$Mutation)[2]*100/length(fig.4.with$Student) fig.4.graphing[2,2] <- summary(fig.4.with$Random)[2]*100/length(fig.4.with$Student) fig.4.graphing[2,3] <- summary(fig.4.with$DNA)[2]*100/length(fig.4.with$Student) fig.4.graphing[2,4] <- summary(fig.4.with$Reproduction)[2]*100/length(fig.4.with$Student) fig.4.graphing[2,5] <- summary(fig.4.with$Pass.on.gene)[2]*100/length(fig.4.with$Student) fig.4.graphing[2,6] <- summary(fig.4.with$Selection)[2]*100/length(fig.4.with$Student) fig.4.graphing[2,7] <- summary(fig.4.with$Intentionality)[2]*100/length(fig.4.with$Student) fig.4.graphing[1,1] <- summary(fig.4.without$Mutation)[2]*100/length(fig.4.without$Student) fig.4.graphing[1,2] <- summary(fig.4.without$Random)[2]*100/length(fig.4.without$Student) fig.4.graphing[1,3] <- summary(fig.4.without$DNA)[2]*100/length(fig.4.without$Student) fig.4.graphing[1,4] <- summary(fig.4.without$Reproduction)[2]*100/length(fig.4.without$Student) fig.4.graphing[1,5] <- summary(fig.4.without$Pass.on.gene)[2]*100/length(fig.4.without$Student) fig.4.graphing[1,6] <- summary(fig.4.without$Selection)[2]*100/length(fig.4.without$Student) fig.4.graphing[1,7] <- summary(fig.4.without$Intentionality)[2]*100/length(fig.4.without$Student) rownames(fig.4.graphing) <- c ("Without Avida-ED", "With Avida-ED") # Now we run analyses on contingency tables to determine effect sizes. # First, assemble all the contingency tables table.Mutation <- matrix(c(summary(fig.4.without$Mutation)[2],summary(fig.4.without$Mutation)[1],summary(fig.4.with$Mutation)[2],summary(fig.4.with$Mutation)[1]),nrow=2, byrow=T) table.Random <- matrix(c(summary(fig.4.without$Random)[2],summary(fig.4.without$Random)[1],summary(fig.4.with$Random)[2],summary(fig.4.with$Random)[1]),nrow=2, byrow=T) table.DNA <- matrix(c(summary(fig.4.without$DNA)[2],summary(fig.4.without$DNA)[1],summary(fig.4.with$DNA)[2],summary(fig.4.with$DNA)[1]),nrow=2, byrow=T) table.Reproduction <- matrix(c(summary(fig.4.without$Reproduction)[2],summary(fig.4.without$Reproduction)[1],summary(fig.4.with$Reproduction)[2],summary(fig.4.with$Reproduction)[1]),nrow=2, byrow=T) table.Pass <- matrix(c(summary(fig.4.without$Pass.on.gene)[2],summary(fig.4.without$Pass.on.gene)[1],summary(fig.4.with$Pass.on.gene)[2],summary(fig.4.with$Pass.on.gene)[1]),nrow=2, byrow=T) table.Selection <- matrix(c(summary(fig.4.without$Selection)[2],summary(fig.4.without$Selection)[1],summary(fig.4.with$Selection)[2],summary(fig.4.with$Selection)[1]),nrow=2, byrow=T) table.Intentionality <- matrix(c(summary(fig.4.without$Intentionality)[2],summary(fig.4.without$Intentionality)[1],summary(fig.4.with$Intentionality)[2],summary(fig.4.with$Intentionality)[1]),nrow=2, byrow=T) rownames(table.Mutation) <- c("Without", "With") rownames(table.Random) <- c("Without", "With") rownames(table.DNA) <- c("Without", "With") rownames(table.Reproduction) <- c("Without", "With") rownames(table.Pass) <- c("Without", "With") rownames(table.Selection) <- c("Without", "With") rownames(table.Intentionality) <- c("Without", "With") colnames(table.Mutation) <- c("Yes", "No") colnames(table.Random) <- c("Yes", "No") colnames(table.DNA) <- c("Yes", "No") colnames(table.Reproduction) <- c("Yes", "No") colnames(table.Pass) <- c("Yes", "No") colnames(table.Selection) <- c("Yes", "No") colnames(table.Intentionality) <- c("Yes", "No") Mutation.test <- prop.test(table.Mutation) Random.test <- prop.test(table.Random) DNA.test <- prop.test(table.DNA) Reproduction.test <- prop.test(table.Reproduction) Pass.test <- prop.test(table.Pass) Selection.test <- prop.test(table.Selection) Intentionality.test <- prop.test(table.Intentionality) stats.table.fig.4 <- matrix(nrow=7, ncol=2) rownames(stats.table.fig.4) <- c("Mutation", "Random", "DNA", "Reproduction", "Pass", "Selection", "Intentionality") colnames(stats.table.fig.4) <- c("Chi.sq.p", "Odds.ratio") stats.table.fig.4[1,1] <- as.numeric(as.character(Mutation.test[3])) stats.table.fig.4[2,1] <- as.numeric(as.character(Random.test[3])) stats.table.fig.4[3,1] <- as.numeric(as.character(DNA.test[3])) stats.table.fig.4[4,1] <- as.numeric(as.character(Reproduction.test[3])) stats.table.fig.4[5,1] <- as.numeric(as.character(Pass.test[3])) stats.table.fig.4[6,1] <- as.numeric(as.character(Selection.test[3])) stats.table.fig.4[7,1] <- as.numeric(as.character(Intentionality.test[3])) Mutation.odds <- Mutation.test$estimate / (1 - Mutation.test$estimate) Random.odds <- Random.test$estimate / (1 - Random.test$estimate) DNA.odds <- DNA.test$estimate / (1 - DNA.test$estimate) Reproduction.odds <- Reproduction.test$estimate / (1 - Reproduction.test$estimate) Pass.odds <- Pass.test$estimate / (1 - Pass.test$estimate) Selection.odds <- Selection.test$estimate / (1 - Selection.test$estimate) Intentionality.odds <- Intentionality.test$estimate / (1 - Intentionality.test$estimate) stats.table.fig.4[1,2] <- as.numeric(as.character(Mutation.odds[2]/Mutation.odds[1])) stats.table.fig.4[2,2] <- as.numeric(as.character(Random.odds[2]/Random.odds[1])) stats.table.fig.4[3,2] <- as.numeric(as.character(DNA.odds[2]/DNA.odds[1])) stats.table.fig.4[4,2] <- as.numeric(as.character(Reproduction.odds[2]/Reproduction.odds[1])) stats.table.fig.4[5,2] <- as.numeric(as.character(Pass.odds[2]/Pass.odds[1])) stats.table.fig.4[6,2] <- as.numeric(as.character(Selection.odds[2]/Selection.odds[1])) stats.table.fig.4[7,2] <- as.numeric(as.character(Intentionality.odds[2]/Intentionality.odds[1])) fig.4.names <- c("", "", "", "", "", "", "") graphics.off() pdf(file="Figure.4.pdf", width=9, height=6) par(mfrow=c(1,1), oma=c(7, 5, 3, 3), bty="n", xpd=NA, mar=c(5, 5, 1, 1)) #fig.4.names <- c("Mutation total", "Random mutation", "DNA or gene", "Reproduction total", "Pass on gene or trait", "Selection", "Intentionality or teleology") barplot(fig.4.graphing, beside=T, legend.text=T, col=c("darkred", "lightskyblue"), width=0.4, xlim=c(1, 8.5), ylim=c(0, 100), ylab="", xlab="", axes=F, names.arg=fig.4.names, args.legend=list(x=7.5, y=100, bty="y")) text(labels="**", x=2, y=45) text(labels="*", x=3.2, y=55) text(labels="**", x=8, y=40) text(labels="Effect \n size \n large", x=2, y=60) text(labels="Effect \n size \n small", x=3.2, y=70) text(labels="Effect \n size \n medium", x=8, y=60) axis(2, at=c(0, 100), labels=c("", ""), lwd.ticks=0, pos=0) axis(1, at=c(0, 8), labels=c("", ""), lwd.ticks=0, pos=0) axis(1, at=c(0.8, 2, 3.2, 4.4, 5.6, 6.8, 8), labels=c("Mutation \ntotal", "Random \nmutation", "DNA or \ngene", "Reproduction \ntotal", "Pass on \ngene/trait", "Selection", "Intentionality \nor teleology"), las=2, pos=0) axis(2, at=c(0, 20, 40, 60, 80, 100), labels=c("0", "20", "40", "60", "80", "100"), las=2, pos=0) mtext("Answer contains term", side=1, outer=TRUE, cex=1.2, line=1.5) mtext("Percentage of students", side=2, outer=TRUE, cex=1.2, line=1.5) dev.off() # Figure 5 is a screen shot from EvoGrader; no need to replicate it here. # Figure 6 compares student affect responses in the Fall and Spring classes. summary(data.affect.fall) # 0 of 38 Hate It # 2 of 38 Don't Like It # 13 of 38 It's Okay # 20 of 38 Like It # 3 of 38 Love It. summary(data.affect.spring) # 17 of 90 Hate It # 27 of 90 Don't Like It # 29 of 90 It's OK # 16 of 90 Like It # 1 of 90 Love It # (2 students, labeled 1.5, circled the line between Hate It and Don't Like It. Because # there were 2 such responses, we counted them as 1 each of Hate It and Don't Like It) # Now we turn those into percentages in a matrix. affect.matrix <- matrix(nrow=2, ncol=5) affect.matrix[1, 1] <- (17/90)*100 affect.matrix[1, 2] <- (27/90)*100 affect.matrix[1, 3] <- (29/90)*100 affect.matrix[1, 4] <- (16/90)*100 affect.matrix[1, 5] <- (1/90)*100 affect.matrix[2, 1] <- (0/38)*100 affect.matrix[2, 2] <- (2/38)*100 affect.matrix[2, 3] <- (13/38)*100 affect.matrix[2, 4] <- (20/38)*100 affect.matrix[2, 5] <- (3/38)*100 colnames(affect.matrix) <- c("Hate It", "Don't Like It", "It's Okay", "Like It", "Love It") rownames(affect.matrix) <- c("LB145 S14", "LB145 F14") category.names <- c("Hate It", "Don't Like It", "It's Okay", "Like It", "Love It") graphics.off() pdf(file="Figure.6.pdf", width=6.9, height=4.6) par(mfrow=c(1,1), oma=c(3, 3, 3, 3), bty="n", xpd=NA, mar=c(3, 3, 1, 1)) barplot(affect.matrix, beside=T, legend.text=T, col=c("darkred", "lightskyblue"), width=0.4, xlim=c(1, 6), ylim=c(0, 60), ylab="", xlab="", axes=F, names.arg=category.names, args.legend=list(x=3, y=60, bty="y")) axis(2, at=c(0, 60), labels=c("", ""), lwd.ticks=0, pos=0.33) axis(1, at=c(.33, 6), labels=c("", ""), lwd.ticks=0, pos=0) axis(2, at=c(0, 10, 20, 30, 40, 50, 60), labels=c("0", "10", "20", "30", "40", "50", "60"), las=2, pos=0.33) mtext("Student Affective Response", side=1, outer=TRUE, cex=1.2) mtext("Percentage of Students", side=2, outer=TRUE, cex=1.2, line=1.5) dev.off()