#################################################### ###File S2: Model Analyses for Duveau et al. 2014### #################################################### #1. Packages #2. Data #3. Functions #4. Power Analysis #5. Fisher's Exact Test vs G-test #6. False Positive Rate #7. Deterministic Allele Frequencies ################# ###1. Packages### ################# library(nleqslv) library(Rsolnp) library(RColorBrewer) ############# ###2. Data### ############# #YFP expression from Metzger and Yuan et al. 2014 (in prep) #Used to convert between expression as percentage and expression as standard deviation WT <- c(0.853788726,0.020919973) names(WT) <- c("YFP","sd") NEG <- c(0.576945829,0.063310097) names(NEG) <- c("YFP","sd") ################## ###3. Functions### ################## #Determine phenotypic cutoff numerically quantile.minimize <- function(QUANTILE, CUTOFF = CUTOFF, MU = MU, SIGMA = SIGMA, MUTANT.FREQ = MUTANT.FREQ) { ((1-MUTANT.FREQ)*pnorm(qnorm(QUANTILE,MU,SIGMA),0,1) + MUTANT.FREQ*QUANTILE - CUTOFF)^2 } #Determine frequences from relative abundances overlap <- function(THRESHOLD = z.score.cutoff, MU = mutant.mean, SIGMA = mutant.variance, LOWER.TAIL = which.tail, MUTANT.FREQ = mutant.frequency.overall) { OVERLAP <- (MUTANT.FREQ*pnorm(THRESHOLD,MU,SIGMA,LOWER.TAIL))/((1-MUTANT.FREQ)*pnorm(THRESHOLD,0,1,LOWER.TAIL)) FREQUENCY <- OVERLAP/(1 + OVERLAP) return(FREQUENCY) } #Perform power analysis Power <- function(ALPHA = ALPHA, BETA = BETA, CUTOFF = CUTOFF, MU = MU, SIGMA = SIGMA, POPULATION = POPULATION, SELECTION = SELECTION, GENERATION = GENERATION, TEST = TEST) { I <- 1:10000 POWER <- vector(mode = "numeric",length = length(I)) THETA.LOW <- vector(mode = "numeric",length = length(I)) THETA.HIGH <- vector(mode = "numeric",length = length(I)) MUTANT.HIGH <- vector(mode = "numeric",length = length(I)) WT.HIGH <- vector(mode = "numeric",length = length(I)) MUTANT.LOW <- vector(mode = "numeric",length = length(I)) WT.LOW <- vector(mode = "numeric",length = length(I)) QUANTILES.START.LOW <- CUTOFF QUANTILES.START.HIGH <- 1-CUTOFF MUTANT.FITNESS <- (1-SELECTION)^(GENERATION/2) MUTANT.FREQ <- (0.5*MUTANT.FITNESS)/(0.5*MUTANT.FITNESS + 0.5*1) QUANTILES.LOW <- solnp(QUANTILES.START.LOW, fun = quantile.minimize, LB = 10^-20, UB = 1 - 10^-20, MU = MU, SIGMA = SIGMA, MUTANT.FREQ = MUTANT.FREQ, CUTOFF = CUTOFF, control = list(trace = 0))$pars QUANTILES.HIGH <- solnp(QUANTILES.START.HIGH, fun = quantile.minimize, LB = 10^-20, UB = 1 - 10^-20, MU = MU, SIGMA = SIGMA, MUTANT.FREQ = MUTANT.FREQ, CUTOFF = 1 - CUTOFF, control = list(trace = 0))$pars THRESHOLD.LOW <- qnorm(QUANTILES.LOW, MU, SIGMA) THRESHOLD.HIGH <- qnorm(QUANTILES.HIGH, MU, SIGMA) LOW.MUTANT.FREQ.EXPECTED <- overlap(THRESHOLD = THRESHOLD.LOW, MU = MU, SIGMA = SIGMA, MUTANT.FREQ = MUTANT.FREQ, LOWER.TAIL = TRUE) HIGH.MUTANT.FREQ.EXPECTED <- overlap(THRESHOLD = THRESHOLD.HIGH, MU = MU, SIGMA = SIGMA, MUTANT.FREQ = MUTANT.FREQ, LOWER.TAIL = FALSE) LOW.MUTANT.FREQ.GROWTH <- (LOW.MUTANT.FREQ.EXPECTED*MUTANT.FITNESS)/(LOW.MUTANT.FREQ.EXPECTED*MUTANT.FITNESS + (1-LOW.MUTANT.FREQ.EXPECTED)*1) HIGH.MUTANT.FREQ.GROWTH <- (HIGH.MUTANT.FREQ.EXPECTED*MUTANT.FITNESS)/(HIGH.MUTANT.FREQ.EXPECTED*MUTANT.FITNESS + (1-HIGH.MUTANT.FREQ.EXPECTED)*1) POP.SIZE <- POPULATION*CUTOFF for(i in I) { LOW.MUTANT.FREQ <- rbinom(1, POP.SIZE, LOW.MUTANT.FREQ.GROWTH)/POP.SIZE HIGH.MUTANT.FREQ <- rbinom(1, POP.SIZE, HIGH.MUTANT.FREQ.GROWTH)/POP.SIZE LOW.COVERAGE <- rnbinom(1, size = ALPHA, prob = BETA/(1 + BETA)) HIGH.COVERAGE <- rnbinom(1, size = ALPHA, prob = BETA/(1 + BETA)) MUTANT.LOW[i] <- rbinom(1,LOW.COVERAGE,LOW.MUTANT.FREQ) WT.LOW[i] <- LOW.COVERAGE - MUTANT.LOW[i] MUTANT.HIGH[i] <- rbinom(1,HIGH.COVERAGE,HIGH.MUTANT.FREQ) WT.HIGH[i] <- HIGH.COVERAGE - MUTANT.HIGH[i] THETA.LOW[i] <- MUTANT.LOW[i]/(WT.LOW[i] + MUTANT.LOW[i] + 1) THETA.HIGH[i] <- MUTANT.HIGH[i]/(WT.HIGH[i] + MUTANT.HIGH[i] + 1) matrix <- matrix(c(MUTANT.LOW[i],WT.LOW[i],MUTANT.HIGH[i],WT.HIGH[i]), nrow = 2) if(TEST == "F") { POWER[i] <- fisher.test(matrix, alternative = "less")$p.value < 0.001 }else if(TEST == "G") { matrix <- matrix + 0.5 if(sum(matrix) == 0) { POWER[i] <- 1 }else { row.sum <- apply(matrix,1,sum) col.sum <- apply(matrix,2,sum) n = sum(matrix) EXPECTED <- (row.sum %o% col.sum)/n G.STAT <- 2*sum(matrix*log(matrix/EXPECTED)) POWER[i] <- pchisq(G.STAT, df=1, lower.tail=FALSE) < 0.001 } } } return(list(Power = POWER, Mutant.High = MUTANT.HIGH, WT.High = WT.HIGH, Mutant.Low = MUTANT.LOW, WT.Low = WT.LOW)) } #Transform data in SD to data in percentage convert.mu.to.percent <- function(MU) { PERCENT <- (MU*WT[2] + WT[1] - NEG[1])/(WT[1] - NEG[1]) - 1 return(PERCENT) } #Transform data in percentage to data in SD convert.percent.to.mu <- function(PERCENT) { MU <- ((PERCENT + 1)*(WT[1] - NEG[1]) - WT[1] + NEG[1])/(WT[2]) return(MU) } ####################### ###4. Power Anlaysis### ####################### #Parameters and values tested ALPHA <- 80 MU.test <- c(convert.percent.to.mu(seq(0,.15,.01)),convert.percent.to.mu(c(0.2,0.25))) SIGMA.test <- c(0.25,0.5,0.75,1,1.25,1.5,2,3) CUTOFF.test <- c(0.5,0.1,0.05,0.01) BETA.test <- c(0.16,0.32,0.8,1.6,3.2,8) POPULATION.test <- c(10^7,10^5,10^3,10^2) SELECTION.test <- c(-.01,0,0.01,0.03,0.07,0.1,0.15,0.2) GENERATION.test <- c(10,20,50) COLOR <- rainbow(8) ###PLOT I #X-axis MU #Y-axis POWER #Lines SIGMA #Get set of parameters to test try <- expand.grid(MU.test,SIGMA.test,CUTOFF.test[3],BETA.test[3],POPULATION.test[1],SELECTION.test[4],GENERATION.test[2]) K <- 1:nrow(try) power <- numeric(length(K)) diff <- matrix(0, nrow = length(K), ncol = 2) #Determine power for each set of parameters for(k in K) { x <- Power(ALPHA = 80, MU = try[k,1], SIGMA = try[k,2], CUTOFF = try[k,3], BETA = try[k,4], POPULATION = try[k,5], SELECTION = try[k,6], GENERATION = try[k,7], TEST="G") diff[k,1] <- quantile(x$Mutant.High/(x$Mutant.High + x$WT.High + 1) - x$Mutant.Low/(x$Mutant.Low + x$WT.Low + 1),0.025) diff[k,2] <- quantile(x$Mutant.High/(x$Mutant.High + x$WT.High + 1) - x$Mutant.Low/(x$Mutant.Low + x$WT.Low + 1),0.975) power[k] <- mean(x$Power) } total <- cbind(try,power,diff) colnames(total) <- c("MU","SIGMA","CUTOFF","BETA","POPULATION","SELECTION","GENERATION","POWER","5%LB","5%UB") #Pull out subsets that will correspond to lines MU.SIGMA <- total SIGMA.LEVEL.1 <- subset(MU.SIGMA, MU.SIGMA$SIGMA == SIGMA.test[1]) SIGMA.LEVEL.2 <- subset(MU.SIGMA, MU.SIGMA$SIGMA == SIGMA.test[2]) SIGMA.LEVEL.3 <- subset(MU.SIGMA, MU.SIGMA$SIGMA == SIGMA.test[3]) SIGMA.LEVEL.4 <- subset(MU.SIGMA, MU.SIGMA$SIGMA == SIGMA.test[4]) SIGMA.LEVEL.5 <- subset(MU.SIGMA, MU.SIGMA$SIGMA == SIGMA.test[5]) SIGMA.LEVEL.6 <- subset(MU.SIGMA, MU.SIGMA$SIGMA == SIGMA.test[6]) SIGMA.LEVEL.7 <- subset(MU.SIGMA, MU.SIGMA$SIGMA == SIGMA.test[7]) SIGMA.LEVEL.8 <- subset(MU.SIGMA, MU.SIGMA$SIGMA == SIGMA.test[8]) #Plot results plot( convert.mu.to.percent(SIGMA.LEVEL.1$MU),SIGMA.LEVEL.1$POWER, typ = "l", col = COLOR[1], lwd = 2, ylim = c(0,1), xlab = "Mean Effect (%)", ylab = "Power") points(convert.mu.to.percent(SIGMA.LEVEL.2$MU),SIGMA.LEVEL.2$POWER, typ = "l", col = COLOR[2], lwd = 2) points(convert.mu.to.percent(SIGMA.LEVEL.3$MU),SIGMA.LEVEL.3$POWER, typ = "l", col = COLOR[3], lwd = 2) points(convert.mu.to.percent(SIGMA.LEVEL.4$MU),SIGMA.LEVEL.4$POWER, typ = "l", col = COLOR[4], lwd = 2) points(convert.mu.to.percent(SIGMA.LEVEL.5$MU),SIGMA.LEVEL.5$POWER, typ = "l", col = COLOR[5], lwd = 2) points(convert.mu.to.percent(SIGMA.LEVEL.6$MU),SIGMA.LEVEL.6$POWER, typ = "l", col = COLOR[6], lwd = 2) points(convert.mu.to.percent(SIGMA.LEVEL.7$MU),SIGMA.LEVEL.7$POWER, typ = "l", col = COLOR[7], lwd = 2) points(convert.mu.to.percent(SIGMA.LEVEL.8$MU),SIGMA.LEVEL.8$POWER, typ = "l", col = COLOR[8], lwd = 2) abline(h = 0.9, lty = 2) legend(0.2, 0.4, legend = SIGMA.test, fill = COLOR, title = "Mutant Variance") rect(xleft = 0.01, xright=0.11, ybottom=0, ytop=1, col = "#88888844", border = "#88888844") #PLOT II #X-axis MU #Y-axis POWER #Lines POPULATION try <- expand.grid(MU.test,SIGMA.test[4],CUTOFF.test[3],BETA.test[3],POPULATION.test,SELECTION.test[4],GENERATION.test[2]) K <- 1:nrow(try) power <- numeric(length(K)) diff <- matrix(0, nrow = length(K), ncol = 2) for(k in K) { x <- Power(ALPHA = 80, MU = try[k,1], SIGMA = try[k,2], CUTOFF = try[k,3], BETA = try[k,4], POPULATION = try[k,5], SELECTION = try[k,6], GENERATION = try[k,7], TEST="G") diff[k,1] <- quantile(x$Mutant.High/(x$Mutant.High + x$WT.High + 1) - x$Mutant.Low/(x$Mutant.Low + x$WT.Low + 1),0.025) diff[k,2] <- quantile(x$Mutant.High/(x$Mutant.High + x$WT.High + 1) - x$Mutant.Low/(x$Mutant.Low + x$WT.Low + 1),0.975) power[k] <- mean(x$Power) } total <- cbind(try,power,diff) colnames(total) <- c("MU","SIGMA","CUTOFF","BETA","POPULATION","SELECTION","GENERATION","POWER","5%LB","5%UB") MU.POPULATION <- total POPULATION.LEVEL.1 <- subset(MU.POPULATION, MU.POPULATION$POPULATION == POPULATION.test[1]) POPULATION.LEVEL.2 <- subset(MU.POPULATION, MU.POPULATION$POPULATION == POPULATION.test[2]) POPULATION.LEVEL.3 <- subset(MU.POPULATION, MU.POPULATION$POPULATION == POPULATION.test[3]) POPULATION.LEVEL.4 <- subset(MU.POPULATION, MU.POPULATION$POPULATION == POPULATION.test[4]) plot( convert.mu.to.percent(POPULATION.LEVEL.1$MU),POPULATION.LEVEL.1$POWER, typ = "l", col = COLOR[1], lwd = 2, ylim = c(0,1), xlab = "Mean Effect", ylab = "Power") points(convert.mu.to.percent(POPULATION.LEVEL.2$MU),POPULATION.LEVEL.2$POWER, typ = "l", col = COLOR[2], lwd = 2) points(convert.mu.to.percent(POPULATION.LEVEL.3$MU),POPULATION.LEVEL.3$POWER, typ = "l", col = COLOR[3], lwd = 2) points(convert.mu.to.percent(POPULATION.LEVEL.4$MU),POPULATION.LEVEL.4$POWER, typ = "l", col = COLOR[4], lwd = 2) abline(h = 0.9, lty = 2) legend(0.2, 0.4, legend = POPULATION.test, fill = COLOR, title = "Population Size") rect(xleft = 0.01, xright=0.11, ybottom=0, ytop=1, col = "#88888844", border = "#88888844") #PLOT III #X-axis MU #Y-axis POWER #Lines COVERAGE try <- expand.grid(MU.test,SIGMA.test[4],CUTOFF.test[3],BETA.test,POPULATION.test[1],SELECTION.test[4],GENERATION.test[2]) K <- 1:nrow(try) power <- numeric(length(K)) diff <- matrix(0, nrow = length(K), ncol = 2) for(k in K) { x <- Power(ALPHA = 80, MU = try[k,1], SIGMA = try[k,2], CUTOFF = try[k,3], BETA = try[k,4], POPULATION = try[k,5], SELECTION = try[k,6], GENERATION = try[k,7], TEST="G") diff[k,1] <- quantile(x$Mutant.High/(x$Mutant.High + x$WT.High + 1) - x$Mutant.Low/(x$Mutant.Low + x$WT.Low + 1),0.025) diff[k,2] <- quantile(x$Mutant.High/(x$Mutant.High + x$WT.High + 1) - x$Mutant.Low/(x$Mutant.Low + x$WT.Low + 1),0.975) power[k] <- mean(x$Power) } total <- cbind(try,power,diff) colnames(total) <- c("MU","SIGMA","CUTOFF","BETA","POPULATION","SELECTION","GENERATION","POWER","5%LB","5%UB") MU.BETA <- total BETA.LEVEL.1 <- subset(MU.BETA, MU.BETA$BETA == BETA.test[1]) BETA.LEVEL.2 <- subset(MU.BETA, MU.BETA$BETA == BETA.test[2]) BETA.LEVEL.3 <- subset(MU.BETA, MU.BETA$BETA == BETA.test[3]) BETA.LEVEL.4 <- subset(MU.BETA, MU.BETA$BETA == BETA.test[4]) BETA.LEVEL.5 <- subset(MU.BETA, MU.BETA$BETA == BETA.test[5]) BETA.LEVEL.6 <- subset(MU.BETA, MU.BETA$BETA == BETA.test[6]) plot( convert.mu.to.percent(BETA.LEVEL.1$MU),BETA.LEVEL.1$POWER, typ = "l", col = COLOR[1], lwd = 2, ylim = c(0,1), xlab = "Mutant Effect (%)", ylab = "Power" ) points(convert.mu.to.percent(BETA.LEVEL.2$MU),BETA.LEVEL.2$POWER, typ = "l", col = COLOR[2], lwd = 2) points(convert.mu.to.percent(BETA.LEVEL.3$MU),BETA.LEVEL.3$POWER, typ = "l", col = COLOR[3], lwd = 2) points(convert.mu.to.percent(BETA.LEVEL.4$MU),BETA.LEVEL.4$POWER, typ = "l", col = COLOR[4], lwd = 2) points(convert.mu.to.percent(BETA.LEVEL.5$MU),BETA.LEVEL.5$POWER, typ = "l", col = COLOR[5], lwd = 2) points(convert.mu.to.percent(BETA.LEVEL.6$MU),BETA.LEVEL.6$POWER, typ = "l", col = COLOR[6], lwd = 2) abline(h = 0.9, lty = 2) legend(.2, 0.4, legend = ALPHA/BETA.test, fill = COLOR, title = "Average Coverage") rect(xleft = 0.01, xright=0.11, ybottom=0, ytop=1, col = "#88888844", border = "#88888844") #PLOT IV #X-axis MU #Y-axis POWER #Lines CUTOFF try <- expand.grid(MU.test,SIGMA.test[4],CUTOFF.test,BETA.test[3],POPULATION.test[1],SELECTION.test[4],GENERATION.test[2]) K <- 1:nrow(try) power <- numeric(length(K)) diff <- matrix(0, nrow = length(K), ncol = 2) for(k in K) { x <- Power(ALPHA = 80, MU = try[k,1], SIGMA = try[k,2], CUTOFF = try[k,3], BETA = try[k,4], POPULATION = try[k,5], SELECTION = try[k,6], GENERATION = try[k,7], TEST="G") diff[k,1] <- quantile(x$Mutant.High/(x$Mutant.High + x$WT.High + 1) - x$Mutant.Low/(x$Mutant.Low + x$WT.Low + 1),0.025) diff[k,2] <- quantile(x$Mutant.High/(x$Mutant.High + x$WT.High + 1) - x$Mutant.Low/(x$Mutant.Low + x$WT.Low + 1),0.975) power[k] <- mean(x$Power) } total <- cbind(try,power,diff) colnames(total) <- c("MU","SIGMA","CUTOFF","BETA","POPULATION","SELECTION","GENERATION","POWER","5%LB","5%UB") MU.CUTOFF <- total CUTOFF.LEVEL.1 <- subset(MU.CUTOFF, MU.CUTOFF$CUTOFF == CUTOFF.test[1]) CUTOFF.LEVEL.2 <- subset(MU.CUTOFF, MU.CUTOFF$CUTOFF == CUTOFF.test[2]) CUTOFF.LEVEL.3 <- subset(MU.CUTOFF, MU.CUTOFF$CUTOFF == CUTOFF.test[3]) CUTOFF.LEVEL.4 <- subset(MU.CUTOFF, MU.CUTOFF$CUTOFF == CUTOFF.test[4]) plot( convert.mu.to.percent(CUTOFF.LEVEL.1$MU),CUTOFF.LEVEL.1$POWER, typ = "l", col = COLOR[1], lwd = 2, ylim = c(0,1), xlab = "Mean Effect", ylab = "Power") points(convert.mu.to.percent(CUTOFF.LEVEL.2$MU),CUTOFF.LEVEL.2$POWER, typ = "l", col = COLOR[2], lwd = 2) points(convert.mu.to.percent(CUTOFF.LEVEL.3$MU),CUTOFF.LEVEL.3$POWER, typ = "l", col = COLOR[3], lwd = 2) points(convert.mu.to.percent(CUTOFF.LEVEL.4$MU),CUTOFF.LEVEL.4$POWER, typ = "l", col = COLOR[4], lwd = 2) abline(h = 0.9, lty = 2) legend(0.2, 0.4, legend = CUTOFF.test, fill = COLOR, title = "Cutoff Percent") rect(xleft = 0.01, xright=0.11, ybottom=0, ytop=1, col = "#88888844", border = "#88888844") #PLOT V #X-axis MU #Y-axis POWER #Lines SELECTION try <- expand.grid(MU.test,SIGMA.test[4],CUTOFF.test[3],BETA.test[3],POPULATION.test[1],SELECTION.test,GENERATION.test[2]) K <- 1:nrow(try) power <- numeric(length(K)) diff <- matrix(0, nrow = length(K), ncol = 2) for(k in K) { x <- Power(ALPHA = 80, MU = try[k,1], SIGMA = try[k,2], CUTOFF = try[k,3], BETA = try[k,4], POPULATION = try[k,5], SELECTION = try[k,6], GENERATION = try[k,7], TEST="G") diff[k,1] <- quantile(x$Mutant.High/(x$Mutant.High + x$WT.High + 1) - x$Mutant.Low/(x$Mutant.Low + x$WT.Low + 1),0.025) diff[k,2] <- quantile(x$Mutant.High/(x$Mutant.High + x$WT.High + 1) - x$Mutant.Low/(x$Mutant.Low + x$WT.Low + 1),0.975) power[k] <- mean(x$Power) } total <- cbind(try,power,diff) colnames(total) <- c("MU","SIGMA","CUTOFF","BETA","POPULATION","SELECTION","GENERATION","POWER","5%LB","5%UB") MU.SELECTION <- total SELECTION.LEVEL.1 <- subset(MU.SELECTION, MU.SELECTION$SELECTION == SELECTION.test[1]) SELECTION.LEVEL.2 <- subset(MU.SELECTION, MU.SELECTION$SELECTION == SELECTION.test[2]) SELECTION.LEVEL.3 <- subset(MU.SELECTION, MU.SELECTION$SELECTION == SELECTION.test[3]) SELECTION.LEVEL.4 <- subset(MU.SELECTION, MU.SELECTION$SELECTION == SELECTION.test[4]) SELECTION.LEVEL.5 <- subset(MU.SELECTION, MU.SELECTION$SELECTION == SELECTION.test[5]) SELECTION.LEVEL.6 <- subset(MU.SELECTION, MU.SELECTION$SELECTION == SELECTION.test[6]) SELECTION.LEVEL.7 <- subset(MU.SELECTION, MU.SELECTION$SELECTION == SELECTION.test[7]) SELECTION.LEVEL.8 <- subset(MU.SELECTION, MU.SELECTION$SELECTION == SELECTION.test[8]) plot( convert.mu.to.percent(SELECTION.LEVEL.1$MU),SELECTION.LEVEL.1$POWER, typ = "l", col = COLOR[1], lwd = 2, ylim = c(0,1), xlab = "Mean Effect", ylab = "Power") points(convert.mu.to.percent(SELECTION.LEVEL.2$MU),SELECTION.LEVEL.2$POWER, typ = "l", col = COLOR[2], lwd = 2) points(convert.mu.to.percent(SELECTION.LEVEL.3$MU),SELECTION.LEVEL.3$POWER, typ = "l", col = COLOR[3], lwd = 2) points(convert.mu.to.percent(SELECTION.LEVEL.4$MU),SELECTION.LEVEL.4$POWER, typ = "l", col = COLOR[4], lwd = 2) points(convert.mu.to.percent(SELECTION.LEVEL.5$MU),SELECTION.LEVEL.5$POWER, typ = "l", col = COLOR[5], lwd = 2) points(convert.mu.to.percent(SELECTION.LEVEL.6$MU),SELECTION.LEVEL.6$POWER, typ = "l", col = COLOR[6], lwd = 2) points(convert.mu.to.percent(SELECTION.LEVEL.7$MU),SELECTION.LEVEL.7$POWER, typ = "l", col = COLOR[7], lwd = 2) points(convert.mu.to.percent(SELECTION.LEVEL.8$MU),SELECTION.LEVEL.8$POWER, typ = "l", col = COLOR[8], lwd = 2) abline(h = 0.9, lty = 2) legend(0.2, 0.4, legend = SELECTION.test, fill = COLOR, title = "Selection Coefficient") rect(xleft = 0.01, xright=0.11, ybottom=0, ytop=1, col = "#88888844", border = "#88888844") #PLOT VI #X-axis MU #Y-axis POWER #Lines GENERATIONS try <- expand.grid(MU.test,SIGMA.test[4],CUTOFF.test[3],BETA.test[3],POPULATION.test[1],SELECTION.test[4],GENERATION.test) K <- 1:nrow(try) power <- numeric(length(K)) diff <- matrix(0, nrow = length(K), ncol = 2) for(k in K) { x <- Power(ALPHA = 80, MU = try[k,1], SIGMA = try[k,2], CUTOFF = try[k,3], BETA = try[k,4], POPULATION = try[k,5], SELECTION = try[k,6], GENERATION = try[k,7], TEST="G") diff[k,1] <- quantile(x$Mutant.High/(x$Mutant.High + x$WT.High + 1) - x$Mutant.Low/(x$Mutant.Low + x$WT.Low + 1),0.025) diff[k,2] <- quantile(x$Mutant.High/(x$Mutant.High + x$WT.High + 1) - x$Mutant.Low/(x$Mutant.Low + x$WT.Low + 1),0.975) power[k] <- mean(x$Power) } total <- cbind(try,power,diff) colnames(total) <- c("MU","SIGMA","CUTOFF","BETA","POPULATION","SELECTION","GENERATION","POWER","5%LB","5%UB") MU.GENERATION <- total GENERATION.LEVEL.1 <- subset(MU.GENERATION, MU.GENERATION$GENERATION == GENERATION.test[1]) GENERATION.LEVEL.2 <- subset(MU.GENERATION, MU.GENERATION$GENERATION == GENERATION.test[2]) GENERATION.LEVEL.3 <- subset(MU.GENERATION, MU.GENERATION$GENERATION == GENERATION.test[3]) plot( convert.mu.to.percent(GENERATION.LEVEL.1$MU),GENERATION.LEVEL.1$POWER, typ = "l", col = COLOR[1], lwd = 2, ylim = c(0,1), xlab = "Mean Effect", ylab = "Power") points(convert.mu.to.percent(GENERATION.LEVEL.2$MU),GENERATION.LEVEL.2$POWER, typ = "l", col = COLOR[2], lwd = 2) points(convert.mu.to.percent(GENERATION.LEVEL.3$MU),GENERATION.LEVEL.3$POWER, typ = "l", col = COLOR[3], lwd = 2) abline(h = 0.9, lty = 2) legend(0.2, 0.4, legend = GENERATION.test, fill = COLOR, title = "Generations") rect(xleft = 0.01, xright=0.11, ybottom=0, ytop=1, col = "#88888844", border = "#88888844") #PLOT VII #X-axis SIGMA #Y-axis POWER #Lines MU try <- expand.grid(MU.test,SIGMA.test,CUTOFF.test[3],BETA.test[3],POPULATION.test[1],SELECTION.test[4],GENERATION.test[2]) K <- 1:nrow(try) power <- numeric(length(K)) diff <- matrix(0, nrow = length(K), ncol = 2) for(k in K) { x <- Power(ALPHA = 80, MU = try[k,1], SIGMA = try[k,2], CUTOFF = try[k,3], BETA = try[k,4], POPULATION = try[k,5], SELECTION = try[k,6], GENERATION = try[k,7], TEST="G") diff[k,1] <- quantile(x$Mutant.High/(x$Mutant.High + x$WT.High + 1) - x$Mutant.Low/(x$Mutant.Low + x$WT.Low + 1),0.025) diff[k,2] <- quantile(x$Mutant.High/(x$Mutant.High + x$WT.High + 1) - x$Mutant.Low/(x$Mutant.Low + x$WT.Low + 1),0.975) power[k] <- mean(x$Power) } total <- cbind(try,power,diff) colnames(total) <- c("MU","SIGMA","CUTOFF","BETA","POPULATION","SELECTION","GENERATION","POWER","5%LB","5%UB") SIGMA.MU <- total MU.LEVEL.1 <- subset(SIGMA.MU, SIGMA.MU$MU == MU.test[1]) MU.LEVEL.2 <- subset(SIGMA.MU, SIGMA.MU$MU == MU.test[2]) MU.LEVEL.3 <- subset(SIGMA.MU, SIGMA.MU$MU == MU.test[3]) MU.LEVEL.4 <- subset(SIGMA.MU, SIGMA.MU$MU == MU.test[4]) MU.LEVEL.5 <- subset(SIGMA.MU, SIGMA.MU$MU == MU.test[5]) MU.LEVEL.6 <- subset(SIGMA.MU, SIGMA.MU$MU == MU.test[6]) MU.LEVEL.7 <- subset(SIGMA.MU, SIGMA.MU$MU == MU.test[7]) MU.LEVEL.8 <- subset(SIGMA.MU, SIGMA.MU$MU == MU.test[8]) MU.LEVEL.9 <- subset(SIGMA.MU, SIGMA.MU$MU == MU.test[9]) MU.LEVEL.10<- subset(SIGMA.MU, SIGMA.MU$MU == MU.test[10]) MU.LEVEL.11<- subset(SIGMA.MU, SIGMA.MU$MU == MU.test[11]) MU.LEVEL.12<- subset(SIGMA.MU, SIGMA.MU$MU == MU.test[12]) MU.LEVEL.13<- subset(SIGMA.MU, SIGMA.MU$MU == MU.test[13]) MU.LEVEL.14<- subset(SIGMA.MU, SIGMA.MU$MU == MU.test[14]) MU.LEVEL.15<- subset(SIGMA.MU, SIGMA.MU$MU == MU.test[15]) MU.LEVEL.16<- subset(SIGMA.MU, SIGMA.MU$MU == MU.test[16]) MU.LEVEL.17<- subset(SIGMA.MU, SIGMA.MU$MU == MU.test[17]) MU.LEVEL.18<- subset(SIGMA.MU, SIGMA.MU$MU == MU.test[18]) plot( MU.LEVEL.1$SIGMA, MU.LEVEL.1$POWER, typ = "l", col = COLOR[1], lwd = 2, lty = 1, xlim = c(0.25,4), ylim = c(0,1), xlab = "Mutant Variance", ylab = "Power") points(MU.LEVEL.2$SIGMA, MU.LEVEL.2$POWER, typ = "l", col = COLOR[2], lwd = 2, lty = 1) points(MU.LEVEL.3$SIGMA, MU.LEVEL.3$POWER, typ = "l", col = COLOR[3], lwd = 2, lty = 1) points(MU.LEVEL.4$SIGMA, MU.LEVEL.4$POWER, typ = "l", col = COLOR[4], lwd = 2, lty = 1) points(MU.LEVEL.5$SIGMA, MU.LEVEL.5$POWER, typ = "l", col = COLOR[5], lwd = 2, lty = 1) points(MU.LEVEL.6$SIGMA, MU.LEVEL.6$POWER, typ = "l", col = COLOR[6], lwd = 2, lty = 1) points(MU.LEVEL.7$SIGMA, MU.LEVEL.7$POWER, typ = "l", col = COLOR[7], lwd = 2, lty = 1) points(MU.LEVEL.8$SIGMA, MU.LEVEL.8$POWER, typ = "l", col = COLOR[8], lwd = 2, lty = 1) points(MU.LEVEL.9$SIGMA, MU.LEVEL.9$POWER, typ = "l", col = COLOR[1], lwd = 2, lty = 2) points(MU.LEVEL.10$SIGMA, MU.LEVEL.10$POWER, typ = "l", col = COLOR[2], lwd = 2, lty = 2) points(MU.LEVEL.11$SIGMA, MU.LEVEL.11$POWER, typ = "l", col = COLOR[3], lwd = 2, lty = 2) points(MU.LEVEL.12$SIGMA, MU.LEVEL.12$POWER, typ = "l", col = COLOR[4], lwd = 2, lty = 2) points(MU.LEVEL.13$SIGMA, MU.LEVEL.13$POWER, typ = "l", col = COLOR[5], lwd = 2, lty = 2) points(MU.LEVEL.14$SIGMA, MU.LEVEL.14$POWER, typ = "l", col = COLOR[6], lwd = 2, lty = 2) points(MU.LEVEL.15$SIGMA, MU.LEVEL.15$POWER, typ = "l", col = COLOR[7], lwd = 2, lty = 2) points(MU.LEVEL.16$SIGMA, MU.LEVEL.16$POWER, typ = "l", col = COLOR[8], lwd = 2, lty = 2) points(MU.LEVEL.17$SIGMA, MU.LEVEL.17$POWER, typ = "l", col = COLOR[1], lwd = 2, lty = 3) points(MU.LEVEL.18$SIGMA, MU.LEVEL.18$POWER, typ = "l", col = COLOR[2], lwd = 2, lty = 3) abline(h = 0.9, lty = 2) legend(3.2, 1, legend = round(convert.mu.to.percent(MU.test),3), fill = COLOR, title = "Main Effect") rect(xleft = .75, xright=1.5, ybottom=0, ytop=1, col = "#88888844", border = "#88888844") #PLOT VIII #X-axis SIGMA #Y-axis POWER #Lines POPULATION try <- expand.grid(MU.test[6],SIGMA.test,CUTOFF.test[3],BETA.test[3],POPULATION.test,SELECTION.test[4],GENERATION.test[2]) K <- 1:nrow(try) power <- numeric(length(K)) diff <- matrix(0, nrow = length(K), ncol = 2) for(k in K) { x <- Power(ALPHA = 80, MU = try[k,1], SIGMA = try[k,2], CUTOFF = try[k,3], BETA = try[k,4], POPULATION = try[k,5], SELECTION = try[k,6], GENERATION = try[k,7], TEST="G") diff[k,1] <- quantile(x$Mutant.High/(x$Mutant.High + x$WT.High + 1) - x$Mutant.Low/(x$Mutant.Low + x$WT.Low + 1),0.025) diff[k,2] <- quantile(x$Mutant.High/(x$Mutant.High + x$WT.High + 1) - x$Mutant.Low/(x$Mutant.Low + x$WT.Low + 1),0.975) power[k] <- mean(x$Power) } total <- cbind(try,power,diff) colnames(total) <- c("MU","SIGMA","CUTOFF","BETA","POPULATION","SELECTION","GENERATION","POWER","5%LB","5%UB") SIGMA.POPULATION <- total POPULATION.LEVEL.1 <- subset(SIGMA.POPULATION, SIGMA.POPULATION$POPULATION == POPULATION.test[1]) POPULATION.LEVEL.2 <- subset(SIGMA.POPULATION, SIGMA.POPULATION$POPULATION == POPULATION.test[2]) POPULATION.LEVEL.3 <- subset(SIGMA.POPULATION, SIGMA.POPULATION$POPULATION == POPULATION.test[3]) POPULATION.LEVEL.4 <- subset(SIGMA.POPULATION, SIGMA.POPULATION$POPULATION == POPULATION.test[4]) plot( POPULATION.LEVEL.1$SIGMA,POPULATION.LEVEL.1$POWER, typ = "l", col = COLOR[1], lwd = 2, xlim = c(0.25,4), ylim = c(0,1), xlab = "Mutant Variance", ylab = "Power") points(POPULATION.LEVEL.2$SIGMA,POPULATION.LEVEL.2$POWER, typ = "l", col = COLOR[2], lwd = 2) points(POPULATION.LEVEL.3$SIGMA,POPULATION.LEVEL.3$POWER, typ = "l", col = COLOR[3], lwd = 2) points(POPULATION.LEVEL.4$SIGMA,POPULATION.LEVEL.4$POWER, typ = "l", col = COLOR[4], lwd = 2) abline(h = 0.9, lty = 2) legend(3.2, 0.8, legend = POPULATION.test, fill = COLOR, title = "Population Size") rect(xleft = .75, xright=1.5, ybottom=0, ytop=1, col = "#88888844", border = "#88888844") ###PLOT IX #X-axis SIGMA #Y-axis POWER #Lines COVERAGE try <- expand.grid(MU.test[6],SIGMA.test,CUTOFF.test[3],BETA.test,POPULATION.test[1],SELECTION.test[4],GENERATION.test[2]) K <- 1:nrow(try) power <- numeric(length(K)) diff <- matrix(0, nrow = length(K), ncol = 2) for(k in K) { x <- Power(ALPHA = 80, MU = try[k,1], SIGMA = try[k,2], CUTOFF = try[k,3], BETA = try[k,4], POPULATION = try[k,5], SELECTION = try[k,6], GENERATION = try[k,7], TEST="G") diff[k,1] <- quantile(x$Mutant.High/(x$Mutant.High + x$WT.High + 1) - x$Mutant.Low/(x$Mutant.Low + x$WT.Low + 1),0.025) diff[k,2] <- quantile(x$Mutant.High/(x$Mutant.High + x$WT.High + 1) - x$Mutant.Low/(x$Mutant.Low + x$WT.Low + 1),0.975) power[k] <- mean(x$Power) } total <- cbind(try,power,diff) colnames(total) <- c("MU","SIGMA","CUTOFF","BETA","POPULATION","SELECTION","GENERATION","POWER","5%LB","5%UB") SIGMA.BETA <- total BETA.LEVEL.1 <- subset(SIGMA.BETA, SIGMA.BETA$BETA == BETA.test[1]) BETA.LEVEL.2 <- subset(SIGMA.BETA, SIGMA.BETA$BETA == BETA.test[2]) BETA.LEVEL.3 <- subset(SIGMA.BETA, SIGMA.BETA$BETA == BETA.test[3]) BETA.LEVEL.4 <- subset(SIGMA.BETA, SIGMA.BETA$BETA == BETA.test[4]) BETA.LEVEL.5 <- subset(SIGMA.BETA, SIGMA.BETA$BETA == BETA.test[5]) BETA.LEVEL.6 <- subset(SIGMA.BETA, SIGMA.BETA$BETA == BETA.test[6]) plot( BETA.LEVEL.1$SIGMA,BETA.LEVEL.1$POWER, typ = "l", col = COLOR[1], lwd = 2, xlim = c(0.25,4), ylim = c(0,1), xlab = "Mutant Variance", ylab = "Power" ) points(BETA.LEVEL.2$SIGMA,BETA.LEVEL.2$POWER, typ = "l", col = COLOR[2], lwd = 2) points(BETA.LEVEL.3$SIGMA,BETA.LEVEL.3$POWER, typ = "l", col = COLOR[3], lwd = 2) points(BETA.LEVEL.4$SIGMA,BETA.LEVEL.4$POWER, typ = "l", col = COLOR[4], lwd = 2) points(BETA.LEVEL.5$SIGMA,BETA.LEVEL.5$POWER, typ = "l", col = COLOR[5], lwd = 2) points(BETA.LEVEL.6$SIGMA,BETA.LEVEL.6$POWER, typ = "l", col = COLOR[6], lwd = 2) abline(h = 0.9, lty = 2) legend(3.2, 0.8, legend = ALPHA/BETA.test, fill = COLOR, title = "Average Coverage") rect(xleft = .75, xright=1.5, ybottom=0, ytop=1, col = "#88888844", border = "#88888844") ###PLOT X #X-axis SIGMA #Y-axis POWER #Lines CUTOFF try <- expand.grid(MU.test[6],SIGMA.test,CUTOFF.test,BETA.test[3],POPULATION.test[1],SELECTION.test[4],GENERATION.test[2]) K <- 1:nrow(try) power <- numeric(length(K)) diff <- matrix(0, nrow = length(K), ncol = 2) for(k in K) { x <- Power(ALPHA = 80, MU = try[k,1], SIGMA = try[k,2], CUTOFF = try[k,3], BETA = try[k,4], POPULATION = try[k,5], SELECTION = try[k,6], GENERATION = try[k,7], TEST="G") diff[k,1] <- quantile(x$Mutant.High/(x$Mutant.High + x$WT.High + 1) - x$Mutant.Low/(x$Mutant.Low + x$WT.Low + 1),0.025) diff[k,2] <- quantile(x$Mutant.High/(x$Mutant.High + x$WT.High + 1) - x$Mutant.Low/(x$Mutant.Low + x$WT.Low + 1),0.975) power[k] <- mean(x$Power) } total <- cbind(try,power,diff) colnames(total) <- c("MU","SIGMA","CUTOFF","BETA","POPULATION","SELECTION","GENERATION","POWER","5%LB","5%UB") SIGMA.CUTOFF <- total CUTOFF.LEVEL.1 <- subset(SIGMA.CUTOFF, SIGMA.CUTOFF$CUTOFF == CUTOFF.test[1]) CUTOFF.LEVEL.2 <- subset(SIGMA.CUTOFF, SIGMA.CUTOFF$CUTOFF == CUTOFF.test[2]) CUTOFF.LEVEL.3 <- subset(SIGMA.CUTOFF, SIGMA.CUTOFF$CUTOFF == CUTOFF.test[3]) CUTOFF.LEVEL.4 <- subset(SIGMA.CUTOFF, SIGMA.CUTOFF$CUTOFF == CUTOFF.test[4]) plot( CUTOFF.LEVEL.1$SIGMA,CUTOFF.LEVEL.1$POWER, typ = "l", col = COLOR[1], lwd = 2, xlim =c(0.25,4), ylim = c(0,1), xlab = "Mutant Variance", ylab = "Power") points(CUTOFF.LEVEL.2$SIGMA,CUTOFF.LEVEL.2$POWER, typ = "l", col = COLOR[2], lwd = 2) points(CUTOFF.LEVEL.3$SIGMA,CUTOFF.LEVEL.3$POWER, typ = "l", col = COLOR[3], lwd = 2) points(CUTOFF.LEVEL.4$SIGMA,CUTOFF.LEVEL.4$POWER, typ = "l", col = COLOR[4], lwd = 2) abline(h = 0.9, lty = 2) legend(3.2, 0.8, legend = CUTOFF.test, fill = COLOR, title = "Cutoff Percent") rect(xleft = .75, xright=1.5, ybottom=0, ytop=1, col = "#88888844", border = "#88888844") ###PLOT XI #X-axis SIGMA #Y-axis POWER #Lines SELECTION try <- expand.grid(MU.test[6],SIGMA.test,CUTOFF.test[3],BETA.test[3],POPULATION.test[1],SELECTION.test,GENERATION.test[2]) K <- 1:nrow(try) power <- numeric(length(K)) diff <- matrix(0, nrow = length(K), ncol = 2) for(k in K) { x <- Power(ALPHA = 80, MU = try[k,1], SIGMA = try[k,2], CUTOFF = try[k,3], BETA = try[k,4], POPULATION = try[k,5], SELECTION = try[k,6], GENERATION = try[k,7], TEST="G") diff[k,1] <- quantile(x$Mutant.High/(x$Mutant.High + x$WT.High + 1) - x$Mutant.Low/(x$Mutant.Low + x$WT.Low + 1),0.025) diff[k,2] <- quantile(x$Mutant.High/(x$Mutant.High + x$WT.High + 1) - x$Mutant.Low/(x$Mutant.Low + x$WT.Low + 1),0.975) power[k] <- mean(x$Power) } total <- cbind(try,power,diff) colnames(total) <- c("MU","SIGMA","CUTOFF","BETA","POPULATION","SELECTION","GENERATION","POWER","5%LB","5%UB") SIGMA.SELECTION <- total SELECTION.LEVEL.1 <- subset(SIGMA.SELECTION, SIGMA.SELECTION$SELECTION == SELECTION.test[1]) SELECTION.LEVEL.2 <- subset(SIGMA.SELECTION, SIGMA.SELECTION$SELECTION == SELECTION.test[2]) SELECTION.LEVEL.3 <- subset(SIGMA.SELECTION, SIGMA.SELECTION$SELECTION == SELECTION.test[3]) SELECTION.LEVEL.4 <- subset(SIGMA.SELECTION, SIGMA.SELECTION$SELECTION == SELECTION.test[4]) SELECTION.LEVEL.5 <- subset(SIGMA.SELECTION, SIGMA.SELECTION$SELECTION == SELECTION.test[5]) SELECTION.LEVEL.6 <- subset(SIGMA.SELECTION, SIGMA.SELECTION$SELECTION == SELECTION.test[6]) SELECTION.LEVEL.7 <- subset(SIGMA.SELECTION, SIGMA.SELECTION$SELECTION == SELECTION.test[7]) SELECTION.LEVEL.8 <- subset(SIGMA.SELECTION, SIGMA.SELECTION$SELECTION == SELECTION.test[8]) plot( SELECTION.LEVEL.1$SIGMA,SELECTION.LEVEL.1$POWER, typ = "l", col = COLOR[1], lwd = 2, xlim=c(0.25,4), ylim = c(0,1), xlab = "Mutant Variance", ylab = "Power") points(SELECTION.LEVEL.2$SIGMA,SELECTION.LEVEL.2$POWER, typ = "l", col = COLOR[2], lwd = 2) points(SELECTION.LEVEL.3$SIGMA,SELECTION.LEVEL.3$POWER, typ = "l", col = COLOR[3], lwd = 2) points(SELECTION.LEVEL.4$SIGMA,SELECTION.LEVEL.4$POWER, typ = "l", col = COLOR[4], lwd = 2) points(SELECTION.LEVEL.5$SIGMA,SELECTION.LEVEL.5$POWER, typ = "l", col = COLOR[5], lwd = 2) points(SELECTION.LEVEL.6$SIGMA,SELECTION.LEVEL.6$POWER, typ = "l", col = COLOR[6], lwd = 2) points(SELECTION.LEVEL.7$SIGMA,SELECTION.LEVEL.7$POWER, typ = "l", col = COLOR[7], lwd = 2) points(SELECTION.LEVEL.8$SIGMA,SELECTION.LEVEL.8$POWER, typ = "l", col = COLOR[8], lwd = 2) abline(h = 0.9, lty = 2) legend(3.2, 0.8, legend = SELECTION.test, fill = COLOR, title = "Selection Coefficient") rect(xleft = .75, xright=1.5, ybottom=0, ytop=1, col = "#88888844", border = "#88888844") ###PLOT XII #X-axis SIGMA #Y-axis POWER #Lines GENERATIONS try <- expand.grid(MU.test[6],SIGMA.test,CUTOFF.test[3],BETA.test[3],POPULATION.test[1],SELECTION.test[4],GENERATION.test) K <- 1:nrow(try) power <- numeric(length(K)) diff <- matrix(0, nrow = length(K), ncol = 2) for(k in K) { x <- Power(ALPHA = 80, MU = try[k,1], SIGMA = try[k,2], CUTOFF = try[k,3], BETA = try[k,4], POPULATION = try[k,5], SELECTION = try[k,6], GENERATION = try[k,7], TEST="G") diff[k,1] <- quantile(x$Mutant.High/(x$Mutant.High + x$WT.High + 1) - x$Mutant.Low/(x$Mutant.Low + x$WT.Low + 1),0.025) diff[k,2] <- quantile(x$Mutant.High/(x$Mutant.High + x$WT.High + 1) - x$Mutant.Low/(x$Mutant.Low + x$WT.Low + 1),0.975) power[k] <- mean(x$Power) } total <- cbind(try,power,diff) colnames(total) <- c("MU","SIGMA","CUTOFF","BETA","POPULATION","SELECTION","GENERATION","POWER","5%LB","5%UB") SIGMA.GENERATION <- total GENERATION.LEVEL.1 <- subset(SIGMA.GENERATION, SIGMA.GENERATION$GENERATION == GENERATION.test[1]) GENERATION.LEVEL.2 <- subset(SIGMA.GENERATION, SIGMA.GENERATION$GENERATION == GENERATION.test[2]) GENERATION.LEVEL.3 <- subset(SIGMA.GENERATION, SIGMA.GENERATION$GENERATION == GENERATION.test[3]) plot( GENERATION.LEVEL.1$SIGMA,GENERATION.LEVEL.1$POWER, typ = "l", col = COLOR[1], lwd = 2, xlim=c(0.25,4), ylim = c(0,1), xlab = "Mutant Variance", ylab = "Power") points(GENERATION.LEVEL.2$SIGMA,GENERATION.LEVEL.2$POWER, typ = "l", col = COLOR[2], lwd = 2) points(GENERATION.LEVEL.3$SIGMA,GENERATION.LEVEL.3$POWER, typ = "l", col = COLOR[3], lwd = 2) abline(h = 0.9, lty = 2) legend(3.2, 0.8, legend = GENERATION.test, fill = COLOR, title = "Generations") rect(xleft = .75, xright=1.5, ybottom=0, ytop=1, col = "#88888844", border = "#88888844") #PLOT XIII #X-axis SELECTION #Y-axis POWER #Lines MU try <- expand.grid(MU.test,SIGMA.test[4],CUTOFF.test[3],BETA.test[3],POPULATION.test[1],SELECTION.test,GENERATION.test[2]) K <- 1:nrow(try) power <- numeric(length(K)) diff <- matrix(0, nrow = length(K), ncol = 2) for(k in K) { x <- Power(ALPHA = 80, MU = try[k,1], SIGMA = try[k,2], CUTOFF = try[k,3], BETA = try[k,4], POPULATION = try[k,5], SELECTION = try[k,6], GENERATION = try[k,7], TEST="G") diff[k,1] <- quantile(x$Mutant.High/(x$Mutant.High + x$WT.High + 1) - x$Mutant.Low/(x$Mutant.Low + x$WT.Low + 1),0.025) diff[k,2] <- quantile(x$Mutant.High/(x$Mutant.High + x$WT.High + 1) - x$Mutant.Low/(x$Mutant.Low + x$WT.Low + 1),0.975) power[k] <- mean(x$Power) } total <- cbind(try,power,diff) colnames(total) <- c("MU","SIGMA","CUTOFF","BETA","POPULATION","SELECTION","GENERATION","POWER","5%LB","5%UB") SELECTION.MU <- total MU.LEVEL.1 <- subset(SELECTION.MU, SELECTION.MU$MU == MU.test[1]) MU.LEVEL.2 <- subset(SELECTION.MU, SELECTION.MU$MU == MU.test[2]) MU.LEVEL.3 <- subset(SELECTION.MU, SELECTION.MU$MU == MU.test[3]) MU.LEVEL.4 <- subset(SELECTION.MU, SELECTION.MU$MU == MU.test[4]) MU.LEVEL.5 <- subset(SELECTION.MU, SELECTION.MU$MU == MU.test[5]) MU.LEVEL.6 <- subset(SELECTION.MU, SELECTION.MU$MU == MU.test[6]) MU.LEVEL.7 <- subset(SELECTION.MU, SELECTION.MU$MU == MU.test[7]) MU.LEVEL.8 <- subset(SELECTION.MU, SELECTION.MU$MU == MU.test[8]) MU.LEVEL.9 <- subset(SELECTION.MU, SELECTION.MU$MU == MU.test[9]) MU.LEVEL.10<- subset(SELECTION.MU, SELECTION.MU$MU == MU.test[10]) MU.LEVEL.11<- subset(SELECTION.MU, SELECTION.MU$MU == MU.test[11]) MU.LEVEL.12<- subset(SELECTION.MU, SELECTION.MU$MU == MU.test[12]) MU.LEVEL.13<- subset(SELECTION.MU, SELECTION.MU$MU == MU.test[13]) MU.LEVEL.14<- subset(SELECTION.MU, SELECTION.MU$MU == MU.test[14]) MU.LEVEL.15<- subset(SELECTION.MU, SELECTION.MU$MU == MU.test[15]) MU.LEVEL.16<- subset(SELECTION.MU, SELECTION.MU$MU == MU.test[16]) MU.LEVEL.17<- subset(SELECTION.MU, SELECTION.MU$MU == MU.test[17]) MU.LEVEL.18<- subset(SELECTION.MU, SELECTION.MU$MU == MU.test[18]) plot( MU.LEVEL.1$SELECTION, MU.LEVEL.1$POWER, typ = "l", col = COLOR[1], lwd = 2, lty = 1, xlim = c(-.01,.25), ylim = c(0,1), xlab = "Mutant Selection Coefficient", ylab = "Power") points(MU.LEVEL.2$SELECTION, MU.LEVEL.2$POWER, typ = "l", col = COLOR[2], lwd = 2, lty = 1) points(MU.LEVEL.3$SELECTION, MU.LEVEL.3$POWER, typ = "l", col = COLOR[3], lwd = 2, lty = 1) points(MU.LEVEL.4$SELECTION, MU.LEVEL.4$POWER, typ = "l", col = COLOR[4], lwd = 2, lty = 1) points(MU.LEVEL.5$SELECTION, MU.LEVEL.5$POWER, typ = "l", col = COLOR[5], lwd = 2, lty = 1) points(MU.LEVEL.6$SELECTION, MU.LEVEL.6$POWER, typ = "l", col = COLOR[6], lwd = 2, lty = 1) points(MU.LEVEL.7$SELECTION, MU.LEVEL.7$POWER, typ = "l", col = COLOR[7], lwd = 2, lty = 1) points(MU.LEVEL.8$SELECTION, MU.LEVEL.8$POWER, typ = "l", col = COLOR[8], lwd = 2, lty = 1) points(MU.LEVEL.9$SELECTION, MU.LEVEL.9$POWER, typ = "l", col = COLOR[1], lwd = 2, lty = 2) points(MU.LEVEL.10$SELECTION, MU.LEVEL.10$POWER, typ = "l", col = COLOR[2], lwd = 2, lty = 2) points(MU.LEVEL.11$SELECTION, MU.LEVEL.11$POWER, typ = "l", col = COLOR[3], lwd = 2, lty = 2) points(MU.LEVEL.12$SELECTION, MU.LEVEL.12$POWER, typ = "l", col = COLOR[4], lwd = 2, lty = 2) points(MU.LEVEL.13$SELECTION, MU.LEVEL.13$POWER, typ = "l", col = COLOR[5], lwd = 2, lty = 2) points(MU.LEVEL.14$SELECTION, MU.LEVEL.14$POWER, typ = "l", col = COLOR[6], lwd = 2, lty = 2) points(MU.LEVEL.15$SELECTION, MU.LEVEL.15$POWER, typ = "l", col = COLOR[7], lwd = 2, lty = 2) points(MU.LEVEL.16$SELECTION, MU.LEVEL.16$POWER, typ = "l", col = COLOR[8], lwd = 2, lty = 2) points(MU.LEVEL.17$SELECTION, MU.LEVEL.17$POWER, typ = "l", col = COLOR[1], lwd = 2, lty = 3) points(MU.LEVEL.18$SELECTION, MU.LEVEL.18$POWER, typ = "l", col = COLOR[2], lwd = 2, lty = 3) abline(h = 0.9, lty = 2) legend(.2, 1, legend = round(convert.mu.to.percent(MU.test),3), fill = COLOR, title = "Main Effect") rect(xleft = -.01, xright=0.1, ybottom=0, ytop=1, col = "#88888844", border = "#88888844") #PLOT XIV #X-axis SELECTION #Y-axis POWER #Lines POPULATION try <- expand.grid(MU.test[6],SIGMA.test[4],CUTOFF.test[3],BETA.test[3],POPULATION.test,SELECTION.test,GENERATION.test[2]) K <- 1:nrow(try) power <- numeric(length(K)) diff <- matrix(0, nrow = length(K), ncol = 2) for(k in K) { x <- Power(ALPHA = 80, MU = try[k,1], SIGMA = try[k,2], CUTOFF = try[k,3], BETA = try[k,4], POPULATION = try[k,5], SELECTION = try[k,6], GENERATION = try[k,7], TEST="G") diff[k,1] <- quantile(x$Mutant.High/(x$Mutant.High + x$WT.High + 1) - x$Mutant.Low/(x$Mutant.Low + x$WT.Low + 1),0.025) diff[k,2] <- quantile(x$Mutant.High/(x$Mutant.High + x$WT.High + 1) - x$Mutant.Low/(x$Mutant.Low + x$WT.Low + 1),0.975) power[k] <- mean(x$Power) } total <- cbind(try,power,diff) colnames(total) <- c("MU","SIGMA","CUTOFF","BETA","POPULATION","SELECTION","GENERATION","POWER","5%LB","5%UB") SELECTION.POPULATION <- total POPULATION.LEVEL.1 <- subset(SELECTION.POPULATION, SELECTION.POPULATION$POPULATION == POPULATION.test[1]) POPULATION.LEVEL.2 <- subset(SELECTION.POPULATION, SELECTION.POPULATION$POPULATION == POPULATION.test[2]) POPULATION.LEVEL.3 <- subset(SELECTION.POPULATION, SELECTION.POPULATION$POPULATION == POPULATION.test[3]) POPULATION.LEVEL.4 <- subset(SELECTION.POPULATION, SELECTION.POPULATION$POPULATION == POPULATION.test[4]) plot( POPULATION.LEVEL.1$SELECTION,POPULATION.LEVEL.1$POWER, typ = "l", col = COLOR[1], lwd = 2, xlim = c(-.01,.25), ylim = c(0,1), xlab = "Mutant Selection Coefficient", ylab = "Power") points(POPULATION.LEVEL.2$SELECTION,POPULATION.LEVEL.2$POWER, typ = "l", col = COLOR[2], lwd = 2) points(POPULATION.LEVEL.3$SELECTION,POPULATION.LEVEL.3$POWER, typ = "l", col = COLOR[3], lwd = 2) points(POPULATION.LEVEL.4$SELECTION,POPULATION.LEVEL.4$POWER, typ = "l", col = COLOR[4], lwd = 2) abline(h = 0.9, lty = 2) legend(.2, 1, legend = POPULATION.test, fill = COLOR, title = "Population Size") rect(xleft = -.01, xright=0.1, ybottom=0, ytop=1, col = "#88888844", border = "#88888844") ###PLOT XV #X-axis SELECTION #Y-axis POWER #Lines COVERAGE try <- expand.grid(MU.test[6],SIGMA.test[4],CUTOFF.test[3],BETA.test,POPULATION.test[1],SELECTION.test,GENERATION.test[2]) K <- 1:nrow(try) power <- numeric(length(K)) diff <- matrix(0, nrow = length(K), ncol = 2) for(k in K) { x <- Power(ALPHA = 80, MU = try[k,1], SIGMA = try[k,2], CUTOFF = try[k,3], BETA = try[k,4], POPULATION = try[k,5], SELECTION = try[k,6], GENERATION = try[k,7], TEST="G") diff[k,1] <- quantile(x$Mutant.High/(x$Mutant.High + x$WT.High + 1) - x$Mutant.Low/(x$Mutant.Low + x$WT.Low + 1),0.025) diff[k,2] <- quantile(x$Mutant.High/(x$Mutant.High + x$WT.High + 1) - x$Mutant.Low/(x$Mutant.Low + x$WT.Low + 1),0.975) power[k] <- mean(x$Power) } total <- cbind(try,power,diff) colnames(total) <- c("MU","SIGMA","CUTOFF","BETA","POPULATION","SELECTION","GENERATION","POWER","5%LB","5%UB") SELECTION.BETA <- total BETA.LEVEL.1 <- subset(SELECTION.BETA, SELECTION.BETA$BETA == BETA.test[1]) BETA.LEVEL.2 <- subset(SELECTION.BETA, SELECTION.BETA$BETA == BETA.test[2]) BETA.LEVEL.3 <- subset(SELECTION.BETA, SELECTION.BETA$BETA == BETA.test[3]) BETA.LEVEL.4 <- subset(SELECTION.BETA, SELECTION.BETA$BETA == BETA.test[4]) BETA.LEVEL.5 <- subset(SELECTION.BETA, SELECTION.BETA$BETA == BETA.test[5]) BETA.LEVEL.6 <- subset(SELECTION.BETA, SELECTION.BETA$BETA == BETA.test[6]) plot( BETA.LEVEL.1$SELECTION,BETA.LEVEL.1$POWER, typ = "l", col = COLOR[1], lwd = 2, xlim = c(-0.01,.25), ylim = c(0,1), xlab = "Mutant Selection Coefficient", ylab = "Power" ) points(BETA.LEVEL.2$SELECTION,BETA.LEVEL.2$POWER, typ = "l", col = COLOR[2], lwd = 2) points(BETA.LEVEL.3$SELECTION,BETA.LEVEL.3$POWER, typ = "l", col = COLOR[3], lwd = 2) points(BETA.LEVEL.4$SELECTION,BETA.LEVEL.4$POWER, typ = "l", col = COLOR[4], lwd = 2) points(BETA.LEVEL.5$SELECTION,BETA.LEVEL.5$POWER, typ = "l", col = COLOR[5], lwd = 2) points(BETA.LEVEL.6$SELECTION,BETA.LEVEL.6$POWER, typ = "l", col = COLOR[6], lwd = 2) abline(h = 0.9, lty = 2) legend(.2, 1, legend = ALPHA/BETA.test, fill = COLOR, title = "Average Coverage") rect(xleft = -.01, xright=0.1, ybottom=0, ytop=1, col = "#88888844", border = "#88888844") ###PLOT XVI #X-axis SELECTION #Y-axis POWER #Lines CUTOFF try <- expand.grid(MU.test[6],SIGMA.test[4],CUTOFF.test,BETA.test[3],POPULATION.test[1],SELECTION.test,GENERATION.test[2]) K <- 1:nrow(try) power <- numeric(length(K)) diff <- matrix(0, nrow = length(K), ncol = 2) for(k in K) { x <- Power(ALPHA = 80, MU = try[k,1], SIGMA = try[k,2], CUTOFF = try[k,3], BETA = try[k,4], POPULATION = try[k,5], SELECTION = try[k,6], GENERATION = try[k,7], TEST="G") diff[k,1] <- quantile(x$Mutant.High/(x$Mutant.High + x$WT.High + 1) - x$Mutant.Low/(x$Mutant.Low + x$WT.Low + 1),0.025) diff[k,2] <- quantile(x$Mutant.High/(x$Mutant.High + x$WT.High + 1) - x$Mutant.Low/(x$Mutant.Low + x$WT.Low + 1),0.975) power[k] <- mean(x$Power) } total <- cbind(try,power,diff) colnames(total) <- c("MU","SIGMA","CUTOFF","BETA","POPULATION","SELECTION","GENERATION","POWER","5%LB","5%UB") SELECTION.CUTOFF <- total CUTOFF.LEVEL.1 <- subset(SELECTION.CUTOFF, SELECTION.CUTOFF$CUTOFF == CUTOFF.test[1]) CUTOFF.LEVEL.2 <- subset(SELECTION.CUTOFF, SELECTION.CUTOFF$CUTOFF == CUTOFF.test[2]) CUTOFF.LEVEL.3 <- subset(SELECTION.CUTOFF, SELECTION.CUTOFF$CUTOFF == CUTOFF.test[3]) CUTOFF.LEVEL.4 <- subset(SELECTION.CUTOFF, SELECTION.CUTOFF$CUTOFF == CUTOFF.test[4]) plot( CUTOFF.LEVEL.1$SELECTION,CUTOFF.LEVEL.1$POWER, typ = "l", col = COLOR[1], lwd = 2, xlim =c(-0.01,.25), ylim = c(0,1), xlab = "Mutant Selection Coefficient", ylab = "Power") points(CUTOFF.LEVEL.2$SELECTION,CUTOFF.LEVEL.2$POWER, typ = "l", col = COLOR[2], lwd = 2) points(CUTOFF.LEVEL.3$SELECTION,CUTOFF.LEVEL.3$POWER, typ = "l", col = COLOR[3], lwd = 2) points(CUTOFF.LEVEL.4$SELECTION,CUTOFF.LEVEL.4$POWER, typ = "l", col = COLOR[4], lwd = 2) abline(h = 0.9, lty = 2) legend(.2, 1, legend = CUTOFF.test, fill = COLOR, title = "Cutoff Percent") rect(xleft = -.01, xright=0.1, ybottom=0, ytop=1, col = "#88888844", border = "#88888844") ###PLOT XVII #X-axis SELECTION #Y-axis POWER #Lines SIGMA try <- expand.grid(MU.test[6],SIGMA.test,CUTOFF.test[3],BETA.test[3],POPULATION.test[1],SELECTION.test,GENERATION.test[2]) K <- 1:nrow(try) power <- numeric(length(K)) diff <- matrix(0, nrow = length(K), ncol = 2) for(k in K) { x <- Power(ALPHA = 80, MU = try[k,1], SIGMA = try[k,2], CUTOFF = try[k,3], BETA = try[k,4], POPULATION = try[k,5], SELECTION = try[k,6], GENERATION = try[k,7], TEST="G") diff[k,1] <- quantile(x$Mutant.High/(x$Mutant.High + x$WT.High + 1) - x$Mutant.Low/(x$Mutant.Low + x$WT.Low + 1),0.025) diff[k,2] <- quantile(x$Mutant.High/(x$Mutant.High + x$WT.High + 1) - x$Mutant.Low/(x$Mutant.Low + x$WT.Low + 1),0.975) power[k] <- mean(x$Power) } total <- cbind(try,power,diff) colnames(total) <- c("MU","SIGMA","CUTOFF","BETA","POPULATION","SELECTION","GENERATION","POWER","5%LB","5%UB") SELECTION.SIGMA <- total SIGMA.LEVEL.1 <- subset(SELECTION.SIGMA, SELECTION.SIGMA$SIGMA == SIGMA.test[1]) SIGMA.LEVEL.2 <- subset(SELECTION.SIGMA, SELECTION.SIGMA$SIGMA == SIGMA.test[2]) SIGMA.LEVEL.3 <- subset(SELECTION.SIGMA, SELECTION.SIGMA$SIGMA == SIGMA.test[3]) SIGMA.LEVEL.4 <- subset(SELECTION.SIGMA, SELECTION.SIGMA$SIGMA == SIGMA.test[4]) SIGMA.LEVEL.5 <- subset(SELECTION.SIGMA, SELECTION.SIGMA$SIGMA == SIGMA.test[5]) SIGMA.LEVEL.6 <- subset(SELECTION.SIGMA, SELECTION.SIGMA$SIGMA == SIGMA.test[6]) SIGMA.LEVEL.7 <- subset(SELECTION.SIGMA, SELECTION.SIGMA$SIGMA == SIGMA.test[7]) SIGMA.LEVEL.8 <- subset(SELECTION.SIGMA, SELECTION.SIGMA$SIGMA == SIGMA.test[8]) plot( SIGMA.LEVEL.1$SELECTION,SELECTION.LEVEL.1$POWER, typ = "l", col = COLOR[1], lwd = 2, xlim=c(-0.01,.25), ylim = c(0,1), xlab = "Mutant Selection Coefficient", ylab = "Power") points(SIGMA.LEVEL.2$SELECTION,SIGMA.LEVEL.2$POWER, typ = "l", col = COLOR[2], lwd = 2) points(SIGMA.LEVEL.3$SELECTION,SIGMA.LEVEL.3$POWER, typ = "l", col = COLOR[3], lwd = 2) points(SIGMA.LEVEL.4$SELECTION,SIGMA.LEVEL.4$POWER, typ = "l", col = COLOR[4], lwd = 2) points(SIGMA.LEVEL.5$SELECTION,SIGMA.LEVEL.5$POWER, typ = "l", col = COLOR[5], lwd = 2) points(SIGMA.LEVEL.6$SELECTION,SIGMA.LEVEL.6$POWER, typ = "l", col = COLOR[6], lwd = 2) points(SIGMA.LEVEL.7$SELECTION,SIGMA.LEVEL.7$POWER, typ = "l", col = COLOR[7], lwd = 2) points(SIGMA.LEVEL.8$SELECTION,SIGMA.LEVEL.8$POWER, typ = "l", col = COLOR[8], lwd = 2) abline(h = 0.9, lty = 2) legend(.2, 1, legend = SIGMA.test, fill = COLOR, title = "Mutant Variance") rect(xleft = -0.1, xright=0.1, ybottom=0, ytop=1, col = "#88888844", border = "#88888844") ###PLOT XVIII #X-axis SELECTION #Y-axis POWER #Lines GENERATIONS try <- expand.grid(MU.test[6],SIGMA.test[4],CUTOFF.test[3],BETA.test[3],POPULATION.test[1],SELECTION.test,GENERATION.test) K <- 1:nrow(try) power <- numeric(length(K)) diff <- matrix(0, nrow = length(K), ncol = 2) for(k in K) { x <- Power(ALPHA = 80, MU = try[k,1], SIGMA = try[k,2], CUTOFF = try[k,3], BETA = try[k,4], POPULATION = try[k,5], SELECTION = try[k,6], GENERATION = try[k,7], TEST="G") diff[k,1] <- quantile(x$Mutant.High/(x$Mutant.High + x$WT.High + 1) - x$Mutant.Low/(x$Mutant.Low + x$WT.Low + 1),0.025) diff[k,2] <- quantile(x$Mutant.High/(x$Mutant.High + x$WT.High + 1) - x$Mutant.Low/(x$Mutant.Low + x$WT.Low + 1),0.975) power[k] <- mean(x$Power) } total <- cbind(try,power,diff) colnames(total) <- c("MU","SIGMA","CUTOFF","BETA","POPULATION","SELECTION","GENERATION","POWER","5%LB","5%UB") SELECTION.GENERATION <- total GENERATION.LEVEL.1 <- subset(SELECTION.GENERATION, SELECTION.GENERATION$GENERATION == GENERATION.test[1]) GENERATION.LEVEL.2 <- subset(SELECTION.GENERATION, SELECTION.GENERATION$GENERATION == GENERATION.test[2]) GENERATION.LEVEL.3 <- subset(SELECTION.GENERATION, SELECTION.GENERATION$GENERATION == GENERATION.test[3]) plot( GENERATION.LEVEL.1$SELECTION,GENERATION.LEVEL.1$POWER, typ = "l", col = COLOR[1], lwd = 2, xlim=c(-0.01,.25), ylim = c(0,1), xlab = "Mutant Selection Coefficient", ylab = "Power") points(GENERATION.LEVEL.2$SELECTION,GENERATION.LEVEL.2$POWER, typ = "l", col = COLOR[2], lwd = 2) points(GENERATION.LEVEL.3$SELECTION,GENERATION.LEVEL.3$POWER, typ = "l", col = COLOR[3], lwd = 2) abline(h = 0.9, lty = 2) abline(h = 0.9, lty = 2) legend(.2, 1, legend = GENERATION.test, fill = COLOR, title = "Generations") rect(xleft = -0.1, xright=0.1, ybottom=0, ytop=1, col = "#88888844", border = "#88888844") ##################################################### ###5. Comparison of Fisher's Exact Test and G-test### ##################################################### try <- expand.grid(MU.test[1:10],SIGMA.test[4],CUTOFF.test[3],BETA.test[c(3:4,6)],POPULATION.test[1],SELECTION.test[4],GENERATION.test[2],TEST=c("F","G")) K <- 1:nrow(try) power <- numeric(length(K)) diff <- matrix(0, nrow = length(K), ncol = 2) for(k in K) { x <- Power(ALPHA = 80, MU = try[k,1], SIGMA = try[k,2], CUTOFF = try[k,3], BETA = try[k,4], POPULATION = try[k,5], SELECTION = try[k,6], GENERATION = try[k,7], TEST = try[k,8]) diff[k,1] <- quantile(x$Mutant.High/(x$Mutant.High + x$WT.High + 1) - x$Mutant.Low/(x$Mutant.Low + x$WT.Low + 1),0.025) diff[k,2] <- quantile(x$Mutant.High/(x$Mutant.High + x$WT.High + 1) - x$Mutant.Low/(x$Mutant.Low + x$WT.Low + 1),0.975) power[k] <- mean(x$Power) } G.100 <- power[which(try[,8] == "G" & try[,4] == 0.80)] G.50 <- power[which(try[,8] == "G" & try[,4] == 1.6)] G.10 <- power[which(try[,8] == "G" & try[,4] == 8)] F.100 <- power[which(try[,8] == "F" & try[,4] == 0.80)] F.50 <- power[which(try[,8] == "F" & try[,4] == 1.6)] F.10 <- power[which(try[,8] == "F" & try[,4] == 8)] #Plot plot( G.100, F.100, type="b", lwd=3, col="red", pch = 19, xlab="G-Test Power", ylab="Fisher Exact Test Power") points(G.100, F.100, type="b", lwd=3, col="red", pch = 19) points(G.50, F.50, type="b", lwd=3, col="green", pch = 19) points(G.10, F.10, type="b", lwd=3, col="blue", pch = 19) abline(a = 0, b= 1, lwd = 2, lty = 2) legend(.2,1,fill=c("red","green","blue"), legend = c("100","50","10")) ############################ ###6. False Positive Rate### ############################ #Calculate power assuming a mutation of no effect on mean or variance x <- Power(ALPHA = 80, MU = MU.test[1], SIGMA.test[4],CUTOFF.test[3],BETA.test[3],POPULATION.test[1],SELECTION.test[4],GENERATION.test[2],TEST="G") ######################################### ###7. Deterministic Allele Frequencies### ######################################### #Estimate distribution of effects prior to sampling x <- rnorm((1-MUTANT.FREQ)*20000000,0,1) y <- rnorm(MUTANT.FREQ*20000000,MU,SIGMA) hist(c(x,y), breaks = 100, xlim = c(-6,6), ylim = c(0,1000000), col = "#000000AA", main = "", xlab = "", xaxt="n") axis(1,convert.percent.to.mu(c(-.45,-.3,-.15,0,.15,.3,.45)),c("-45","-30","-15","0","15","30","45")) par(new = TRUE) hist(x, breaks = 100, xlim = c(-6,6), ylim = c(0,1000000), col = "#FF0000AA", main = "", xlab = "",xaxt="n") par(new = TRUE) hist(y, breaks = 100, xlim = c(-6,6), ylim = c(0,1000000), col = "#0000FFAA", main = "", xlab = "",xaxt="n") abline(v = THRESHOLD.LOW, lwd = 2) abline(v = THRESHOLD.HIGH, lwd = 2) legend(-6,500000,fill = c("red","blue","black"), legend = c("WT","Mutant","Total")) #Get power z <- Power(ALPHA,BETA,CUTOFF,MU,SIGMA,POPULATION,SELECTION,GENERATION,TEST)