Skip to content

Commit

Permalink
Se agrego tabla de promedio de modelos
Browse files Browse the repository at this point in the history
Esta tabla permite  visualizar los resultados de los promedio de modelo
  • Loading branch information
biorey committed Sep 20, 2024
1 parent 17453a7 commit 608c376
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
Binary file modified .DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion runners/r-dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM rocker/geospatial:4.4.1

# Additionnal R packages
RUN R -e 'install.packages(c("rjson", "RCurl", "rstac", "rgbif", "CoordinateCleaner", "dismo", "ENMeval", "gdalUtils", "ggsci", "landscapemetrics", "geodata", "rredlist", "gdalUtilities", "OpenStreetMap"))'
RUN R -e 'install.packages(c("rjson", "RCurl", "rstac", "rgbif", "CoordinateCleaner", "dismo", "ENMeval", "gdalUtils", "ggsci", "landscapemetrics", "geodata", "rredlist", "gdalUtilities", "OpenStreetMap", "nloptr", "MuMIn", "lme4", "unmarked", "AICcmodavg"))'
RUN R -e 'devtools::install_github("appelmar/gdalcubes_R")'
RUN R -e 'devtools::install_github("ReseauBiodiversiteQuebec/stac-catalogue")'
RUN R -e 'devtools::install_github("gearslaboratory/gdalUtils")'
Expand Down
18 changes: 14 additions & 4 deletions scripts/occ_model_resultsv3/occ_model_resultsv3.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Install necessary libraries - packages
packagesPrev<- installed.packages()[,"Package"] # Check and get a list of installed packages in this machine and R version
packagesNeed<-c("magrittr", "data.table", "tools", "Rcpp", "this.path", "rjson", "dplyr", "plyr", "raster", "terra", "auk",
"lme4", "minqa", "nloptr", "unmarked", "MuMIn", "VGAM", "AICcmodavg", "ggplot2", "janitor", "snakecase")
"lme4", "minqa", "nloptr", "unmarked", "MuMIn", "VGAM", "AICcmodavg", "ggplot2", "janitor", "snakecase", "knitr")
new.packages <- packagesNeed[!(packagesNeed %in% packagesPrev)]; if(length(new.packages)) {install.packages(new.packages, binary=T, force=T, dependencies = F, repos= "https://packagemanager.posit.co/cran/__linux__/jammy/latest")} # Check and install required packages that are not previously installed

# Load libraries
Expand Down Expand Up @@ -74,8 +74,13 @@ occ_model <- occu(formula_occ, data = occ_um, starts = start_vals)

occ_dredge <- MuMIn::dredge(occ_model)



# model comparison
#model_comparasion<- select(occ_dredge, starts_with("psi(p"), df, AICc, delta, weight) %>%
# dplyr::mutate_all(~ round(., 3)) %>%
# knitr::kable()
# model comparison
#write.csv(final, final_path, row.names = T ) # Write the 'val_wkt_path' output

#occ_dredge_delta <- MuMIn::get.models(occ_dredge, subset = delta <= 1000)

# average models based on model weights
Expand All @@ -84,7 +89,10 @@ occ_dredge <- MuMIn::dredge(occ_model)
occ_dredge_delta <- MuMIn::get.models(occ_dredge, subset = cumsum(weight) <= 1)

# average models based on model weights
# test models data frame
test_models_table<- file.path(outputFolder, "test_models.csv") # Define the file path for the 'val_wkt_path' output
test_models<- dplyr::filter(as.data.frame(occ_dredge), cumsum(weight) <= 1)
write.csv(test_models, test_models_table, row.names = T ) # Write the 'val_wkt_path' output

occ_avg<- if(nrow(test_models)<=1){
occ_dredge_delta[[1]]
Expand Down Expand Up @@ -282,6 +290,7 @@ occ_avg<- if(nrow(test_models)<=1){
#####
final_path<- file.path(outputFolder, "final.csv") # Define the file path for the 'val_wkt_path' output
write.csv(final, final_path, row.names = T ) # Write the 'val_wkt_path' output


summary_occ_path<- file.path(outputFolder, "summary_occModel.txt") # Define the file path for the 'val_wkt_path' output

Expand All @@ -294,7 +303,8 @@ occ_avg<- if(nrow(test_models)<=1){
occse_raster_export = occse_raster_path,
occPlotFacet= occPlotFacet_path,
final_export = final_path, VEB_export = FVEB,
summary_occ_path= summary_occ_path)
summary_occ_path= summary_occ_path,
test_models_table = test_models_table)



Expand Down
7 changes: 6 additions & 1 deletion scripts/occ_model_resultsv3/occ_model_resultsv3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ inputs:
type: boolean
example: false
outputs:
test_models:
label: test_models
description: "Summary of test models"
type: text/csv
summary_occ_path:
label: summary_occ_path
description: "Summary of ocupation model"
Expand All @@ -56,4 +60,5 @@ outputs:
VEB_export:
label: FVEB
description: "Result of Essential biodiversity variable in terms of Occupancy area VEB (Ψ>0.6)"
type: text
type: text

0 comments on commit 608c376

Please sign in to comment.