Skip to content

Commit

Permalink
🧪 first pass at some quantitative stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
TanyaS08 committed Feb 16, 2024
1 parent 9297d5b commit acabd56
Show file tree
Hide file tree
Showing 14 changed files with 113 additions and 9 deletions.
4 changes: 2 additions & 2 deletions _freeze/index/execute-results/docx.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions _freeze/index/execute-results/html.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions _freeze/index/execute-results/tex.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions _freeze/index/execute-results/xml.json

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions _freeze/notebooks/model_quantitative/execute-results/html.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"hash": "3c02c0ae4e362950344da631f9cb2eb3",
"result": {
"engine": "knitr",
"markdown": "---\ntitle: Quantitative approach to topology generators\nauthor: Tanya Strydom\nbibliography: ../references.bib\n---\n\n\nI think in the long run I will probably turn the other repo ([BecksLab/topology_generators](https://github.com/BecksLab/topology_generators)) into a project that we can then access and I will port all of the working code here... I think it will just come down to what the 'cost' is of the computational side of things and how convoluted it might end up looking.\n\nAnyway so for now I am just pulling in the INTERIM data from some of the models. This uses (for now) 20 mangal [@poisotMangalMakingEcological2016] datasets and just generates some networks for using the niche and cascade models. The 'results' for now is just counting the number of links each model generates for each network because that's what my brain decided on doing...\n\n\n::: {.cell .hidden}\n\n```{.r .cell-code .hidden}\n#| include: false\n#| echo: false\nlibrary(tidyverse)\n```\n\n::: {.cell-output .cell-output-stderr .hidden}\n\n```\n── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──\n✔ dplyr 1.1.4 ✔ readr 2.1.5\n✔ forcats 1.0.0 ✔ stringr 1.5.1\n✔ ggplot2 3.4.4 ✔ tibble 3.2.1\n✔ lubridate 1.9.3 ✔ tidyr 1.3.1\n✔ purrr 1.0.2 \n── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──\n✖ dplyr::filter() masks stats::filter()\n✖ dplyr::lag() masks stats::lag()\nℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors\n```\n\n\n:::\n\n```{.r .cell-code .hidden}\n#| include: false\n#| echo: false\n# download file from other repo\ndownload.file(\"https://raw.githubusercontent.com/BecksLab/topology_generators/main/data/topology_summary.csv\", \"notebooks/data/topology_models.csv\")\n```\n\n::: {.cell-output .cell-output-stderr .hidden}\n\n```\nWarning in\ndownload.file(\"https://raw.githubusercontent.com/BecksLab/topology_generators/main/data/topology_summary.csv\",\n: URL\nhttps://raw.githubusercontent.com/BecksLab/topology_generators/main/data/topology_summary.csv:\ncannot open destfile 'notebooks/data/topology_models.csv', reason 'No such file\nor directory'\n```\n\n\n:::\n\n::: {.cell-output .cell-output-stderr .hidden}\n\n```\nWarning in\ndownload.file(\"https://raw.githubusercontent.com/BecksLab/topology_generators/main/data/topology_summary.csv\",\n: download had nonzero exit status\n```\n\n\n:::\n\n```{.r .cell-code .hidden}\n#| include: false\n#| echo: false\ndf = read.csv(\"data/topology_models.csv\")\n```\n:::\n\n\nLets just do a simple little plot where we plot real vs model observed\n\n\n::: {#cell-fig-topology .cell}\n\n```{.r .cell-code .hidden}\n#| echo: false\n#| label: fig-topology\n#| fig-cap: \"Real vs observed values for network summary statistics\"\n#| fig-alt: \"TODO\"\nggplot() +\n geom_abline(slope = 1,\n intercept = 0) +\n geom_point(data = df,\n aes(x = links,\n y = niche_links),\n fill = \"blue\",\n shape = 21,\n alpha = 0.7,\n size = 5) +\n geom_point(data = df,\n aes(x = links,\n y = cascade_links),\n fill = \"green\",\n shape = 23,\n alpha = 0.7,\n size = 5) +\n theme_bw()\n```\n\n::: {.cell-output-display}\n![Real vs observed values for network summary statistics](model_quantitative_files/figure-html/fig-topology-1.png){#fig-topology fig-alt='TODO' width=672}\n:::\n:::\n\n\n## References {.unnumbered}\n\n::: {#refs}\n:::",
"supporting": [
"model_quantitative_files"
],
"filters": [
"rmarkdown/pagebreak.lua"
],
"includes": {},
"engineDependencies": {},
"preserve": {},
"postProcess": true
}
}
17 changes: 17 additions & 0 deletions _freeze/notebooks/model_quantitative/execute-results/xml.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"hash": "3c02c0ae4e362950344da631f9cb2eb3",
"result": {
"engine": "knitr",
"markdown": "---\ntitle: Quantitative approach to topology generators\nauthor: Tanya Strydom\nbibliography: ../references.bib\n---\n\n\n\n\nI think in the long run I will probably turn the other repo ([BecksLab/topology_generators](https://github.com/BecksLab/topology_generators)) into a project that we can then access and I will port all of the working code here... I think it will just come down to what the 'cost' is of the computational side of things and how convoluted it might end up looking.\n\nAnyway so for now I am just pulling in the INTERIM data from some of the models. This uses (for now) 20 mangal [@poisotMangalMakingEcological2016] datasets and just generates some networks for using the niche and cascade models. The 'results' for now is just counting the number of links each model generates for each network because that's what my brain decided on doing...\n\n\n\n\n::: {.cell .hidden}\n\n```{.r .cell-code .hidden}\n#| include: false\n#| echo: false\nlibrary(tidyverse)\n```\n\n::: {.cell-output .cell-output-stderr .hidden}\n\n```\n── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──\n✔ dplyr 1.1.4 ✔ readr 2.1.5\n✔ forcats 1.0.0 ✔ stringr 1.5.1\n✔ ggplot2 3.4.4 ✔ tibble 3.2.1\n✔ lubridate 1.9.3 ✔ tidyr 1.3.1\n✔ purrr 1.0.2 \n── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──\n✖ dplyr::filter() masks stats::filter()\n✖ dplyr::lag() masks stats::lag()\nℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors\n```\n\n\n:::\n\n```{.r .cell-code .hidden}\n#| include: false\n#| echo: false\n# download file from other repo\ndownload.file(\"https://raw.githubusercontent.com/BecksLab/topology_generators/main/data/topology_summary.csv\", \"notebooks/data/topology_models.csv\")\n```\n\n::: {.cell-output .cell-output-stderr .hidden}\n\n```\nWarning in\ndownload.file(\"https://raw.githubusercontent.com/BecksLab/topology_generators/main/data/topology_summary.csv\",\n: URL\nhttps://raw.githubusercontent.com/BecksLab/topology_generators/main/data/topology_summary.csv:\ncannot open destfile 'notebooks/data/topology_models.csv', reason 'No such file\nor directory'\n```\n\n\n:::\n\n::: {.cell-output .cell-output-stderr .hidden}\n\n```\nWarning in\ndownload.file(\"https://raw.githubusercontent.com/BecksLab/topology_generators/main/data/topology_summary.csv\",\n: download had nonzero exit status\n```\n\n\n:::\n\n```{.r .cell-code .hidden}\n#| include: false\n#| echo: false\ndf = read.csv(\"data/topology_models.csv\")\n```\n:::\n\n\n\n\nLets just do a simple little plot where we plot real vs model observed\n\n\n\n\n::: {#cell-fig-topology .cell}\n\n```{.r .cell-code .hidden}\n#| echo: false\n#| label: fig-topology\n#| fig-cap: \"Real vs observed values for network summary statistics\"\n#| fig-alt: \"TODO\"\nggplot() +\n geom_abline(slope = 1,\n intercept = 0) +\n geom_point(data = df,\n aes(x = links,\n y = niche_links),\n fill = \"blue\",\n shape = 21,\n alpha = 0.7,\n size = 5) +\n geom_point(data = df,\n aes(x = links,\n y = cascade_links),\n fill = \"green\",\n shape = 23,\n alpha = 0.7,\n size = 5) +\n theme_bw()\n```\n\n::: {.cell-output-display}\n![Real vs observed values for network summary statistics](model_quantitative_files/figure-jats/fig-topology-1.png){#fig-topology fig-alt='TODO'}\n:::\n:::\n\n\n\n\n## References {.unnumbered}\n\n::: {#refs}\n:::",
"supporting": [
"model_quantitative_files/figure-jats"
],
"filters": [
"rmarkdown/pagebreak.lua"
],
"includes": {},
"engineDependencies": {},
"preserve": null,
"postProcess": false
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 7 additions & 1 deletion index.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ At some point we are going to need to discuss the key differences and implicatio

**Trait-based** [@caronAddressingEltonianShortfall2022]:

**Graph embedding** [@strydomFoodWebReconstruction2022; @strydomGraphEmbeddingTransfer2023]: At a high level graph embedding focuses on capturing the structural data of a network as opposed to a list of pairwise (*i.e.,* mechanistic) interactions. Here specifically the embedding is preformed on a known interaction network and captures information as to where species (nodes) are positioned in a network *e.g.,* are they basal prey species or top predators, similar to the log ratio model. In @strydomFoodWebReconstruction2022 the products of the embedding process are fed into a transfer leanring framework for novel prediction...
**Graph embedding** [@strydomFoodWebReconstruction2022; @strydomGraphEmbeddingTransfer2023]: At a high level graph embedding focuses on capturing the structural data of a network as opposed to a list of pairwise (*i.e.,* mechanistic) interactions. Here specifically the embedding is preformed on a known interaction network and captures information as to where species (nodes) are positioned in a network *e.g.,* are they basal prey species or top predators, similar to the log ratio model. In @strydomFoodWebReconstruction2022 the products of the embedding process are fed into a transfer learning framework for novel prediction...

I know tables are awful but in this case they may make more sense. Also I don't think I'm at the point where I can say that the table is complete/comprehensive but it getting there Not sure about putting in some papers that have used the model - totes happy to drop those I think...

Expand Down Expand Up @@ -164,6 +164,12 @@ How we want to compare and contrast. I think there won't be a 'winner' and thus

{{< embed notebooks/model_qualitative.qmd#fig-venn >}}

### Quantitative stuff

{{< embed notebooks/model_quantitative.qmd#fig-topology >}}

This is actually an awful way to try and summarise the data but rolling with it for now...

## Discussion

I think a big take home will (hopefully) be how different approaches do better in different situations and so you as an end user need to take this into consideration and pick accordingly. I think @petcheyFitEfficiencyBiology2011 might have (and share) some thoughts on this (thanks Andrew). I feel like I need to look at @berlowGoldilocksFactorFood2008 but maybe not exactly in this context but vaguely adjacent.
Expand Down
11 changes: 11 additions & 0 deletions notebooks/data/topology_models.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
id,richness,links,connectance,niche_links,cascade_links
19,1327,9334,0.005300611211468492,9572,9292
12,101,150,0.014704440741103813,182,152
13,54,92,0.03155006858710562,99,100
18,29,38,0.04518430439952437,43,30
15,280,950,0.01211734693877551,929,970
3259,20,50,0.125,58,56
908,43,63,0.03407247160627366,75,58
23,19,20,0.055401662049861494,24,28
909,100,192,0.0192,208,186
946,96,343,0.03721788194444445,368,363
53 changes: 53 additions & 0 deletions notebooks/model_quantitative.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
title: Quantitative approach to topology generators
author: Tanya Strydom
bibliography: ../references.bib
---

I think in the long run I will probably turn the other repo ([BecksLab/topology_generators](https://github.com/BecksLab/topology_generators)) into a project that we can then access and I will port all of the working code here... I think it will just come down to what the 'cost' is of the computational side of things and how convoluted it might end up looking.

Anyway so for now I am just pulling in the INTERIM data from some of the models. This uses (for now) 20 mangal [@poisotMangalMakingEcological2016] datasets and just generates some networks for using the niche and cascade models. The 'results' for now is just counting the number of links each model generates for each network because that's what my brain decided on doing...

```{r}
#| include: false
#| echo: false
library(tidyverse)
# download file from other repo
download.file("https://raw.githubusercontent.com/BecksLab/topology_generators/main/data/topology_summary.csv", "notebooks/data/topology_models.csv")
df = read.csv("data/topology_models.csv")
```

Lets just do a simple little plot where we plot real vs model observed

```{r}
#| echo: false
#| label: fig-topology
#| fig-cap: "Real vs observed values for network summary statistics"
#| fig-alt: "TODO"
ggplot() +
geom_abline(slope = 1,
intercept = 0) +
geom_point(data = df,
aes(x = links,
y = niche_links),
fill = "blue",
shape = 21,
alpha = 0.7,
size = 5) +
geom_point(data = df,
aes(x = links,
y = cascade_links),
fill = "green",
shape = 23,
alpha = 0.7,
size = 5) +
theme_bw()
```

## References {.unnumbered}

::: {#refs}
:::

0 comments on commit acabd56

Please sign in to comment.