Title: | 'Mangal' Client |
---|---|
Description: | An interface to the 'Mangal' database - a collection of ecological networks. This package includes functions to work with the 'Mangal RESTful API' methods (<https://mangal-interactions.github.io/mangal-api/>). |
Authors: | Steve Vissault [aut, ctb] |
Maintainer: | Kevin Cazelles <[email protected]> |
License: | MIT + file LICENSE |
Version: | 2.1.3 |
Built: | 2024-08-29 23:00:08 UTC |
Source: | https://github.com/ropensci/rmangal |
mgNetworksCollection
or mgNetwork
objects to igraph
objects.Coerce mgNetworksCollection
or mgNetwork
objects to igraph
objects.
## S3 method for class 'mgNetwork' as.igraph(x, ...) ## S3 method for class 'mgNetworksCollection' as.igraph(x, ...)
## S3 method for class 'mgNetwork' as.igraph(x, ...) ## S3 method for class 'mgNetworksCollection' as.igraph(x, ...)
x |
either a |
... |
currently ignored. |
An object of class igraph
for a mgNetwork
object and a list of
igraph
objects for mgNetworksCollection
.
as.igraph(mgNetwork)
: Convert mgNetwork
objects to igraph
objects.
as.igraph(mgNetworksCollection)
: Convert mgNetworksCollection
objects to a list of igraph
objects.
List interactions type contains in mangal-db
avail_type()
avail_type()
Resets the cache of the memoised function used for http GET queries
(see memoise::forget()
).
clear_cache_rmangal()
clear_cache_rmangal()
TRUE
when the cache has been reset.
clear_cache_rmangal()
clear_cache_rmangal()
Combine mgNetworksCollection
and mgNetwork
objects into a
mgNetworksCollection
object.
combine_mgNetworks(...)
combine_mgNetworks(...)
... |
objects of class |
An object of class mgNetworksCollection
.
mg_random_1071 <- get_collection(c(1071)) mg_random_1074 <- get_collection(c(1074)) combine_mgNetworks(mg_random_1071, mg_random_1074)
mg_random_1071 <- get_collection(c(1071)) mg_random_1074 <- get_collection(c(1074)) combine_mgNetworks(mg_random_1071, mg_random_1074)
Retrieve all references pertaining to the networks collection or individual network
get_citation(x) ## S3 method for class 'mgNetwork' get_citation(x) ## S3 method for class 'mgNetworksCollection' get_citation(x)
get_citation(x) ## S3 method for class 'mgNetwork' get_citation(x) ## S3 method for class 'mgNetworksCollection' get_citation(x)
x |
an object of class |
Bibtex entries as a character vector.
get_citation(mgNetwork)
: Get BibTeX entries for the publication associated to the network.
get_citation(mgNetworksCollection)
: Get BibTeX entries for the publication associated to the networks.
# network collection lagoon_net_collection <- get_collection(search_datasets("lagoon")) get_citation(lagoon_net_collection) # individual network mg_18 <- get_network_by_id(18) get_citation(mg_18)
# network collection lagoon_net_collection <- get_collection(search_datasets("lagoon")) get_citation(lagoon_net_collection) # individual network mg_18 <- get_network_by_id(18) get_citation(mg_18)
Retrieve a set of networks based on the results of one of the search_*()
function. The function also accepts a numeric vector of Mangal network IDs.
get_collection(x, ...) ## Default S3 method: get_collection(x, ...) ## S3 method for class 'mgSearchDatasets' get_collection(x, ...) ## S3 method for class 'mgSearchNetworks' get_collection(x, ...) ## S3 method for class 'mgSearchReferences' get_collection(x, ...) ## S3 method for class 'mgSearchNodes' get_collection(x, ...) ## S3 method for class 'mgSearchTaxonomy' get_collection(x, ...) ## S3 method for class 'mgSearchInteractions' get_collection(x, ...)
get_collection(x, ...) ## Default S3 method: get_collection(x, ...) ## S3 method for class 'mgSearchDatasets' get_collection(x, ...) ## S3 method for class 'mgSearchNetworks' get_collection(x, ...) ## S3 method for class 'mgSearchReferences' get_collection(x, ...) ## S3 method for class 'mgSearchNodes' get_collection(x, ...) ## S3 method for class 'mgSearchTaxonomy' get_collection(x, ...) ## S3 method for class 'mgSearchInteractions' get_collection(x, ...)
x |
|
... |
arguments to be passed on to |
Returns a object of class mgNetworksCollection
which is a collection
(actually, a list) of mgNetwork
objects get_network_by_id()
).
get_collection(default)
: Get a collection of networks (default).
get_collection(mgSearchDatasets)
: Get a collection of networks from a mgSearchDatasets
object.
get_collection(mgSearchNetworks)
: Get a collection of networks from a mgSearchNetworks
object.
get_collection(mgSearchReferences)
: Get a collection of networks from a mgSearchReferences
object.
get_collection(mgSearchNodes)
: Get a collection of networks from a mgSearchNodes
object.
get_collection(mgSearchTaxonomy)
: Get a collection of networks from a mgSearchTaxa
object.
get_collection(mgSearchInteractions)
: Get a collection of networks from a mgSearchTaxa
object.
search_datasets()
, search_interactions()
, search_networks()
,
search_nodes()
, search_references()
, search_taxonomy()
.
mg_2 <- get_collection(c(1076:1077), verbose = FALSE) mg_anemone <- get_collection(search_networks(query='anemone%'), verbose = FALSE)
mg_2 <- get_collection(c(1076:1077), verbose = FALSE) mg_anemone <- get_collection(search_networks(query='anemone%'), verbose = FALSE)
Summarize mgNetwork properties.
Summarize mgNetworksCollection properties.
get_network_by_id(ids, as_sf = FALSE, force_collection = FALSE, verbose = TRUE) get_network_by_id_indiv(id, as_sf = FALSE, verbose = TRUE) ## S3 method for class 'mgNetwork' print(x, ...) ## S3 method for class 'mgNetworksCollection' print(x, ...) ## S3 method for class 'mgNetwork' summary(object, ...) ## S3 method for class 'mgNetworksCollection' summary(object, ...)
get_network_by_id(ids, as_sf = FALSE, force_collection = FALSE, verbose = TRUE) get_network_by_id_indiv(id, as_sf = FALSE, verbose = TRUE) ## S3 method for class 'mgNetwork' print(x, ...) ## S3 method for class 'mgNetworksCollection' print(x, ...) ## S3 method for class 'mgNetwork' summary(object, ...) ## S3 method for class 'mgNetworksCollection' summary(object, ...)
ids |
a vector of Mangal ID for networks ( |
as_sf |
a logical. Should networks metadata be converted into an sf object? Note that to use this feature |
force_collection |
a logical. Should the output to be of class |
verbose |
a logical. Should extra information be reported on progress? |
id |
a single ID network ( |
x |
an object of class |
... |
ignored. |
object |
object of of class |
A mgNetwork
object includes five data frames:
network: includes all generic information on the network (if as_sf=TRUE
then it is an object of class sf
);
nodes: information pertaining to nodes (includes taxonomic information);
interactions: includes ecological interactions and their attributes;
dataset: information pertaining to the original dataset;
reference: details about the original publication.
A summary method is available for objects of class mgNetwork
object and returns the following network properties:
the number of nodes;
the number of edges;
the connectance;
the linkage density;
the degree (in, out an total) and the eigenvector centrality of every nodes.
get_network_by_id_indiv()
: Retrieve a network by its collection of networks (default).
net18 <- get_network_by_id(id = 18) net18_c <- get_network_by_id(id = 18, force_collection = TRUE) nets <- get_network_by_id(id = c(18, 23))
net18 <- get_network_by_id(id = 18) net18_c <- get_network_by_id(id = 18, force_collection = TRUE) nets <- get_network_by_id(id = c(18, 23))
Identify relevant datasets using a keyword or a custom query.
If the query
is a character string, then all character columns in the table
are searched and the entries for which at least one
partial match was found are returned. Alternatively, a named list can be
used to look for an exact match in a specific column (see Details section).
search_datasets(query, verbose = TRUE, ...)
search_datasets(query, verbose = TRUE, ...)
query |
either a character string including a single keyword or a named list containing a custom query (see details section below). Note that if an empty character string is passed, then all datasets available are returned. |
verbose |
a logical. Should extra information be reported on progress? |
... |
further arguments to be passed to |
If query
is a named list, the name used should be one of the following:
id: unique identifier of the dataset
name: name of the dataset
date: date (YYYY-mm-dd
) of the corresponding publication
description: a brief description of the data set
ref_id: the Mangal identifier of the dataset
Note that for lists with more than one element, only the first element is used, the others are ignored. Examples covering custom queries are provided below.
An object of class mgSearchDatasets
, which basically is a data.frame
object including all datasets corresponding to the query. For each dataset
entry, the networks and the original reference are attached.
# Return all datasets (takes time) all_datasets <- search_datasets("") all_datasets class(all_datasets) # Search with keyword mg_lagoon <- search_datasets(query = 'lagoon') # Search with a custom query (specific column) mg_kemp <- search_datasets(query = list(name = 'kemp_1977')) mg_16 <- search_datasets(query = list(ref_id = 16))
# Return all datasets (takes time) all_datasets <- search_datasets("") all_datasets class(all_datasets) # Search with keyword mg_lagoon <- search_datasets(query = 'lagoon') # Search with a custom query (specific column) mg_kemp <- search_datasets(query = list(name = 'kemp_1977')) mg_16 <- search_datasets(query = list(ref_id = 16))
Search for specific interactions using a keyword or a specific type of
interactions (e.g. mutualism). If the query
is a character string, then all character columns in the table
are searched and the entries for which at least one
partial match was found are returned.
Alternatively, a named list can be used to look for an exact match in a specific column (see Details section)
search_interactions( query, type = NULL, expand_node = FALSE, verbose = TRUE, ... )
search_interactions( query, type = NULL, expand_node = FALSE, verbose = TRUE, ... )
query |
either a character string including a single keyword or a named list containing a custom query (see details section below). Note that if an empty character string is passed, then all datasets available are returned. |
type |
a |
expand_node |
a logical. Should the function returned extra information pertaining to nodes? Default is set to |
verbose |
a |
... |
further arguments to be passed to |
Names of the list should match one of the column names within the table.
For the interaction
table, those are:
id: unique identifier of the interaction;
attr_id: identifier of a specific attribute;
direction: edge direction ("directed", "undirected" or "unknown");
network_id: Mangal network identifier;
node_from: node id which the interaction end to;
node_to: node to which the interaction end to;
type: use argument type
instead.
Note that for lists with more than one element, only the first element is
used, the others are ignored. The type of interactions (argument type
)
currently available are the following
"competition";
"amensalism";
"neutralism";
"commensalism";
"mutualism";
"parasitism";
"predation";
"herbivory";
"symbiosis";
"scavenger";
"detritivore".
An object of class mgSearchInteractions
, i.e. a data.frame
object including interactions.
All networks in which interactions are involved are also attached to the data.frame
.
df_inter <- search_interactions(type = "competition", verbose = FALSE) # Get all networks containing competition competition_networks <- get_collection(df_inter, verbose = FALSE) df_net_926 <- search_interactions(list(network_id = 926), verbose = FALSE)
df_inter <- search_interactions(type = "competition", verbose = FALSE) # Get all networks containing competition competition_networks <- get_collection(df_inter, verbose = FALSE) df_net_926 <- search_interactions(list(network_id = 926), verbose = FALSE)
Search over all networks using a keyword, a custom query or a spatial object
If the query
is a character string, then all character columns in the table
are searched and the entries for which at least one
partial match was found are returned.
Alternatively, a named list can be used to look for an exact match in a specific column (see Details section)
search_networks(query, verbose = TRUE, ...) search_networks_sf(query_sf, verbose = TRUE, ...)
search_networks(query, verbose = TRUE, ...) search_networks_sf(query_sf, verbose = TRUE, ...)
query |
either a character string including a single keyword or a named list containing a custom query (see details section below), or a spatial object (see the description of |
verbose |
a |
... |
further arguments to be passed to |
query_sf |
a spatial object of class |
Names of the list should match one of the column names within the table.
For the networks
table, those are
id: unique identifier of the network;
all_interactions: false interaction can be considered as real false interaction
dataset_id: the identifier of the dataset;
public: network publicly available;
Note that for lists with more than one element, only the first element is used, the others are ignored. An example is provided below.
An object of class mgSearchNetworks
, which is a data.frame
object with all networks informations
search_networks_sf()
: Search networks within a spatial object passed as an argument. Note that sf
must be installed to use this function.
mg_insect <- search_networks(query = "insect%") # Retrieve the search results nets_insect <- get_collection(mg_insect) # Spatial query if (requireNamespace("sf", quietly = TRUE)) { area <- sf::st_read(system.file("shape/nc.shp", package="sf")) networks_in_area <- search_networks_sf(area, verbose = FALSE) plot(networks_in_area) } else warning("Package sf is missing") # Retrieve network ID 5013 net_5013 <- search_networks(query = list(id = 5013)) # Network(s) of dataset ID 19 mg_19 <- search_networks(list(dataset_id = 19))
mg_insect <- search_networks(query = "insect%") # Retrieve the search results nets_insect <- get_collection(mg_insect) # Spatial query if (requireNamespace("sf", quietly = TRUE)) { area <- sf::st_read(system.file("shape/nc.shp", package="sf")) networks_in_area <- search_networks_sf(area, verbose = FALSE) plot(networks_in_area) } else warning("Package sf is missing") # Retrieve network ID 5013 net_5013 <- search_networks(query = list(id = 5013)) # Network(s) of dataset ID 19 mg_19 <- search_networks(list(dataset_id = 19))
Search for networks by querying the nodes table.
If the query
is a character string, then all character columns in the table
are searched and the entries for which at least one
partial match was found are returned.
Alternatively, a named list can be used to look for an exact match in a specific column (see Details section)
search_nodes(query, verbose = TRUE, ...)
search_nodes(query, verbose = TRUE, ...)
query |
either a character string including a single keyword or a named list containing a custom query (see details section below). Note that if an empty character string is passed, then all datasets available are returned. |
verbose |
a |
... |
further arguments to be passed to |
Names of the list should match one of the column names within the table.
For the networks
table, those are:
id: unique identifier of the nodes;
original_name: taxonomic name as in the original publication;
node_level: either population, taxon or individual;
network_id: Mangal network identifier.
Note that for lists with more than one element, only the first element is used, the others are ignored. An example is provided below.
An object of class mgSearchNodes
, which basically is a data.frame
object
including taxa that are matching the query and corresponding information.
All networks in which taxa are involved are also attached to the data.frame
.
res_acer <- search_nodes("Acer") res_926 <- search_nodes(list(network_id = 926))
res_acer <- search_nodes("Acer") res_926 <- search_nodes(list(network_id = 926))
Search for a specific reference using a key word or a Digital Object Identifier (DOI).
If the query
is a character string, then all character columns in the table
are searched and the entries for which at least one
partial match was found are returned.
Alternatively, a named list can be used to look for an exact match in a specific column (see Details section).
search_references(query, doi = NULL, verbose = TRUE, ...)
search_references(query, doi = NULL, verbose = TRUE, ...)
query |
either a character string including a single keyword or a named list containing a custom query (see details section below). Note that if an empty character string is passed, then all datasets available are returned. |
doi |
|
verbose |
a |
... |
further arguments to be passed to |
Names of the list should match one of the column names within the table.
For the reference
table, those are:
id: unique identifier of the reference
first_author: first author
doi: use doi
instead
jstor: JSTOR identifier
year: year of publication.
Note that for lists with more than one element, only the first element is used, the others are ignored. An example is provided below.
An object of class mgSearchReferences
, which is a list that includes a
wide range of details associated to the reference, including all datasets
and networks related to the publication that are included in Mangal database.
search_references(doi = "10.2307/3225248") search_references(list(jstor = 3683041)) search_references(list(year = 2010))
search_references(doi = "10.2307/3225248") search_references(list(jstor = 3683041)) search_references(list(year = 2010))
Search network by taxon names and unique taxonomic identifiers.
This function offers the opportunity to retrieve taxon based on (i) known identifier
such as the taxonomic serial number (TSN), GBIF ID etc. or (ii) text search using partial match.
Have a look at the list of arguments to see the complete list of identifiers accessible.
If any unique identifier argument is used (i.e. tsn etc.), then query
is ignored. Moreover,
if several taxonomic identifiers are specified, then only the first one is considered.
search_taxonomy( query, tsn = NULL, gbif = NULL, eol = NULL, col = NULL, bold = NULL, ncbi = NULL, verbose = TRUE, ... )
search_taxonomy( query, tsn = NULL, gbif = NULL, eol = NULL, col = NULL, bold = NULL, ncbi = NULL, verbose = TRUE, ... )
query |
a character string including a single keyword. Note that if an empty character string is passed, then all datasets available are returned. |
tsn |
a |
gbif |
a |
eol |
a |
col |
a |
bold |
a |
ncbi |
a |
verbose |
a |
... |
further arguments to be passed to |
Taxon names of the taxonomy
table were validated with
TNRS (see https://tnrs.biendata.org and/or GNR
might not be the taxon name documented in the original publication.
In order to identify relevant networks with the original name, use
search_nodes()
.
The validation of taxon names was performed by an automated procedure and if there is any doubt, the original names recorded by authors should be regarded as the most reliable information. Please report any issue related to taxonomy at https://github.com/mangal-interactions/contribute/issues/new/choose/.
An object of class mgSearchTaxonomy
, which is a data.frame
including
all taxa matching the query.
search_taxonomy("Acer") # Retrieve higher classification tsn_acer <- search_taxonomy("Acer")$taxonomy.tsn
search_taxonomy("Acer") # Retrieve higher classification tsn_acer <- search_taxonomy("Acer")$taxonomy.tsn