diff --git a/figures/Figure_1.png b/figures/Figure_1.png index e427c14..c298004 100644 Binary files a/figures/Figure_1.png and b/figures/Figure_1.png differ diff --git a/figures/Figure_2.png b/figures/Figure_2.png index a7ba7d9..e8ef350 100644 Binary files a/figures/Figure_2.png and b/figures/Figure_2.png differ diff --git a/figures/Figure_3.png b/figures/Figure_3.png index 0e289ad..ffb3a28 100644 Binary files a/figures/Figure_3.png and b/figures/Figure_3.png differ diff --git a/figures/Figure_4.png b/figures/Figure_4.png index 3ff00b9..f28fef2 100644 Binary files a/figures/Figure_4.png and b/figures/Figure_4.png differ diff --git a/figures/Figure_5.png b/figures/Figure_5.png index e2892ad..31fec6c 100644 Binary files a/figures/Figure_5.png and b/figures/Figure_5.png differ diff --git a/figures/Figure_SI_1.png b/figures/Figure_SI_1.png index 70cdb04..fe753c6 100644 Binary files a/figures/Figure_SI_1.png and b/figures/Figure_SI_1.png differ diff --git a/figures/Figure_SI_10.png b/figures/Figure_SI_10.png index 03d688b..7b7e40c 100644 Binary files a/figures/Figure_SI_10.png and b/figures/Figure_SI_10.png differ diff --git a/figures/Figure_SI_11.png b/figures/Figure_SI_11.png index e899817..c63d1f5 100644 Binary files a/figures/Figure_SI_11.png and b/figures/Figure_SI_11.png differ diff --git a/figures/Figure_SI_12.png b/figures/Figure_SI_12.png index 9dec44a..1913eef 100644 Binary files a/figures/Figure_SI_12.png and b/figures/Figure_SI_12.png differ diff --git a/figures/Figure_SI_2.png b/figures/Figure_SI_2.png index e87d535..2df142d 100644 Binary files a/figures/Figure_SI_2.png and b/figures/Figure_SI_2.png differ diff --git a/figures/Figure_SI_3.png b/figures/Figure_SI_3.png index 37eebcd..f0aa81e 100644 Binary files a/figures/Figure_SI_3.png and b/figures/Figure_SI_3.png differ diff --git a/figures/Figure_SI_4.png b/figures/Figure_SI_4.png index dfeaf0b..736eb82 100644 Binary files a/figures/Figure_SI_4.png and b/figures/Figure_SI_4.png differ diff --git a/figures/Figure_SI_5.png b/figures/Figure_SI_5.png index 2f10902..6d9c2cb 100644 Binary files a/figures/Figure_SI_5.png and b/figures/Figure_SI_5.png differ diff --git a/figures/Figure_SI_6.png b/figures/Figure_SI_6.png index 0b19b26..3fcfd93 100644 Binary files a/figures/Figure_SI_6.png and b/figures/Figure_SI_6.png differ diff --git a/figures/Figure_SI_7.png b/figures/Figure_SI_7.png index 425cbbc..46fac19 100644 Binary files a/figures/Figure_SI_7.png and b/figures/Figure_SI_7.png differ diff --git a/figures/Figure_SI_8.png b/figures/Figure_SI_8.png index 6d910a2..540915d 100644 Binary files a/figures/Figure_SI_8.png and b/figures/Figure_SI_8.png differ diff --git a/figures/Figure_SI_9.png b/figures/Figure_SI_9.png index ba6cf6d..653820d 100644 Binary files a/figures/Figure_SI_9.png and b/figures/Figure_SI_9.png differ diff --git a/figures/Figures.zip b/figures/Figures.zip deleted file mode 100644 index eead19d..0000000 Binary files a/figures/Figures.zip and /dev/null differ diff --git a/figures/pdf/Figure_2.pdf b/figures/pdf/Figure_2.pdf index 5a05b5a..a36668d 100644 Binary files a/figures/pdf/Figure_2.pdf and b/figures/pdf/Figure_2.pdf differ diff --git a/figures/pdf/Figure_3.pdf b/figures/pdf/Figure_3.pdf index 10e63d2..d12c512 100644 Binary files a/figures/pdf/Figure_3.pdf and b/figures/pdf/Figure_3.pdf differ diff --git a/figures/pdf/Figure_4.pdf b/figures/pdf/Figure_4.pdf index 066dfc2..66b170e 100644 Binary files a/figures/pdf/Figure_4.pdf and b/figures/pdf/Figure_4.pdf differ diff --git a/figures/pdf/Figure_5.pdf b/figures/pdf/Figure_5.pdf index 8487cbe..61be604 100644 Binary files a/figures/pdf/Figure_5.pdf and b/figures/pdf/Figure_5.pdf differ diff --git a/figures/pdf/Figure_SI_1.pdf b/figures/pdf/Figure_SI_1.pdf index 26aaf06..33ac584 100644 Binary files a/figures/pdf/Figure_SI_1.pdf and b/figures/pdf/Figure_SI_1.pdf differ diff --git a/figures/pdf/Figure_SI_10.pdf b/figures/pdf/Figure_SI_10.pdf index 398a76e..e30d420 100644 Binary files a/figures/pdf/Figure_SI_10.pdf and b/figures/pdf/Figure_SI_10.pdf differ diff --git a/figures/pdf/Figure_SI_11.pdf b/figures/pdf/Figure_SI_11.pdf index bc908c5..7009dbb 100644 Binary files a/figures/pdf/Figure_SI_11.pdf and b/figures/pdf/Figure_SI_11.pdf differ diff --git a/figures/pdf/Figure_SI_12.pdf b/figures/pdf/Figure_SI_12.pdf index 6a2f9f5..77e373c 100644 Binary files a/figures/pdf/Figure_SI_12.pdf and b/figures/pdf/Figure_SI_12.pdf differ diff --git a/figures/pdf/Figure_SI_2.pdf b/figures/pdf/Figure_SI_2.pdf index 8e1d2a7..2994335 100644 Binary files a/figures/pdf/Figure_SI_2.pdf and b/figures/pdf/Figure_SI_2.pdf differ diff --git a/figures/pdf/Figure_SI_3.pdf b/figures/pdf/Figure_SI_3.pdf index b39cd28..9cf1dfb 100644 Binary files a/figures/pdf/Figure_SI_3.pdf and b/figures/pdf/Figure_SI_3.pdf differ diff --git a/figures/pdf/Figure_SI_4.pdf b/figures/pdf/Figure_SI_4.pdf index 603e4e7..b7c2aab 100644 Binary files a/figures/pdf/Figure_SI_4.pdf and b/figures/pdf/Figure_SI_4.pdf differ diff --git a/figures/pdf/Figure_SI_5.pdf b/figures/pdf/Figure_SI_5.pdf index 56bea48..a091c4b 100644 Binary files a/figures/pdf/Figure_SI_5.pdf and b/figures/pdf/Figure_SI_5.pdf differ diff --git a/figures/pdf/Figure_SI_6.pdf b/figures/pdf/Figure_SI_6.pdf index c07f0c3..bc5d75a 100644 Binary files a/figures/pdf/Figure_SI_6.pdf and b/figures/pdf/Figure_SI_6.pdf differ diff --git a/figures/pdf/Figure_SI_7.pdf b/figures/pdf/Figure_SI_7.pdf index e145f8a..55de0ca 100644 Binary files a/figures/pdf/Figure_SI_7.pdf and b/figures/pdf/Figure_SI_7.pdf differ diff --git a/figures/pdf/Figure_SI_8.pdf b/figures/pdf/Figure_SI_8.pdf index 8832d1e..a0867d8 100644 Binary files a/figures/pdf/Figure_SI_8.pdf and b/figures/pdf/Figure_SI_8.pdf differ diff --git a/figures/pdf/Figure_SI_9.pdf b/figures/pdf/Figure_SI_9.pdf index c85801e..afeaf7a 100644 Binary files a/figures/pdf/Figure_SI_9.pdf and b/figures/pdf/Figure_SI_9.pdf differ diff --git a/images/moons_legend_light.png b/images/moons_legend_light.png new file mode 100644 index 0000000..97d5628 Binary files /dev/null and b/images/moons_legend_light.png differ diff --git a/images/traitstrap_hex.png b/images/traitstrap_hex.png new file mode 100644 index 0000000..6a722ca Binary files /dev/null and b/images/traitstrap_hex.png differ diff --git a/r_functions/tidy_simdata.R b/r_functions/tidy_simdata.R index 5ef6778..ac0edac 100644 --- a/r_functions/tidy_simdata.R +++ b/r_functions/tidy_simdata.R @@ -28,7 +28,7 @@ tidy_simdata <-function(data){ TRUE ~ moment), method = case_when(method == 'global cwm' ~ 'Cross-Site CW', method == 'site-specic CWM' ~ 'Site-Specific CW', - method == 'nonparametric bs' ~ 'Non-Parametric BS', + method == 'nonparametric bs' ~ 'Nonparametric BS', method == 'parametric bs' ~ 'Parametric BS', TRUE ~ method)) %>% filter(true_moment == moment) %>% @@ -36,7 +36,7 @@ tidy_simdata <-function(data){ mutate(method = ordered(method,levels = c("Cross-Site CW", "Site-Specific CW", "Parametric BS", - "Non-Parametric BS")), + "Nonparametric BS")), overunder = ifelse(true_value <= estimate, "over", "under"), diff --git a/scripts_for_ms_with_traitstrap/2_simulation_analyses_and_figures.R b/scripts_for_ms_with_traitstrap/2_simulation_analyses_and_figures.R index 01bf7b6..26d6a9c 100644 --- a/scripts_for_ms_with_traitstrap/2_simulation_analyses_and_figures.R +++ b/scripts_for_ms_with_traitstrap/2_simulation_analyses_and_figures.R @@ -62,7 +62,7 @@ cowplot::ggdraw( y = method, fill = method, alpha = hit), - color = colorspace::lighten("#5e5e5e", 0.3), + color = colorspace::lighten("grey69", 0.3), size = 1, stroke = 0.2, position = position_jitternormal(sd_x = 0, sd_y = 0.1), shape = 21) + @@ -811,8 +811,8 @@ lollipop_CO = angle = 0), strip.text.x.top = element_text(size = rel(1.3)), legend.position = 'top', - legend.background = element_rect(colour = colorspace::darken("#dddddd", 0.1), - size = 0.4), + # legend.background = element_rect(colour = colorspace::darken("#dddddd", 0.1), + # size = 0.4), legend.margin = margin(3, 5, 3, 5), plot.margin = margin(5, 0, 7, 0)) + @@ -882,8 +882,9 @@ lollipop_CO = align_to = 'full', ignore_tag = TRUE) + theme_void() + plot_annotation(theme = theme( - plot.background = element_rect(fill = "white", colour = NA), - panel.background = element_rect(fill = "white", colour = NA), + plot.background = element_rect(fill = "#141438", colour = NA), + panel.background = element_rect(fill = "#141438", colour = NA), + legend.background = element_rect(fill = "#141438", colour = NA), text = element_text(face = 'bold'))) + plot_layout(heights = c(1, 0.15, 0.15)) @@ -1069,3 +1070,4 @@ ggsave(here::here("figures/Figure_SI_5.png"), ggsave(here::here("figures/pdf/Figure_SI_5.pdf"), height = 314, width = 180, units = "mm", dpi = 600) + diff --git a/scripts_for_ms_with_traitstrap/3_distrubution_figure.R b/scripts_for_ms_with_traitstrap/3_distrubution_figure.R index cd8eeb3..c07df68 100644 --- a/scripts_for_ms_with_traitstrap/3_distrubution_figure.R +++ b/scripts_for_ms_with_traitstrap/3_distrubution_figure.R @@ -125,7 +125,7 @@ np_dist <- get_distributions(imputed_traits = imputed_full,nrep = n_distribution -np_dist$method <- "Non-parametric BS" +np_dist$method <- "Nonparametric BS" pbs_dist$method <- "Parametric BS" cwm_dist$method <- "Cross-Site WM" cwm_site_dist$method <- "Site-Specific WM" @@ -151,7 +151,7 @@ rm(atraits_dist) all_dists$method <- factor(all_dists$method, levels = c("Cross-Site WM", "Site-Specific WM", - "Non-parametric BS", + "Nonparametric BS", "Parametric BS", "True")) @@ -167,7 +167,7 @@ joy_plot = scale_colour_manual(guide = guide_legend(title = "Method", title.position="top", title.hjust = 0.5), - values = c(pal_df$c, "#5e5e5e"), + values = c(pal_df$c, "grey69"), labels = c(pal_df$l, "True")) + guides(colour = guide_legend(override.aes = list(linetype = c(1, 1, 1, 1, 3)), title = "Method", @@ -216,14 +216,14 @@ joy_plot = guides(alpha = 'none') + figure_theme + theme(axis.text.x = element_blank(), - panel.background = element_rect(colour = '#5e5e5e', + panel.background = element_rect(colour = "grey69", size = 0.3), strip.text.y = element_text(margin = margin(0, 0, 10, 0), size = rel(.9), face = "bold", - colour = "#5e5e5e"), + colour = "grey69"), strip.text.x.top = element_text(margin = margin(0, 0, 10, 0), size = rel(.9), face = "bold", - colour = "#5e5e5e"), + colour = "grey69"), strip.background = element_blank(), axis.line = element_blank(), strip.placement = 'outside', @@ -263,7 +263,7 @@ ggsave(here::here("figures/pdf/Figure_SI_1.pdf"), np_dist_3x <- get_distributions(imputed_traits = imputed_full,nrep = 3,sample_size = sample_size_dist) np_dist_3x <- merge(np_dist_3x,elev) -np_dist_3x$method <- "Non-parametric BS" +np_dist_3x$method <- "Nonparametric BS" np_dist_3x$n <- paste("Replicate",np_dist_3x$n) atraits_dist <- atraits diff --git a/scripts_for_ms_with_traitstrap/4_biased_simulation_analyses_and_figures.R b/scripts_for_ms_with_traitstrap/4_biased_simulation_analyses_and_figures.R index bc64e40..aa28a8f 100644 --- a/scripts_for_ms_with_traitstrap/4_biased_simulation_analyses_and_figures.R +++ b/scripts_for_ms_with_traitstrap/4_biased_simulation_analyses_and_figures.R @@ -385,29 +385,32 @@ inset_AZ <- colorado_percent <- readRDS("output_data/Colorado_percent_community_sims.RDS") colorado_percent$method = fct_recode(colorado_percent$method, `Cross-Site CW` = "Cross-Site CWM", - `Site-Specific CW` = "Site-Specific CWM") + `Site-Specific CW` = "Site-Specific CWM", + `Nonparametric BS` = 'Non-Parametric BS') panama_percent <- readRDS("output_data/Panama_percent_community_sims.RDS") panama_percent$method = fct_recode(panama_percent$method, `Cross-Site CW` = "Cross-Site CWM", - `Site-Specific CW` = "Site-Specific CWM") + `Site-Specific CW` = "Site-Specific CWM", + `Nonparametric BS` = 'Non-Parametric BS') rodent_percent <- readRDS("output_data/Rodent_percent_community_sims.RDS") rodent_percent$method = fct_recode(rodent_percent$method, `Cross-Site CW` = "Cross-Site CWM", - `Site-Specific CW` = "Site-Specific CWM") + `Site-Specific CW` = "Site-Specific CWM", + `Nonparametric BS` = 'Non-Parametric BS') rodent_percent$method <- ordered(rodent_percent$method, levels = c("Cross-Site CW", "Site-Specific CW", "Parametric BS", - "Non-Parametric BS")) + "Nonparametric BS")) colorado_percent$method <- ordered(colorado_percent$method, - levels = c("Cross-Site CW","Site-Specific CW","Parametric BS","Non-Parametric BS")) + levels = c("Cross-Site CW","Site-Specific CW","Parametric BS","Nonparametric BS")) panama_percent$method <- ordered(panama_percent$method, - levels = c("Cross-Site CW","Site-Specific CW","Parametric BS","Non-Parametric BS")) + levels = c("Cross-Site CW","Site-Specific CW","Parametric BS","Nonparametric BS")) colorado_percent$moment = ordered(colorado_percent$moment,levels = c("mean", @@ -421,6 +424,7 @@ rodent_percent$moment = "skewness", "kurtosis")) + #### Combine CO and AZ ---- data <- vector('list', 2) @@ -675,7 +679,7 @@ CC # heights = c(1, 0.7), design = layout) + plot_annotation(theme = theme( - plot.background = element_rect(fill = "white", colour = NA), + plot.background = element_rect(fill = "#141438", colour = NA), legend.position = 'right')) + inset_element(moon_legend, left = 0.87, @@ -846,8 +850,8 @@ for (i in 1:5) { align_to = 'full') + theme_void()) + plot_layout(guides = 'collect') + plot_annotation(theme = theme( - plot.background = element_rect(fill = "white", colour = NA), - panel.background = element_rect(fill = "white", colour = NA), + plot.background = element_rect(fill = "#141438", colour = NA), + panel.background = element_rect(fill = "#141438", colour = NA), legend.position = 'bottom')) ggsave(here::here("figures/Figure_SI_7.png"), diff --git a/scripts_for_ms_with_traitstrap/5_plankton_timeseries.R b/scripts_for_ms_with_traitstrap/5_plankton_timeseries.R index 442283a..80e6eac 100644 --- a/scripts_for_ms_with_traitstrap/5_plankton_timeseries.R +++ b/scripts_for_ms_with_traitstrap/5_plankton_timeseries.R @@ -35,7 +35,7 @@ cowplot::ggdraw( y = true_value, group = method, linetype = "True value"), - colour = 'grey30', + colour = 'grey69', size = 0.4, smooth = 3) + geom_ribbon(aes( x = as.numeric(site), @@ -68,7 +68,7 @@ cowplot::ggdraw( title.position="top", title.hjust = 0.5, override.aes = - list(colour = c("grey69","grey30")))) + + list(colour = c("grey90","grey69")))) + facet_grid(rows = vars(moment), cols = vars(method), labeller = labeller( diff --git a/scripts_for_ms_with_traitstrap/6_comparing_CWM_methods.R b/scripts_for_ms_with_traitstrap/6_comparing_CWM_methods.R index e81825e..7524f0d 100644 --- a/scripts_for_ms_with_traitstrap/6_comparing_CWM_methods.R +++ b/scripts_for_ms_with_traitstrap/6_comparing_CWM_methods.R @@ -66,7 +66,7 @@ cowplot::ggdraw( geom_abline(aes(slope = 1, intercept = 0, linetype = "1:1 line"), - colour = "black") + + colour = "white") + geom_ribbon(data = cwm_CI, aes(x = traditional_CWM, ymin = ci_low, @@ -76,7 +76,7 @@ cowplot::ggdraw( aes(slope = grad, intercept = yint, linetype = "Regression slope"), - colour = "grey69", + colour = "grey60", alpha = 0.9) + geom_point(aes(x = traditional_CWM, y = bootstrap_CWM), @@ -87,7 +87,7 @@ cowplot::ggdraw( alpha = 0.5) + geom_point(aes(x = traditional_CWM, y = bootstrap_CWM), - colour = "grey69", + colour = "grey60", fill = NA, shape = 21, size = 2, @@ -121,7 +121,7 @@ cowplot::ggdraw( scale_linetype_manual("", values=c("1:1 line" = 2, "Regression slope" = 1), - guide = guide_legend(override.aes = list(colour = c("black","grey69")))) + + guide = guide_legend(override.aes = list(colour = c("white","grey60")))) + coord_cartesian(clip = "off") + theme_moon + theme(axis.ticks.length=unit(.5, "mm"), @@ -222,18 +222,18 @@ for (i in 1:length(samp_size)) { # Theme figure_theme + theme( - axis.text = element_text(color = "#5e5e5e", size = rel(.4)), - axis.title = element_text(color = "#5e5e5e", size = rel(.5)), - legend.text = element_text(color = "#5e5e5e", size = rel(.5)), - legend.title = element_text(color = "#5e5e5e", size = rel(.6)), + axis.text = element_text(color = "grey69", size = rel(.4)), + axis.title = element_text(color = "grey69", size = rel(.5)), + legend.text = element_text(color = "grey69", size = rel(.5)), + legend.title = element_text(color = "grey69", size = rel(.6)), strip.text.y = element_text(margin = margin(0, 0, 3, 0), size = rel(.6), face = "bold", - color = "#5e5e5e"), + color = "grey69"), strip.text.x.top = element_text(margin = margin(0, 0, 3, 0), size = rel(.6), - color = "#5e5e5e", face = "bold"), + color = "grey69", face = "bold"), panel.grid.major.y = element_line(size = 0.03, - color = "#5e5e5e"), + color = "grey69"), strip.background = element_blank(), axis.line = element_blank(), strip.placement = 'outside', @@ -242,7 +242,7 @@ for (i in 1:length(samp_size)) { plot.title.position = "panel", plot.title = element_text(margin = margin(0, 0, 10, 0), size = rel(.5), face = "bold", - color = "#5e5e5e"), + color = "grey69"), legend.position = 'bottom', plot.margin = margin(2, 2, 2, 2), legend.key.size = unit(3, "mm"), @@ -272,8 +272,8 @@ for (i in 1:length(samp_size)) { labs(title = "F: Bootstrap sample size: 1 600")) + plot_layout(guides = 'collect') + plot_annotation(theme = theme( - plot.background = element_rect(fill = "white", colour = NA), - panel.background = element_rect(fill = "white", colour = NA), + plot.background = element_rect(fill = "#141438", colour = NA), + panel.background = element_rect(fill = "#141438", colour = NA), legend.position = 'none') ) @@ -305,7 +305,7 @@ ggplot(bs_ci) + geom_line(aes(x = boot_sample_size, y = true_value, linetype = "True value"), - colour = 'grey30', + colour = 'grey90', size = 0.5) + geom_bump(aes(x = boot_sample_size, y = estimate, @@ -324,7 +324,7 @@ ggplot(bs_ci) + title.position="top", title.hjust = 0.5, override.aes = - list(colour = c("grey69","grey30")))) + + list(colour = c("grey69","grey90")))) + scale_colour_manual(guide = guide_legend(title = "Method", title.position="top", title.hjust = 0.5), diff --git a/scripts_for_ms_with_traitstrap/7_global_mean.R b/scripts_for_ms_with_traitstrap/7_global_mean.R index 1045f83..42acef9 100644 --- a/scripts_for_ms_with_traitstrap/7_global_mean.R +++ b/scripts_for_ms_with_traitstrap/7_global_mean.R @@ -27,7 +27,7 @@ global = TRUE ~ moment), method = case_when(method == 'global cwm' ~ 'Cross-Site CW', method == 'site-specic CWM' ~ 'Site-Specific CW', - method == 'nonparametric bs' ~ 'Non-Parametric BS', + method == 'nonparametric bs' ~ 'Nonparametric BS', method == 'parametric bs' ~ 'Parametric BS', TRUE ~ method)) %>% pivot_longer(cols = contains('true'), @@ -40,7 +40,7 @@ global = mutate(method = ordered(method,levels = c("Cross-Site CW", "Site-Specific CW", "Parametric BS", - "Non-Parametric BS"))) %>% + "Nonparametric BS"))) %>% left_join(., readRDS("data/elevations.RDS")) %>% distinct(trait_source, method, site, trait, moment, n, estimate, @@ -50,7 +50,7 @@ global = "skewness", "kurtosis"))) %>% filter(method %in% c("Cross-Site CW", - "Non-Parametric BS")) + "Nonparametric BS")) @@ -67,7 +67,7 @@ for (i in 1:length(trait_select)) { geom_line(aes(x = mean_elev, y = true_value, linetype = "True value"), - colour = "grey30", + colour = "grey69", size = 0.8) + geom_ribbon(data = global %>% filter(trait == trait_select[i]) %>% @@ -115,9 +115,9 @@ for (i in 1:length(trait_select)) { guide = guide_legend(title = "Data source", title.position="top", title.hjust = 0.5, - override.aes = list(colour = c("grey69", - "grey69", - "grey30"), + override.aes = list(colour = c("grey90", + "grey90", + "grey69"), size = 0.5))) + labs(x = "Elevation (m)", y = "Estimate") + @@ -151,8 +151,8 @@ global_plots[[1]] + strip.text.y = element_blank()) + plot_layout(guides = 'collect') + plot_annotation(theme = theme( - plot.background = element_rect(fill = "white", colour = NA), - panel.background = element_rect(fill = "white", colour = NA), + plot.background = element_rect(fill = "#141438", colour = NA), + panel.background = element_rect(fill = "#141438", colour = NA), legend.position = 'bottom')) ggsave(here::here("figures/Figure_4.png"), diff --git a/scripts_for_ms_with_traitstrap/8_simulation_comparison_by_trait.R b/scripts_for_ms_with_traitstrap/8_simulation_comparison_by_trait.R index d2b1041..3136206 100644 --- a/scripts_for_ms_with_traitstrap/8_simulation_comparison_by_trait.R +++ b/scripts_for_ms_with_traitstrap/8_simulation_comparison_by_trait.R @@ -25,7 +25,8 @@ sim_moon_means = group_by(method, moment, sample_size, trait) %>% #calcualte proportion of 'hits' per trait, methods, moment summarise(percentage = sum(hit - 1)/n(), - deviation = mean(abs(deviation))) + deviation = mean(abs(deviation))) %>% + filter(sample_size < 51) sim_moon_means_AZ = simdata_rats %>% @@ -37,26 +38,25 @@ sim_moon_means_AZ = #calcualte proportion of 'hits' per trait, methods, moment summarise(percentage = sum(hit - 1)/n(), deviation = mean(abs(deviation))) %>% - filter(sample_size %in% c(1,9,25,49,100,169)) %>% + filter(sample_size < 51) %>% mutate(trait = case_when(trait == "log10_weight" ~ "Weight")) #### Moon plots #### ggplot(sim_moon_means %>% - filter(sample_size %in% c(1,9,49,100,196,441) & - method == "Non-Parametric BS")) + + filter(method == "Nonparametric BS")) + geom_hline(aes(yintercept = 0), color = "grey50", size = 0.3) + - geom_smooth(data = sim_moon_means %>% - filter(sample_size %in% c(1,9,49,100,196,441)), + geom_smooth(data = sim_moon_means, aes( x = sample_size, y = deviation, color = method, linetype = method), se = FALSE, - size = 0.4) + + size = 0.4, + alpha = 0.5) + geom_point(aes( x = sample_size, y = deviation, @@ -83,8 +83,6 @@ ggplot(sim_moon_means %>% breaks = pal_df$l) + scale_linetype_manual(values=c(2,2,2,1), guide = guide_legend(override.aes = list(colour = "grey69"))) + - scale_x_continuous(trans = 'sqrt', breaks = c(0,10,50,100,200,500), - limits = c(0, 500)) + facet_grid(rows = vars(moment), cols = vars(trait), labeller = labeller( @@ -110,9 +108,11 @@ ggplot(sim_moon_means %>% legend.text = element_text(size = rel(.3)), legend.title = element_text(size = rel(.5)), strip.text.y = element_text(margin = margin(0, 0, 3, 0), - size = rel(.5), face = "bold"), + size = rel(.5), face = "bold", + colour = "grey69"), strip.text.x.top = element_text(margin = margin(0, 0, 3, 0), - size = rel(.5), face = "bold"), + size = rel(.5), face = "bold", + colour = "grey69"), panel.grid.major.y = element_line(size = 0.03), strip.background = element_blank(), axis.line = element_blank(), @@ -135,7 +135,7 @@ ggplot(sim_moon_means %>% align_to = 'full') + theme_void() + #AZ Rodents ggplot(sim_moon_means_AZ %>% - filter(method == "Non-Parametric BS")) + + filter(method == "Nonparametric BS")) + geom_hline(aes(yintercept = 0), color = "grey50", size = 0.3) + @@ -146,7 +146,8 @@ ggplot(sim_moon_means %>% color = method, linetype = method), se = FALSE, - size = 0.4) + + size = 0.4, + alpha = 0.5) + geom_point(aes( x = sample_size, y = deviation, @@ -173,8 +174,6 @@ ggplot(sim_moon_means %>% breaks = pal_df$l) + scale_linetype_manual(values=c(2,2,2,1), guide = guide_legend(override.aes = list(colour = "grey69"))) + - scale_x_continuous(trans = 'sqrt', breaks = c(0,10,50,100,200), - limits = c(0, 200)) + facet_grid(rows = vars(moment), cols = vars(trait), labeller = labeller( @@ -201,7 +200,8 @@ ggplot(sim_moon_means %>% legend.title = element_text(size = rel(.5)), strip.text.y = element_blank(), strip.text.x.top = element_text(margin = margin(0, 0, 3, 0), - size = rel(.5), face = "bold"), + size = rel(.5), face = "bold", + colour = "grey69"), panel.grid.major.y = element_line(size = 0.03), strip.background = element_blank(), axis.line = element_blank(), @@ -225,7 +225,7 @@ ggplot(sim_moon_means %>% plot_layout(guides = 'collect', widths = c(1, 0.21)) + plot_annotation(theme = theme( - plot.background = element_rect(fill = "white", colour = NA), + plot.background = element_rect(fill = "#141438", colour = NA), legend.position = 'bottom')) ggsave(here::here("figures/Figure_SI_8.png"), diff --git a/scripts_for_ms_with_traitstrap/plotting_aesthetics.R b/scripts_for_ms_with_traitstrap/plotting_aesthetics.R index 2f2b3b9..2dcfeaf 100644 --- a/scripts_for_ms_with_traitstrap/plotting_aesthetics.R +++ b/scripts_for_ms_with_traitstrap/plotting_aesthetics.R @@ -30,20 +30,20 @@ figure_theme = theme( panel.grid.minor = element_blank(), panel.grid.major.x = element_blank(), - panel.grid.major.y = element_line(size = 0.1, color = "#5e5e5e"), - axis.text = element_text(size = rel(.7)), + panel.grid.major.y = element_line(size = 0.1, color = "grey69"), + axis.text = element_text(color = "grey69", size = rel(.7)), axis.title= element_text(size = rel(.9)), axis.line = element_blank(), - axis.ticks = element_line(colour = colorspace::darken("#dddddd", 0.1), + axis.ticks = element_line(colour = "grey69", size = 0.3), - plot.background = element_rect(fill = "white", colour = NA), - panel.background = element_rect(fill = "white", colour = NA), - legend.background = element_rect(fill = "white", colour = NA), + plot.background = element_rect(fill = "#141438", colour = NA), + panel.background = element_rect(fill = "#141438", colour = NA), + legend.background = element_rect(fill = "#141438", colour = NA), legend.position = 'bottom', legend.key = element_blank(), legend.text = element_text(size = rel(.6)), legend.title = element_text(size = rel(.7)), - text = element_text(color = "#5e5e5e"), #font change + text = element_text(color = "grey69"), #font change plot.margin = margin(10, 5, 5, 10), legend.margin = margin(1, 2, 1, 2) ) @@ -54,20 +54,24 @@ figure_theme = theme_doughnut = theme_void() + theme( - plot.background = element_rect(fill = "white", + plot.background = element_rect(fill = "#141438", colour = NA), - panel.background = element_rect(fill = "white", + panel.background = element_rect(fill = "#141438", + colour = NA), + legend.background = element_rect(fill = "#141438", colour = NA), strip.text.y.left = element_text(margin = margin(0, 0, 10, 0), size = rel(1), face = "bold", vjust = 0, - angle = 0), + angle = 0, + colour = "grey69"), strip.text.x.top = element_text(margin = margin(0, 0, 10, 0), - size = rel(1),face = "bold"), + size = rel(1), face = "bold", + colour = "grey69"), legend.text = element_text(size = rel(.7)), legend.title = element_text(size = rel(.9)), plot.margin = margin(15, 15, 10, 15), legend.position = 'bottom', - text = element_text(color = "#5e5e5e"), + text = element_text(color = "grey69"), legend.key.size = unit(4, "mm") ) @@ -78,15 +82,17 @@ theme_moon = theme( legend.position = 'right', strip.text.y = element_text(margin = margin(0, 0, 10, 0), - size = rel(.9), face = "bold"), + size = rel(.9), face = "bold", + colour = "grey69"), strip.text.x.top = element_text(margin = margin(0, 0, 5, 0), size = rel(.9), - face = "bold"), + face = "bold", + colour = "grey69"), panel.grid.major.y = element_line(size = 0.05), strip.background = element_blank(), axis.line = element_blank(), strip.placement = 'outside', - panel.background = element_rect(colour = colorspace::darken("#dddddd", 0.1), + panel.background = element_rect(colour = colorspace::lighten("#141438", 0.2), size = 0.6), plot.title.position = "panel", plot.title = element_text(margin = margin(0, 0, 10, 0), @@ -98,13 +104,15 @@ theme_moon = theme_lollipop = figure_theme + theme(axis.text.y = element_blank(), - panel.background = element_rect(colour = colorspace::darken("#dddddd", 0.1), + panel.background = element_rect(colour = colorspace::lighten("#141438", 0.2), size = 0.6), strip.text.y.left = element_text(margin = margin(0, 2, 2, 0), size = rel(0.7), vjust = 0, - angle = 0), + angle = 0, + colour = "grey69"), strip.text.x.top = element_text(margin = margin(0, 0, 3, 0), - size = rel(1), face = "bold"), + size = rel(1), face = "bold", + colour = "grey69"), panel.grid.major.y = element_blank(), strip.background = element_blank(), axis.line = element_blank(), @@ -115,10 +123,10 @@ theme_lollipop = legend.title = element_text(size = rel(.9))) ##Colour palete---- -colors <- c("Cross-Site CW" = "#ff4ccc", - "Site-Specific CW" = "#4c79ff", - "Parametric BS" = "#90ff4c", - "Non-Parametric BS" = "#f3b155", +colors <- c("Cross-Site CW" = "#F235B0", + "Site-Specific CW" = "#65B4E6", + "Parametric BS" = "#D4F294", + "Nonparametric BS" = "#F29472", "True" = "#ACBAF5") # Join colors with categories @@ -170,11 +178,11 @@ moon_legend = size = rel(1.7)), plot.title.position = "panel") -moon_legend = png::readPNG("images/moons_legend.png", native = TRUE) +moon_legend = png::readPNG("images/moons_legend_light.png", native = TRUE) ## Inset images ---- -img1 = png::readPNG("images/Colorado_dark.png", native = TRUE) -img2 = png::readPNG("images/Frogs_dark.png", native = TRUE) -img3 = png::readPNG("images/Panama_dark.png", native = TRUE) -img4 = png::readPNG("images/AZ_dark.png", native = TRUE) -img5 = png::readPNG("images/Phyto_dark.png", native = TRUE) +img1 = png::readPNG("images/Colorado.png", native = TRUE) +img2 = png::readPNG("images/Frogs.png", native = TRUE) +img3 = png::readPNG("images/Panama.png", native = TRUE) +img4 = png::readPNG("images/AZ.png", native = TRUE) +img5 = png::readPNG("images/Phyto.png", native = TRUE)