Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified figures/Figure_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified figures/Figure_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified figures/Figure_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified figures/Figure_4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified figures/Figure_5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified figures/Figure_SI_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified figures/Figure_SI_10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified figures/Figure_SI_11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified figures/Figure_SI_12.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified figures/Figure_SI_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified figures/Figure_SI_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified figures/Figure_SI_4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified figures/Figure_SI_5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified figures/Figure_SI_6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified figures/Figure_SI_7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified figures/Figure_SI_8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified figures/Figure_SI_9.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed figures/Figures.zip
Binary file not shown.
Binary file modified figures/pdf/Figure_2.pdf
Binary file not shown.
Binary file modified figures/pdf/Figure_3.pdf
Binary file not shown.
Binary file modified figures/pdf/Figure_4.pdf
Binary file not shown.
Binary file modified figures/pdf/Figure_5.pdf
Binary file not shown.
Binary file modified figures/pdf/Figure_SI_1.pdf
Binary file not shown.
Binary file modified figures/pdf/Figure_SI_10.pdf
Binary file not shown.
Binary file modified figures/pdf/Figure_SI_11.pdf
Binary file not shown.
Binary file modified figures/pdf/Figure_SI_12.pdf
Binary file not shown.
Binary file modified figures/pdf/Figure_SI_2.pdf
Binary file not shown.
Binary file modified figures/pdf/Figure_SI_3.pdf
Binary file not shown.
Binary file modified figures/pdf/Figure_SI_4.pdf
Binary file not shown.
Binary file modified figures/pdf/Figure_SI_5.pdf
Binary file not shown.
Binary file modified figures/pdf/Figure_SI_6.pdf
Binary file not shown.
Binary file modified figures/pdf/Figure_SI_7.pdf
Binary file not shown.
Binary file modified figures/pdf/Figure_SI_8.pdf
Binary file not shown.
Binary file modified figures/pdf/Figure_SI_9.pdf
Binary file not shown.
Binary file added images/moons_legend_light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/traitstrap_hex.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions r_functions/tidy_simdata.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ 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) %>%
select(-c(global, true_moment, ci_low_moment, ci_high_moment)) %>%
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"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) +
Expand Down Expand Up @@ -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))
+
Expand Down Expand Up @@ -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))

Expand Down Expand Up @@ -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)

14 changes: 7 additions & 7 deletions scripts_for_ms_with_traitstrap/3_distrubution_figure.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"))

Expand All @@ -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",
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -421,6 +424,7 @@ rodent_percent$moment =
"skewness",
"kurtosis"))


#### Combine CO and AZ ----

data <- vector('list', 2)
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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"),
Expand Down
4 changes: 2 additions & 2 deletions scripts_for_ms_with_traitstrap/5_plankton_timeseries.R
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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(
Expand Down
32 changes: 16 additions & 16 deletions scripts_for_ms_with_traitstrap/6_comparing_CWM_methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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),
Expand All @@ -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,
Expand Down Expand Up @@ -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"),
Expand Down Expand Up @@ -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',
Expand All @@ -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"),
Expand Down Expand Up @@ -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')
)

Expand Down Expand Up @@ -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,
Expand All @@ -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),
Expand Down
18 changes: 9 additions & 9 deletions scripts_for_ms_with_traitstrap/7_global_mean.R
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand All @@ -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,
Expand All @@ -50,7 +50,7 @@ global =
"skewness",
"kurtosis"))) %>%
filter(method %in% c("Cross-Site CW",
"Non-Parametric BS"))
"Nonparametric BS"))



Expand All @@ -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]) %>%
Expand Down Expand Up @@ -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") +
Expand Down Expand Up @@ -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"),
Expand Down
Loading