Title: | Handling and Representing Trophic Networks in Space and Time |
---|---|
Description: | A toolbox to handle and represent trophic networks in space or time across aggregation levels. This package contains a layout algorithm specifically designed for trophic networks, using dimension reduction on a diffusion graph kernel and trophic levels. Importantly, this package provides a layout method applicable for large trophic networks. The package also implements network diversity indices at different aggregation levels and connectance computation. |
Authors: | Marc Ohlmann [aut, cre] , Jimmy Garnier [aut, ctb], Laurent Vuillon [aut, ctb] |
Maintainer: | Marc Ohlmann <[email protected]> |
License: | GPL-3 |
Version: | 0.8.0 |
Built: | 2024-11-26 04:23:02 UTC |
Source: | https://github.com/marcohlmann/metanetwork |
Like dplyr, metanetwork also uses the pipe function, %>%
to turn
function composition into a series of imperative statements.
an object of the class of the output of the last called method/function
library(metanetwork) data("meta_angola") meta_angola %>% attach_layout() %>% ggmetanet()
library(metanetwork) data("meta_angola") meta_angola %>% attach_layout() %>% ggmetanet()
Method to append aggregated metawebs and local networks using
the hierarchy described in trophicTable
append_agg_nets(metanetwork) ## S3 method for class 'metanetwork' append_agg_nets(metanetwork)
append_agg_nets(metanetwork) ## S3 method for class 'metanetwork' append_agg_nets(metanetwork)
metanetwork |
object of class 'metanetwork' |
It uses the network aggregation method developed in Ohlmann et al. 2019. It computes group abundances and edge probabilities of the aggregated networks.
an object of class 'metanetwork', with aggregated networks appended to the network list.
NULL
Ohlmann, M., Miele, V., Dray, S., Chalmandrier, L., O connor, L., & Thuiller, W. 2019. Diversity indices for ecological networks: a unifying framework using Hill numbers. Ecology letters, 22 4 , 737-747.
library(metanetwork) data(meta_angola) meta_angola = append_agg_nets(meta_angola) names(meta_angola)
library(metanetwork) data(meta_angola) meta_angola = append_agg_nets(meta_angola) names(meta_angola)
Method to compute 'TL-tsne'
and 'group-TL-tsne'
layouts and save it as node attributes of the focal network.
attach_layout( metanetwork, g = NULL, beta = 0.1, mode = "TL-tsne", TL_tsne.config = TL_tsne.default, res = NULL, group_layout.config = group_layout.default ) ## S3 method for class 'metanetwork' attach_layout( metanetwork, g = NULL, beta = 0.1, mode = "TL-tsne", TL_tsne.config = TL_tsne.default, res = NULL, group_layout.config = group_layout.default )
attach_layout( metanetwork, g = NULL, beta = 0.1, mode = "TL-tsne", TL_tsne.config = TL_tsne.default, res = NULL, group_layout.config = group_layout.default ) ## S3 method for class 'metanetwork' attach_layout( metanetwork, g = NULL, beta = 0.1, mode = "TL-tsne", TL_tsne.config = TL_tsne.default, res = NULL, group_layout.config = group_layout.default )
metanetwork |
object of class 'metanetwork' |
g |
character indicating the name of the network for which the 'TL-tsne' layout is computed, default is 'metaweb' |
beta |
the diffusion parameter of the diffusion kernel, a positive scalar controlling the squeezing of the network, default is 0.1 |
mode |
'TL-tsne' or 'group-TL-tsne', default is 'TL-tsne'. |
TL_tsne.config |
configuration list for mode 'TL-tsne', default is TL_tsne.default |
res |
resolution for the 'group-TL-tsne' layout |
group_layout.config |
configuration list for mode 'group-TL-tsne', default is group_layout.default |
The 'TL-tsne'
layout is a diffusion based layout algorithm specifically designed for trophic networks.
In metanetwork, first axis is the trophic level (see compute_TL
method) whereas the second axis is computed using a diffusion graph kernel (Kondor & Lafferty 2002)
and tsne dimension reduction algorithm to (see van der Maaten & Hinton (2008) and 'tsne' R package).
Let be the adjacency matrix of the considered network and
its degree diagonal matrix.
The Laplacian matrix of the symmetrised network is defined by:
The diffusion graph kernel is:
It is a similarity matrix between nodes according to a diffusion process. beta
is the diffusion constant,it must be provided by the user.
beta
parameter influences the layout by grouping together similar paths (see pyramid
vignette).
Each node of the focal network has an attribute layout_beta_VALUE
.
If this function is run several times for a given beta value, repetitions of the layout algorithm will be stored as node attributes.
The 'group-TL-tsne'
layout is a variation of 'TL-tsne
layout. For a focal network, it mixes 'TL-tsne'
layout at the desired aggregated level
with the layout_with_graphopt
function from igraph
. It clusters nodes belonging to the same group.
'group-TL-tsne'
layout is recommended for large networks since you only need to compute 'TL-tsne'
at the aggregated network
that is much smaller than the focal network. group_layout.config
allows controlling the overall size of the groups.
an object of class 'metanetwork', with the computed layout added as node attribute of the considered network
NULL
Kondor, R. I., & Lafferty, J. (2002, July). Diffusion kernels on graphs and other discrete structures. In Proceedings of the 19th international conference on machine learning (Vol. 2002, pp. 315-322). Van der Maaten, L., & Hinton, G. (2008). Visualizing data using t-SNE. Journal of machine learning research, 9(11).
ggmetanet()
, vismetaNetwork()
,group_layout.default
library(metanetwork) library(igraph) # on angola dataset (metaweb) data("meta_angola") meta_angola = attach_layout(meta_angola,beta = 0.05) V(meta_angola$metaweb)$layout_beta0.05
library(metanetwork) library(igraph) # on angola dataset (metaweb) data("meta_angola") meta_angola = attach_layout(meta_angola,beta = 0.05) V(meta_angola$metaweb)$layout_beta0.05
Build metanetwork object
build_metanet( metaweb, abTable = NULL, trophicTable = NULL, compute_local_nets = TRUE )
build_metanet( metaweb, abTable = NULL, trophicTable = NULL, compute_local_nets = TRUE )
metaweb |
metaweb of the metanetwork, object of class 'graph', 'matrix', 'data.frame' or 'dgCMatrix'. Metaweb needs to be directed and connected. This argument must be non-null. |
abTable |
node abundances in local networks, matrix of class 'matrix', columns must have names corresponding to node labels of the metaweb, rows are node abundances in local networks. Default is null, in that case, uniform abundances are assigned |
trophicTable |
a 'matrix' or 'data.frame' indicating hierarchy of the nodes. Names of the columns correspond to the different resolutions. It indicates the membership of each node of the metaweb. Default is null. |
compute_local_nets |
a boolean, indicates whether local networks must be computed or not.
Default is |
an object of S3 class 'metanetwork'
library(metanetwork) library(igraph) #with a single metaweb g = igraph::make_ring(5,directed = TRUE) meta = build_metanet(g) #on Angola dataset (re-building the dataset) data("meta_angola") metaweb = meta_angola$metaweb abTable = meta_angola$abTable trophicTable = meta_angola$trophicTable meta_angola = build_metanet(metaweb,abTable,trophicTable) print(meta_angola)
library(metanetwork) library(igraph) #with a single metaweb g = igraph::make_ring(5,directed = TRUE) meta = build_metanet(g) #on Angola dataset (re-building the dataset) data("meta_angola") metaweb = meta_angola$metaweb abTable = meta_angola$abTable trophicTable = meta_angola$trophicTable meta_angola = build_metanet(metaweb,abTable,trophicTable) print(meta_angola)
Function to compute pairwise network dissimilarity indices based on Hill numbers following the method described in Ohlmann et al. 2019
compute_dis(metanetwork, q = 1, res = NULL, ncores = 4)
compute_dis(metanetwork, q = 1, res = NULL, ncores = 4)
metanetwork |
object of class 'metanetwork' |
q |
viewpoint parameter controlling the weight given to abundant species/groups and links, default is 1 |
res |
a vector containing the resolutions at which the diversities are computed |
ncores |
number of cores used for the computation, default is 4 |
This function compute pairwise dissimilarity indices using Hill numbers on node and link abundances. Importantly, a viewpoint parameters allows giving more weigth to abundant nodes/links. Given a network, we note
the abundance of node
(stored as node attribute
ab
) and interaction probability between nodes
and
(stored as edge attribute
weight
). The link abundance between nodes
and
is then:
Node diversity (for ) is then computed as:
Link diversity is computed as:
where is the weighted connectance
For , the pairwise node dissimilarity indices are computed from pairwise diversities as:
where is node
-diversity and
the node
-diversity
Pairwise link diversity is:
where is the link
-diversity and
the link
-diversity
For more details on -,
- and
-diversity, see Ohlmann et al. 2019.
a list of data.frame
containing node and link pairwise dissimilarities
Ohlmann, M., Miele, V., Dray, S., Chalmandrier, L., O'connor, L., & Thuiller, W. (2019). Diversity indices for ecological networks: a unifying framework using Hill numbers. Ecology letters, 22(4), 737-747.
library(metanetwork) library(igraph) #on angola dataset data(meta_angola) compute_dis(meta_angola,q = 1,ncores = 1) #computing dissimilarities only at Phylum level compute_dis(meta_angola,q = 1,res = "Phylum",ncores = 1)
library(metanetwork) library(igraph) #on angola dataset data(meta_angola) compute_dis(meta_angola,q = 1,ncores = 1) #computing dissimilarities only at Phylum level compute_dis(meta_angola,q = 1,res = "Phylum",ncores = 1)
Function to compute network diversity indices based on Hill numbers following the method described in Ohlmann et al. 2019
compute_div(metanetwork, q = 1, res = NULL)
compute_div(metanetwork, q = 1, res = NULL)
metanetwork |
object of class 'metanetwork' |
q |
viewpoint parameter controlling the weight given to abundant species/groups and links, default is 1 |
res |
a vector containing the resolutions at which the diversities are computed |
This function compute diversity indices using Hill numbers on node and link abundances. Importantly, a viewpoint parameters allows giving more weigth to abundant nodes/links. Given a network, we note
the abundance of node
(stored as node attribute
ab
) and interaction probability between nodes
and
(stored as edge attribute
weight
). The link abundance between nodes
and
is then:
Node diversity (for ) is then computed as:
Link diversity is computed as:
where is the weighted connectance
The overall -diversity in node abundances is (for
):
The overall -diversity in node abundances is (for
):
where
The overall
-diversities in link abundances and link probabilities are equal to:
where .
The
-diversity in node and link abundances are (for
):
The -diversity is then defined in a multiplicative way:
For more details on -,
- and
-diversity, see Ohlmann et al. 2019.
a data.frame
Ohlmann, M., Miele, V., Dray, S., Chalmandrier, L., O'connor, L., & Thuiller, W. (2019). Diversity indices for ecological networks: a unifying framework using Hill numbers. Ecology letters, 22(4), 737-747.
library(metanetwork) library(igraph) #on angola dataset data("meta_angola") compute_div(meta_angola,q = 1) #computing diversities only at Phylum level compute_div(meta_angola,q = 1,res = "Phylum")
library(metanetwork) library(igraph) #on angola dataset data("meta_angola") compute_div(meta_angola,q = 1) #computing diversities only at Phylum level compute_div(meta_angola,q = 1,res = "Phylum")
Function to compute (some) network metrics on the metaweb and local networks
compute_metrics(metanetwork, res = NULL)
compute_metrics(metanetwork, res = NULL)
metanetwork |
object of class 'metanetwork' |
res |
a vector containing the resolutions at which the metrics are computed |
This function computes network metrics for the metaweb and local networks at the available resolutions. This function computes the following metrics:
weighted connectance: connectance weighted by abundances and link probability (see Ohlmann et al. 2019)
Denoting abundance of node
and
the interaction probability between nodes
and
, then the weighted connectance
is:
mean_TL and max_TL: mean and max trophic level of each network, using values computed from compute_TL() method.
mean_shortest_path_length: mean shortest path lenght of each network computed using igraph mean_distance() function.
a data.frame
Csardi, G., & Nepusz, T. (2006). The igraph software package for complex network research. InterJournal, complex systems, 1695(5), 1-9.
Ohlmann, M., Miele, V., Dray, S., Chalmandrier, L., O'connor, L., & Thuiller, W. (2019). Diversity indices for ecological networks: a unifying framework using Hill numbers. Ecology letters, 22(4), 737-747.
library(metanetwork) library(igraph) #on angola dataset data("meta_angola") compute_metrics(meta_angola) #computing metrics only at Phylum level compute_metrics(meta_angola,res = "Phylum")
library(metanetwork) library(igraph) #on angola dataset data("meta_angola") compute_metrics(meta_angola) #computing metrics only at Phylum level compute_metrics(meta_angola,res = "Phylum")
Method to compute trophic levels using graph Laplacian using the method described in MacKay et al 2020.
compute_TL(metanetwork) ## S3 method for class 'metanetwork' compute_TL(metanetwork)
compute_TL(metanetwork) ## S3 method for class 'metanetwork' compute_TL(metanetwork)
metanetwork |
object of class 'metanetwork' |
Let be the adjacency matrix of the considered network and
its degree diagonal matrix.
The Laplacian matrix of the symmetrised network is defined by:
With the imbalance degree vector, the trophic level
is defined as the solution of:
For a connected network, the solution is unique up to a translation. We then fix the minimum trophic level value at 0 thus fixing trophic levels of all others species. Local networks may be disconnected due to sampling effect. In that case, we fix the minimum value on each connected component.
an object of class 'metanetwork', with computed trophic levels stored as node attribute TL
NULL
MacKay, R. S., Johnson, S., & Sansom, B. (2020). How directed is a directed network?. Royal Society open science, 7(9), 201138.
library(metanetwork) library(igraph) #on angola dataset data(meta_angola) meta_angola = compute_TL(meta_angola) V(meta_angola$metaweb)$TL
library(metanetwork) library(igraph) #on angola dataset data(meta_angola) meta_angola = compute_TL(meta_angola) V(meta_angola$metaweb)$TL
Function to represent difference between two networks belonging to a metanetwork with specific layout ('TL-tsne' or group 'TL-tsne') using either 'ggnet' or 'visNetwork' visualisation. This function represent the difference between g1 and g2 (g1-g2).
diff_plot( metanetwork, g1, g2, beta = 0.1, mode = "TL-tsne", vis_tool = "ggnet", edge_thrs = NULL, edge_diff_thrs = NULL, layout_metaweb = FALSE, flip_coords = FALSE, alpha_per_group = NULL, alpha_per_node = NULL, TL_tsne.config = TL_tsne.default, nrep_ly = 1, ggnet.config = ggnet.default, visNetwork.config = visNetwork.default )
diff_plot( metanetwork, g1, g2, beta = 0.1, mode = "TL-tsne", vis_tool = "ggnet", edge_thrs = NULL, edge_diff_thrs = NULL, layout_metaweb = FALSE, flip_coords = FALSE, alpha_per_group = NULL, alpha_per_node = NULL, TL_tsne.config = TL_tsne.default, nrep_ly = 1, ggnet.config = ggnet.default, visNetwork.config = visNetwork.default )
metanetwork |
object of class 'metanetwork' |
g1 |
network (of class 'igraph') of metanetwork |
g2 |
network (of class 'igraph') of metanetwork |
beta |
the diffusion parameter of the diffusion kernel, a positive scalar controlling the squeezing of the network |
mode |
mode used for layout, either 'TL-tsne' or 'group-TL-tsne' (see |
vis_tool |
a character indicating the visualisation tool, either 'ggnet' or visNetwork |
edge_thrs |
if non-null, a numeric (between 0 and 1) indicating an edge weight threshold for the representation |
edge_diff_thrs |
if non-null, a numeric (between 0 and 1) indicating an edge weight difference threshold under which edge weights of the two networks are considered equal |
layout_metaweb |
a boolean indicating whether the layout of the metaweb should be used to represent the difference network.
to use metaweb layout = T, you need first to compute 'TL-tsne' layout for the metaweb for this beta value using |
flip_coords |
a boolean indicating whether coordinates should be flipped. In that case, y-axis is the trophic level and x-axis is the layout axis |
alpha_per_group |
controlling alpha per group (only for 'ggnet' vis), a list of format
|
alpha_per_node |
controlling alpha per node (only for 'ggnet' vis), a list of format
|
TL_tsne.config |
configuration list for mode 'TL-tsne', default is TL_tsne.default |
nrep_ly |
If several layouts for this beta value are attached to the metaweb
(if |
ggnet.config |
configuration list for ggnet representation, default is ggnet.default |
visNetwork.config |
configuration list for visNetwork representation, default is visNetwork.default |
an object of class ggplot
or visNetwork
, representation of the difference network
#on Angola dataset library(igraph) library(metanetwork) data(meta_angola) diff_plot(g1 = meta_angola$X2003,g2 = meta_angola$X1986,metanetwork = meta_angola, beta = 0.05)
#on Angola dataset library(igraph) library(metanetwork) data(meta_angola) diff_plot(g1 = meta_angola$X2003,g2 = meta_angola$X1986,metanetwork = meta_angola, beta = 0.05)
Function to extract metawebs and local networks from a metanetwork object
extract_networks(metanetwork)
extract_networks(metanetwork)
metanetwork |
the object whose networks need to be extracted |
Return a list of 'igraph' objects
a list of igraph
objects with attributes computed by metanetwork
library(metanetwork) data("meta_angola") nets = extract_networks(meta_angola) sapply(nets,class)
library(metanetwork) data("meta_angola") nets = extract_networks(meta_angola) sapply(nets,class)
Function that provides network static representation (using 'ggnet') from a 'metanetwork' object using 'TL-tsne' or 'group-TL-tsne' layout.
ggmetanet( metanetwork, g = NULL, beta = 0.1, legend = NULL, mode = "TL-tsne", edge_thrs = NULL, layout_metaweb = FALSE, nrep_ly = 1, flip_coords = FALSE, diff_plot_bool = FALSE, alpha_per_group = NULL, alpha_per_node = NULL, alpha_interactive = FALSE, ggnet.config = ggnet.default, TL_tsne.config = TL_tsne.default )
ggmetanet( metanetwork, g = NULL, beta = 0.1, legend = NULL, mode = "TL-tsne", edge_thrs = NULL, layout_metaweb = FALSE, nrep_ly = 1, flip_coords = FALSE, diff_plot_bool = FALSE, alpha_per_group = NULL, alpha_per_node = NULL, alpha_interactive = FALSE, ggnet.config = ggnet.default, TL_tsne.config = TL_tsne.default )
metanetwork |
object of class metanetwork |
g |
network (igraph object) to represent, default is metaweb |
beta |
the diffusion parameter of the diffusion kernel, a positive scalar controlling the vertical squeezing of the network |
legend |
resolution for the legend, legend resolution must be a coarser resolution than the resolution of g, default is NULL |
mode |
mode used for layout, 'TL-tsne' or 'group-TL-tsne' Default is 'TL-tsne'. This argument can also be a two-column matrix for custom layout. |
edge_thrs |
if non-null, a numeric (between 0 and 1) indicating an edge threshold for the representation |
layout_metaweb |
a boolean indicating whether the layout of the metaweb should be used to represent the network
to use metaweb layout = TRUE, you need first to compute metaweb layout for this beta value using |
nrep_ly |
If several layouts for this beta value are attached to the metaweb (if |
flip_coords |
a boolean indicating whether coordinates should be flipped. |
diff_plot_bool |
boolean, do not edit by hand |
alpha_per_group |
controlling alpha per group (only for 'ggnet' vis), a list of format
|
alpha_per_node |
controlling alpha per node (only for 'ggnet' vis), a list of format
|
alpha_interactive |
a boolean indicating whether alpha (that is node transparency) should be asked in interactive mode to the user |
ggnet.config |
configuration list for ggnet representation, default is ggnet.default |
TL_tsne.config |
configuration list for mode 'TL-tsne', default is TL_tsne.default |
At each call of the function with 'TL-tsne' layout, it computes a layout for the current beta value. If a layout is already attached to the current network, it uses directly this layout (without computing). This function provides many static visualisation tools:
customising ggnet parameters wrapped in ggnet.config
legending using the trophicTable
playing on group transparency (alpha)
using the metaweb layout
building a legend for large networks.
an object of class ggplot
, the current network representation
library(metanetwork) library(igraph) #lattice example g = make_lattice(dim = 2,length = 4,directed = TRUE) #building metanetwork and computing trophic levels meta0 = build_metanet(g) meta0 = compute_TL(meta0) ggmetanet(meta0) #storing layout meta0 = attach_layout(meta0) ggmetanet(meta0) #custom ggnet parameters ggnet.custom = ggnet.default ggnet.custom$label = TRUE ggnet.custom$edge.alpha = 0.5 ggnet.custom$alpha = 0.7 ggnet.custom$arrow.size = 1 ggnet.custom$max_size = 12 # using pre-computed layout and custom ggnet parametersfor vertebrates metaweb data("meta_vrtb") #custom ggnet parameters ggnet.custom = ggnet.default ggnet.custom$label = TRUE ggnet.custom$edge.alpha = 0.5 ggnet.custom$alpha = 0.7 ggnet.custom$arrow.size = 1 ggnet.custom$max_size = 12 #at SBM group level beta = 0.005 ggmetanet(meta_vrtb,g = meta_vrtb$metaweb_group,flip_coords = TRUE, beta = beta,legend = "group", ggnet.config = ggnet.custom,edge_thrs = 0.1)
library(metanetwork) library(igraph) #lattice example g = make_lattice(dim = 2,length = 4,directed = TRUE) #building metanetwork and computing trophic levels meta0 = build_metanet(g) meta0 = compute_TL(meta0) ggmetanet(meta0) #storing layout meta0 = attach_layout(meta0) ggmetanet(meta0) #custom ggnet parameters ggnet.custom = ggnet.default ggnet.custom$label = TRUE ggnet.custom$edge.alpha = 0.5 ggnet.custom$alpha = 0.7 ggnet.custom$arrow.size = 1 ggnet.custom$max_size = 12 # using pre-computed layout and custom ggnet parametersfor vertebrates metaweb data("meta_vrtb") #custom ggnet parameters ggnet.custom = ggnet.default ggnet.custom$label = TRUE ggnet.custom$edge.alpha = 0.5 ggnet.custom$alpha = 0.7 ggnet.custom$arrow.size = 1 ggnet.custom$max_size = 12 #at SBM group level beta = 0.005 ggmetanet(meta_vrtb,g = meta_vrtb$metaweb_group,flip_coords = TRUE, beta = beta,legend = "group", ggnet.config = ggnet.custom,edge_thrs = 0.1)
A list with parameters customizing ggmetanet representation (see ggnet documentations)
ggnet.default
ggnet.default
An object of class metanetwork_config
of length 16.
# display all default settings ggnet.default # create a new settings ggnet.custom = ggnet.default ggnet.custom$edge.size = 2 ggnet.custom
# display all default settings ggnet.default # create a new settings ggnet.custom = ggnet.default ggnet.custom$edge.size = 2 ggnet.custom
A list with parameters customizing group-TL-tsne layout
group_layout.default
group_layout.default
An object of class list
of length 3.
# display all default settings group_layout.default # create a new settings object with n_neighbors set to 5 group_layout.custom = group_layout.default group_layout.custom$group_height = 10 group_layout.custom
# display all default settings group_layout.default # create a new settings object with n_neighbors set to 5 group_layout.custom = group_layout.default group_layout.custom$group_height = 10 group_layout.custom
Return a boolean indicating whether the object belongs to class metanetwork
is.metanetwork(metanetwork) ## S3 method for class 'metanetwork' is.metanetwork(metanetwork)
is.metanetwork(metanetwork) ## S3 method for class 'metanetwork' is.metanetwork(metanetwork)
metanetwork |
the object to test |
a boolean indicating whether the object belongs to class metanetwork
NULL
library(metanetwork) library(igraph) g = make_ring(5,directed = TRUE) meta = build_metanet(g) is.metanetwork(meta) #on Angola dataset data("meta_angola") is.metanetwork(meta_angola)
library(metanetwork) library(igraph) g = make_ring(5,directed = TRUE) meta = build_metanet(g) is.metanetwork(meta) #on Angola dataset data("meta_angola") is.metanetwork(meta_angola)
Angola fishery metanetwork metanetwork built from: Angelini & Velho 2011, Data from: Angelini, R., Velho, VF. (2011) Ecosystem structure and trophic analysis of Angolan fishery landings. Scientia Marina 75(2)
data(meta_angola)
data(meta_angola)
A object of class 'metanetwork'
The metaweb from Angelini & Velho 2011, containing 28 groups and 127 interactions, a igraph
object
Abundance table built from biomass at two dates: 1986 and 2003, a matrix
Taxonomic table, a three column data.frame
with three different taxonomic levels (species (or group), phylum and kingdom)
https://scientiamarina.revistas.csic.es/index.php/scientiamarina/article/view/1254
Norway soil metanetwork metanetwork built from: Calderon-Sanou et al. 2021, Data from: Calderon-Sanou, I., Munkemuller, T., Zinger, L., Schimann, H., Yoccoz, N. G., Gielly, L., ... & Thuiller, W. (2021). Cascading effects of moth outbreaks on subarctic soil food webs. Scientific reports, 11(1), 1-12.
data(meta_norway)
data(meta_norway)
A object of class 'metanetwork'
The metaweb from Calderon-Sanou et al. 2021, containing 40 groups and 204 interactions, a igraph
object
Abundance table built from eDNA data in disturbed (moth outbreaks) and non-disturbed sites, a matrix
Trophic table, a three column data.frame
with three different taxonomic levels (trophic_group, trophic_class and taxa)
https://www.nature.com/articles/s41598-021-94227-z
European vertebrates metanetwork metanetwork built using data from: O'Connor, L. M., Pollock, L. J., Braga, J., Ficetola, G. F., Maiorano, L., Martinez-Almoyna, C., ... & Thuiller, W. (2020). Unveiling the food webs of tetrapods across Europe through the prism of the Eltonian niche. Journal of Biogeography, 47(1), 181-192. and Maiorano, L., Montemaggiori, A., Ficetola, G. F., O'connor, L., & Thuiller, W. (2020). TETRA-EU 1.0: a species-level trophic metaweb of European tetrapods. Global Ecology and Biogeography, 29(9), 1452-1457.
data(meta_vrtb)
data(meta_vrtb)
A object of class 'metanetwork'
The metaweb from Maiorano et al. 2020, O'Connor et al 2020, containing 1101 species and 49013 interactions, a igraph
object
Trophic table, a two columns data.frame
with a column containing species name and a column containing Stochastic Block Model groups inferred in O'Connor et al 2020
https://onlinelibrary.wiley.com/doi/abs/10.1111/geb.13138, https://onlinelibrary.wiley.com/doi/abs/10.1111/jbi.13773
Method executing the whole metanetwork pipeline, including building 'metanetwork' object (build_metanet
,append_agg_nets
, compute_TL
,
attach_layout
)
metanet_build_pipe( metaweb, abTable = NULL, trophicTable = NULL, compute_local_nets = TRUE, verbose = TRUE, beta = 0.1 )
metanet_build_pipe( metaweb, abTable = NULL, trophicTable = NULL, compute_local_nets = TRUE, verbose = TRUE, beta = 0.1 )
metaweb |
metaweb of the metanetwork, object of class 'graph', 'matrix', 'data.frame' or 'dgCMatrix'. Metaweb needs to be directed and connected. This parameter must be non-null. |
abTable |
abundances of nodes in local networks, matrix of class 'matrix', columns must have names corresponding to node labels of the metaweb, rows are node abundances in local networks. Default is null, in that case, uniform abundances are assigned |
trophicTable |
a 'matrix' or 'data.frame' indicating hierarchy of the nodes. Names of the columns correspond to the different resolutions. It indicates the membership of each node of the metaweb. Default is null. |
compute_local_nets |
a boolean, indicates whether local networks must be computed or not.
Default is |
verbose |
a boolean indicating whether message along the pipeline should be printed |
beta |
the diffusion parameter of the diffusion kernel, a positive scalar controlling the squeezing of the network |
object of class 'metanetwork', with computed layout stored as node attribute
library(metanetwork) library(igraph) g = make_lattice(dimvector = c(4,4),2,3,directed = TRUE) meta0 = metanet_build_pipe(g) ggmetanet(meta0)
library(metanetwork) library(igraph) g = make_lattice(dimvector = c(4,4),2,3,directed = TRUE) meta0 = metanet_build_pipe(g) ggmetanet(meta0)
Method executing the whole metanetwork pipeline for the initial metanetwork object (append_agg_nets
, compute_TL
,
attach_layout
)
metanet_pipe(metanetwork, beta = 0.1, verbose = TRUE) ## S3 method for class 'metanetwork' metanet_pipe(metanetwork, beta = 0.1, verbose = TRUE)
metanet_pipe(metanetwork, beta = 0.1, verbose = TRUE) ## S3 method for class 'metanetwork' metanet_pipe(metanetwork, beta = 0.1, verbose = TRUE)
metanetwork |
object of class 'metanetwork' |
beta |
the diffusion parameter of the diffusion kernel, a positive scalar controlling the squeezing of the network |
verbose |
a boolean indicating whether message along the pipeline should be printed |
object of class 'metanetwork', with computed trophic levels and layout stored as node attribute
NULL
library(metanetwork) library(igraph) g = make_lattice(dimvector = c(4,4),2,3,directed = TRUE) meta0 = build_metanet(g) meta0 = metanet_pipe(meta0) ggmetanet(meta0)
library(metanetwork) library(igraph) g = make_lattice(dimvector = c(4,4),2,3,directed = TRUE) meta0 = build_metanet(g) meta0 = metanet_pipe(meta0) ggmetanet(meta0)
Function to represent trophic groups hierarchy provided by trophicTable
plot_trophicTable(metanetwork, res = "all", ggnet.config = ggnet.default)
plot_trophicTable(metanetwork, res = "all", ggnet.config = ggnet.default)
metanetwork |
object of class 'metanetwork' |
res |
resolutions included in the hierarchy representation. Default is "all" (all resolutions are then included) but can be also a vector of given resolutions |
ggnet.config |
configuration list for ggnet representation, default is ggnet.default |
object of class 'ggnet', representation of group hierarchy
library(metanetwork) #on Angola data_set data("meta_angola") plot_trophicTable(meta_angola)
library(metanetwork) #on Angola data_set data("meta_angola") plot_trophicTable(meta_angola)
Print method for class metanetwork
print(metanetwork) ## S3 method for class 'metanetwork' print(metanetwork)
print(metanetwork) ## S3 method for class 'metanetwork' print(metanetwork)
metanetwork |
object of class 'metanetwork' |
character indicating number of nodes and edges of the metaweb, available resolutions and number of local networks
NULL
library(metanetwork) library(igraph) g = make_ring(5,directed = TRUE) meta = build_metanet(g) print(meta) #on Angola dataset data("meta_angola") print(meta_angola) #on Norway dataset data("meta_norway") print(meta_norway)
library(metanetwork) library(igraph) g = make_ring(5,directed = TRUE) meta = build_metanet(g) print(meta) #on Angola dataset data("meta_angola") print(meta_angola) #on Norway dataset data("meta_norway") print(meta_norway)
A list with parameters customizing configuration for the diffusion kernel based t-sne (see 'tsne' R package documentation)
TL_tsne.default
TL_tsne.default
An object of class metanetwork_config
of length 11.
# display all default settings TL_tsne.default # create a new settings object with n_neighbors set to 5 TL_tsne.custom = TL_tsne.default TL_tsne.custom$max_iter = 5 TL_tsne.custom
# display all default settings TL_tsne.default # create a new settings object with n_neighbors set to 5 TL_tsne.custom = TL_tsne.default TL_tsne.custom$max_iter = 5 TL_tsne.custom
Function that provides network dynamic representation (using 'visNetwork') from a 'metanetwork' object with a layout based on a diffusion kernel
vismetaNetwork( metanetwork, g = NULL, beta = 0.1, legend = NULL, mode = "TL-tsne", edge_thrs = NULL, layout_metaweb = FALSE, nrep_ly = 1, flip_coords = FALSE, diff_plot_bool = FALSE, x_y_range = c(100, 100), visNetwork.config = visNetwork.default, TL_tsne.config = TL_tsne.default )
vismetaNetwork( metanetwork, g = NULL, beta = 0.1, legend = NULL, mode = "TL-tsne", edge_thrs = NULL, layout_metaweb = FALSE, nrep_ly = 1, flip_coords = FALSE, diff_plot_bool = FALSE, x_y_range = c(100, 100), visNetwork.config = visNetwork.default, TL_tsne.config = TL_tsne.default )
metanetwork |
object of class metanetwork |
g |
network (igraph object) to represent, default is metaweb |
beta |
the diffusion parameter of the diffusion kernel, a positive scalar controlling the vertical squeezing of the network |
legend |
resolution for the legend, legend resolution must be a coarser resolution than the resolution of g, default is NULL |
mode |
mode used for layout, 'TL-tsne' for trophic level t-sne. Default is 'TL-tsne' |
edge_thrs |
if non-null, a numeric (between 0 and 1) indicating an edge threshold for the representation |
layout_metaweb |
a boolean indicating whether the layout of the metaweb should be used to represent the network
to use metaweb layout = T, you need first to compute metaweb layout for this beta value using |
nrep_ly |
If several layouts for this beta value are attached to the metaweb (if |
flip_coords |
a boolean indicating whether coordinates should be flipped. In that case, y-axis is the trophic level and x-axis is the layout axis |
diff_plot_bool |
boolean, do not edit by hand |
x_y_range |
a two dimension numeric vector, indicating dilatation of x,y axis |
visNetwork.config |
configuration list for visNetwork representation, default is visNetwork.default |
TL_tsne.config |
configuration list for mode 'TL-tsne', default is TL_tsne.default |
object of class 'visNetwork', dynamic representation of the current network
library(metanetwork) library(igraph) data("meta_angola") ## Return htmlwidget # on angola dataset meta_angola = attach_layout(meta_angola, beta = 0.05) vismetaNetwork(meta_angola, beta = 0.05)
library(metanetwork) library(igraph) data("meta_angola") ## Return htmlwidget # on angola dataset meta_angola = attach_layout(meta_angola, beta = 0.05) vismetaNetwork(meta_angola, beta = 0.05)
A list with parameters customizing visNetwork visualisation (see visNetwork documentations)
visNetwork.default
visNetwork.default
An object of class metanetwork_config
of length 4.
# display all default settings visNetwork.default # create a new settings visNetwork.custom = visNetwork.default visNetwork.custom$label.size = 10 visNetwork.custom
# display all default settings visNetwork.default # create a new settings visNetwork.custom = visNetwork.default visNetwork.custom$label.size = 10 visNetwork.custom