Skip to content

Commit

Permalink
Merge pull request #2 from NiklasHohmann/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
NiklasHohmann authored Aug 22, 2024
2 parents 7237b5d + 4ed77b6 commit 4ee0106
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 43 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
.Ruserdata

# don't track csv files
*.csv
*.csv
*.pdf
15 changes: 11 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.10782803.svg)](https://doi.org/10.5281/zenodo.10782803)

Supplementary code for _"A revised marine fossil record of the Mediterranean before and after the Messinian Salinity Crisis"_. Generates summary statistics and maps.
Supplementary code for _"A revised marine fossil record of the Mediterranean before and after the Messinian Salinity Crisis"_ (Agiadi et al 2024, [DOI: 10.5194/essd-2024-75](https://doi.org/10.5194/essd-2024-75)). Generates summary statistics, figures, and maps.

Project webpage: [REMARE project](https://sites.google.com/view/kagiadi/projects/remare)

Expand Down Expand Up @@ -51,7 +51,7 @@ source("code/download_data.R")
to download the latest version of the database from Zenodo. Then, run

```R
source("code/make_table.R")
source("code/make_table_and_plots.R")
```

in the console to produce the summary statistics of the database (stored in the variable `table`). You can view the values by running
Expand All @@ -60,12 +60,12 @@ in the console to produce the summary statistics of the database (stored in the
table
```

in the console. Details on producing the map are given in the file `code/make_maps.R`.
in the console, and inspect the figures in `figs/`. Details on producing the map are given in the file `code/make_maps.R`.

## Repository structure

* _code_ : folder with R code
* _make_table.R_ : script to generate table 1
* _make_table_and_plots.R_ : script to generate table 1 and figures
* _make_maps.R_ : script to generate the maps
* _download_data.R_ : script to download data from Zenodo
* _data_ : folder for raw data. Initially empty, will be filled with downloaded data after the script in `code/download_data.R` is run.
Expand All @@ -77,6 +77,13 @@ in the console. Details on producing the map are given in the file `code/make_ma
* _README_ : README file
* _renv.lock_ : lock file for `renv` package

## References

This repository downloads and uses data from

* Agiadi, K., Hohmann, N., Gliozzi, E., Thivaiou, D., Francesca, B., Taviani, M., Bianucci, G., Collareta, A., Londeix, L., Faranda, C., Bulian, F., Koskeridou, E., Lozar, F., Mancini, A. M., Dominici, S., Moissette, P., Bajo Campos, I., Borghi, E., Iliopoulos, G., … Garcia-Castellanos, D. (2024). Revised marine fossil record of the Mediterranean before and after the Messinian Salinity Crisis [Data set]. Zenodo. https://doi.org/10.5281/zenodo.13358435


## Funding

This work was supported by the Austrian Science Fund (FWF) project “Late Miocene Mediterranean Marine Ecosystem Crisis” (2022–2026), Project no. V 986, [DOI 10.55776/V986](https://www.doi.org/10.55776/V986) (PI: K.Agiadi).
3 changes: 2 additions & 1 deletion code/download_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# download latest version of the database from Zenodo, https://doi.org/10.5281/zenodo.12698765

cat("Downloading raw data\n")
zen4R::download_zenodo("10.5281/zenodo.12698765", path = "data/")

zen4R::download_zenodo("10.5281/zenodo.13358435", path = "data/")

cat("Data successfully downloaded! \n")
37 changes: 37 additions & 0 deletions code/make_table.R → code/make_table_and_plots.R
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,40 @@ table["total", "families"] <- sum(table[group_names,"families"])
table

cat("Table successfully generated!\n")

#### make plots ####
library(ggplot2)
cat("Creating plots\n")
## plot occurrences
make_occ_plot = function(file_name){
df = data.frame(group = rep(group_names, each = 3),
regions = rep(regions, length(group_names)),
nocc = rep(NA, length(regions) * length(group_names)))
for (i in seq_len(nrow(df))){
df[i, "nocc"] = length(unique(messinian_db$ID[messinian_db$group.name == df$group[i] & messinian_db$region.new == df$regions[i]]))
}
ggplot(df, aes(x = group, fill = regions, y = nocc)) +
geom_bar(stat = "identity", position = "dodge") +
theme_classic()
ggsave(file_name)
}
make_occ_plot("figs/occ.pdf")

make_loc_plot = function(file_name){
df = data.frame(group = rep(group_names, each = 3),
regions = rep(regions, length(group_names)),
nloc = rep(NA, length(regions) * length(group_names)))
for (i in seq_len(nrow(df))){
df[i, "nloc"] = length(unique(messinian_db$Locality[messinian_db$group.name == df$group[i] & messinian_db$region.new == df$regions[i]]))
}

ggplot(df, aes(x = group, y = nloc, fill = regions)) +
geom_bar(position = position_dodge(), stat = "identity") +
theme_classic()
ggsave(file_name)
}
make_loc_plot("figs/locs.pdf")



cat("Plots are in figs/ \n")
78 changes: 41 additions & 37 deletions renv.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"R": {
"Version": "4.3.2",
"Version": "4.4.1",
"Repositories": [
{
"Name": "CRAN",
Expand All @@ -22,7 +22,7 @@
},
"MASS": {
"Package": "MASS",
"Version": "7.3-60",
"Version": "7.3-61",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
Expand All @@ -33,11 +33,11 @@
"stats",
"utils"
],
"Hash": "a56a6365b3fa73293ea8d084be0d9bb0"
"Hash": "0cafd6f0500e5deba33be22c46bf6055"
},
"Matrix": {
"Package": "Matrix",
"Version": "1.6-4",
"Version": "1.7-0",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
Expand All @@ -50,7 +50,7 @@
"stats",
"utils"
],
"Hash": "d9c655b30a2edc6bb2244c1d1e8d549d"
"Hash": "1920b2f11133b12350024297d8a4ff4a"
},
"R6": {
"Package": "R6",
Expand All @@ -74,14 +74,14 @@
},
"Rcpp": {
"Package": "Rcpp",
"Version": "1.0.12",
"Version": "1.0.13",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
"methods",
"utils"
],
"Hash": "5ea2700d21e038ace58269ecdbeb9ec0"
"Hash": "f27411eb6d9c3dada5edd444b8416675"
},
"XML": {
"Package": "XML",
Expand Down Expand Up @@ -180,10 +180,10 @@
},
"bitops": {
"Package": "bitops",
"Version": "1.0-7",
"Version": "1.0-8",
"Source": "Repository",
"Repository": "CRAN",
"Hash": "b7d8d8ee39869c18d8846a184dd8a1af"
"Hash": "da69e6b6f8feebec0827205aad3fdbd8"
},
"blob": {
"Package": "blob",
Expand Down Expand Up @@ -226,7 +226,7 @@
},
"bslib": {
"Package": "bslib",
"Version": "0.7.0",
"Version": "0.8.0",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
Expand All @@ -244,7 +244,7 @@
"rlang",
"sass"
],
"Hash": "8644cc53f43828f19133548195d7e59e"
"Hash": "b299c6741ca9746fb227debcb0f9fb6c"
},
"cachem": {
"Package": "cachem",
Expand Down Expand Up @@ -305,7 +305,7 @@
},
"colorspace": {
"Package": "colorspace",
"Version": "2.1-0",
"Version": "2.1-1",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
Expand All @@ -315,7 +315,7 @@
"methods",
"stats"
],
"Hash": "f20c47fd52fae58b4e377c37bb8c335b"
"Hash": "d954cb1c57e8d8b756165d7ba18aa55a"
},
"commonmark": {
"Package": "commonmark",
Expand Down Expand Up @@ -423,14 +423,14 @@
},
"digest": {
"Package": "digest",
"Version": "0.6.36",
"Version": "0.6.37",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
"R",
"utils"
],
"Hash": "fd6824ad91ede64151e93af67df6376b"
"Hash": "33698c4b3127fc9f506654607fb73676"
},
"dplyr": {
"Package": "dplyr",
Expand Down Expand Up @@ -1040,7 +1040,7 @@
},
"nlme": {
"Package": "nlme",
"Version": "3.1-165",
"Version": "3.1-166",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
Expand All @@ -1050,17 +1050,17 @@
"stats",
"utils"
],
"Hash": "2769a88be217841b1f33ed469675c3cc"
"Hash": "ccbb8846be320b627e6aa2b4616a2ded"
},
"openssl": {
"Package": "openssl",
"Version": "2.2.0",
"Version": "2.2.1",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
"askpass"
],
"Hash": "2bcca3848e4734eb3b16103bc9aa4b8e"
"Hash": "c62edf62de70cadf40553e10c739049d"
},
"pillar": {
"Package": "pillar",
Expand Down Expand Up @@ -1233,7 +1233,7 @@
},
"rdflib": {
"Package": "rdflib",
"Version": "0.2.8",
"Version": "0.2.9",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
Expand All @@ -1245,7 +1245,7 @@
"tidyr",
"utils"
],
"Hash": "7aabe63f0e0a33190643e25ba9dd3774"
"Hash": "7d812c4fa75df359492a135421fa0c12"
},
"readr": {
"Package": "readr",
Expand Down Expand Up @@ -1317,9 +1317,12 @@
"renv": {
"Package": "renv",
"Version": "1.0.7",
"OS_type": null,
"Repository": "CRAN",
"Source": "Repository"
"Source": "Repository",
"Repository": "RSPM",
"Requirements": [
"utils"
],
"Hash": "397b7b2a265bc5a7a06852524dabae20"
},
"reprex": {
"Package": "reprex",
Expand Down Expand Up @@ -1356,7 +1359,7 @@
},
"rmarkdown": {
"Package": "rmarkdown",
"Version": "2.27",
"Version": "2.28",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
Expand All @@ -1375,7 +1378,7 @@
"xfun",
"yaml"
],
"Hash": "27f9502e1cdbfa195f94e03b0f517484"
"Hash": "062470668513dcda416927085ee9bdc7"
},
"roxygen2": {
"Package": "roxygen2",
Expand Down Expand Up @@ -1666,13 +1669,13 @@
},
"tinytex": {
"Package": "tinytex",
"Version": "0.51",
"Version": "0.52",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
"xfun"
],
"Hash": "d44e2fcd2e4e076f0aac540208559d1d"
"Hash": "cfbad971a71f0e27cec22e544a08bc3b"
},
"tzdb": {
"Package": "tzdb",
Expand All @@ -1697,13 +1700,13 @@
},
"uuid": {
"Package": "uuid",
"Version": "1.2-0",
"Version": "1.2-1",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
"R"
],
"Hash": "303c19bfd970bece872f93a824e323d9"
"Hash": "34e965e62a41fcafb1ca60e9b142085b"
},
"vctrs": {
"Package": "vctrs",
Expand Down Expand Up @@ -1757,27 +1760,28 @@
},
"withr": {
"Package": "withr",
"Version": "3.0.0",
"Version": "3.0.1",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
"R",
"grDevices",
"graphics"
],
"Hash": "d31b6c62c10dcf11ec530ca6b0dd5d35"
"Hash": "07909200e8bbe90426fbfeb73e1e27aa"
},
"xfun": {
"Package": "xfun",
"Version": "0.45",
"Version": "0.47",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
"R",
"grDevices",
"stats",
"tools"
],
"Hash": "ca59c87fe305b16a9141a5874c3a7889"
"Hash": "36ab21660e2d095fef0d83f689e0477c"
},
"xml2": {
"Package": "xml2",
Expand All @@ -1794,10 +1798,10 @@
},
"yaml": {
"Package": "yaml",
"Version": "2.3.9",
"Version": "2.3.10",
"Source": "Repository",
"Repository": "CRAN",
"Hash": "9cb28d11799d93c953f852083d55ee9e"
"Hash": "51dab85c6c98e50a18d7551e9d49f76c"
},
"zen4R": {
"Package": "zen4R",
Expand Down Expand Up @@ -1825,7 +1829,7 @@
"Package": "zip",
"Version": "2.3.1",
"Source": "Repository",
"Repository": "RSPM",
"Repository": "CRAN",
"Hash": "fcc4bd8e6da2d2011eb64a5e5cc685ab"
}
}
Expand Down

0 comments on commit 4ee0106

Please sign in to comment.