---
title: "SuppMat 2: Looking at the 'traits' of the different model families"
authors:
  - name: Tanya Strydom
    id: ts
    orcid: 0000-0001-6067-1349
abstract: |
  The purpose of this document is to provide a rationalisation but also 'formalisation' of the different model families of sorts. This starts of by trying to construct a 'traits' table that focuses on what the resulting network is (is it a prediction of structure or is it a prediction of interactions), how the resulting network is encoded (*i.e.,* its anatomy) as well as trying to identify what type of data are needed to 'parametrise' the model. Finally we take this traits table and feed it into a hierarchical clustering model to sort of see how our broader *a priori* ideas of models being either topology generators or interaction predictors.
date: last-modified
bibliography: ../references.bib
---

Understanding the rationale of the traits table is perhaps the most crucial thing though so I will try and elaborate on some of the 'categories' that I have selected and provide a very high-level glossary of terms. Many of these categories are the product of discussions we've hard and this is an attempt to articulate those discussions in a more categorical manner.

First. What the model is predicting. Is it the structure of a network, interactions between species, or their co-occurrence patterns.

Second. What does the network represent. Is it a conceptual network (*i.e.,* cannot be assigned to specific community/geographic location), metaweb (network of potential interactions), realised network, or a 'metacommunity' (collection of co-occurring species).

Third. What is the underlying mechanism that determines the interactions between species. This is an attempt at trying to code what is discussed in Box 1 of the main text but a bit more related to the 'computational' mechanism and not the 'ecological' mechanism. Note here that the use of mathematical is used to refer to a framework that uses some sort of mathematical formalisation to determine interactions/structure, unlike 'statistical' which is attempting to find and apply a pattern to determine interactions.

Fourth. What do the links represent - this is much more aligned with Box 1 in the main text

Fifth. What do the nodes represent. Note here that 'agnostic' means that there is no node-level metadata for the species/the information at the species level is not ecologically meaningful.

Sixth. The ecological theory as to what constrains links (again Box 1 in the main text)

Seventh. How the interactions quantified

Eight. What are the data sources needed for each model.

```{r}
#| include: false
#| warning: false
suppressPackageStartupMessages(library(tidyverse))
library(gt)
library(ggdendro)

options(warn = -1)

# this is the clustering code
source("scripts/hierarchy_cluster.R")

trait_tbl <-
  read.csv("data/traits_table.csv")  %>% 
  tibble()
```

## Model family traits table

We can visualise these eight 'character traits' as a table 

```{r}
#| warning: false
#| echo: false
#| label: tbl-traits
#| tbl-cap: "Traits table for the different model families"

trait_tbl %>% 
  gt(
    rowname_col = "trait") %>% 
  sub_missing(
    missing_text = "") %>% 
  tab_spanner(
    label = "Network generators",
    columns = c(null, neutral, resource, generative)) %>% 
  tab_spanner(
    label = "Interaction predictors",
    columns = c(energetic, embedding, classifiers, matching, expert, scavenging))  %>%
  tab_row_group(
    label = "What is predicted?",
    id = "predicts",
    rows = trait_grp == "predicts"
  ) %>%
  tab_row_group(
    label = "What is the generated network representing?",
    id = "scale",
    rows = trait_grp == "scale"
  ) %>% 
  tab_row_group(
    label = "What is the underlying mechanism that determines links?",
    id = "mechanism",
    rows = trait_grp == "mechanism"
  ) %>%
  tab_row_group(
    label = "What do the links between nodes represent?",
    id = "links",
    rows = trait_grp == "links"
  ) %>%
  tab_row_group(
    label = "Is there information at the node level?",
    id = "nodes",
    rows = trait_grp == "nodes"
  ) %>%
  tab_row_group(
    label = "What type of interactions are predicted?",
    id = "interactions",
    rows = trait_grp == "interactions"
  ) %>%
  tab_row_group(
    label = "What constrains how links are determined between nodes?",
    id = "constraints",
    rows = trait_grp == "constraints"
  ) %>% 
  tab_row_group(
    label = "What data is needed to generate the network?",
    id = "data",
    rows = trait_grp %in% c("data_edge", "data_node", "data_meta", "data_network")
  ) %>% 
  row_group_order(
    groups = c("predicts", "scale", "mechanism", "links", "nodes", "constraints", 
      "interactions", "data"))  %>% 
  tab_style(
    style = cell_text(weight = "bold"),
    locations = cells_row_groups()) %>% 
  tab_style(
    style = cell_fill(color = "bisque"),
    locations = cells_row_groups()) %>% 
  cols_hide(columns = trait_grp) %>% 
  cols_align(
    align = "center",
    columns = everything()) %>% 
  opt_row_striping(row_striping = FALSE)

```

## Visualisation

![Dendrogram of the trait table using a hierarchical clustering model, This is based off of the traits table in SuppMat 2)](../images/dendo.png){#fig-dendro}

## References {.unnumbered}

::: {#refs}
:::