Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
CamilleLeclerc committed Jul 26, 2024
1 parent 00c84e5 commit 629910a
Show file tree
Hide file tree
Showing 20 changed files with 249 additions and 391 deletions.
Binary file not shown.
Binary file removed outputs/SEM/sem_effect_cold_lakes.rda
Binary file not shown.
Binary file removed outputs/SEM/sem_effect_moderate_lakes.rda
Binary file not shown.
Binary file removed outputs/SEM/sem_effect_warm_lakes.rda
Binary file not shown.
23 changes: 11 additions & 12 deletions rscripts/09_Computation_Mann-Kendall_temperature_trend_bioclim.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ daily_temp_okp = as.data.frame(daily_temp_okp)


##get read of useless symbols
daily_temp_okp$Lake_ID <- str_sub(daily_temp_okp$Lake_ID, start = 48, end = 52)
daily_temp_okp$Lake_ID <- str_sub(daily_temp_okp$Lake_ID, start = 25, end = 29)
daily_temp_okp$Lake_ID[daily_temp_okp$Lake_ID == "GRO21"] <- "GRO21b"
daily_temp_okp$Lake_ID[daily_temp_okp$Lake_ID == "LER27"] <- "LER27a"
head(daily_temp_okp)
Expand All @@ -54,7 +54,7 @@ daily_temp_okp <- daily_temp_okp %>% dplyr::select(Lake_ID, date, year, month, d
rm(list_of_files)


date_fish_sampling <- read.csv("./B_Thermal_trajectories/outputs/date_fish_sampling.txt", sep="")
date_fish_sampling <- read.csv("./outputs/date_fish_sampling.txt", sep="")
length(unique(date_fish_sampling$code_lac))


Expand Down Expand Up @@ -133,7 +133,6 @@ for(i in 1:nrow(date_fish_sampling)){
sub_monthly_temp_okp <- monthly_temp_okp %>% dplyr::filter(Lake_ID == date_fish_sampling[i, 1])
sub_monthly_temp_okp <- sub_monthly_temp_okp %>% dplyr::filter(date >= format(as.Date(ymd(date_fish_sampling$date_pose[i]) - years(period[j])), "%Y-%m"))
sub_monthly_temp_okp <- sub_monthly_temp_okp %>% dplyr::filter(date < format(as.Date(date_fish_sampling$date_pose[i]), "%Y-%m"))

sub_monthly_temp_okp$year2 <- rep(as.numeric(min(sub_monthly_temp_okp$year)):(max(as.numeric(max(sub_monthly_temp_okp$year)))-1), each = 12)
sub_monthly_temp_okp <- sub_monthly_temp_okp %>% dplyr::select(Lake_ID, date, year2, tmean.epi, tmin.epi, tmax.epi)
colnames(sub_monthly_temp_okp) <- c("Lake_ID", "date", "year", "tmean.epi", "tmin.epi", "tmax.epi")
Expand Down Expand Up @@ -340,13 +339,13 @@ colnames(temporal_trend_bio11) <- c("lake.code", "year.samp", "id.samp", "bio11.



datasetTempTrendBioclim40_258L <- left_join(temporal_trend_bio1, temporal_trend_bio2 %>% dplyr::select(id.samp, bio2.slope.50y, bio2.pvalue.50y), by = "id.samp")
datasetTempTrendBioclim40_258L <- left_join(datasetTempTrendBioclim40_258L, temporal_trend_bio3 %>% dplyr::select(id.samp, bio3.slope.50y, bio3.pvalue.50y), by = "id.samp")
datasetTempTrendBioclim40_258L <- left_join(datasetTempTrendBioclim40_258L, temporal_trend_bio4 %>% dplyr::select(id.samp, bio4.slope.50y, bio4.pvalue.50y), by = "id.samp")
datasetTempTrendBioclim40_258L <- left_join(datasetTempTrendBioclim40_258L, temporal_trend_bio5 %>% dplyr::select(id.samp, bio5.slope.50y, bio5.pvalue.50y), by = "id.samp")
datasetTempTrendBioclim40_258L <- left_join(datasetTempTrendBioclim40_258L, temporal_trend_bio6 %>% dplyr::select(id.samp, bio6.slope.50y, bio6.pvalue.50y), by = "id.samp")
datasetTempTrendBioclim40_258L <- left_join(datasetTempTrendBioclim40_258L, temporal_trend_bio7 %>% dplyr::select(id.samp, bio7.slope.50y, bio7.pvalue.50y), by = "id.samp")
datasetTempTrendBioclim40_258L <- left_join(datasetTempTrendBioclim40_258L, temporal_trend_bio10 %>% dplyr::select(id.samp, bio10.slope.50y, bio10.pvalue.50y), by = "id.samp")
datasetTempTrendBioclim40_258L <- left_join(datasetTempTrendBioclim40_258L, temporal_trend_bio11 %>% dplyr::select(id.samp, bio11.slope.50y, bio11.pvalue.50y), by = "id.samp")
datasetTempTrendBioclim40 <- left_join(temporal_trend_bio1, temporal_trend_bio2 %>% dplyr::select(id.samp, bio2.slope.50y, bio2.pvalue.50y), by = "id.samp")
datasetTempTrendBioclim40 <- left_join(datasetTempTrendBioclim40, temporal_trend_bio3 %>% dplyr::select(id.samp, bio3.slope.50y, bio3.pvalue.50y), by = "id.samp")
datasetTempTrendBioclim40 <- left_join(datasetTempTrendBioclim40, temporal_trend_bio4 %>% dplyr::select(id.samp, bio4.slope.50y, bio4.pvalue.50y), by = "id.samp")
datasetTempTrendBioclim40 <- left_join(datasetTempTrendBioclim40, temporal_trend_bio5 %>% dplyr::select(id.samp, bio5.slope.50y, bio5.pvalue.50y), by = "id.samp")
datasetTempTrendBioclim40 <- left_join(datasetTempTrendBioclim40, temporal_trend_bio6 %>% dplyr::select(id.samp, bio6.slope.50y, bio6.pvalue.50y), by = "id.samp")
datasetTempTrendBioclim40 <- left_join(datasetTempTrendBioclim40, temporal_trend_bio7 %>% dplyr::select(id.samp, bio7.slope.50y, bio7.pvalue.50y), by = "id.samp")
datasetTempTrendBioclim40 <- left_join(datasetTempTrendBioclim40, temporal_trend_bio10 %>% dplyr::select(id.samp, bio10.slope.50y, bio10.pvalue.50y), by = "id.samp")
datasetTempTrendBioclim40 <- left_join(datasetTempTrendBioclim40, temporal_trend_bio11 %>% dplyr::select(id.samp, bio11.slope.50y, bio11.pvalue.50y), by = "id.samp")

mysave(datasetTempTrendBioclim40_258L, dir = "./outputs/Temperature", overwrite = TRUE)
mysave(datasetTempTrendBioclim40, dir = "./outputs/Temperature", overwrite = TRUE)
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ daily_temp_okp = as.data.frame(daily_temp_okp)


##get read of useless symbols
daily_temp_okp$Lake_ID <- str_sub(daily_temp_okp$Lake_ID, start = 48, end = 52)
daily_temp_okp$Lake_ID <- str_sub(daily_temp_okp$Lake_ID, start = 25, end = 29)
daily_temp_okp$Lake_ID[daily_temp_okp$Lake_ID == "GRO21"] <- "GRO21b"
daily_temp_okp$Lake_ID[daily_temp_okp$Lake_ID == "LER27"] <- "LER27a"
head(daily_temp_okp)
Expand Down Expand Up @@ -218,13 +218,13 @@ rm(i, j, period)



datasetTempCurrentBioclim_258L <- left_join(bio1, bio2 %>% dplyr::select(id.samp, bio2.current), by = "id.samp")
datasetTempCurrentBioclim_258L <- left_join(datasetTempCurrentBioclim_258L, bio3 %>% dplyr::select(id.samp, bio3.current), by = "id.samp")
datasetTempCurrentBioclim_258L <- left_join(datasetTempCurrentBioclim_258L, bio4 %>% dplyr::select(id.samp, bio4.current), by = "id.samp")
datasetTempCurrentBioclim_258L <- left_join(datasetTempCurrentBioclim_258L, bio5 %>% dplyr::select(id.samp, bio5.current), by = "id.samp")
datasetTempCurrentBioclim_258L <- left_join(datasetTempCurrentBioclim_258L, bio6 %>% dplyr::select(id.samp, bio6.current), by = "id.samp")
datasetTempCurrentBioclim_258L <- left_join(datasetTempCurrentBioclim_258L, bio7 %>% dplyr::select(id.samp, bio7.current), by = "id.samp")
datasetTempCurrentBioclim_258L <- left_join(datasetTempCurrentBioclim_258L, bio10 %>% dplyr::select(id.samp, bio10.current), by = "id.samp")
datasetTempCurrentBioclim_258L <- left_join(datasetTempCurrentBioclim_258L, bio11 %>% dplyr::select(id.samp, bio11.current), by = "id.samp")
datasetTempCurrentBioclim <- left_join(bio1, bio2 %>% dplyr::select(id.samp, bio2.current), by = "id.samp")
datasetTempCurrentBioclim <- left_join(datasetTempCurrentBioclim, bio3 %>% dplyr::select(id.samp, bio3.current), by = "id.samp")
datasetTempCurrentBioclim <- left_join(datasetTempCurrentBioclim, bio4 %>% dplyr::select(id.samp, bio4.current), by = "id.samp")
datasetTempCurrentBioclim <- left_join(datasetTempCurrentBioclim, bio5 %>% dplyr::select(id.samp, bio5.current), by = "id.samp")
datasetTempCurrentBioclim <- left_join(datasetTempCurrentBioclim, bio6 %>% dplyr::select(id.samp, bio6.current), by = "id.samp")
datasetTempCurrentBioclim <- left_join(datasetTempCurrentBioclim, bio7 %>% dplyr::select(id.samp, bio7.current), by = "id.samp")
datasetTempCurrentBioclim <- left_join(datasetTempCurrentBioclim, bio10 %>% dplyr::select(id.samp, bio10.current), by = "id.samp")
datasetTempCurrentBioclim <- left_join(datasetTempCurrentBioclim, bio11 %>% dplyr::select(id.samp, bio11.current), by = "id.samp")

mysave(datasetTempCurrentBioclim_258L, dir = "./outputs/Temperature", overwrite = TRUE)
mysave(datasetTempCurrentBioclim, dir = "./outputs/Temperature", overwrite = TRUE)
2 changes: 1 addition & 1 deletion rscripts/10_Compute_native_vs_nonindigenous_diversity.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ colnames(df.speciestype) ; colnames(df.speciestype)[1] <- "species"

#--

myload(ind_size, dir = "data/IndividualSize")
myload(ind_size, dir = "outputs/IndividualSize")

head(ind_size)
df.fish <- ind_size %>% dplyr::select(id_campagne, species, fish)
Expand Down
6 changes: 3 additions & 3 deletions rscripts/11_Computation_community_size_spectra_binsmethod.R
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,6 @@ for(i in 1:length(id)){

rm(sub.df, size, SS.parameters, frequencytable)
}
CSSOLSfishcommunityBenthicPelagic <- CSSOLSfishcommunity
CSSOLSfrequencytableBenthicPelagic <- CSSOLSfrequencytable
mysave(CSSOLSfishcommunityBenthicPelagic, CSSOLSfrequencytableBenthicPelagic, dir = "./outputs/CommunitySizeSpectra", overwrite = TRUE)
CSSOLSfishcommunity <- CSSOLSfishcommunity
CSSOLSfrequencytable <- CSSOLSfrequencytable
mysave(CSSOLSfishcommunity, CSSOLSfrequencytable, dir = "./outputs/CommunitySizeSpectra", overwrite = TRUE)
4 changes: 2 additions & 2 deletions rscripts/12_SEManalysis.R
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,6 @@ data.effect$significant <- NA
data.effect$significant[data.effect$SymbSign == "*"] <- TRUE
data.effect$significant[data.effect$SymbSign == ""] <- FALSE
data.effect <- data.effect %>% mutate(position = if_else(Effect > 0, UpperCI + 0.02, LowerCI - 0.02))
#sem_effect_all_lakes <- data.effect
#mysave(sem_effect_all_lakes, dir = "outputs/SEM", overwrite = TRUE)
sem_effect_all_lakes <- data.effect
mysave(sem_effect_all_lakes, dir = "outputs/SEM", overwrite = TRUE)

49 changes: 9 additions & 40 deletions rscripts/13_Figure1.R
Original file line number Diff line number Diff line change
Expand Up @@ -72,44 +72,13 @@ coord <- dataset.thermal.trajectories %>%
bio1.slope.40y = mean(bio1.slope.40y),
bio1.current = mean(bio1.current))
str(coord)
coord.sf <- st_as_sf(coord, coords = c("long", "lat"), crs = 4326)
data <- bi_class(coord.sf, x = bio1.slope.40y, y = bio1.current, style = "quantile", dim = 4)


map <- ggplot() +
geom_sf(data = world_joined, fill = "white", color = "black", size = 0.05) +
geom_sf(data = francemap, fill = gray(0.9), color = "black", size = 0.25) +
geom_sf(data = francerivers, col = '#6baed6', size = 0.25) +
geom_sf(data = francelakes, col = '#6baed6', fill = '#6baed6', size = 0.05) +
geom_sf(data = data, mapping = aes(fill = bi_class), shape = 21, size = 2, color = "black", show.legend = FALSE) +
bi_scale_fill(pal = "Brown2", dim = 4) +
annotation_scale(location = "bl", width_hint = 0.1) +
annotation_north_arrow(which_north = "true", location = "tr", height = unit(0.5, "cm"), width = unit(0.5, "cm"), style = north_arrow_orienteering(fill = c("black", "black"), text_size = 6)) +
coord_sf(xlim = c(-5, 9.75), ylim = c(41.3, 51.5), expand = FALSE) +
map_theme +
theme(strip.background = element_rect(color = "black", size = 1, linetype = "solid"),
strip.text.x = element_text(size = 12, color = "black", face = "bold"),
panel.border = element_rect(colour = "black", fill = NA, size = 1)) + theme(legend.position = "none")
map
#4.5 x 4.5

legend <- bi_legend(pal = "Brown2",
dim = 4,
xlab = "bio1.slope.40y",
ylab = "bio1.current",
#rotate_pal = TRUE,
#flip_axes = TRUE,
size = 8)
ggdraw() + draw_plot(legend, 0.2, .65, 0.2, 0.2)
#"Bluegill", "BlueGold", "BlueOr", "BlueYl", "Brown"/"Brown2", "DkBlue"/"DkBlue2", "DkCyan"/"DkCyan2", "DkViolet"/"DkViolet2", "GrPink"/"GrPink2", "PinkGrn", "PurpleGrn", or "PurpleOr".


data$bio1.slope.40y <- data$bio1.slope.40y * 10 #in°C/dec
data$class.bio1.slope.40y <- NA
data$class.bio1.slope.40y[data$bio1.slope.40y < 0] <- "A"
data$class.bio1.slope.40y[data$bio1.slope.40y >= 0 & data$bio1.slope.40y < 0.25] <- "B"
data$class.bio1.slope.40y[data$bio1.slope.40y >= 0.25 & data$bio1.slope.40y < 0.50] <- "C"
data$class.bio1.slope.40y[data$bio1.slope.40y >= 0.50] <- "D"
coord <- st_as_sf(coord, coords = c("long", "lat"), crs = 4326)
coord$bio1.slope.40y <- coord$bio1.slope.40y * 10 #in°C/dec
coord$class.bio1.slope.40y <- NA
coord$class.bio1.slope.40y[coord$bio1.slope.40y < 0] <- "A"
coord$class.bio1.slope.40y[coord$bio1.slope.40y >= 0 & coord$bio1.slope.40y < 0.25] <- "B"
coord$class.bio1.slope.40y[coord$bio1.slope.40y >= 0.25 & coord$bio1.slope.40y < 0.50] <- "C"
coord$class.bio1.slope.40y[coord$bio1.slope.40y >= 0.50] <- "D"



Expand All @@ -118,7 +87,7 @@ map <- ggplot() +
geom_sf(data = francemap, fill = gray(0.9), color = "black", size = 0.25) +
geom_sf(data = francerivers, col = '#6baed6', size = 0.25) +
geom_sf(data = francelakes, col = '#6baed6', fill = '#6baed6', size = 0.05) +
geom_sf(data = data, mapping = aes(fill = bio1.current, shape = class.bio1.slope.40y), size = 2, color = "black", show.legend = FALSE) +
geom_sf(data = coord, mapping = aes(fill = bio1.current, shape = class.bio1.slope.40y), size = 2, color = "black", show.legend = FALSE) +
scale_shape_manual(values = c(25, 21, 22, 23)) +
scale_fill_continuous_sequential(palette = "Heat") +
annotation_scale(location = "bl", width_hint = 0.1) +
Expand Down Expand Up @@ -381,7 +350,7 @@ summary(mod.size)



plot_grid(pTemp, psizespecies,
plot_grid(map, psizespecies,
pslope, pmidpoint,
pconnect, pmaxtl,
labels = c("A", "B", "C", "D", "E", "F"),
Expand Down
Loading

0 comments on commit 629910a

Please sign in to comment.