Skip to content

Commit

Permalink
Merge branch 'derek-corcoran-barrios:master' into ErikDevel
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikKusch authored Dec 6, 2022
2 parents baa0f47 + bf24e0b commit 603d874
Show file tree
Hide file tree
Showing 9 changed files with 96 additions and 6,196 deletions.
7 changes: 7 additions & 0 deletions .Rproj.user/shared/notebooks/paths
Original file line number Diff line number Diff line change
@@ -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"
5 changes: 3 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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 = "[email protected]",
role = c("aut", "cre"), comment = c(ORCID = "0000-0002-0248-6230")), person("M. Isidora", "Ávila-Thieme", email = "[email protected]",
role = c("aut"), comment = c(ORCID = "0000-0003-0772-4717")), person("Fernanda S.", "Valdovinos", role = c("aut")), person("Sergio A.", "Navarrete", role = c("aut")),
Expand All @@ -21,6 +21,7 @@ Suggests:
knitr,
rmarkdown,
pkgdown,
testthat (>= 3.0.0)
testthat (>= 3.0.0),
covr
VignetteBuilder: knitr
Config/testthat/edition: 3
6,189 changes: 0 additions & 6,189 deletions NetworkExtinction-report.html

This file was deleted.

7 changes: 6 additions & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ bibliography: vignettes/biblio.bib

<!-- README.md is generated from README.Rmd. Please edit that file -->

<!-- badges: start -->
[![DOI](https://zenodo.org/badge/116978043.svg)](https://zenodo.org/badge/latestdoi/116978043)

<!-- badges: end -->

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
Expand All @@ -20,7 +25,7 @@ knitr::opts_chunk$set(

# pkgdown <img src="pkgdown/favicon/apple-touch-icon-180x180.png" align="right" />

<!-- badges: start -->


The goal of NetworkExtinction is to Simulate the extinction of species in the food web and to analyze its cascading effects, as described in Dunne et al. (2002) \doi{10.1073/pnas.192407699}

Expand Down
65 changes: 63 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

<!-- README.md is generated from README.Rmd. Please edit that file -->

[![DOI](https://zenodo.org/badge/116978043.svg)](https://zenodo.org/badge/latestdoi/116978043)

# NetworkExtinction

# pkgdown <img src="pkgdown/favicon/apple-touch-icon-180x180.png" align="right" />
Expand Down Expand Up @@ -63,7 +65,16 @@ history <- SimulateExtinctions(Network = net, Method = "Mostconnected")
ExtinctionPlot(History = history[[1]], Variable = "AccSecExt")
```

<div class="figure">

<img src="man/figures/README-mostconnected3-1.png" alt="Figure 3. The graph shows the number of accumulated secondary extinctions that occur when removing species from the most to the least connected species" width="100%" />
<p class="caption">
Figure 3. The graph shows the number of accumulated secondary
extinctions that occur when removing species from the most to the least
connected species
</p>

</div>

In addition, the list returned by `SimulateExtinctions()` also contains
the final Network that remains after all primary extinctions have been
Expand All @@ -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.

<div class="figure">

<img src="man/figures/README-unnamed-chunk-5-1.png" alt="Figure 4. The graph shows the number of accumulated secondary extinctions that occur when removing species in a custom order." width="100%" />
<p class="caption">
Figure 4. The graph shows the number of accumulated secondary
extinctions that occur when removing species in a custom order.
</p>

</div>

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

<div class="figure">

<img src="man/figures/README-unnamed-chunk-8-1.png" alt="Figure 5. The resulting graph of the RandomExtinctions function" width="100%" />
<p class="caption">
Figure 5. The resulting graph of the RandomExtinctions function
</p>

</div>

### Comparison of Null hypothesis with other extinction histories

Expand All @@ -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.

<div class="figure">

<img src="man/figures/README-unnamed-chunk-10-1.png" alt="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" width="100%" />
<p class="caption">
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
</p>

</div>

## Plotting the extinction histories of a network

Expand All @@ -155,13 +190,29 @@ data(net)
ExtinctionPlot(History = Order[[1]])
```

<div class="figure">

<img src="man/figures/README-unnamed-chunk-11-1.png" alt="Figure 7. Example of the use of the ExtinctionPlot function showing the accumulated secondary extinctions against number of extinctions" width="100%" />
<p class="caption">
Figure 7. Example of the use of the ExtinctionPlot function showing the
accumulated secondary extinctions against number of extinctions
</p>

</div>

``` r
ExtinctionPlot(History = Order[[1]], Variable = "Link_density")
```

<div class="figure">

<img src="man/figures/README-unnamed-chunk-12-1.png" alt="Figure 8. Another example of the use of the ExtinctionPlot function showing the number of links per species against number of extinctions" width="100%" />
<p class="caption">
Figure 8. Another example of the use of the ExtinctionPlot function
showing the number of links per species against number of extinctions
</p>

</div>

## Degree distribution function

Expand All @@ -185,7 +236,17 @@ data("chilean_intertidal")
DegreeDistribution(chilean_intertidal)
```

<div class="figure">

<img src="man/figures/README-unnamed-chunk-15-1.png" alt="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" width="100%" />
<p class="caption">
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
</p>

</div>

| logLik | AIC | BIC | model | Normal.Resid | family |
|----------:|-----------:|-----------:|:---------|:-------------|:------------|
Expand Down Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
comment: false

coverage:
status:
project:
default:
target: auto
threshold: 1%
informational: true
patch:
default:
target: auto
threshold: 1%
informational: true
2 changes: 1 addition & 1 deletion tests/testthat/test-CompareExtinctions.R
Original file line number Diff line number Diff line change
@@ -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))
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-RandomExtinctions.R
Original file line number Diff line number Diff line change
@@ -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")
})
1 change: 1 addition & 0 deletions tests/testthat/test-SimulateExtinctions.R
Original file line number Diff line number Diff line change
@@ -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")
Expand Down

0 comments on commit 603d874

Please sign in to comment.