From 6a9950915c2f8ae9018a507320361fb7cd1fd20d Mon Sep 17 00:00:00 2001 From: derek-corcoran-barrios Date: Tue, 6 Dec 2022 21:09:12 +0100 Subject: [PATCH] Last batch ready --- .Rproj.user/shared/notebooks/paths | 7 +++ DESCRIPTION | 2 +- README.Rmd | 4 ++ README.md | 65 ++++++++++++++++++++++- tests/testthat/test-CompareExtinctions.R | 2 +- tests/testthat/test-RandomExtinctions.R | 2 +- tests/testthat/test-SimulateExtinctions.R | 1 + 7 files changed, 78 insertions(+), 5 deletions(-) diff --git a/.Rproj.user/shared/notebooks/paths b/.Rproj.user/shared/notebooks/paths index e005ca9..9532df5 100644 --- a/.Rproj.user/shared/notebooks/paths +++ b/.Rproj.user/shared/notebooks/paths @@ -1,2 +1,9 @@ +/home/au687614/Documents/NetworkExtinction/DESCRIPTION="C6DA7162" +/home/au687614/Documents/NetworkExtinction/R/DataInit.R="14A5E109" /home/au687614/Documents/NetworkExtinction/R/Extintions.R="5517A387" /home/au687614/Documents/NetworkExtinction/README.Rmd="BEC06318" +/home/au687614/Documents/NetworkExtinction/tests/testthat/test-CompareExtinctions.R="6BE3E114" +/home/au687614/Documents/NetworkExtinction/tests/testthat/test-DegreeDistribution.R="F64CC0F8" +/home/au687614/Documents/NetworkExtinction/tests/testthat/test-ExtinctionOrder.R="4C836922" +/home/au687614/Documents/NetworkExtinction/tests/testthat/test-ExtinctionPlot.R="C28F2628" +/home/au687614/Documents/NetworkExtinction/tests/testthat/test-RandomExtinctions.R="DF2F622F" diff --git a/DESCRIPTION b/DESCRIPTION index da2efbd..838f2a6 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: NetworkExtinction Type: Package Title: Extinction Simulation in Ecological Networks -Version: 1.0.1 +Version: 1.0.2 Authors@R: c(person("Derek", "Corcoran", email = "derek.corcoran.barrios@gmail.com", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-0248-6230")), person("M. Isidora", "Ávila-Thieme", email = "msavila@uc.cl", role = c("aut"), comment = c(ORCID = "0000-0003-0772-4717")), person("Fernanda S.", "Valdovinos", role = c("aut")), person("Sergio A.", "Navarrete", role = c("aut")), diff --git a/README.Rmd b/README.Rmd index c583e67..c7352a9 100644 --- a/README.Rmd +++ b/README.Rmd @@ -5,6 +5,10 @@ bibliography: vignettes/biblio.bib + +[![DOI](https://zenodo.org/badge/116978043.svg)](https://zenodo.org/badge/latestdoi/116978043) + + ```{r, include = FALSE} knitr::opts_chunk$set( collapse = TRUE, diff --git a/README.md b/README.md index a75b609..faccf9c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ +[![DOI](https://zenodo.org/badge/116978043.svg)](https://zenodo.org/badge/latestdoi/116978043) + # NetworkExtinction # pkgdown @@ -63,7 +65,16 @@ history <- SimulateExtinctions(Network = net, Method = "Mostconnected") ExtinctionPlot(History = history[[1]], Variable = "AccSecExt") ``` +
+ Figure 3. The graph shows the number of accumulated secondary extinctions that occur when removing species from the most to the least connected species +

+Figure 3. The graph shows the number of accumulated secondary +extinctions that occur when removing species from the most to the least +connected species +

+ +
In addition, the list returned by `SimulateExtinctions()` also contains the final Network that remains after all primary extinctions have been @@ -85,7 +96,15 @@ SimulateExtinctions(Network = net, Order = 1:8, Method = "Ordered") Already at the removal of node 5, we loose support for all other species in the network. +
+ Figure 4. The graph shows the number of accumulated secondary extinctions that occur when removing species in a custom order. +

+Figure 4. The graph shows the number of accumulated secondary +extinctions that occur when removing species in a custom order. +

+ +
The results of this function are a dataframe with the topological indexes of the network calculated from each extinction step (Table 2), @@ -117,7 +136,14 @@ set.seed(707) RandomExtinctions(Network= net, nsim= 100, SimNum = 8) ``` +
+ Figure 5. The resulting graph of the RandomExtinctions function +

+Figure 5. The resulting graph of the RandomExtinctions function +

+ +
### Comparison of Null hypothesis with other extinction histories @@ -140,7 +166,16 @@ The result will be a graph (Figue 6) with a dashed line showing the observed extinction history and a solid line showing the expected value of secondary extinctions randomly generated. +
+ Figure 6. The resulting graph of the CompareExtinctions function, where the dashed line shows the observed extinction history, and a solid line shows the expected value of secondary extinctions originated at random +

+Figure 6. The resulting graph of the CompareExtinctions function, where +the dashed line shows the observed extinction history, and a solid line +shows the expected value of secondary extinctions originated at random +

+ +
## Plotting the extinction histories of a network @@ -155,13 +190,29 @@ data(net) ExtinctionPlot(History = Order[[1]]) ``` +
+ Figure 7. Example of the use of the ExtinctionPlot function showing the accumulated secondary extinctions against number of extinctions +

+Figure 7. Example of the use of the ExtinctionPlot function showing the +accumulated secondary extinctions against number of extinctions +

+ +
``` r ExtinctionPlot(History = Order[[1]], Variable = "Link_density") ``` +
+ Figure 8. Another example of the use of the ExtinctionPlot function showing the number of links per species against number of extinctions +

+Figure 8. Another example of the use of the ExtinctionPlot function +showing the number of links per species against number of extinctions +

+ +
## Degree distribution function @@ -185,7 +236,17 @@ data("chilean_intertidal") DegreeDistribution(chilean_intertidal) ``` +
+ Figure 9: Fitted vs observed values of the degree distribution. The black line and points show the observed values, the red, green and blue lines show the fitted values for the Exponential, power law and trucated distribution, respectively +

+Figure 9: Fitted vs observed values of the degree distribution. The +black line and points show the observed values, the red, green and blue +lines show the fitted values for the Exponential, power law and trucated +distribution, respectively +

+ +
| logLik | AIC | BIC | model | Normal.Resid | family | |----------:|-----------:|-----------:|:---------|:-------------|:------------| @@ -352,8 +413,8 @@ Rewiring <- SimulateExtinctions(Network = net, Order = 1:2, Method = "Ordered", | Spp | S | L | C | Link_density | Modularity | SecExt | Pred_release | Iso_nodes | AccSecExt | NumExt | TotalExt | |----:|----:|----:|----------:|-------------:|-----------:|-------:|-------------:|----------:|----------:|-------:|---------:| -| 1 | 9 | 9 | 0.1111111 | 1.0000000 | 0.2901235 | 1 | 1 | 0 | 1 | 1 | 2 | -| 2 | 7 | 6 | 0.1224490 | 0.8571429 | 0.0000000 | 2 | 1 | 0 | 3 | 2 | 5 | +| 1 | 9 | 9 | 0.1111111 | 1.000 | 0.2901235 | 0 | 0 | 0 | 0 | 1 | 1 | +| 2 | 8 | 7 | 0.1250000 | 0.875 | 0.3571429 | 1 | 1 | 0 | 1 | 2 | 3 | Table 7: The resulting dataframe of the rewiring version of SimulateExtinctions diff --git a/tests/testthat/test-CompareExtinctions.R b/tests/testthat/test-CompareExtinctions.R index bf25b4c..b7270cc 100644 --- a/tests/testthat/test-CompareExtinctions.R +++ b/tests/testthat/test-CompareExtinctions.R @@ -1,5 +1,5 @@ test_that("CompareExtinctions works", { - #skip_on_cran() + skip_on_cran() data("Less_Connected") expect_warning(History <- SimulateExtinctions(Network = Less_Connected, Method = "Mostconnected")) capture_warnings(NullHyp <- RandomExtinctions(Network = Less_Connected, nsim = 100)) diff --git a/tests/testthat/test-RandomExtinctions.R b/tests/testthat/test-RandomExtinctions.R index 95b11b9..43f73d2 100644 --- a/tests/testthat/test-RandomExtinctions.R +++ b/tests/testthat/test-RandomExtinctions.R @@ -1,5 +1,5 @@ test_that("RandomExtinctions works", { - #skip_on_cran() + skip_on_cran() capture_warnings(DF <- RandomExtinctions(Network = More_Connected, nsim = 20)$sims) expect_s3_class(DF, "data.frame") }) diff --git a/tests/testthat/test-SimulateExtinctions.R b/tests/testthat/test-SimulateExtinctions.R index b49557d..acc384b 100644 --- a/tests/testthat/test-SimulateExtinctions.R +++ b/tests/testthat/test-SimulateExtinctions.R @@ -1,4 +1,5 @@ test_that("SimulateExtinction works", { + skip_on_cran() capture_warnings(DF <- SimulateExtinctions(Network = NetworkExtinction::net, Method = "Mostconnected", clust.method = "cluster_infomap")$sims) expect_s3_class(DF, "data.frame")