diff --git a/03_Figures_Simulations.R b/03_Figures_Simulations.R index 5c19cacfe911fdea43c549db803d0c7627135af6..0502cd511bbaf4885b1212c4ebc5b4047f169379 100644 --- a/03_Figures_Simulations.R +++ b/03_Figures_Simulations.R @@ -82,11 +82,10 @@ ggplot(data=outp.summary %>% dplyr::filter(stat.type=="XY") %>% dplyr::filter(trait %in% c("1", "2", "1 2", "3", "1 3", "2 3")) %>% mutate(trait=factor(trait, levels=c("1", "2", "3", "1 2", "1 3", "2 3"), - labels=c("t1", "t2", "tn", "t1 t2", "t1 tn", "t2 tn")))) + #%>% - #dplyr::filter(trait %in% c("1", "2", "1 2", "3")) %>% - #mutate(inter=as.factor(inter))) + - geom_line(aes(x=main, y=power, group=trait, col=trait)) + - #scale_colour_brewer(palette = "Dark2") + + labels=c("t1", "t2", "tn", "t1 t2", "t1 tn", "t2 tn"))) %>% + mutate(linetype=as.factor(ifelse(grepl(pattern="tn", x = trait), 2, 1)))) + + geom_line(aes(x=main, y=power, group=trait, col=trait, lty=linetype)) + + guides(linetype = FALSE) + scale_color_manual("Trait\ncomb.", values=c("#e41a1c", #1 - red) "#e6ab02", #2 - yellow @@ -102,7 +101,7 @@ ggplot(data=outp.summary %>% scale_y_continuous(name="Prop. of significant tests") + theme(panel.grid = element_blank()) -ggsave(filename="_pics/Fig2_CorrInte_02March.png", width=6, height=5, device="png", dpi = 300, last_plot()) +ggsave(filename="_pics/R1/Fig2_CorrInte_02March.png", width=6, height=5, device="png", dpi = 300, last_plot()) @@ -137,7 +136,8 @@ outp.summary2 <- outp.summary %>% ### rename null trait to "tn" outp.summary2 <- outp.summary2 %>% mutate(tn.name=paste0("t", ntraits)) %>% - mutate(trait=str_replace(trait, pattern=tn.name, replacement="tn")) + mutate(trait=str_replace(trait, pattern=tn.name, replacement="tn")) %>% + mutate(linetype=as.factor(ifelse(grepl(pattern="tn", x = trait), 2, 1))) #reorder factors outp.summary2$trait <- factor(outp.summary2$trait, levels= c('t1', 't2','t3', 't4', 'tn', @@ -167,7 +167,8 @@ outp.summary2 <- outp.summary2 %>% left_join(hugepalette, by="trait") fig3 <- ggplot(data=outp.summary2) + - geom_line(aes(x=main, y=power, group=trait, col=trait.col)) + + geom_line(aes(x=main, y=power, group=trait, col=trait.col, lty=linetype)) + + guides(linetype = FALSE) + scale_x_continuous(name="Effect of factor e1 -> trait t1", n.breaks = 4) + scale_y_continuous(name="Prop. of significant tests") + facet_grid(sel.ntraits.lab~ntraits.lab) + @@ -202,7 +203,7 @@ fig3.panel <- cowplot::plot_grid(fig3 + theme(legend.position = "none"), nrow=1, rel_widths = c(0.6,.4)) -ggsave(filename="_pics/Fig3_TraitNumber.png", +ggsave(filename="_pics/R1/Fig3_TraitNumber.png", width=9, height=7, device="png", dpi = 300, fig3.panel) @@ -221,10 +222,10 @@ ggplot(data=outp.summary %>% dplyr::filter(stat.type=="XY") %>% dplyr::filter(trait %in% c("1", "2", "3", "4")) %>% mutate(trait=factor(trait, levels=c("1", "2", "3", "4"), - labels=c("t1", "t2", "t3","tn")))) + #%>% - #dplyr::filter(trait %in% c("1", "2", "1 2", "3")) %>% - #mutate(inter=as.factor(inter))) + - geom_line(aes(x=main, y=power, group=trait, col=trait)) + + labels=c("t1", "t2", "t3","tn"))) %>% + mutate(linetype=as.factor(ifelse(grepl(pattern="tn", x = trait), 2, 1)))) + + geom_line(aes(x=main, y=power, group=trait, col=trait, lty=linetype)) + + guides(linetype = FALSE) + #scale_colour_brewer(palette = "Dark2") + #scale_color_manual("Trait\ncomb.", scale_color_manual("Trait", @@ -242,12 +243,14 @@ ggplot(data=outp.summary %>% scale_y_continuous(name="Prop. of significant tests") + theme(panel.grid = element_blank()) -ggsave(filename="_pics/FigS4_Extra_CorrInte_08Jul20.png", width=6, height=5, device="png", dpi = 300, last_plot()) +ggsave(filename="_pics/R1/FigS4_Extra_CorrInte_08Jul20.png", width=6, height=5, device="png", dpi = 300, last_plot()) + +### Additional Figures for JVS R1 #### -### FIGURE SXXX #### +#### FIGURE SXXX - XW #### mypath <- "_data/Experiment_30Oct2020_FactorInteraction&TraitCorr_XW" myfiles <- list.files(path=mypath, pattern = "Summary.txt", recursive = T) outp.summary <- FormatData(myfiles) @@ -267,8 +270,10 @@ ggplot(data=outp.summary %>% dplyr::filter(stat.type=="XY") %>% dplyr::filter(trait %in% c("1", "2", "1 2", "3", "1 3", "2 3")) %>% mutate(trait=factor(trait, levels=c("1", "2", "3", "1 2", "1 3", "2 3"), - labels=c("t1", "t2", "tn", "t1 t2", "t1 tn", "t2 tn")))) + - geom_line(aes(x=main, y=power, group=trait, col=trait)) + + labels=c("t1", "t2", "tn", "t1 t2", "t1 tn", "t2 tn"))) %>% + mutate(linetype=as.factor(ifelse(grepl(pattern="tn", x = trait), 2, 1)))) + + geom_line(aes(x=main, y=power, group=trait, col=trait, lty=linetype)) + + guides(linetype = FALSE) + scale_color_manual("Trait\ncomb.", values=c("#e41a1c", #1 - red) "#e6ab02", #2 - yellow @@ -283,9 +288,51 @@ ggplot(data=outp.summary %>% scale_y_continuous(name="Prop. of significant tests") + theme(panel.grid = element_blank()) -ggsave(filename="_pics/FigSXXX_CorrInte_30November_XW.png", width=6, height=5, device="png", dpi = 300, last_plot()) +ggsave(filename="_pics/R1/FigSXXX_CorrInte_30November_XW.png", width=6, height=5, device="png", dpi = 300, last_plot()) + + + + +### FIGURE SXXY - SBM #### +mypath <- "_data/Experiment_30Oct2020_FactorInteraction&TraitCorr_XW" +myfiles <- list.files(path=mypath, pattern = "Summary.txt", recursive = T) +outp.summary <- FormatData(myfiles) + +mypalette <- palette(c("#e41a1c", #1 - red) + "#ff7f00", #12 - orange + "#984ea3", #13 - violet + "##ffed6f", #2 - yellow + "#4daf4a", #23 - green + "#377eb8")) #3 - blue +ggplot(data=outp.summary %>% + mutate(main=main/100) %>% + mutate(corr=factor(corr/10, levels=c(0, 0.4, 0.8), labels=paste0("Correlation = ", c(0, 0.4, 0.8)))) %>% + mutate(inter=factor(inter/10, levels=c(0, 0.3, 0.5), labels=paste0("Interaction = ", c(0, 0.3, 0.5)))) %>% + ungroup() %>% + dplyr::filter(stat.type=="SbM") %>% + dplyr::filter(envir==1) %>% + dplyr::filter(trait %in% c("1", "2", "1 2", "3", "1 3", "2 3")) %>% + mutate(trait=factor(trait, levels=c("1", "2", "3", "1 2", "1 3", "2 3"), + labels=c("t1", "t2", "tn", "t1 t2", "t1 tn", "t2 tn"))) %>% + mutate(linetype=as.factor(ifelse(grepl(pattern="tn", x = trait), 2, 1)))) + + geom_line(aes(x=main, y=power, group=trait, col=trait, lty=linetype)) + + guides(linetype = FALSE) + + scale_color_manual("Trait\ncomb.", + values=c("#e41a1c", #1 - red) + "#e6ab02", #2 - yellow + "#377eb8", #3 - blue + "#d95f02", #12 - orange + "#984ea3", #13 - violet + "#4daf4a" #23 - green + )) + + facet_grid(corr~inter) + + theme_bw() + + scale_x_continuous(name="Effect of factor e1 -> trait t1") + + scale_y_continuous(name="Prop. of significant tests") + + theme(panel.grid = element_blank()) +ggsave(filename="_pics/R1/FigSXXX_CorrInte_30November_SbM.png", width=6, height=5, device="png", dpi = 300, last_plot())