| Title: | Food Web Construction for Paleo Communities |
|---|---|
| Description: | R tools for reconstructing paleo food webs from species traits and size rules. |
| Authors: | Tanya Strydom [aut, cre] (ORCID: <https://orcid.org/0000-0001-6067-1349>), Jack O. Shaw [ctb] (ORCID: <https://orcid.org/0000-0002-2725-2334>), Alexander M. Dunhill [ctb] (ORCID: <https://orcid.org/0000-0002-8680-9163>), Andrew Beckerman [ctb] (ORCID: <https://orcid.org/0000-0002-4797-9143>), Baran Karapunar [ctb] (ORCID: <https://orcid.org/0000-0001-9711-1492>), Jennifer A. Dunne [ctb] (ORCID: <https://orcid.org/0000-0002-3789-9561>), Pincelli M. Hull [ctb] (ORCID: <https://orcid.org/0000-0001-8607-4817>) |
| Maintainer: | Tanya Strydom <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 1.0.2 |
| Built: | 2026-06-04 14:28:20 UTC |
| Source: | https://github.com/beckslab/pfwim |
traits
A mock trait dataset using four trait classes specified in traits
to infer feeding interactions
A mock trait dataset using four trait classes specified in traits
to infer feeding interactions
feeding_rules feeding_rulesfeeding_rules feeding_rules
feeding_rulesA data frame with 7,240 rows and 60 columns:
broader resource trait class - i.e. column name in traits
specific resource trait class - i.e. row entry in trait column
broader consumer trait class - i.e. column name in traits
specific consumer trait class - i.e. row entry in trait column
...
feeding_rulesA data frame with 7,240 rows and 60 columns:
broader resource trait class - i.e. column name in traits
specific resource trait class - i.e. row entry in trait column
broader consumer trait class - i.e. column name in traits
specific consumer trait class - i.e. row entry in trait column
...
NA
NA
Infers a consumer–resource edgelist using categorical trait matching rules based on the PFWIM (Paleo Food Web Inference Model) described in Shaw (2024). Interactions are inferred by comparing resource and consumer trait combinations against a set of allowed trait rules.
infer_edgelist( data, cat_combo_list, col_taxon = "taxon", col_num_size = NULL, cat_trait_types = NULL, num_size_rule = NULL, certainty_req = "all", allow_self = TRUE, return_full_matrix = FALSE, print_dropped_taxa = FALSE, hide_printout = FALSE, ... )infer_edgelist( data, cat_combo_list, col_taxon = "taxon", col_num_size = NULL, cat_trait_types = NULL, num_size_rule = NULL, certainty_req = "all", allow_self = TRUE, return_full_matrix = FALSE, print_dropped_taxa = FALSE, hide_printout = FALSE, ... )
data |
A |
cat_combo_list |
A
|
col_taxon |
Character string indicating the column containing taxon
names in |
col_num_size |
Optional column name containing numerical size values for taxa. Used when applying a numeric predator–prey size rule. |
cat_trait_types |
Optional character vector specifying a subset of
categorical trait columns to use. If |
num_size_rule |
Optional function defining the predator–prey size
feasibility rule. The function must accept two numeric vectors:
Example:
|
certainty_req |
Defines how many trait rules must be satisfied for an interaction to be considered feasible.
|
allow_self |
Logical. If TRUE, allows interactions where the resource and consumer are the same taxon (self-loops). Default is FALSE. |
return_full_matrix |
Logical. If |
print_dropped_taxa |
Logical. If |
hide_printout |
Logical. If |
... |
Additional arguments reserved for future extensions. |
Trait matching is performed across all trait types present in
cat_combo_list. For each potential taxon pair, the number of satisfied
trait rules is calculated. An interaction is inferred when the number of
satisfied rules meets the required threshold defined by certainty_req.
Optionally, a numerical predator–prey size rule can also be applied using
num_size_rule.
The function evaluates all possible consumer–resource taxon pairs and determines interaction feasibility using categorical trait rules and, optionally, a numerical size constraint. The final edgelist includes only interactions meeting the certainty requirement.
If return_full_matrix = FALSE:
A two-column matrix containing:
Resource taxon
Consumer taxon
If return_full_matrix = TRUE:
A matrix containing all taxon pairs and the number of trait rules satisfied.
Shaw, J. (2024). PFWIM: Paleo Food web Inference Model. Preprint.
infer_edgelist( data = traits, cat_combo_list = feeding_rules, col_taxon = "species", certainty_req = "all" )infer_edgelist( data = traits, cat_combo_list = feeding_rules, col_taxon = "species", certainty_req = "all" )
PFWIM generates a series of replicate hypothetical realised food webs by reducing the feasible links for each consumer to match a target link distribution. The default distribution is a mixed exponential–power law in-degree distribution as described in Shaw (2024) and Roopnarine (2006).
powerlaw_prey( el, n_samp = 50, y = 2.5, func = function(r, M, y) exp(-r/(exp((y - 1) * (log(M)/y)))) )powerlaw_prey( el, n_samp = 50, y = 2.5, func = function(r, M, y) exp(-r/(exp((y - 1) * (log(M)/y)))) )
el |
Data frame or matrix containing a feasible consumer–resource edgelist. Column 1 = resource, Column 2 = consumer. |
n_samp |
Integer. Number of replicate realised webs to generate. Default = 50. |
y |
Numeric. Parameter controlling the shape of the power-law distribution. Default = 2.5. |
func |
Function. Probability function of the in-degree |
For each consumer in el, the number of prey links in a realised
web is sampled according to the distribution defined by func. The sampled
prey are drawn randomly without exceeding the maximum feasible prey for that
consumer.
A list of length n_samp. Each element is a data frame
representing a realised food web edgelist with two columns:
Resource species
Consumer species
Shaw, J. (2024). PFWIM: Paleo Food-web Inference Model. Preprint. Roopnarine, P. (2006). Palaeoecology and food-web structure in fossil communities.
# Infer a minimal edgelist edgelist <- infer_edgelist( data = data.frame( species = c("plankton","plant_1","plant_2","cod","rat","deer"), feeding = c("primary","primary","primary","secondary","secondary","secondary") ), cat_combo_list = data.frame( trait_type_resource = c("feeding","feeding","feeding"), trait_resource = c("primary","primary","primary"), trait_type_consumer = c("feeding","feeding","feeding"), trait_consumer = c("secondary","secondary","secondary") ), col_taxon = "species", certainty_req = "all" ) # Generate realized webs webs <- powerlaw_prey(edgelist, n_samp = 3, y = 2.5)# Infer a minimal edgelist edgelist <- infer_edgelist( data = data.frame( species = c("plankton","plant_1","plant_2","cod","rat","deer"), feeding = c("primary","primary","primary","secondary","secondary","secondary") ), cat_combo_list = data.frame( trait_type_resource = c("feeding","feeding","feeding"), trait_resource = c("primary","primary","primary"), trait_type_consumer = c("feeding","feeding","feeding"), trait_consumer = c("secondary","secondary","secondary") ), col_taxon = "species", certainty_req = "all" ) # Generate realized webs webs <- powerlaw_prey(edgelist, n_samp = 3, y = 2.5)
A mock trait dataset using four trait classes to determine interactions
as specified in feeding_rules
traitstraits
traitsA data frame with 7,240 rows and 60 columns:
species name
motility class of species
habitat species found in
trophic level of species
categorical size classes
...
NA