library(resistance) library(ggplot2)
#resistance cost a <- setExposure(exposure=0.5, insecticideUsed='insecticide1') i1 <- setInputOneScenario( max_gen = 500, P_1 = 0.01, h.RS1_A0 = 0.5, h.RS2_0B = 0.5, a = a, phi.SS1_A0 = 0.5, phi.SS2_0B = 0.5, rr_restoration_ins1 = 0.5, rr_restoration_ins2 = 0.5, z.RR1_00 = 0, h.RS1_00 = 0.1) i2 <- setInputOneScenario( max_gen = 500, P_1 = 0.01, h.RS1_A0 = 0.5, h.RS2_0B = 0.5, a = a, phi.SS1_A0 = 0.5, phi.SS2_0B = 0.5, rr_restoration_ins1 = 0.5, rr_restoration_ins2 = 0.5, z.RR1_00 = 0.25, h.RS1_00 = 0.1 ) i3 <- setInputOneScenario( max_gen = 500, P_1 = 0.01, h.RS1_A0 = 0.5, h.RS2_0B = 0.5, a = a, phi.SS1_A0 = 0.5, phi.SS2_0B = 0.5, rr_restoration_ins1 = 0.5, rr_restoration_ins2 = 0.5, z.RR1_00 = 0.75, h.RS1_00 = 0.1 ) input <- cbind(i1,i2,i3) listOut <- runModel2( input ) df_resist <- get_resistance(locus=1, listOut) print( ggplot(df_resist, aes(x=generation, y=resistance, colour=factor(z.RR1_00))) + theme_bw() + theme(legend.position = "bottom", legend.key = element_blank()) + guides(colour = guide_legend(reverse=TRUE)) + labs(colour = "cost of\nresistance") + coord_trans(y = "log10") + geom_line() )
#dominance cost a <- setExposure(exposure=0.5, insecticideUsed='insecticide1') i1 <- setInputOneScenario( max_gen = 500, P_1 = 0.01, h.RS1_A0 = 0.5, h.RS2_0B = 0.5, a = a, phi.SS1_A0 = 0.5, phi.SS2_0B = 0.5, rr_restoration_ins1 = 0.5, rr_restoration_ins2 = 0.5, z.RR1_00 = 0.25, h.RS1_00 = 0) i2 <- setInputOneScenario( max_gen = 500, P_1 = 0.01, h.RS1_A0 = 0.5, h.RS2_0B = 0.5, a = a, phi.SS1_A0 = 0.5, phi.SS2_0B = 0.5, rr_restoration_ins1 = 0.5, rr_restoration_ins2 = 0.5, z.RR1_00 = 0.25, h.RS1_00 = 0.5 ) i3 <- setInputOneScenario( max_gen = 500, P_1 = 0.01, h.RS1_A0 = 0.5, h.RS2_0B = 0.5, a = a, phi.SS1_A0 = 0.5, phi.SS2_0B = 0.5, rr_restoration_ins1 = 0.5, rr_restoration_ins2 = 0.5, z.RR1_00 = 0.25, h.RS1_00 = 1 ) input <- cbind(i1,i2,i3) listOut <- runModel2( input ) df_resist <- get_resistance(locus=1, listOut) print( ggplot(df_resist, aes(x=generation, y=resistance, colour=factor(h.RS1_00))) + theme_bw() + theme(legend.position = "bottom", legend.key = element_blank()) + guides(colour = guide_legend(reverse=TRUE)) + labs(colour = "dominance\nof cost") + coord_trans(y = "log10") + geom_line() )
#dominance cost at low cost a <- setExposure(exposure=0.5, insecticideUsed='insecticide1') i1 <- setInputOneScenario( max_gen = 500, P_1 = 0.01, h.RS1_A0 = 0.5, h.RS2_0B = 0.5, a = a, phi.SS1_A0 = 0.5, phi.SS2_0B = 0.5, rr_restoration_ins1 = 0.5, rr_restoration_ins2 = 0.5, z.RR1_00 = 0.1, h.RS1_00 = 0) i2 <- setInputOneScenario( max_gen = 500, P_1 = 0.01, h.RS1_A0 = 0.5, h.RS2_0B = 0.5, a = a, phi.SS1_A0 = 0.5, phi.SS2_0B = 0.5, rr_restoration_ins1 = 0.5, rr_restoration_ins2 = 0.5, z.RR1_00 = 0.1, h.RS1_00 = 0.5 ) i3 <- setInputOneScenario( max_gen = 500, P_1 = 0.01, h.RS1_A0 = 0.5, h.RS2_0B = 0.5, a = a, phi.SS1_A0 = 0.5, phi.SS2_0B = 0.5, rr_restoration_ins1 = 0.5, rr_restoration_ins2 = 0.5, z.RR1_00 = 0.1, h.RS1_00 = 1 ) input <- cbind(i1,i2,i3) listOut <- runModel2( input ) df_resist <- get_resistance(locus=1, listOut) print( ggplot(df_resist, aes(x=generation, y=resistance, colour=factor(h.RS1_00))) + theme_bw() + theme(legend.position = "bottom", legend.key = element_blank()) + guides(colour = guide_legend(reverse=TRUE)) + labs(colour = "dominance\nof cost") + coord_trans(y = "log10") + geom_line() )
#low costs at dominance 0.5 a <- setExposure(exposure=0.5, insecticideUsed='insecticide1') i1 <- setInputOneScenario( max_gen = 500, P_1 = 0.01, h.RS1_A0 = 0.5, h.RS2_0B = 0.5, a = a, phi.SS1_A0 = 0.5, phi.SS2_0B = 0.5, rr_restoration_ins1 = 0.5, rr_restoration_ins2 = 0.5, z.RR1_00 = 0, h.RS1_00 = 0.5) i2 <- setInputOneScenario( max_gen = 500, P_1 = 0.01, h.RS1_A0 = 0.5, h.RS2_0B = 0.5, a = a, phi.SS1_A0 = 0.5, phi.SS2_0B = 0.5, rr_restoration_ins1 = 0.5, rr_restoration_ins2 = 0.5, z.RR1_00 = 0.05, h.RS1_00 = 0.5 ) i3 <- setInputOneScenario( max_gen = 500, P_1 = 0.01, h.RS1_A0 = 0.5, h.RS2_0B = 0.5, a = a, phi.SS1_A0 = 0.5, phi.SS2_0B = 0.5, rr_restoration_ins1 = 0.5, rr_restoration_ins2 = 0.5, z.RR1_00 = 0.15, h.RS1_00 = 0.5 ) input <- cbind(i1,i2,i3) listOut <- runModel2( input ) df_resist <- get_resistance(locus=1, listOut) print( ggplot(df_resist, aes(x=generation, y=resistance, colour=factor(z.RR1_00))) + theme_bw() + theme(legend.position = "bottom", legend.key = element_blank()) + guides(colour = guide_legend(reverse=TRUE)) + labs(colour = "cost of\nresistance") + coord_trans(y = "log10") + geom_line() )
#4 panel figure looking at effectiveness and exposure #test of rearranging figures on a grid #eff1 0.5 0.8 #exp #0.5 1 2 #0.8 3 4 #layout(matrix(1:4,2,2, byrow = TRUE)) #add lower panel for legend #layout(matrix(c(1,2,3,4,5,5),3,2, byrow = TRUE), heights=c(1,1,0.5), respect=FALSE) #layout( matrix(c(1,2,3,4,5,5),3,2, byrow = TRUE), heights=c(1,1,0.2), # respect=matrix(c(1,1,1,1,0,0),3,2, byrow = TRUE) ) #layout.show(n=5) # add side panels for labels layout( matrix(c(1:6,0,7,7,0,8,9),4,3, byrow = TRUE), heights=c(1,1,0.15,0.2), widths=c(0.1,1,1) ) #effectiveness on mixture #label par(mar=c(0, 0, 0, 0), pty='m') #b,l,t,r default c(5, 4, 4, 2) plot( 0, type="n", axes=FALSE, ann=FALSE, pty='m') mtext('cost 1 = 0', line= -2, side=2, cex=0.9) #side=1b,2l,3t,4r #base scenario par(mar=c(1.5, 4, 2, 0)) #b,l,t,r default c(5, 4, 4, 2) runcurtis_f2( max_gen=500, P_1 = 0.01 , P_2 = 0.01 , h.RS1_A0 = 0.5 , h.RS2_0B = 0.5 , exposure = 0.5 , phi.SS1_A0 = 0.5 , phi.SS2_0B = 0.5 , rr_restoration_ins1 = 0.5 , rr_restoration_ins2 = 0.5 , addCombinedStrategy = FALSE, strategyLabels = c('s','','a','m'), xlabs = FALSE, cex.axis = 0.8, addLegend=FALSE, main='', maxX = 150, labelMixSeqRatio = 1 ) mtext('A.',side=3, adj=0, line=1, cex=0.9) #side=1b,2l,3t,4r #plot margins par(mar=c(1.5, 0, 2, 0)) #b,l,t,r default c(5, 4, 4, 2) #effectiveness1 0.8 runcurtis_f2( max_gen=500, P_1 = 0.01 , P_2 = 0.01 , h.RS1_A0 = 0.5 , h.RS2_0B = 0.5 , exposure = 0.5 , phi.SS1_A0 = 0.8 , phi.SS2_0B = 0.5 , rr_restoration_ins1 = 0.5 , rr_restoration_ins2 = 0.5 , addCombinedStrategy = FALSE, strategyLabels = c('s','','a','m'), ylab="", ylabs = FALSE, xlabs = FALSE, cex.axis = 0.8, addLegend=FALSE, main='', maxX = 150, labelMixSeqRatio = 1 ) mtext('B.',side=3, adj=0, line=1, cex=0.9) #side=1b,2l,3t,4r #label par(mar=c(0, 0, 0, 0), pty='m') #b,l,t,r default c(5, 4, 4, 2) plot( 0, type="n", axes=FALSE, ann=FALSE, pty='m') mtext('cost 1 = 0.15', line= -2, side=2, cex=0.9) #side=1b,2l,3t,4r #plot margins par(mar=c(1.5, 4, 2, 0)) #b,l,t,r default c(5, 4, 4, 2) #exposure 0.8 runcurtis_f2( max_gen=500, P_1 = 0.01 , P_2 = 0.01 , h.RS1_A0 = 0.5 , h.RS2_0B = 0.5 , exposure = 0.5 , phi.SS1_A0 = 0.5 , phi.SS2_0B = 0.5 , rr_restoration_ins1 = 0.5 , rr_restoration_ins2 = 0.5 , addCombinedStrategy = FALSE, strategyLabels = c('s','','a','m'), xlabs = TRUE, cex.axis = 0.8, addLegend=FALSE, main='', maxX = 150, labelMixSeqRatio = 1, z.RR1_00 = 0.15 ) mtext('C.',side=3, adj=0, line=1, cex=0.9) #side=1b,2l,3t,4r #plot margins par(mar=c(1.5, 0, 2, 0)) #b,l,t,r default c(5, 4, 4, 2) #eff1 and expos 0.8 runcurtis_f2( max_gen=500, P_1 = 0.01 , P_2 = 0.01 , h.RS1_A0 = 0.5 , h.RS2_0B = 0.5 , exposure = 0.5 , phi.SS1_A0 = 0.8 , phi.SS2_0B = 0.5 , rr_restoration_ins1 = 0.5 , rr_restoration_ins2 = 0.5 , addCombinedStrategy = FALSE, strategyLabels = c('s','','a','m'), ylab="", ylabs = FALSE, xlabs = TRUE, cex.axis = 0.8, addLegend=FALSE, main='', maxX = 150, labelMixSeqRatio = 1, z.RR1_00 = 0.15 ) mtext('D.',side=3, adj=0, line=1, cex=0.9) #side=1b,2l,3t,4r #adding legend in lower panel #plot margins par(mar=c(0, 0, 0, 0), pty='m') #b,l,t,r default c(5, 4, 4, 2) plot( 0, type="n", axes=FALSE, ann=FALSE, pty='m') # legend( 'bottom', legend=c("insecticide1 alone ", "insecticide1 in mix ", "insecticide2 alone ", "insecticide2 in mix "), col=c("red","red","blue","blue"), lty=c(2,1,2,1), pch=c(NA,NA,NA,NA), bty="n", cex=0.7, horiz =TRUE ) #add for when insecticides same legend( 'bottom', legend=c("insecticide1 alone ", "insecticide2 alone ", "insecticide1 in mix ", "insecticide2 in mix ", "insecticides1&2 in mix "), col=c("red","blue","red","blue","purple"), lty=c(2,2,1,1,1), pch=c(NA,NA,NA,NA,NA), bty="n", cex=0.7, horiz =TRUE ) #label par(mar=c(0, 0, 0, 0), pty='m') #b,l,t,r default c(5, 4, 4, 2) plot( 0, type="n", axes=FALSE, ann=FALSE, pty='m') mtext('effectiveness1 = 0.5', line= -2, side=1, cex=0.9) #side=1b,2l,3t,4r #label par(mar=c(0, 0, 0, 0), pty='m') #b,l,t,r default c(5, 4, 4, 2) plot( 0, type="n", axes=FALSE, ann=FALSE, pty='m') mtext('effectiveness1 = 0.8', line= -2, side=1, cex=0.9) #side=1b,2l,3t,4r
#4 panel figure looking at effectiveness and exposure #test of rearranging figures on a grid #eff1 0.5 0.8 #exp #0.5 1 2 #0.8 3 4 #layout(matrix(1:4,2,2, byrow = TRUE)) #add lower panel for legend #layout(matrix(c(1,2,3,4,5,5),3,2, byrow = TRUE), heights=c(1,1,0.5), respect=FALSE) #layout( matrix(c(1,2,3,4,5,5),3,2, byrow = TRUE), heights=c(1,1,0.2), # respect=matrix(c(1,1,1,1,0,0),3,2, byrow = TRUE) ) #layout.show(n=5) # add side panels for labels layout( matrix(c(1:6,0,7,7,0,8,9),4,3, byrow = TRUE), heights=c(1,1,0.15,0.2), widths=c(0.1,1,1) ) #effectiveness on mixture #label par(mar=c(0, 0, 0, 0), pty='m') #b,l,t,r default c(5, 4, 4, 2) plot( 0, type="n", axes=FALSE, ann=FALSE, pty='m') mtext('cost 1 = 0', line= -2, side=2, cex=0.9) #side=1b,2l,3t,4r #base scenario par(mar=c(1.5, 4, 2, 0)) #b,l,t,r default c(5, 4, 4, 2) runcurtis_f2( max_gen=500, P_1 = 0.01 , P_2 = 0.01 , h.RS1_A0 = 0.5 , h.RS2_0B = 0.5 , exposure = 0.5 , phi.SS1_A0 = 0.5 , phi.SS2_0B = 0.5 , rr_restoration_ins1 = 0.5 , rr_restoration_ins2 = 0.5 , addCombinedStrategy = FALSE, strategyLabels = c('s','','a','m'), xlabs = FALSE, cex.axis = 0.8, addLegend=FALSE, main='', maxX = 350, labelMixSeqRatio = 1 ) mtext('A.',side=3, adj=0, line=1, cex=0.9) #side=1b,2l,3t,4r #plot margins par(mar=c(1.5, 0, 2, 0)) #b,l,t,r default c(5, 4, 4, 2) #effectiveness1 0.8 runcurtis_f2( max_gen=500, P_1 = 0.01 , P_2 = 0.01 , h.RS1_A0 = 0.5 , h.RS2_0B = 0.5 , exposure = 0.5 , phi.SS1_A0 = 0.8 , phi.SS2_0B = 0.5 , rr_restoration_ins1 = 0.5 , rr_restoration_ins2 = 0.5 , addCombinedStrategy = FALSE, strategyLabels = c('s','','a','m'), ylab="", ylabs = FALSE, xlabs = FALSE, cex.axis = 0.8, addLegend=FALSE, main='', maxX = 350, labelMixSeqRatio = 1 ) mtext('B.',side=3, adj=0, line=1, cex=0.9) #side=1b,2l,3t,4r #label par(mar=c(0, 0, 0, 0), pty='m') #b,l,t,r default c(5, 4, 4, 2) plot( 0, type="n", axes=FALSE, ann=FALSE, pty='m') mtext('cost 1&2 = 0.15', line= -2, side=2, cex=0.9) #side=1b,2l,3t,4r #plot margins par(mar=c(1.5, 4, 2, 0)) #b,l,t,r default c(5, 4, 4, 2) #exposure 0.8 runcurtis_f2( max_gen=500, P_1 = 0.01 , P_2 = 0.01 , h.RS1_A0 = 0.5 , h.RS2_0B = 0.5 , exposure = 0.5 , phi.SS1_A0 = 0.5 , phi.SS2_0B = 0.5 , rr_restoration_ins1 = 0.5 , rr_restoration_ins2 = 0.5 , addCombinedStrategy = FALSE, strategyLabels = c('s','','a','m'), xlabs = TRUE, cex.axis = 0.8, addLegend=FALSE, main='', maxX = 350, labelMixSeqRatio = 1, z.RR1_00 = 0.15, z.RR2_00 = 0.15 ) mtext('C.',side=3, adj=0, line=1, cex=0.9) #side=1b,2l,3t,4r #plot margins par(mar=c(1.5, 0, 2, 0)) #b,l,t,r default c(5, 4, 4, 2) #eff1 and expos 0.8 runcurtis_f2( max_gen=500, P_1 = 0.01 , P_2 = 0.01 , h.RS1_A0 = 0.5 , h.RS2_0B = 0.5 , exposure = 0.5 , phi.SS1_A0 = 0.8 , phi.SS2_0B = 0.5 , rr_restoration_ins1 = 0.5 , rr_restoration_ins2 = 0.5 , addCombinedStrategy = FALSE, strategyLabels = c('s','','a','m'), ylab="", ylabs = FALSE, xlabs = TRUE, cex.axis = 0.8, addLegend=FALSE, main='', maxX = 350, labelMixSeqRatio = 1, z.RR1_00 = 0.15, z.RR2_00 = 0.15 ) mtext('D.',side=3, adj=0, line=1, cex=0.9) #side=1b,2l,3t,4r #adding legend in lower panel #plot margins par(mar=c(0, 0, 0, 0), pty='m') #b,l,t,r default c(5, 4, 4, 2) plot( 0, type="n", axes=FALSE, ann=FALSE, pty='m') # legend( 'bottom', legend=c("insecticide1 alone ", "insecticide1 in mix ", "insecticide2 alone ", "insecticide2 in mix "), col=c("red","red","blue","blue"), lty=c(2,1,2,1), pch=c(NA,NA,NA,NA), bty="n", cex=0.7, horiz =TRUE ) #add for when insecticides same legend( 'bottom', legend=c("insecticide1 alone ", "insecticide2 alone ", "insecticide1 in mix ", "insecticide2 in mix ", "insecticides1&2 in mix "), col=c("red","blue","red","blue","purple"), lty=c(2,2,1,1,1), pch=c(NA,NA,NA,NA,NA), bty="n", cex=0.7, horiz =TRUE ) #label par(mar=c(0, 0, 0, 0), pty='m') #b,l,t,r default c(5, 4, 4, 2) plot( 0, type="n", axes=FALSE, ann=FALSE, pty='m') mtext('effectiveness1 = 0.5', line= -2, side=1, cex=0.9) #side=1b,2l,3t,4r #label par(mar=c(0, 0, 0, 0), pty='m') #b,l,t,r default c(5, 4, 4, 2) plot( 0, type="n", axes=FALSE, ann=FALSE, pty='m') mtext('effectiveness1 = 0.8', line= -2, side=1, cex=0.9) #side=1b,2l,3t,4r
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.